summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMathieu Duponchelle <mathieu@centricular.com>2019-02-23 00:23:01 +0100
committerMathieu Duponchelle <mathieu@centricular.com>2019-03-06 11:29:20 +0100
commit156865541fb18e93b445f759f940989bc66ccd7d (patch)
treeec014063d35c64a0d3a12e8f586ac2f8d09567f7 /tests
parentfa8134ed1109e8dbc42a4fc74defdc668927fdaf (diff)
downloadgstreamer-plugins-bad-156865541fb18e93b445f759f940989bc66ccd7d.tar.gz
closedcaption: add line21 encoder
This element acts as a counterpart of line21encoder. Also adds a simple test validating each element using the other.
Diffstat (limited to 'tests')
-rw-r--r--tests/check/Makefile.am2
-rw-r--r--tests/check/elements/line21.c103
-rw-r--r--tests/check/meson.build1
3 files changed, 105 insertions, 1 deletions
diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am
index 36518d449..a07ce8277 100644
--- a/tests/check/Makefile.am
+++ b/tests/check/Makefile.am
@@ -41,7 +41,7 @@ check_assrender =
endif
if USE_PANGO
-check_closedcaption = elements/ccconverter elements/cccombiner elements/ccextractor
+check_closedcaption = elements/ccconverter elements/cccombiner elements/ccextractor elements/line21
else
check_closedcaption =
endif
diff --git a/tests/check/elements/line21.c b/tests/check/elements/line21.c
new file mode 100644
index 000000000..029ff238f
--- /dev/null
+++ b/tests/check/elements/line21.c
@@ -0,0 +1,103 @@
+/* GStreamer
+ *
+ * Copyright (C) 2019 Mathieu Duponchelle <mathieu@centricular.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <gst/gst.h>
+#include <gst/check/gstcheck.h>
+#include <gst/check/gstharness.h>
+#include <gst/video/video.h>
+
+GST_START_TEST (basic)
+{
+ GstHarness *h;
+ GstBuffer *buf, *outbuf;
+ GstVideoInfo info;
+ GstVideoCaptionMeta *in_cc_meta, *out_cc_meta;
+ guint i;
+ guint8 empty_data[] = { 0x90, 0x80, 0x80, 0x0, 0x80, 0x80 };
+ guint8 full_data[] = { 0x90, 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, 625,
+ "interlace-mode", G_TYPE_STRING, "interleaved",
+ NULL);
+
+ h = gst_harness_new_parse ("line21encoder ! line21decoder");
+ 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);
+ 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), 1);
+
+ out_cc_meta = gst_buffer_get_video_caption_meta (outbuf);
+
+ fail_unless (out_cc_meta != NULL);
+ fail_unless (out_cc_meta->size == 6);
+
+ for (i = 0; i < out_cc_meta->size; i++)
+ fail_unless (out_cc_meta->data[i] == empty_data[i]);
+
+ gst_buffer_unref (outbuf);
+
+ 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);
+ fail_unless_equals_int (gst_buffer_get_n_meta (outbuf,
+ 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);
+
+ for (i = 0; i < out_cc_meta->size; i++)
+ fail_unless (out_cc_meta->data[i] == full_data[i]);
+
+ gst_buffer_unref (outbuf);
+}
+
+GST_END_TEST;
+
+static Suite *
+line21_suite (void)
+{
+ Suite *s = suite_create ("line21");
+ TCase *tc = tcase_create ("general");
+
+ suite_add_tcase (s, tc);
+
+ tcase_add_test (tc, basic);
+
+ return s;
+}
+
+GST_CHECK_MAIN (line21);
diff --git a/tests/check/meson.build b/tests/check/meson.build
index 1007b7554..90a334745 100644
--- a/tests/check/meson.build
+++ b/tests/check/meson.build
@@ -58,6 +58,7 @@ if host_machine.system() != 'windows'
[['elements/ccconverter.c']],
[['elements/cccombiner.c']],
[['elements/ccextractor.c']],
+ [['elements/line21.c']],
[['elements/curlhttpsink.c'], not curl_dep.found(), [curl_dep]],
[['elements/curlhttpsrc.c'], not curl_dep.found(), [curl_dep, gio_dep]],
[['elements/curlfilesink.c'],