From b74d2e83a60c10c0c2c79bf246131b15568d7637 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Wed, 27 Sep 2006 09:23:18 +0000 Subject: [PATCH] tests/check/gst/gstcaps.c: Add some tests for gst_caps_intersect(). 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 | 8 +++ tests/check/gst/gstcaps.c | 114 ++++++++++++++++++++++++++++++++++++++ tools/gst-launch.c | 2 +- 3 files changed, 123 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 78373b8776..79eaf24657 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-09-27 Tim-Philipp Müller + + * 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 * tools/gst-inspect.c: (print_element_properties_info), diff --git a/tests/check/gst/gstcaps.c b/tests/check/gst/gstcaps.c index 1d56d00e12..7cdee343c9 100644 --- a/tests/check/gst/gstcaps.c +++ b/tests/check/gst/gstcaps.c @@ -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; } diff --git a/tools/gst-launch.c b/tools/gst-launch.c index 6f3bad8e16..38e7203779 100644 --- a/tools/gst-launch.c +++ b/tools/gst-launch.c @@ -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; }