📄 gstcaps.c
字号:
fail_unless (GST_VALUE_HOLDS_FRACTION_RANGE (framerate_value)); val_fps = gst_value_get_fraction_range_min (framerate_value); gst_value_set_fraction (&test_fps, 1, 100); fail_unless (gst_value_compare (&test_fps, val_fps) == GST_VALUE_EQUAL); val_fps = gst_value_get_fraction_range_max (framerate_value); gst_value_set_fraction (&test_fps, 100, 1); fail_unless (gst_value_compare (&test_fps, val_fps) == GST_VALUE_EQUAL); g_value_unset (&test_fps); width_value = gst_structure_get_value (s2, "width"); fail_unless (width_value != NULL); fail_unless (GST_VALUE_HOLDS_INT_RANGE (width_value)); min_width = gst_value_get_int_range_min (width_value); max_width = gst_value_get_int_range_max (width_value); fail_unless (min_width == 16 && max_width == 4096); height_value = gst_structure_get_value (s2, "height"); fail_unless (height_value != NULL); fail_unless (GST_VALUE_HOLDS_INT_RANGE (height_value)); min_height = gst_value_get_int_range_min (height_value); max_height = gst_value_get_int_range_max (height_value); fail_unless (min_height == 16 && max_height == 4096); } gst_caps_unref (caps);}GST_END_TEST;GST_START_TEST (test_truncate){ GstCaps *caps; caps = gst_caps_from_string (non_simple_caps_string); fail_unless (caps != NULL, "gst_caps_from_string (non_simple_caps_string) failed"); fail_unless_equals_int (gst_caps_get_size (caps), 4); gst_caps_truncate (caps); fail_unless_equals_int (gst_caps_get_size (caps), 1); gst_caps_unref (caps);}GST_END_TEST;GST_START_TEST (test_merge_fundamental){ GstCaps *c1, *c2; /* ANY + specific = ANY */ c1 = gst_caps_from_string ("audio/x-raw-int,rate=44100"); c2 = gst_caps_new_any (); gst_caps_merge (c2, c1); GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2); fail_unless (gst_caps_get_size (c2) == 0, NULL); fail_unless (gst_caps_is_any (c2), NULL); gst_caps_unref (c2); /* specific + ANY = ANY */ c2 = gst_caps_from_string ("audio/x-raw-int,rate=44100"); c1 = gst_caps_new_any (); gst_caps_merge (c2, c1); GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2); fail_unless (gst_caps_get_size (c2) == 0, NULL); fail_unless (gst_caps_is_any (c2), NULL); gst_caps_unref (c2); /* EMPTY + specific = specific */ c1 = gst_caps_from_string ("audio/x-raw-int,rate=44100"); c2 = gst_caps_new_empty (); gst_caps_merge (c2, c1); GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2); fail_unless (gst_caps_get_size (c2) == 1, NULL); fail_if (gst_caps_is_empty (c2), NULL); gst_caps_unref (c2); /* specific + EMPTY = specific */ c2 = gst_caps_from_string ("audio/x-raw-int,rate=44100"); c1 = gst_caps_new_empty (); gst_caps_merge (c2, c1); GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2); fail_unless (gst_caps_get_size (c2) == 1, NULL); fail_if (gst_caps_is_empty (c2), NULL); gst_caps_unref (c2);}GST_END_TEST;GST_START_TEST (test_merge_same){ GstCaps *c1, *c2; /* this is the same */ c1 = gst_caps_from_string ("audio/x-raw-int,rate=44100,channels=1"); c2 = gst_caps_from_string ("audio/x-raw-int,rate=44100,channels=1"); gst_caps_merge (c2, c1); GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2); fail_unless (gst_caps_get_size (c2) == 1, NULL); gst_caps_unref (c2); /* and so is this */ c1 = gst_caps_from_string ("audio/x-raw-int,rate=44100,channels=1"); c2 = gst_caps_from_string ("audio/x-raw-int,channels=1,rate=44100"); gst_caps_merge (c2, c1); GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2); fail_unless (gst_caps_get_size (c2) == 1, NULL); gst_caps_unref (c2); c1 = gst_caps_from_string ("video/x-foo, data=(buffer)AA"); c2 = gst_caps_from_string ("video/x-foo, data=(buffer)AABB"); gst_caps_merge (c2, c1); GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2); fail_unless (gst_caps_get_size (c2) == 2, NULL); gst_caps_unref (c2); c1 = gst_caps_from_string ("video/x-foo, data=(buffer)AABB"); c2 = gst_caps_from_string ("video/x-foo, data=(buffer)AA"); gst_caps_merge (c2, c1); GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2); fail_unless (gst_caps_get_size (c2) == 2, NULL); gst_caps_unref (c2); c1 = gst_caps_from_string ("video/x-foo, data=(buffer)AA"); c2 = gst_caps_from_string ("video/x-foo, data=(buffer)AA"); gst_caps_merge (c2, c1); GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2); fail_unless (gst_caps_get_size (c2) == 1, NULL); gst_caps_unref (c2); c1 = gst_caps_from_string ("video/x-foo, data=(buffer)AA"); c2 = gst_caps_from_string ("video/x-bar, data=(buffer)AA"); gst_caps_merge (c2, c1); GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2); fail_unless (gst_caps_get_size (c2) == 2, NULL); gst_caps_unref (c2);}GST_END_TEST;GST_START_TEST (test_merge_subset){ GstCaps *c1, *c2; /* the 2nd is already covered */ c2 = gst_caps_from_string ("audio/x-raw-int,channels=[1,2]"); c1 = gst_caps_from_string ("audio/x-raw-int,channels=1"); gst_caps_merge (c2, c1); GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2); fail_unless (gst_caps_get_size (c2) == 1, NULL); gst_caps_unref (c2); /* here it is not */ c2 = gst_caps_from_string ("audio/x-raw-int,channels=1,rate=44100"); c1 = gst_caps_from_string ("audio/x-raw-int,channels=[1,2],rate=44100"); gst_caps_merge (c2, c1); GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2); fail_unless (gst_caps_get_size (c2) == 2, NULL); gst_caps_unref (c2);}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){ Suite *s = suite_create ("GstCaps"); TCase *tc_chain = tcase_create ("mutability"); suite_add_tcase (s, tc_chain); tcase_add_test (tc_chain, test_from_string); tcase_add_test (tc_chain, test_double_append); tcase_add_test (tc_chain, test_mutability); tcase_add_test (tc_chain, test_buffer); tcase_add_test (tc_chain, test_static_caps); tcase_add_test (tc_chain, test_simplify); tcase_add_test (tc_chain, test_truncate); 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;}GST_CHECK_MAIN (gst_caps);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -