summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/check/Makefile.am5
-rw-r--r--tests/check/elements/mpegvideoparse.c67
-rw-r--r--tests/files/Makefile.am1
-rw-r--r--tests/files/mpeg2-es-with-cea708-cc.datbin0 -> 8192 bytes
4 files changed, 69 insertions, 4 deletions
diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am
index 111a41f35..4a4a03999 100644
--- a/tests/check/Makefile.am
+++ b/tests/check/Makefile.am
@@ -334,7 +334,10 @@ libparser_la_CFLAGS = \
-I$(top_srcdir)/tests/check \
$(GST_CFLAGS) $(GST_CHECK_CFLAGS) $(GST_OPTION_CFLAGS)
-elements_mpegvideoparse_LDADD = libparser.la $(LDADD)
+elements_mpegvideoparse_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) \
+ $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(AM_CFLAGS)
+elements_mpegvideoparse_LDADD = libparser.la \
+ $(GST_PLUGINS_BASE_LIBS) -lgstvideo-$(GST_API_VERSION) $(LDADD)
elements_mpeg4videoparse_LDADD = libparser.la $(LDADD)
diff --git a/tests/check/elements/mpegvideoparse.c b/tests/check/elements/mpegvideoparse.c
index 58c4ee578..86196dbac 100644
--- a/tests/check/elements/mpegvideoparse.c
+++ b/tests/check/elements/mpegvideoparse.c
@@ -4,8 +4,8 @@
* unit test for mpegvideoparse
*
* Copyright (C) 2011 Nokia Corporation. All rights reserved.
- *
- * Contact: Stefan Kost <stefan.kost@nokia.com>
+ * Contact: Stefan Kost <stefan.kost@nokia.com>
+ * Copyright (C) 2018 Tim-Philipp Müller <tim centricular com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -23,7 +23,8 @@
* Boston, MA 02110-1301, USA.
*/
-#include <gst/check/gstcheck.h>
+#include <gst/check/check.h>
+#include <gst/video/video.h>
#include "parser.h"
#define SRC_CAPS_TMPL "video/mpeg, mpegversion=(int)2, systemstream=(boolean)false, parsed=(boolean)false"
@@ -233,6 +234,65 @@ GST_START_TEST (test_parse_gop_split)
GST_END_TEST;
+GST_START_TEST (test_parse_cea708_captions)
+{
+ GstClockTime last_ts = 0;
+ GstHarness *h;
+ GstBuffer *buf;
+ gchar *fn;
+ gint i, j;
+
+ h = gst_harness_new_parse ("filesrc name=filesrc ! mpegvideoparse");
+
+ /* Minimal stripped down MPEG-2 video elementary stream with truncated slices.
+ * Created via mpegvideoparse ! multifilesink and then truncating all files
+ * to 80-100 bytes or such and concatenating them back together. */
+ fn = g_build_filename (GST_TEST_FILES_PATH, "mpeg2-es-with-cea708-cc.dat",
+ NULL);
+ gst_harness_set (h, "filesrc", "location", fn, NULL);
+ g_free (fn);
+
+ gst_harness_play (h);
+
+ for (i = 0; i < 50; ++i) {
+ GstVideoCaptionMeta *caption_meta;
+
+ buf = gst_harness_pull (h);
+ GST_LOG ("pulled buffer %" GST_PTR_FORMAT, buf);
+ caption_meta = gst_buffer_get_video_caption_meta (buf);
+ fail_unless (caption_meta != NULL);
+ fail_unless_equals_int (caption_meta->caption_type,
+ GST_VIDEO_CAPTION_TYPE_CEA708_RAW);
+ fail_unless_equals_int (caption_meta->size, 60);
+
+ /* iterate over triplets */
+ for (j = 0; j < 20; ++j) {
+ guint8 cc_type = caption_meta->data[3 * j] & 0x03;
+
+ /* first triplet always CEA-608 line 21 field 2 in our sample */
+ if (j == 0)
+ fail_unless_equals_int (cc_type, 1);
+ /* second triplet always CEA-608 line 21 field 1 in our sample */
+ if (j == 1)
+ fail_unless_equals_int (cc_type, 0);
+ if (j > 2)
+ fail_unless (cc_type == 2 || cc_type == 3);
+ /* first packet starts with a CCP header */
+ if (i == 0 && j == 2)
+ fail_unless (cc_type == 3);
+ }
+ /* buffer sanity check */
+ if (i > 0)
+ fail_unless (GST_BUFFER_DTS (buf) > last_ts);
+
+ last_ts = GST_BUFFER_DTS (buf);
+ gst_buffer_unref (buf);
+ }
+
+ gst_harness_teardown (h);
+}
+
+GST_END_TEST;
static Suite *
mpegvideoparse_suite (void)
@@ -257,6 +317,7 @@ mpegvideoparse_suite (void)
tcase_add_test (tc_chain, test_parse_detect_stream_mpeg1);
tcase_add_test (tc_chain, test_parse_detect_stream_mpeg2);
tcase_add_test (tc_chain, test_parse_gop_split);
+ tcase_add_test (tc_chain, test_parse_cea708_captions);
return s;
}
diff --git a/tests/files/Makefile.am b/tests/files/Makefile.am
index 359d601e1..d2b255392 100644
--- a/tests/files/Makefile.am
+++ b/tests/files/Makefile.am
@@ -1,4 +1,5 @@
EXTRA_DIST = \
barcode.png \
blue-square.png \
+ mpeg2-es-with-cea708-cc.dat \
s16be-id3v2.aiff
diff --git a/tests/files/mpeg2-es-with-cea708-cc.dat b/tests/files/mpeg2-es-with-cea708-cc.dat
new file mode 100644
index 000000000..ca2f15149
--- /dev/null
+++ b/tests/files/mpeg2-es-with-cea708-cc.dat
Binary files differ