2 * Copyright (C) 2005 Andy Wingo <wingo@pobox.com>
3 * Copyright (C) <2005> Thomas Vander Stichele <thomas at apestaart dot org>
5 * gstcaps.c: Unit test for GstCaps
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
24 #include <gst/check/gstcheck.h>
25 #include <gst/gstcaps.h>
28 GST_START_TEST (test_from_string)
35 for (i = 0; i < G_N_ELEMENTS (caps_list); i++) {
36 caps = gst_caps_from_string (caps_list[i]);
37 fail_if (caps == NULL,
38 "Could not create caps from string %s\n", caps_list[i]);
39 to_str = gst_caps_to_string (caps);
40 fail_if (to_str == NULL,
41 "Could not convert caps back to string %s\n", caps_list[i]);
42 caps2 = gst_caps_from_string (caps_list[i]);
43 fail_if (caps2 == NULL, "Could not create caps from string %s\n", to_str);
45 fail_unless (gst_caps_is_equal (caps, caps));
46 fail_unless (gst_caps_is_equal (caps, caps2));
48 gst_caps_unref (caps);
49 gst_caps_unref (caps2);
56 GST_START_TEST (test_double_append)
61 c1 = gst_caps_new_any ();
62 s1 = gst_structure_from_string ("audio/x-raw,rate=44100", NULL);
63 gst_caps_append_structure (c1, s1);
64 ASSERT_CRITICAL (gst_caps_append_structure (c1, s1));
71 GST_START_TEST (test_mutability)
77 c1 = gst_caps_new_any ();
78 s1 = gst_structure_from_string ("audio/x-raw,rate=44100", NULL);
79 gst_structure_set (s1, "rate", G_TYPE_INT, 48000, NULL);
80 gst_caps_append_structure (c1, s1);
81 gst_structure_set (s1, "rate", G_TYPE_INT, 22500, NULL);
83 ASSERT_CRITICAL (gst_structure_set (s1, "rate", G_TYPE_INT, 11250, NULL));
84 fail_unless (gst_structure_get_int (s1, "rate", &ret));
85 fail_unless (ret == 22500);
86 ASSERT_CRITICAL (gst_caps_set_simple (c1, "rate", G_TYPE_INT, 11250, NULL));
87 fail_unless (gst_structure_get_int (s1, "rate", &ret));
88 fail_unless (ret == 22500);
90 gst_structure_set (s1, "rate", G_TYPE_INT, 11250, NULL);
91 fail_unless (gst_structure_get_int (s1, "rate", &ret));
92 fail_unless (ret == 11250);
93 gst_caps_set_simple (c1, "rate", G_TYPE_INT, 1, NULL);
94 fail_unless (gst_structure_get_int (s1, "rate", &ret));
95 fail_unless (ret == 1);
101 GST_START_TEST (test_static_caps)
103 static GstStaticCaps scaps = GST_STATIC_CAPS ("audio/x-raw,rate=44100");
106 static GstStaticCaps sany = GST_STATIC_CAPS_ANY;
107 static GstStaticCaps snone = GST_STATIC_CAPS_NONE;
110 caps1 = gst_static_caps_get (&scaps);
111 fail_unless (caps1 != NULL);
112 /* 1 refcount core, one from us */
113 fail_unless (GST_CAPS_REFCOUNT (caps1) == 2);
115 /* caps should be the same */
116 caps2 = gst_static_caps_get (&scaps);
117 fail_unless (caps2 != NULL);
118 /* 1 refcount core, two from us */
119 fail_unless (GST_CAPS_REFCOUNT (caps1) == 3);
120 /* caps must be equal */
121 fail_unless (caps1 == caps2);
123 gst_caps_unref (caps1);
124 gst_caps_unref (caps2);
126 caps1 = gst_static_caps_get (&sany);
127 fail_unless (gst_caps_is_equal (caps1, GST_CAPS_ANY));
128 caps2 = gst_static_caps_get (&snone);
129 fail_unless (gst_caps_is_equal (caps2, GST_CAPS_NONE));
130 fail_if (gst_caps_is_equal (caps1, caps2));
131 gst_caps_unref (caps1);
132 gst_caps_unref (caps2);
137 static const gchar non_simple_caps_string[] =
138 "video/x-raw, format=(string)I420, framerate=(fraction)[ 1/100, 100 ], "
139 "width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ]; video/x-raw, "
140 "format=(string)YUY2, framerate=(fraction)[ 1/100, 100 ], width=(int)[ 16, 4096 ], "
141 "height=(int)[ 16, 4096 ]; video/x-raw, format=(string)RGB8_PALETTED, "
142 "framerate=(fraction)[ 1/100, 100 ], width=(int)[ 16, 4096 ], "
143 "height=(int)[ 16, 4096 ]; video/x-raw, "
144 "format=(string){ I420, YUY2, YV12 }, width=(int)[ 16, 4096 ], "
145 "height=(int)[ 16, 4096 ], framerate=(fraction)[ 1/100, 100 ]";
148 check_string_list (const GValue * format_value)
150 const GValue *string_value;
151 gboolean got_rgb8 = FALSE;
152 gboolean got_yv12 = FALSE;
153 gboolean got_i420 = FALSE;
154 gboolean got_yuy2 = FALSE;
157 string_value = gst_value_list_get_value (format_value, 0);
158 fail_unless (string_value != NULL);
159 fail_unless (G_VALUE_HOLDS_STRING (string_value));
160 string = g_value_get_string (string_value);
161 fail_unless (string != NULL);
162 got_rgb8 = got_rgb8 || (g_str_equal (string, "RGB8_PALETTED"));
163 got_i420 = got_i420 || (g_str_equal (string, "I420"));
164 got_yuy2 = got_yuy2 || (g_str_equal (string, "YUY2"));
165 got_yv12 = got_yv12 || (g_str_equal (string, "YV12"));
167 string_value = gst_value_list_get_value (format_value, 1);
168 fail_unless (string_value != NULL);
169 fail_unless (G_VALUE_HOLDS_STRING (string_value));
170 string = g_value_get_string (string_value);
171 fail_unless (string != NULL);
172 got_rgb8 = got_rgb8 || (g_str_equal (string, "RGB8_PALETTED"));
173 got_i420 = got_i420 || (g_str_equal (string, "I420"));
174 got_yuy2 = got_yuy2 || (g_str_equal (string, "YUY2"));
175 got_yv12 = got_yv12 || (g_str_equal (string, "YV12"));
177 string_value = gst_value_list_get_value (format_value, 2);
178 fail_unless (string_value != NULL);
179 fail_unless (G_VALUE_HOLDS_STRING (string_value));
180 string = g_value_get_string (string_value);
181 fail_unless (string != NULL);
182 got_rgb8 = got_rgb8 || (g_str_equal (string, "RGB8_PALETTED"));
183 got_i420 = got_i420 || (g_str_equal (string, "I420"));
184 got_yuy2 = got_yuy2 || (g_str_equal (string, "YUY2"));
185 got_yv12 = got_yv12 || (g_str_equal (string, "YV12"));
187 string_value = gst_value_list_get_value (format_value, 3);
188 fail_unless (string_value != NULL);
189 fail_unless (G_VALUE_HOLDS_STRING (string_value));
190 string = g_value_get_string (string_value);
191 fail_unless (string != NULL);
192 got_rgb8 = got_rgb8 || (g_str_equal (string, "RGB8_PALETTED"));
193 got_i420 = got_i420 || (g_str_equal (string, "I420"));
194 got_yuy2 = got_yuy2 || (g_str_equal (string, "YUY2"));
195 got_yv12 = got_yv12 || (g_str_equal (string, "YV12"));
197 return (got_rgb8 && got_i420 && got_yuy2 && got_yv12);
200 GST_START_TEST (test_simplify)
205 caps = gst_caps_from_string (non_simple_caps_string);
206 fail_unless (caps != NULL,
207 "gst_caps_from_string (non_simple_caps_string) failed");
209 caps = gst_caps_simplify (caps);
210 fail_unless (caps != NULL, "gst_caps_simplify() should have worked");
212 /* check simplified caps, should be:
214 * video/x-raw, format=(string){ RGB8_PALETTED, YV12, YUY2, I420 },
215 * width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ],
216 * framerate=(fraction)[ 1/100, 100 ]
218 GST_DEBUG ("simplyfied %" GST_PTR_FORMAT, caps);
219 fail_unless (gst_caps_get_size (caps) == 1);
220 s1 = gst_caps_get_structure (caps, 0);
221 fail_unless (s1 != NULL);
223 fail_unless (gst_structure_has_name (s1, "video/x-raw"));
225 const GValue *framerate_value;
226 const GValue *format_value;
227 const GValue *width_value;
228 const GValue *height_value;
229 const GValue *val_fps;
230 GValue test_fps = { 0, };
231 gint min_width, max_width;
232 gint min_height, max_height;
234 format_value = gst_structure_get_value (s1, "format");
235 fail_unless (format_value != NULL);
236 fail_unless (GST_VALUE_HOLDS_LIST (format_value));
237 fail_unless (gst_value_list_get_size (format_value) == 4);
238 fail_unless (check_string_list (format_value) == TRUE);
240 g_value_init (&test_fps, GST_TYPE_FRACTION);
241 framerate_value = gst_structure_get_value (s1, "framerate");
242 fail_unless (framerate_value != NULL);
243 fail_unless (GST_VALUE_HOLDS_FRACTION_RANGE (framerate_value));
245 val_fps = gst_value_get_fraction_range_min (framerate_value);
246 gst_value_set_fraction (&test_fps, 1, 100);
247 fail_unless (gst_value_compare (&test_fps, val_fps) == GST_VALUE_EQUAL);
249 val_fps = gst_value_get_fraction_range_max (framerate_value);
250 gst_value_set_fraction (&test_fps, 100, 1);
251 fail_unless (gst_value_compare (&test_fps, val_fps) == GST_VALUE_EQUAL);
253 g_value_unset (&test_fps);
255 width_value = gst_structure_get_value (s1, "width");
256 fail_unless (width_value != NULL);
257 fail_unless (GST_VALUE_HOLDS_INT_RANGE (width_value));
258 min_width = gst_value_get_int_range_min (width_value);
259 max_width = gst_value_get_int_range_max (width_value);
260 fail_unless (min_width == 16 && max_width == 4096);
262 height_value = gst_structure_get_value (s1, "height");
263 fail_unless (height_value != NULL);
264 fail_unless (GST_VALUE_HOLDS_INT_RANGE (height_value));
265 min_height = gst_value_get_int_range_min (height_value);
266 max_height = gst_value_get_int_range_max (height_value);
267 fail_unless (min_height == 16 && max_height == 4096);
270 gst_caps_unref (caps);
275 GST_START_TEST (test_truncate)
279 caps = gst_caps_from_string (non_simple_caps_string);
280 fail_unless (caps != NULL,
281 "gst_caps_from_string (non_simple_caps_string) failed");
282 fail_unless_equals_int (gst_caps_get_size (caps), 4);
283 caps = gst_caps_truncate (caps);
284 fail_unless_equals_int (gst_caps_get_size (caps), 1);
285 gst_caps_unref (caps);
290 GST_START_TEST (test_subset)
294 c1 = gst_caps_from_string ("video/x-raw; video/x-raw");
295 c2 = gst_caps_from_string ("video/x-raw, format=(string)YUY2");
296 fail_unless (gst_caps_is_subset (c2, c1));
297 fail_if (gst_caps_is_subset (c1, c2));
301 c1 = gst_caps_from_string
302 ("audio/x-raw, channels=(int)[ 1, 2 ], rate=(int)44100");
303 c2 = gst_caps_from_string ("audio/x-raw, channels=(int)1, rate=(int)44100");
304 fail_unless (gst_caps_is_subset (c2, c1));
305 fail_if (gst_caps_is_subset (c1, c2));
309 c1 = gst_caps_from_string ("audio/x-raw, channels=(int) {1}");
310 c2 = gst_caps_from_string ("audio/x-raw, channels=(int)1");
311 fail_unless (gst_caps_is_subset (c2, c1));
312 fail_unless (gst_caps_is_subset (c1, c2));
313 fail_unless (gst_caps_is_equal (c1, c2));
317 c1 = gst_caps_from_string
318 ("audio/x-raw, rate=(int)44100, channels=(int)3, format=(string)U16_LE");
319 c2 = gst_caps_from_string
320 ("audio/x-raw, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2147483647 ], format=(string){ S16_LE, U16_LE }");
321 fail_unless (gst_caps_is_subset (c1, c2));
322 fail_if (gst_caps_is_subset (c2, c1));
326 c1 = gst_caps_from_string ("video/x-h264, parsed=(boolean)true");
327 c2 = gst_caps_from_string
328 ("video/x-h264, stream-format=(string)byte-stream, alignment=(string)nal");
329 fail_if (gst_caps_is_subset (c2, c1));
330 fail_if (gst_caps_is_subset (c1, c2));
331 fail_if (gst_caps_is_equal (c1, c2));
338 GST_START_TEST (test_merge_fundamental)
342 /* ANY + specific = ANY */
343 c1 = gst_caps_from_string ("audio/x-raw,rate=44100");
344 c2 = gst_caps_new_any ();
345 c2 = gst_caps_merge (c2, c1);
346 GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2);
347 fail_unless (gst_caps_get_size (c2) == 0, NULL);
348 fail_unless (gst_caps_is_any (c2), NULL);
351 /* specific + ANY = ANY */
352 c2 = gst_caps_from_string ("audio/x-raw,rate=44100");
353 c1 = gst_caps_new_any ();
354 c2 = gst_caps_merge (c2, c1);
355 GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2);
356 fail_unless (gst_caps_get_size (c2) == 0, NULL);
357 fail_unless (gst_caps_is_any (c2), NULL);
360 /* EMPTY + specific = specific */
361 c1 = gst_caps_from_string ("audio/x-raw,rate=44100");
362 c2 = gst_caps_new_empty ();
363 c2 = gst_caps_merge (c2, c1);
364 GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2);
365 fail_unless (gst_caps_get_size (c2) == 1, NULL);
366 fail_if (gst_caps_is_empty (c2), NULL);
369 /* specific + EMPTY = specific */
370 c2 = gst_caps_from_string ("audio/x-raw,rate=44100");
371 c1 = gst_caps_new_empty ();
372 c2 = gst_caps_merge (c2, c1);
373 GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2);
374 fail_unless (gst_caps_get_size (c2) == 1, NULL);
375 fail_if (gst_caps_is_empty (c2), NULL);
381 GST_START_TEST (test_merge_same)
383 GstCaps *c1, *c2, *test;
385 /* this is the same */
386 c1 = gst_caps_from_string ("audio/x-raw,rate=44100,channels=1");
387 c2 = gst_caps_from_string ("audio/x-raw,rate=44100,channels=1");
388 c2 = gst_caps_merge (c2, c1);
389 GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2);
390 fail_unless (gst_caps_get_size (c2) == 1, NULL);
391 test = gst_caps_from_string ("audio/x-raw,rate=44100,channels=1");
392 fail_unless (gst_caps_is_equal (c2, test));
393 gst_caps_unref (test);
397 c1 = gst_caps_from_string ("audio/x-raw,rate=44100,channels=1");
398 c2 = gst_caps_from_string ("audio/x-raw,channels=1,rate=44100");
399 c2 = gst_caps_merge (c2, c1);
400 GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2);
401 fail_unless (gst_caps_get_size (c2) == 1, NULL);
404 c1 = gst_caps_from_string ("video/x-foo, data=(buffer)AA");
405 c2 = gst_caps_from_string ("video/x-foo, data=(buffer)AABB");
406 c2 = gst_caps_merge (c2, c1);
407 GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2);
408 fail_unless (gst_caps_get_size (c2) == 2, NULL);
411 c1 = gst_caps_from_string ("video/x-foo, data=(buffer)AABB");
412 c2 = gst_caps_from_string ("video/x-foo, data=(buffer)AA");
413 c2 = gst_caps_merge (c2, c1);
414 GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2);
415 fail_unless (gst_caps_get_size (c2) == 2, NULL);
418 c1 = gst_caps_from_string ("video/x-foo, data=(buffer)AA");
419 c2 = gst_caps_from_string ("video/x-foo, data=(buffer)AA");
420 c2 = gst_caps_merge (c2, c1);
421 GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2);
422 fail_unless (gst_caps_get_size (c2) == 1, NULL);
425 c1 = gst_caps_from_string ("video/x-foo, data=(buffer)AA");
426 c2 = gst_caps_from_string ("video/x-bar, data=(buffer)AA");
427 c2 = gst_caps_merge (c2, c1);
428 GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2);
429 fail_unless (gst_caps_get_size (c2) == 2, NULL);
435 GST_START_TEST (test_merge_subset)
437 GstCaps *c1, *c2, *test;
439 /* the 2nd is already covered */
440 c2 = gst_caps_from_string ("audio/x-raw,channels=[1,2]");
441 c1 = gst_caps_from_string ("audio/x-raw,channels=1");
442 c2 = gst_caps_merge (c2, c1);
443 GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2);
444 fail_unless (gst_caps_get_size (c2) == 1, NULL);
445 test = gst_caps_from_string ("audio/x-raw,channels=[1,2]");
446 fail_unless (gst_caps_is_equal (c2, test));
448 gst_caps_unref (test);
451 c2 = gst_caps_from_string ("audio/x-raw,channels=1,rate=44100");
452 c1 = gst_caps_from_string ("audio/x-raw,channels=[1,2],rate=44100");
453 c2 = gst_caps_merge (c2, c1);
454 GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2);
455 fail_unless (gst_caps_get_size (c2) == 2, NULL);
456 test = gst_caps_from_string ("audio/x-raw,channels=[1,2],rate=44100");
457 fail_unless (gst_caps_is_equal (c2, test));
459 gst_caps_unref (test);
461 /* second one was already contained in the first one */
462 c2 = gst_caps_from_string ("audio/x-raw,channels=[1,3]");
463 c1 = gst_caps_from_string ("audio/x-raw,channels=[1,2]");
464 c2 = gst_caps_merge (c2, c1);
465 GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2);
466 fail_unless (gst_caps_get_size (c2) == 1, NULL);
467 test = gst_caps_from_string ("audio/x-raw,channels=[1,3]");
468 fail_unless (gst_caps_is_equal (c2, test));
470 gst_caps_unref (test);
472 /* second one was already contained in the first one */
473 c2 = gst_caps_from_string ("audio/x-raw,channels=[1,4]");
474 c1 = gst_caps_from_string ("audio/x-raw,channels=[1,2]");
475 c2 = gst_caps_merge (c2, c1);
476 GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2);
477 fail_unless (gst_caps_get_size (c2) == 1, NULL);
478 test = gst_caps_from_string ("audio/x-raw,channels=[1,4]");
479 fail_unless (gst_caps_is_equal (c2, test));
481 gst_caps_unref (test);
483 /* second one was already contained in the first one */
484 c2 = gst_caps_from_string ("audio/x-raw,channels=[1,4]");
485 c1 = gst_caps_from_string ("audio/x-raw,channels=[2,4]");
486 c2 = gst_caps_merge (c2, c1);
487 GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2);
488 fail_unless (gst_caps_get_size (c2) == 1, NULL);
489 test = gst_caps_from_string ("audio/x-raw,channels=[1,4]");
490 fail_unless (gst_caps_is_equal (c2, test));
492 gst_caps_unref (test);
494 /* second one was already contained in the first one */
495 c2 = gst_caps_from_string ("audio/x-raw,channels=[1,4]");
496 c1 = gst_caps_from_string ("audio/x-raw,channels=[2,3]");
497 c2 = gst_caps_merge (c2, c1);
498 GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2);
499 fail_unless (gst_caps_get_size (c2) == 1, NULL);
500 test = gst_caps_from_string ("audio/x-raw,channels=[1,4]");
501 fail_unless (gst_caps_is_equal (c2, test));
503 gst_caps_unref (test);
505 /* these caps cannot be merged */
506 c2 = gst_caps_from_string ("audio/x-raw,channels=[2,3]");
507 c1 = gst_caps_from_string ("audio/x-raw,channels=[1,4]");
508 c2 = gst_caps_merge (c2, c1);
509 GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2);
510 fail_unless (gst_caps_get_size (c2) == 2, NULL);
513 ("audio/x-raw,channels=[2,3];audio/x-raw,channels=[1,4]");
514 fail_unless (gst_caps_is_equal (c2, test));
516 gst_caps_unref (test);
518 /* these caps cannot be merged */
519 c2 = gst_caps_from_string ("audio/x-raw,channels=[1,2]");
520 c1 = gst_caps_from_string ("audio/x-raw,channels=[1,3]");
521 c2 = gst_caps_merge (c2, c1);
522 GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2);
523 fail_unless (gst_caps_get_size (c2) == 2, NULL);
526 ("audio/x-raw,channels=[1,2];audio/x-raw,channels=[1,3]");
527 fail_unless (gst_caps_is_equal (c2, test));
529 gst_caps_unref (test);
531 c2 = gst_caps_from_string ("audio/x-raw,channels={1,2}");
532 c1 = gst_caps_from_string ("audio/x-raw,channels={1,2,3,4}");
533 c2 = gst_caps_merge (c2, c1);
534 GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2);
535 fail_unless (gst_caps_get_size (c2) == 2, NULL);
536 test = gst_caps_from_string ("audio/x-raw,channels={1,2};"
537 "audio/x-raw,channels={1,2,3,4}");
538 fail_unless (gst_caps_is_equal (c2, test));
540 gst_caps_unref (test);
542 c2 = gst_caps_from_string ("audio/x-raw,channels={1,2}");
543 c1 = gst_caps_from_string ("audio/x-raw,channels={1,3}");
544 c2 = gst_caps_merge (c2, c1);
545 GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2);
546 fail_unless (gst_caps_get_size (c2) == 2, NULL);
547 test = gst_caps_from_string ("audio/x-raw,channels={1,2};"
548 "audio/x-raw,channels={1,3}");
549 fail_unless (gst_caps_is_equal (c2, test));
551 gst_caps_unref (test);
553 c2 = gst_caps_from_string ("video/x-raw, framerate=(fraction){ 15/2, 5/1 }");
554 c1 = gst_caps_from_string ("video/x-raw, framerate=(fraction){ 15/1, 5/1 }");
555 test = gst_caps_copy (c1);
556 c2 = gst_caps_merge (c2, c1);
557 GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2);
558 fail_unless (gst_caps_is_subset (test, c2));
559 gst_caps_unref (test);
562 c2 = gst_caps_from_string ("audio/x-raw");
563 c1 = gst_caps_from_string ("audio/x-raw,channels=1");
564 c2 = gst_caps_merge (c2, c1);
565 GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2);
566 fail_unless (gst_caps_get_size (c2) == 1, NULL);
567 test = gst_caps_from_string ("audio/x-raw");
568 fail_unless (gst_caps_is_equal (c2, test));
570 gst_caps_unref (test);
572 c2 = gst_caps_from_string ("audio/x-raw,channels=1");
573 c1 = gst_caps_from_string ("audio/x-raw");
574 c2 = gst_caps_merge (c2, c1);
575 GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2);
576 fail_unless (gst_caps_get_size (c2) == 2, NULL);
577 test = gst_caps_from_string ("audio/x-raw,channels=1; audio/x-raw");
578 fail_unless (gst_caps_is_equal (c2, test));
580 gst_caps_unref (test);
585 GST_START_TEST (test_intersect)
588 GstCaps *c1, *c2, *ci1, *ci2;
590 /* field not specified = any value possible, so the intersection
591 * should keep fields which are only part of one set of caps */
592 c2 = gst_caps_from_string ("video/x-raw,format=(string)I420,width=20");
593 c1 = gst_caps_from_string ("video/x-raw,format=(string)I420");
595 ci1 = gst_caps_intersect (c2, c1);
596 GST_DEBUG ("intersected: %" GST_PTR_FORMAT, ci1);
597 fail_unless (gst_caps_get_size (ci1) == 1, NULL);
598 s = gst_caps_get_structure (ci1, 0);
599 fail_unless (gst_structure_has_name (s, "video/x-raw"));
600 fail_unless (gst_structure_get_value (s, "format") != NULL);
601 fail_unless (gst_structure_get_value (s, "width") != NULL);
603 /* with changed order */
604 ci2 = gst_caps_intersect (c1, c2);
605 GST_DEBUG ("intersected: %" GST_PTR_FORMAT, ci2);
606 fail_unless (gst_caps_get_size (ci2) == 1, NULL);
607 s = gst_caps_get_structure (ci2, 0);
608 fail_unless (gst_structure_has_name (s, "video/x-raw"));
609 fail_unless (gst_structure_get_value (s, "format") != NULL);
610 fail_unless (gst_structure_get_value (s, "width") != NULL);
612 fail_unless (gst_caps_is_equal (ci1, ci2));
614 gst_caps_unref (ci1);
615 gst_caps_unref (ci2);
622 c2 = gst_caps_from_string ("video/x-raw,format=(string)I420,width=20");
623 c1 = gst_caps_from_string ("video/x-raw,format=(string)I420,width=30");
625 ci1 = gst_caps_intersect (c2, c1);
626 GST_DEBUG ("intersected: %" GST_PTR_FORMAT, ci1);
627 fail_unless (gst_caps_is_empty (ci1), NULL);
629 /* with changed order */
630 ci2 = gst_caps_intersect (c1, c2);
631 GST_DEBUG ("intersected: %" GST_PTR_FORMAT, ci2);
632 fail_unless (gst_caps_is_empty (ci2), NULL);
634 fail_unless (gst_caps_is_equal (ci1, ci2));
636 gst_caps_unref (ci1);
637 gst_caps_unref (ci2);
644 c2 = gst_caps_from_string ("video/x-raw,format=(string)I420,width=20");
645 c1 = gst_caps_from_string ("video/x-raw2,format=(string)I420,width=20");
647 ci1 = gst_caps_intersect (c2, c1);
648 GST_DEBUG ("intersected: %" GST_PTR_FORMAT, ci1);
649 fail_unless (gst_caps_is_empty (ci1), NULL);
651 /* with changed order */
652 ci2 = gst_caps_intersect (c1, c2);
653 GST_DEBUG ("intersected: %" GST_PTR_FORMAT, ci2);
654 fail_unless (gst_caps_is_empty (ci2), NULL);
656 fail_unless (gst_caps_is_equal (ci1, ci2));
658 gst_caps_unref (ci1);
659 gst_caps_unref (ci2);
666 c2 = gst_caps_from_string ("video/x-raw,format=(string)I420,width=20");
667 c1 = gst_caps_from_string ("video/x-raw,format=(string)I420,height=30");
669 ci1 = gst_caps_intersect (c2, c1);
670 GST_DEBUG ("intersected: %" GST_PTR_FORMAT, ci1);
671 fail_unless (gst_caps_get_size (ci1) == 1, NULL);
672 s = gst_caps_get_structure (ci1, 0);
673 fail_unless (gst_structure_has_name (s, "video/x-raw"));
674 fail_unless (gst_structure_get_value (s, "format") != NULL);
675 fail_unless (gst_structure_get_value (s, "width") != NULL);
676 fail_unless (gst_structure_get_value (s, "height") != NULL);
678 /* with changed order */
679 ci2 = gst_caps_intersect (c1, c2);
680 GST_DEBUG ("intersected: %" GST_PTR_FORMAT, ci2);
681 fail_unless (gst_caps_get_size (ci2) == 1, NULL);
682 s = gst_caps_get_structure (ci2, 0);
683 fail_unless (gst_structure_has_name (s, "video/x-raw"));
684 fail_unless (gst_structure_get_value (s, "format") != NULL);
685 fail_unless (gst_structure_get_value (s, "height") != NULL);
686 fail_unless (gst_structure_get_value (s, "width") != NULL);
688 fail_unless (gst_caps_is_equal (ci1, ci2));
690 gst_caps_unref (ci1);
691 gst_caps_unref (ci2);
699 GST_START_TEST (test_intersect2)
701 GstCaps *caps1, *caps2, *icaps;
703 /* tests array subtraction */
704 caps1 = gst_caps_from_string ("audio/x-raw, "
705 "channel-positions=(int)< "
706 "{ 1, 2, 3, 4, 5, 6 }, "
707 "{ 1, 2, 3, 4, 5, 6 }, "
708 "{ 1, 2, 3, 4, 5, 6 }, "
709 "{ 1, 2, 3, 4, 5, 6 }, "
710 "{ 1, 2, 3, 4, 5, 6 }, " "{ 1, 2, 3, 4, 5, 6 }>");
711 caps2 = gst_caps_from_string ("audio/x-raw, "
712 "channel-positions=(int)< 1, 2, 3, 4, 5, 6 >");
713 icaps = gst_caps_intersect (caps1, caps2);
714 GST_LOG ("intersected caps: %" GST_PTR_FORMAT, icaps);
715 fail_if (gst_caps_is_empty (icaps));
716 fail_unless (gst_caps_is_equal (icaps, caps2));
717 gst_caps_unref (caps1);
718 gst_caps_unref (caps2);
719 gst_caps_unref (icaps);
723 caps1 = gst_caps_from_string ("some/type, foo=(int)< { 1, 2 }, { 3, 4} >");
724 caps2 = gst_caps_from_string ("some/type, foo=(int)< 1, 3 >");
725 icaps = gst_caps_intersect (caps1, caps2);
726 GST_LOG ("intersected caps: %" GST_PTR_FORMAT, icaps);
727 fail_if (gst_caps_is_empty (icaps));
728 fail_unless (gst_caps_is_equal (icaps, caps2));
729 gst_caps_unref (caps1);
730 gst_caps_unref (caps2);
731 gst_caps_unref (icaps);
736 GST_START_TEST (test_intersect_list_duplicate)
738 GstCaps *caps1, *caps2, *icaps;
740 /* make sure we don't take too long to intersect these.. */
741 caps1 = gst_caps_from_string ("video/x-raw, format=(string)YV12; "
742 "video/x-raw, format=(string)I420; video/x-raw, format=(string)YUY2; "
743 "video/x-raw, format=(string)UYVY; "
744 "video/x-raw, format=(string){ I420, YV12, YUY2, UYVY, AYUV, RGBx, BGRx,"
745 " xRGB, xBGR, { RGBA, RGBA, { RGBA, RGBA }, "
746 "{ RGBA, RGBA, { RGBA, RGBA } }, { RGBA, RGBA, { RGBA, RGBA }, "
747 "{ RGBA, RGBA, { RGBA, RGBA } } }, { RGBA, RGBA, { RGBA, RGBA }, "
748 "{ RGBA, RGBA, { RGBA, RGBA } }, { RGBA, RGBA, { RGBA, RGBA }, "
749 "{ RGBA, RGBA, { RGBA, RGBA } } } }, { RGBA, RGBA, { RGBA, RGBA }, "
750 "{ RGBA, RGBA, { RGBA, RGBA } }, { RGBA, RGBA, { RGBA, RGBA }, "
751 "{ RGBA, RGBA, { RGBA, RGBA } } }, { RGBA, RGBA, { RGBA, RGBA }, "
752 "{ RGBA, RGBA, { RGBA, RGBA } }, { RGBA, RGBA, { RGBA, RGBA }, "
753 "{ RGBA, RGBA, { RGBA, RGBA } } } } } }, BGRA, ARGB, { ABGR, ABGR, "
754 "{ ABGR, ABGR }, { ABGR, ABGR, { ABGR, ABGR } }, "
755 "{ ABGR, ABGR, { ABGR, ABGR }, { ABGR, ABGR, { ABGR, ABGR } } }, "
756 "{ ABGR, ABGR, { ABGR, ABGR }, { ABGR, ABGR, { ABGR, ABGR } }, "
757 "{ ABGR, ABGR, { ABGR, ABGR }, { ABGR, ABGR, { ABGR, ABGR } } } }, "
758 "{ ABGR, ABGR, { ABGR, ABGR }, { ABGR, ABGR, { ABGR, ABGR } }, "
759 "{ ABGR, ABGR, { ABGR, ABGR }, { ABGR, ABGR, { ABGR, ABGR } } }, "
760 "{ ABGR, ABGR, { ABGR, ABGR }, { ABGR, ABGR, { ABGR, ABGR } }, "
761 "{ ABGR, ABGR, { ABGR, ABGR }, { ABGR, ABGR, { ABGR, ABGR } } } } } }, "
762 "RGB, BGR, Y41B, Y42B, YVYU, Y444 }; "
763 "video/x-raw, format=(string){ I420, YV12, YUY2, UYVY, AYUV, RGBx, BGRx, "
764 "xRGB, xBGR, { RGBA, RGBA, { RGBA, RGBA }, "
765 "{ RGBA, RGBA, { RGBA, RGBA } }, { RGBA, RGBA, { RGBA, RGBA }, "
766 "{ RGBA, RGBA, { RGBA, RGBA } } }, { RGBA, RGBA, { RGBA, RGBA }, "
767 "{ RGBA, RGBA, { RGBA, RGBA } }, { RGBA, RGBA, { RGBA, RGBA }, "
768 "{ RGBA, RGBA, { RGBA, RGBA } } } }, { RGBA, RGBA, { RGBA, RGBA }, "
769 "{ RGBA, RGBA, { RGBA, RGBA } }, { RGBA, RGBA, { RGBA, RGBA }, "
770 "{ RGBA, RGBA, { RGBA, RGBA } } }, { RGBA, RGBA, { RGBA, RGBA }, "
771 "{ RGBA, RGBA, { RGBA, RGBA } }, { RGBA, RGBA, { RGBA, RGBA }, "
772 "{ RGBA, RGBA, { RGBA, RGBA } } } } } }, BGRA, ARGB, "
773 "{ ABGR, ABGR, { ABGR, ABGR }, { ABGR, ABGR, { ABGR, ABGR } }, "
774 "{ ABGR, ABGR, { ABGR, ABGR }, { ABGR, ABGR, { ABGR, ABGR } } }, "
775 "{ ABGR, ABGR, { ABGR, ABGR }, { ABGR, ABGR, { ABGR, ABGR } }, "
776 "{ ABGR, ABGR, { ABGR, ABGR }, { ABGR, ABGR, { ABGR, ABGR } } } }, "
777 "{ ABGR, ABGR, { ABGR, ABGR }, { ABGR, ABGR, { ABGR, ABGR } }, "
778 "{ ABGR, ABGR, { ABGR, ABGR }, { ABGR, ABGR, { ABGR, ABGR } } }, "
779 "{ ABGR, ABGR, { ABGR, ABGR }, { ABGR, ABGR, { ABGR, ABGR } }, "
780 "{ ABGR, ABGR, { ABGR, ABGR }, { ABGR, ABGR, { ABGR, ABGR } } } } } }, "
781 "RGB, BGR, Y41B, Y42B, YVYU, Y444, NV12, NV21 }; "
782 "video/x-raw, format=(string){ I420, YV12, YUY2, UYVY, AYUV, RGBx, "
783 "BGRx, xRGB, xBGR, { RGBA, RGBA, { RGBA, RGBA }, "
784 "{ RGBA, RGBA, { RGBA, RGBA } }, { RGBA, RGBA, { RGBA, RGBA }, "
785 "{ RGBA, RGBA, { RGBA, RGBA } } } }, BGRA, ARGB, "
786 "{ ABGR, ABGR, { ABGR, ABGR }, { ABGR, ABGR, { ABGR, ABGR } }, "
787 "{ ABGR, ABGR, { ABGR, ABGR }, { ABGR, ABGR, { ABGR, ABGR } } } }, "
788 "RGB, BGR, Y41B, Y42B, YVYU, Y444, NV12, NV21 }");
790 caps2 = gst_caps_copy (caps1);
792 icaps = gst_caps_intersect (caps1, caps2);
794 gst_caps_unref (caps1);
795 gst_caps_unref (caps2);
796 gst_caps_unref (icaps);
801 GST_START_TEST (test_intersect_zigzag)
803 GstCaps *caps1, *caps2, *icaps, *result;
805 /* tests if caps order is maintained */
806 caps1 = gst_caps_from_string ("format/A; format/B; format/C; format/D");
807 caps2 = gst_caps_from_string ("format/D; format/A; format/B; format/C");
809 icaps = gst_caps_intersect_full (caps1, caps2, GST_CAPS_INTERSECT_ZIG_ZAG);
810 result = gst_caps_from_string ("format/B; format/A; format/D; format/C");
811 GST_LOG ("intersected caps: %" GST_PTR_FORMAT, icaps);
812 fail_if (gst_caps_is_empty (icaps));
813 fail_unless (gst_caps_is_equal (icaps, result));
814 gst_caps_unref (icaps);
815 gst_caps_unref (result);
817 icaps = gst_caps_intersect_full (caps2, caps1, GST_CAPS_INTERSECT_FIRST);
818 result = gst_caps_from_string ("format/A; format/B; format/D; format/C");
819 GST_LOG ("intersected caps: %" GST_PTR_FORMAT, icaps);
820 fail_if (gst_caps_is_empty (icaps));
821 fail_unless (gst_caps_is_equal (icaps, result));
822 gst_caps_unref (icaps);
823 gst_caps_unref (result);
825 gst_caps_unref (caps1);
826 gst_caps_unref (caps2);
832 GST_START_TEST (test_intersect_first)
834 GstCaps *caps1, *caps2, *icaps, *result;
836 /* tests if caps order is maintained */
837 caps1 = gst_caps_from_string ("format/A; format/B; format/C; format/D");
838 caps2 = gst_caps_from_string ("format/C; format/D; format/A");
839 icaps = gst_caps_intersect_full (caps1, caps2, GST_CAPS_INTERSECT_FIRST);
840 result = gst_caps_from_string ("format/A; format/C; format/D");
841 GST_LOG ("intersected caps: %" GST_PTR_FORMAT, icaps);
842 fail_if (gst_caps_is_empty (icaps));
843 fail_unless (gst_caps_is_equal (icaps, result));
844 gst_caps_unref (caps1);
845 gst_caps_unref (caps2);
846 gst_caps_unref (icaps);
847 gst_caps_unref (result);
853 GST_START_TEST (test_intersect_first2)
855 GstCaps *caps1, *caps2, *icaps, *result;
857 /* tests if caps order is maintained */
858 caps1 = gst_caps_from_string ("format/A; format/B; format/C; format/D");
859 caps2 = gst_caps_from_string ("format/D; format/A; format/B; format/C");
861 icaps = gst_caps_intersect_full (caps1, caps2, GST_CAPS_INTERSECT_FIRST);
862 result = gst_caps_from_string ("format/A; format/B; format/C; format/D");
863 GST_LOG ("intersected caps: %" GST_PTR_FORMAT, icaps);
864 fail_if (gst_caps_is_empty (icaps));
865 fail_unless (gst_caps_is_equal (icaps, result));
866 gst_caps_unref (icaps);
867 gst_caps_unref (result);
869 icaps = gst_caps_intersect_full (caps2, caps1, GST_CAPS_INTERSECT_FIRST);
870 result = gst_caps_from_string ("format/D; format/A; format/B; format/C");
871 GST_LOG ("intersected caps: %" GST_PTR_FORMAT, icaps);
872 fail_if (gst_caps_is_empty (icaps));
873 fail_unless (gst_caps_is_equal (icaps, result));
874 gst_caps_unref (icaps);
875 gst_caps_unref (result);
877 gst_caps_unref (caps1);
878 gst_caps_unref (caps2);
883 GST_START_TEST (test_intersect_duplication)
885 GstCaps *c1, *c2, *test;
887 c1 = gst_caps_from_string
888 ("audio/x-raw, format=(string)S16_LE, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2 ]");
889 c2 = gst_caps_from_string
890 ("audio/x-raw, format=(string) { S16_LE, S16_BE, U16_LE, U16_BE }, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2 ]; audio/x-raw, format=(string) { S16_LE, S16_BE, U16_LE, U16_BE }, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 11 ]; audio/x-raw, format=(string) { S16_LE, S16_BE, U16_LE, U16_BE }, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 11 ]");
892 test = gst_caps_intersect_full (c1, c2, GST_CAPS_INTERSECT_FIRST);
893 fail_unless_equals_int (gst_caps_get_size (test), 1);
894 fail_unless (gst_caps_is_equal (c1, test));
897 gst_caps_unref (test);
903 _caps_is_fixed_foreach (GQuark field_id, const GValue * value, gpointer unused)
905 return gst_value_is_fixed (value);
909 GST_START_TEST (test_normalize)
911 GstCaps *in, *norm, *out;
914 in = gst_caps_from_string ("some/type, foo=(int){ 1 , 2 }");
915 out = gst_caps_from_string ("some/type, foo=(int) 1; some/type, foo=(int) 2");
916 norm = gst_caps_normalize (in);
917 fail_if (gst_caps_is_empty (norm));
918 fail_unless (gst_caps_is_equal (norm, out));
919 for (i = 0; i < gst_caps_get_size (norm); i++) {
920 GstStructure *st = gst_caps_get_structure (norm, i);
921 /* Make sure all fields of all structures are fixed */
922 fail_unless (gst_structure_foreach (st, _caps_is_fixed_foreach, NULL));
925 gst_caps_unref (out);
926 gst_caps_unref (norm);
928 in = gst_caps_from_string
929 ("some/type, foo=(int){ 1 , 2 }, bar=(int){ 3, 4 }");
932 ("some/type, foo=(int) 1, bar=(int) 3; some/type, foo=(int) 2, bar=(int) 3;"
933 "some/type, foo=(int) 1, bar=(int) 4; some/type, foo=(int) 2, bar=(int) 4;");
934 norm = gst_caps_normalize (in);
935 fail_if (gst_caps_is_empty (norm));
936 fail_unless (gst_caps_is_equal (norm, out));
937 for (i = 0; i < gst_caps_get_size (norm); i++) {
938 GstStructure *st = gst_caps_get_structure (norm, i);
939 /* Make sure all fields of all structures are fixed */
940 fail_unless (gst_structure_foreach (st, _caps_is_fixed_foreach, NULL));
943 gst_caps_unref (out);
944 gst_caps_unref (norm);
946 in = gst_caps_from_string
947 ("some/type, foo=(string){ 1 , 2 }, bar=(string) { 3 }");
950 ("some/type, foo=(string) 1, bar=(string) 3; some/type, foo=(string) 2, bar=(string) 3");
951 norm = gst_caps_normalize (in);
952 fail_if (gst_caps_is_empty (norm));
953 fail_unless (gst_caps_is_equal (norm, out));
954 for (i = 0; i < gst_caps_get_size (norm); i++) {
955 GstStructure *st = gst_caps_get_structure (norm, i);
956 /* Make sure all fields of all structures are fixed */
957 fail_unless (gst_structure_foreach (st, _caps_is_fixed_foreach, NULL));
960 gst_caps_unref (out);
961 gst_caps_unref (norm);
966 GST_START_TEST (test_broken)
970 /* NULL is not valid for media_type */
971 ASSERT_CRITICAL (c1 =
972 gst_caps_new_simple (NULL, "field", G_TYPE_INT, 1, NULL));
975 #ifndef G_DISABLE_CHECKS
976 /* such a name is not valid, see gst_structure_validate_name() */
977 ASSERT_CRITICAL (c1 =
978 gst_caps_new_simple ("1#@abc", "field", G_TYPE_INT, 1, NULL));
985 GST_START_TEST (test_features)
987 GstCaps *c1, *c2, *c3;
988 GstStructure *s1, *s2;
989 GstCapsFeatures *f1, *f2;
991 static GstStaticCaps scaps =
993 ("video/x-raw(memory:EGLImage), width=320, height=[ 240, 260 ]");
995 c1 = gst_caps_new_empty ();
996 fail_unless (c1 != NULL);
997 s1 = gst_structure_new ("video/x-raw", "width", G_TYPE_INT, 320, "height",
998 GST_TYPE_INT_RANGE, 240, 260, NULL);
999 fail_unless (s1 != NULL);
1000 f1 = gst_caps_features_new ("memory:EGLImage", NULL);
1001 fail_unless (f1 != NULL);
1003 gst_caps_append_structure_full (c1, s1, f1);
1004 s2 = gst_caps_get_structure (c1, 0);
1005 fail_unless (s1 == s2);
1006 f2 = gst_caps_get_features (c1, 0);
1007 fail_unless (f1 == f2);
1009 str1 = gst_caps_to_string (c1);
1010 fail_unless (str1 != NULL);
1011 c2 = gst_caps_from_string (str1);
1012 fail_unless (c2 != NULL);
1015 fail_unless (gst_caps_is_equal (c1, c2));
1016 fail_unless (gst_caps_is_subset (c1, c2));
1017 fail_unless (gst_caps_is_subset (c2, c1));
1018 fail_unless (gst_caps_can_intersect (c1, c2));
1020 gst_caps_unref (c2);
1022 c2 = gst_caps_new_empty ();
1023 fail_unless (c2 != NULL);
1024 s2 = gst_structure_new ("video/x-raw", "width", G_TYPE_INT, 320, "height",
1025 GST_TYPE_INT_RANGE, 240, 260, NULL);
1026 fail_unless (s2 != NULL);
1027 f2 = gst_caps_features_new ("memory:VASurface", "meta:VAMeta", NULL);
1028 fail_unless (f2 != NULL);
1029 gst_caps_append_structure_full (c2, s2, f2);
1031 fail_if (gst_caps_is_equal (c1, c2));
1032 fail_if (gst_caps_is_subset (c1, c2));
1033 fail_if (gst_caps_is_subset (c2, c1));
1034 fail_if (gst_caps_can_intersect (c1, c2));
1036 str1 = gst_caps_to_string (c2);
1037 fail_unless (str1 != NULL);
1038 c3 = gst_caps_from_string (str1);
1039 fail_unless (c3 != NULL);
1042 fail_unless (gst_caps_is_equal (c2, c3));
1043 fail_unless (gst_caps_is_subset (c2, c3));
1044 fail_unless (gst_caps_is_subset (c3, c2));
1045 fail_unless (gst_caps_can_intersect (c2, c3));
1047 f1 = gst_caps_get_features (c3, 0);
1048 fail_unless (f1 != NULL);
1050 gst_caps_features_contains (f1, "memory:VASurface");
1051 gst_caps_features_remove (f1, "memory:VASurface");
1052 fail_if (gst_caps_is_equal (c2, c3));
1053 fail_if (gst_caps_is_subset (c2, c3));
1054 fail_if (gst_caps_is_subset (c3, c2));
1055 fail_if (gst_caps_can_intersect (c2, c3));
1057 gst_caps_unref (c3);
1058 gst_caps_unref (c2);
1060 c2 = gst_static_caps_get (&scaps);
1061 fail_unless (c2 != NULL);
1062 fail_unless (gst_caps_is_equal (c1, c2));
1063 fail_unless (gst_caps_is_subset (c1, c2));
1064 fail_unless (gst_caps_is_subset (c2, c1));
1065 fail_unless (gst_caps_can_intersect (c1, c2));
1066 gst_caps_unref (c2);
1068 c2 = gst_caps_from_string
1069 ("video/x-raw(ANY), width=320, height=[ 240, 260 ]");
1070 fail_unless (c2 != NULL);
1071 fail_if (gst_caps_is_equal (c1, c2));
1072 fail_unless (gst_caps_is_subset (c1, c2));
1073 fail_if (gst_caps_is_subset (c2, c1));
1074 fail_unless (gst_caps_can_intersect (c1, c2));
1076 c3 = gst_caps_intersect (c1, c2);
1077 fail_unless (gst_caps_is_equal (c3, c1));
1079 gst_caps_unref (c3);
1080 gst_caps_unref (c2);
1081 gst_caps_unref (c1);
1087 gst_caps_suite (void)
1089 Suite *s = suite_create ("GstCaps");
1090 TCase *tc_chain = tcase_create ("operations");
1092 suite_add_tcase (s, tc_chain);
1093 tcase_add_test (tc_chain, test_from_string);
1094 tcase_add_test (tc_chain, test_double_append);
1095 tcase_add_test (tc_chain, test_mutability);
1096 tcase_add_test (tc_chain, test_static_caps);
1097 tcase_add_test (tc_chain, test_simplify);
1098 tcase_add_test (tc_chain, test_truncate);
1099 tcase_add_test (tc_chain, test_subset);
1100 tcase_add_test (tc_chain, test_merge_fundamental);
1101 tcase_add_test (tc_chain, test_merge_same);
1102 tcase_add_test (tc_chain, test_merge_subset);
1103 tcase_add_test (tc_chain, test_intersect);
1104 tcase_add_test (tc_chain, test_intersect2);
1105 tcase_add_test (tc_chain, test_intersect_list_duplicate);
1106 tcase_add_test (tc_chain, test_intersect_zigzag);
1107 tcase_add_test (tc_chain, test_intersect_first);
1108 tcase_add_test (tc_chain, test_intersect_first2);
1109 tcase_add_test (tc_chain, test_intersect_duplication);
1110 tcase_add_test (tc_chain, test_normalize);
1111 tcase_add_test (tc_chain, test_broken);
1112 tcase_add_test (tc_chain, test_features);
1117 GST_CHECK_MAIN (gst_caps);