1 | |
---|
2 | #include <gst/gst.h> |
---|
3 | |
---|
4 | |
---|
5 | void |
---|
6 | test1 (void) |
---|
7 | { |
---|
8 | GstCaps *caps; |
---|
9 | GstCaps *caps2; |
---|
10 | |
---|
11 | g_print ("type is %d\n", (int) gst_caps_get_type ()); |
---|
12 | |
---|
13 | caps = gst_caps_new_empty (); |
---|
14 | g_assert (caps != NULL); |
---|
15 | gst_caps_free (caps); |
---|
16 | |
---|
17 | caps = gst_caps_new_any (); |
---|
18 | g_assert (caps != NULL); |
---|
19 | gst_caps_free (caps); |
---|
20 | |
---|
21 | caps = gst_caps_new_simple ("audio/raw", "_int", G_TYPE_INT, 100, NULL); |
---|
22 | g_assert (caps != NULL); |
---|
23 | g_assert (gst_caps_is_empty (caps) == FALSE); |
---|
24 | g_assert (gst_caps_is_any (caps) == FALSE); |
---|
25 | g_assert (GST_CAPS_IS_SIMPLE (caps) == TRUE); |
---|
26 | g_assert (gst_caps_is_fixed (caps) == TRUE); |
---|
27 | g_print ("%s\n", gst_caps_to_string (caps)); |
---|
28 | gst_caps_free (caps); |
---|
29 | |
---|
30 | caps = gst_caps_new_simple ("audio/raw", |
---|
31 | "_double", G_TYPE_DOUBLE, 100.0, NULL); |
---|
32 | g_assert (caps != NULL); |
---|
33 | g_assert (gst_caps_is_empty (caps) == FALSE); |
---|
34 | g_assert (gst_caps_is_any (caps) == FALSE); |
---|
35 | g_assert (GST_CAPS_IS_SIMPLE (caps) == TRUE); |
---|
36 | g_assert (gst_caps_is_fixed (caps) == TRUE); |
---|
37 | g_print ("%s\n", gst_caps_to_string (caps)); |
---|
38 | gst_caps_free (caps); |
---|
39 | |
---|
40 | caps = gst_caps_new_simple ("audio/raw", |
---|
41 | "_fourcc", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('a', 'b', 'c', 'd'), NULL); |
---|
42 | g_assert (caps != NULL); |
---|
43 | g_assert (gst_caps_is_empty (caps) == FALSE); |
---|
44 | g_assert (gst_caps_is_any (caps) == FALSE); |
---|
45 | g_assert (GST_CAPS_IS_SIMPLE (caps) == TRUE); |
---|
46 | g_assert (gst_caps_is_fixed (caps) == TRUE); |
---|
47 | g_print ("%s\n", gst_caps_to_string (caps)); |
---|
48 | gst_caps_free (caps); |
---|
49 | |
---|
50 | caps = gst_caps_new_simple ("audio/raw", |
---|
51 | "_boolean", G_TYPE_BOOLEAN, TRUE, NULL); |
---|
52 | g_assert (caps != NULL); |
---|
53 | g_assert (gst_caps_is_empty (caps) == FALSE); |
---|
54 | g_assert (gst_caps_is_any (caps) == FALSE); |
---|
55 | g_assert (GST_CAPS_IS_SIMPLE (caps) == TRUE); |
---|
56 | g_assert (gst_caps_is_fixed (caps) == TRUE); |
---|
57 | g_print ("%s\n", gst_caps_to_string (caps)); |
---|
58 | gst_caps_free (caps); |
---|
59 | |
---|
60 | caps = |
---|
61 | gst_caps_new_full (gst_structure_new ("audio/raw", "_int", G_TYPE_INT, |
---|
62 | 100, NULL), gst_structure_new ("audio/raw2", "_int", G_TYPE_INT, 100, |
---|
63 | NULL), NULL); |
---|
64 | g_assert (caps != NULL); |
---|
65 | g_assert (gst_caps_is_empty (caps) == FALSE); |
---|
66 | g_assert (gst_caps_is_any (caps) == FALSE); |
---|
67 | g_assert (GST_CAPS_IS_SIMPLE (caps) == FALSE); |
---|
68 | g_assert (gst_caps_is_fixed (caps) == FALSE); |
---|
69 | g_print ("%s\n", gst_caps_to_string (caps)); |
---|
70 | gst_caps_free (caps); |
---|
71 | |
---|
72 | caps = gst_caps_new_simple ("audio/raw", "_int", G_TYPE_INT, 100, NULL); |
---|
73 | g_assert (caps != NULL); |
---|
74 | caps2 = gst_caps_copy (caps); |
---|
75 | g_assert (caps2 != NULL); |
---|
76 | g_assert (gst_caps_is_empty (caps2) == FALSE); |
---|
77 | g_assert (gst_caps_is_any (caps2) == FALSE); |
---|
78 | g_assert (GST_CAPS_IS_SIMPLE (caps2) == TRUE); |
---|
79 | g_assert (gst_caps_is_fixed (caps2) == TRUE); |
---|
80 | g_print ("%s\n", gst_caps_to_string (caps)); |
---|
81 | g_print ("%s\n", gst_caps_to_string (caps2)); |
---|
82 | gst_caps_free (caps); |
---|
83 | gst_caps_free (caps2); |
---|
84 | |
---|
85 | caps = gst_caps_new_simple ("audio/raw", "_int", G_TYPE_INT, 100, NULL); |
---|
86 | gst_caps_append (caps, |
---|
87 | gst_caps_new_simple ("audio/raw", "_int", G_TYPE_INT, 200, NULL)); |
---|
88 | g_assert (caps != NULL); |
---|
89 | g_assert (gst_caps_is_empty (caps) == FALSE); |
---|
90 | g_assert (gst_caps_is_any (caps) == FALSE); |
---|
91 | g_assert (GST_CAPS_IS_SIMPLE (caps) == FALSE); |
---|
92 | g_assert (gst_caps_is_fixed (caps) == FALSE); |
---|
93 | g_print ("%s\n", gst_caps_to_string (caps)); |
---|
94 | gst_caps_free (caps); |
---|
95 | |
---|
96 | caps = gst_caps_new_simple ("audio/raw", "_int", G_TYPE_INT, 100, NULL); |
---|
97 | g_assert (caps != NULL); |
---|
98 | gst_caps_append_structure (caps, |
---|
99 | gst_structure_new ("audio/raw", "_int", G_TYPE_INT, 200, NULL)); |
---|
100 | g_assert (gst_caps_is_empty (caps) == FALSE); |
---|
101 | g_assert (gst_caps_is_any (caps) == FALSE); |
---|
102 | g_assert (GST_CAPS_IS_SIMPLE (caps) == FALSE); |
---|
103 | g_assert (gst_caps_is_fixed (caps) == FALSE); |
---|
104 | g_print ("%s\n", gst_caps_to_string (caps)); |
---|
105 | gst_caps_free (caps); |
---|
106 | } |
---|
107 | |
---|
108 | void |
---|
109 | test2 (void) |
---|
110 | { |
---|
111 | GstCaps *caps1; |
---|
112 | GstCaps *caps2; |
---|
113 | GstCaps *caps; |
---|
114 | |
---|
115 | caps1 = |
---|
116 | gst_caps_new_full (gst_structure_new ("audio/raw", "_int", G_TYPE_INT, |
---|
117 | 100, NULL), gst_structure_new ("audio/raw", "_int", G_TYPE_INT, 200, |
---|
118 | NULL), NULL); |
---|
119 | caps2 = |
---|
120 | gst_caps_new_full (gst_structure_new ("audio/raw", "_int", G_TYPE_INT, |
---|
121 | 100, NULL), gst_structure_new ("audio/raw", "_int", G_TYPE_INT, 300, |
---|
122 | NULL), NULL); |
---|
123 | caps = gst_caps_intersect (caps1, caps2); |
---|
124 | g_print ("%s\n", gst_caps_to_string (caps)); |
---|
125 | gst_caps_free (caps); |
---|
126 | gst_caps_free (caps1); |
---|
127 | gst_caps_free (caps2); |
---|
128 | |
---|
129 | } |
---|
130 | |
---|
131 | void |
---|
132 | test3 (void) |
---|
133 | { |
---|
134 | GstCaps *caps1; |
---|
135 | GstCaps *caps2; |
---|
136 | |
---|
137 | caps1 = gst_caps_new_any (); |
---|
138 | caps2 = gst_caps_new_simple ("audio/raw", NULL); |
---|
139 | |
---|
140 | gst_caps_append (caps1, caps2); |
---|
141 | g_print ("%s\n", gst_caps_to_string (caps1)); |
---|
142 | |
---|
143 | g_assert (gst_caps_is_any (caps1)); |
---|
144 | g_assert (gst_caps_get_size (caps1) == 0); |
---|
145 | |
---|
146 | gst_caps_free (caps1); |
---|
147 | } |
---|
148 | |
---|
149 | int |
---|
150 | main (int argc, char *argv[]) |
---|
151 | { |
---|
152 | gst_init (&argc, &argv); |
---|
153 | |
---|
154 | test1 (); |
---|
155 | test2 (); |
---|
156 | test3 (); |
---|
157 | |
---|
158 | return 0; |
---|
159 | } |
---|