line21enc: fix remove-caption-meta property test

It's possible for the same address to be allocated to the decoded
metadata. Switch test to actual detect if it was removed.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2159>
This commit is contained in:
Doug Nazar 2021-04-13 16:34:15 -04:00
parent a1535a4dc3
commit 63b5ae0ffe

View file

@ -31,7 +31,7 @@ GST_START_TEST (basic)
GstHarness *h;
GstBuffer *buf, *outbuf;
GstVideoInfo info;
GstVideoCaptionMeta *in_cc_meta, *out_cc_meta;
GstVideoCaptionMeta *out_cc_meta;
guint i;
guint8 empty_data[] = { 0x8c, 0x80, 0x80, 0x0, 0x80, 0x80 };
guint8 full_data[] = { 0x8c, 0x42, 0x43, 0x0, 0x44, 0x45 };
@ -58,7 +58,6 @@ GST_START_TEST (basic)
GST_VIDEO_CAPTION_META_API_TYPE), 1);
out_cc_meta = gst_buffer_get_video_caption_meta (outbuf);
fail_unless (out_cc_meta != NULL);
fail_unless (out_cc_meta->size == 6);
@ -70,7 +69,7 @@ GST_START_TEST (basic)
buf = gst_buffer_new_and_alloc (info.size);
gst_buffer_add_video_caption_meta (buf, GST_VIDEO_CAPTION_TYPE_CEA608_S334_1A,
full_data, 6);
in_cc_meta = gst_buffer_get_video_caption_meta (buf);
outbuf = gst_harness_push_and_pull (h, buf);
fail_unless (outbuf != NULL);
@ -78,7 +77,7 @@ GST_START_TEST (basic)
GST_VIDEO_CAPTION_META_API_TYPE), 1);
out_cc_meta = gst_buffer_get_video_caption_meta (outbuf);
fail_unless (in_cc_meta != out_cc_meta);
fail_unless (out_cc_meta != NULL);
for (i = 0; i < out_cc_meta->size; i++)
fail_unless (out_cc_meta->data[i] == full_data[i]);
@ -89,6 +88,45 @@ GST_START_TEST (basic)
GST_END_TEST;
GST_START_TEST (remove_caption_meta)
{
GstHarness *h;
GstBuffer *buf, *outbuf;
GstVideoInfo info;
GstVideoCaptionMeta *out_cc_meta;
guint8 full_data[] = { 0x8c, 0x42, 0x43, 0x0, 0x44, 0x45 };
GstCaps *caps = gst_caps_new_simple ("video/x-raw",
"format", G_TYPE_STRING, "I420",
"width", G_TYPE_INT, 720,
"height", G_TYPE_INT, 525,
"interlace-mode", G_TYPE_STRING, "interleaved",
NULL);
h = gst_harness_new_parse ("line21encoder remove-caption-meta=true");
gst_harness_set_caps (h, gst_caps_ref (caps), gst_caps_ref (caps));
gst_video_info_from_caps (&info, caps);
gst_caps_unref (caps);
buf = gst_buffer_new_and_alloc (info.size);
gst_buffer_add_video_caption_meta (buf, GST_VIDEO_CAPTION_TYPE_CEA608_S334_1A,
full_data, 6);
outbuf = gst_harness_push_and_pull (h, buf);
fail_unless (outbuf != NULL);
fail_unless_equals_int (gst_buffer_get_n_meta (outbuf,
GST_VIDEO_CAPTION_META_API_TYPE), 0);
out_cc_meta = gst_buffer_get_video_caption_meta (outbuf);
fail_unless (out_cc_meta == NULL);
gst_buffer_unref (outbuf);
gst_harness_teardown (h);
}
GST_END_TEST;
static Suite *
line21_suite (void)
{
@ -98,6 +136,7 @@ line21_suite (void)
suite_add_tcase (s, tc);
tcase_add_test (tc, basic);
tcase_add_test (tc, remove_caption_meta);
return s;
}