tests/check/gst/gstcaps.c: Add some tests for gst_caps_intersect().
authorTim-Philipp Müller <tim@centricular.net>
Wed, 27 Sep 2006 09:23:18 +0000 (09:23 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Wed, 27 Sep 2006 09:23:18 +0000 (09:23 +0000)
Original commit message from CVS:
* tests/check/gst/gstcaps.c: (GST_START_TEST), (gst_caps_suite):
Add some tests for gst_caps_intersect().
* tools/gst-launch.c: (event_loop):
Print all buffering percentages we get, even the 100% one.

ChangeLog
tests/check/gst/gstcaps.c
tools/gst-launch.c

index 78373b8..79eaf24 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-09-27  Tim-Philipp Müller  <tim at centricular dot net>
+
+       * tests/check/gst/gstcaps.c: (GST_START_TEST), (gst_caps_suite):
+         Add some tests for gst_caps_intersect().
+
+       * tools/gst-launch.c: (event_loop):
+         Print all buffering percentages we get, even the 100% one.
+
 2006-09-26  Wim Taymans  <wim@fluendo.com>
 
        * tools/gst-inspect.c: (print_element_properties_info),
index 1d56d00..7cdee34 100644 (file)
@@ -466,6 +466,119 @@ GST_START_TEST (test_merge_subset)
 
 GST_END_TEST;
 
+GST_START_TEST (test_intersect)
+{
+  GstStructure *s;
+  GstCaps *c1, *c2, *ci1, *ci2;
+
+  /* field not specified = any value possible, so the intersection
+   * should keep fields which are only part of one set of caps */
+  c2 = gst_caps_from_string ("video/x-raw-yuv,format=(fourcc)I420,width=20");
+  c1 = gst_caps_from_string ("video/x-raw-yuv,format=(fourcc)I420");
+
+  ci1 = gst_caps_intersect (c2, c1);
+  GST_DEBUG ("intersected: %" GST_PTR_FORMAT, ci1);
+  fail_unless (gst_caps_get_size (ci1) == 1, NULL);
+  s = gst_caps_get_structure (ci1, 0);
+  fail_unless (gst_structure_has_name (s, "video/x-raw-yuv"));
+  fail_unless (gst_structure_get_value (s, "format") != NULL);
+  fail_unless (gst_structure_get_value (s, "width") != NULL);
+
+  /* with changed order */
+  ci2 = gst_caps_intersect (c1, c2);
+  GST_DEBUG ("intersected: %" GST_PTR_FORMAT, ci2);
+  fail_unless (gst_caps_get_size (ci2) == 1, NULL);
+  s = gst_caps_get_structure (ci2, 0);
+  fail_unless (gst_structure_has_name (s, "video/x-raw-yuv"));
+  fail_unless (gst_structure_get_value (s, "format") != NULL);
+  fail_unless (gst_structure_get_value (s, "width") != NULL);
+
+  fail_unless (gst_caps_is_equal (ci1, ci2));
+
+  gst_caps_unref (ci1);
+  gst_caps_unref (ci2);
+
+  gst_caps_unref (c1);
+  gst_caps_unref (c2);
+
+  /* ========== */
+
+  c2 = gst_caps_from_string ("video/x-raw-yuv,format=(fourcc)I420,width=20");
+  c1 = gst_caps_from_string ("video/x-raw-yuv,format=(fourcc)I420,width=30");
+
+  ci1 = gst_caps_intersect (c2, c1);
+  GST_DEBUG ("intersected: %" GST_PTR_FORMAT, ci1);
+  fail_unless (gst_caps_is_empty (ci1), NULL);
+
+  /* with changed order */
+  ci2 = gst_caps_intersect (c1, c2);
+  GST_DEBUG ("intersected: %" GST_PTR_FORMAT, ci2);
+  fail_unless (gst_caps_is_empty (ci2), NULL);
+
+  fail_unless (gst_caps_is_equal (ci1, ci2));
+
+  gst_caps_unref (ci1);
+  gst_caps_unref (ci2);
+
+  gst_caps_unref (c1);
+  gst_caps_unref (c2);
+
+  /* ========== */
+
+  c2 = gst_caps_from_string ("video/x-raw-yuv,format=(fourcc)I420,width=20");
+  c1 = gst_caps_from_string ("video/x-raw-rgb,format=(fourcc)I420,width=20");
+
+  ci1 = gst_caps_intersect (c2, c1);
+  GST_DEBUG ("intersected: %" GST_PTR_FORMAT, ci1);
+  fail_unless (gst_caps_is_empty (ci1), NULL);
+
+  /* with changed order */
+  ci2 = gst_caps_intersect (c1, c2);
+  GST_DEBUG ("intersected: %" GST_PTR_FORMAT, ci2);
+  fail_unless (gst_caps_is_empty (ci2), NULL);
+
+  fail_unless (gst_caps_is_equal (ci1, ci2));
+
+  gst_caps_unref (ci1);
+  gst_caps_unref (ci2);
+
+  gst_caps_unref (c1);
+  gst_caps_unref (c2);
+
+  /* ========== */
+
+  c2 = gst_caps_from_string ("video/x-raw-yuv,format=(fourcc)I420,width=20");
+  c1 = gst_caps_from_string ("video/x-raw-yuv,format=(fourcc)I420,height=30");
+
+  ci1 = gst_caps_intersect (c2, c1);
+  GST_DEBUG ("intersected: %" GST_PTR_FORMAT, ci1);
+  fail_unless (gst_caps_get_size (ci1) == 1, NULL);
+  s = gst_caps_get_structure (ci1, 0);
+  fail_unless (gst_structure_has_name (s, "video/x-raw-yuv"));
+  fail_unless (gst_structure_get_value (s, "format") != NULL);
+  fail_unless (gst_structure_get_value (s, "width") != NULL);
+  fail_unless (gst_structure_get_value (s, "height") != NULL);
+
+  /* with changed order */
+  ci2 = gst_caps_intersect (c1, c2);
+  GST_DEBUG ("intersected: %" GST_PTR_FORMAT, ci2);
+  fail_unless (gst_caps_get_size (ci2) == 1, NULL);
+  s = gst_caps_get_structure (ci2, 0);
+  fail_unless (gst_structure_has_name (s, "video/x-raw-yuv"));
+  fail_unless (gst_structure_get_value (s, "format") != NULL);
+  fail_unless (gst_structure_get_value (s, "height") != NULL);
+  fail_unless (gst_structure_get_value (s, "width") != NULL);
+
+  fail_unless (gst_caps_is_equal (ci1, ci2));
+
+  gst_caps_unref (ci1);
+  gst_caps_unref (ci2);
+
+  gst_caps_unref (c1);
+  gst_caps_unref (c2);
+}
+
+GST_END_TEST;
 
 Suite *
 gst_caps_suite (void)
@@ -484,6 +597,7 @@ gst_caps_suite (void)
   tcase_add_test (tc_chain, test_merge_fundamental);
   tcase_add_test (tc_chain, test_merge_same);
   tcase_add_test (tc_chain, test_merge_subset);
+  tcase_add_test (tc_chain, test_intersect);
 
   return s;
 }
index 6f3bad8..38e7203 100644 (file)
@@ -483,6 +483,7 @@ event_loop (GstElement * pipeline, gboolean blocking, GstState target_state)
         gint percent;
 
         gst_message_parse_buffering (message, &percent);
+        fprintf (stderr, "buffering... %d\r", percent);
 
         if (percent == 100) {
           /* a 100% message means buffering is done */
@@ -501,7 +502,6 @@ event_loop (GstElement * pipeline, gboolean blocking, GstState target_state)
             gst_element_set_state (pipeline, GST_STATE_PAUSED);
             buffering = TRUE;
           }
-          fprintf (stderr, "buffering... %d\r", percent);
         }
         break;
       }