summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian.droege@collabora.co.uk>2009-04-07 15:50:37 +0200
committerDave Robillard <dave@drobilla.net>2009-05-03 12:03:14 -0400
commitb8de3969acdb19bcb68738d512c6ef29a1646a73 (patch)
tree2d201d5c13163649eda64b13c6113439ea375367
parent5885b6d1c4566d8d5c767295835f580d8fc601d9 (diff)
downloadgst-plugins-bad-b8de3969acdb19bcb68738d512c6ef29a1646a73.tar.gz
gst-plugins-bad-b8de3969acdb19bcb68738d512c6ef29a1646a73.tar.bz2
gst-plugins-bad-b8de3969acdb19bcb68738d512c6ef29a1646a73.zip
mxf: Add unit tests for checking if mxfmux ! mxfdemux pipelines are working without errors
-rw-r--r--tests/check/Makefile.am1
-rw-r--r--tests/check/pipelines/mxf.c282
2 files changed, 283 insertions, 0 deletions
diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am
index 80027c82..b8e890c1 100644
--- a/tests/check/Makefile.am
+++ b/tests/check/Makefile.am
@@ -95,6 +95,7 @@ check_PROGRAMS = \
elements/selector \
elements/mxfdemux \
elements/mxfmux \
+ pipelines/mxf \
elements/y4menc \
$(check_metadata)
diff --git a/tests/check/pipelines/mxf.c b/tests/check/pipelines/mxf.c
new file mode 100644
index 00000000..9693bed0
--- /dev/null
+++ b/tests/check/pipelines/mxf.c
@@ -0,0 +1,282 @@
+/* GStreamer
+ *
+ * unit test for mxfmux ! mxfdemux pipelines
+ *
+ * Copyright (C) <2009> Sebastian Dröge <sebastian.droege@collabora.co.uk>
+ *
+ * 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <gst/check/gstcheck.h>
+#include <string.h>
+
+static const gchar *
+get_mpeg2enc_element_name (void)
+{
+ GstElementFactory *factory = NULL;
+
+ if ((factory = gst_element_factory_find ("mpeg2enc"))) {
+ gst_object_unref (factory);
+ return "mpeg2enc";
+ } else if ((factory = gst_element_factory_find ("ffenc_mpeg2video"))) {
+ gst_object_unref (factory);
+ return "ffenc_mpeg2video";
+ } else {
+ return NULL;
+ }
+}
+
+typedef struct
+{
+ GMainLoop *loop;
+ gboolean eos;
+} OnMessageUserData;
+
+static void
+on_message_cb (GstBus * bus, GstMessage * message, gpointer user_data)
+{
+ OnMessageUserData *d = user_data;
+
+ switch (GST_MESSAGE_TYPE (message)) {
+ case GST_MESSAGE_ERROR:
+ case GST_MESSAGE_WARNING:
+ g_assert_not_reached ();
+ break;
+ case GST_MESSAGE_EOS:
+ g_main_loop_quit (d->loop);
+ d->eos = TRUE;
+ break;
+ default:
+ break;
+ }
+}
+
+static void
+on_pad_added (GstElement * element, GstPad * pad, gpointer user_data)
+{
+ gint *n_pads = user_data;
+
+ *n_pads = *n_pads + 1;
+}
+
+static void
+run_test (const gchar * pipeline_string, gint n_pads_expected)
+{
+ GstElement *pipeline;
+ GstBus *bus;
+ GMainLoop *loop;
+ OnMessageUserData omud = { NULL, };
+ GstStateChangeReturn ret;
+ GstElement *demux;
+ gint n_pads = 0;
+
+ GST_DEBUG ("Testing pipeline '%s'", pipeline_string);
+
+ pipeline = gst_parse_launch (pipeline_string, NULL);
+ fail_unless (pipeline != NULL);
+ g_object_set (G_OBJECT (pipeline), "async-handling", TRUE, NULL);
+
+ demux = gst_bin_get_by_name (GST_BIN (pipeline), "demux");
+ fail_unless (demux != NULL);
+ g_signal_connect (demux, "pad-added", (GCallback) on_pad_added, &n_pads);
+ gst_object_unref (demux);
+
+ loop = g_main_loop_new (NULL, FALSE);
+
+ bus = gst_element_get_bus (pipeline);
+ fail_unless (bus != NULL);
+ gst_bus_add_signal_watch (bus);
+
+ omud.loop = loop;
+ omud.eos = FALSE;
+
+ g_signal_connect (bus, "message", (GCallback) on_message_cb, &omud);
+
+ gst_object_unref (bus);
+
+ ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
+ fail_unless (ret == GST_STATE_CHANGE_SUCCESS
+ || ret == GST_STATE_CHANGE_ASYNC);
+
+ g_main_loop_run (loop);
+
+ fail_unless (gst_element_set_state (pipeline,
+ GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS);
+
+ fail_unless (omud.eos == TRUE);
+ fail_unless_equals_int (n_pads, n_pads_expected);
+
+ gst_object_unref (pipeline);
+ g_main_loop_unref (loop);
+}
+
+GST_START_TEST (test_mpeg2)
+{
+ const gchar *mpeg2enc_name = get_mpeg2enc_element_name ();
+ gchar *pipeline;
+
+ if (!mpeg2enc_name)
+ return;
+
+ pipeline = g_strdup_printf ("videotestsrc num-buffers=250 ! "
+ "video/x-raw-yuv,framerate=25/1 ! "
+ "%s ! " "mxfmux name=mux ! "
+ "mxfdemux name=demux ! " "fakesink", mpeg2enc_name);
+
+ run_test (pipeline, 1);
+ g_free (pipeline);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_raw_video_raw_audio)
+{
+ gchar *pipeline;
+
+ pipeline = g_strdup_printf ("videotestsrc num-buffers=250 ! "
+ "video/x-raw-yuv,format=(GstFourcc)v308,width=1920,height=1080,framerate=25/1 ! "
+ "mxfmux name=mux ! "
+ "mxfdemux name=demux ! "
+ "fakesink "
+ "audiotestsrc num-buffers=250 ! "
+ "audioconvert ! " "audio/x-raw-int,rate=48000,channels=2 ! " "mux. ");
+
+ run_test (pipeline, 2);
+ g_free (pipeline);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_raw_video_stride_transform)
+{
+ gchar *pipeline;
+
+ pipeline = g_strdup_printf ("videotestsrc num-buffers=250 ! "
+ "video/x-raw-yuv,format=(GstFourcc)v308,width=1001,height=501,framerate=25/1 ! "
+ "mxfmux name=mux ! " "mxfdemux name=demux ! " "fakesink");
+
+ run_test (pipeline, 1);
+ g_free (pipeline);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_jpeg2000_alaw)
+{
+ gchar *pipeline;
+ GstElementFactory *factory = NULL;
+
+ if ((factory = gst_element_factory_find ("jp2kenc")) == NULL)
+ return;
+ gst_object_unref (factory);
+ if ((factory = gst_element_factory_find ("alawenc")) == NULL)
+ return;
+ gst_object_unref (factory);
+
+ pipeline = g_strdup_printf ("videotestsrc num-buffers=250 ! "
+ "video/x-raw-yuv,framerate=25/1 ! "
+ "jp2kenc ! "
+ "mxfmux name=mux ! "
+ "mxfdemux name=demux ! "
+ "fakesink "
+ "audiotestsrc num-buffers=250 ! " "audioconvert ! " "alawenc ! " "mux. ");
+
+ run_test (pipeline, 2);
+ g_free (pipeline);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_dnxhd_mp3)
+{
+ gchar *pipeline;
+ GstElementFactory *factory = NULL;
+
+ if ((factory = gst_element_factory_find ("ffenc_dnxhd")) == NULL)
+ return;
+ gst_object_unref (factory);
+ if ((factory = gst_element_factory_find ("lame")) == NULL)
+ return;
+ gst_object_unref (factory);
+ if ((factory = gst_element_factory_find ("mp3parse")) == NULL)
+ return;
+ gst_object_unref (factory);
+
+ pipeline = g_strdup_printf ("videotestsrc num-buffers=250 ! "
+ "video/x-raw-yuv,format=(GstFourcc)Y42B,width=1920,height=1080,framerate=25/1 ! "
+ "ffenc_dnxhd bitrate=36000000 ! "
+ "mxfmux name=mux ! "
+ "mxfdemux name=demux ! "
+ "fakesink "
+ "audiotestsrc num-buffers=250 ! "
+ "audioconvert ! "
+ "audio/x-raw-int,channels=2 ! " "lame ! " "mp3parse ! " "mux. ");
+
+ run_test (pipeline, 2);
+ g_free (pipeline);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_multiple_av_streams)
+{
+ gchar *pipeline;
+
+ pipeline = g_strdup_printf ("videotestsrc num-buffers=250 ! "
+ "video/x-raw-yuv,format=(GstFourcc)v308,width=1920,height=1080,framerate=25/1 ! "
+ "mxfmux name=mux ! "
+ "mxfdemux name=demux ! "
+ "fakesink "
+ "audiotestsrc num-buffers=250 ! "
+ "audioconvert ! "
+ "audio/x-raw-int,rate=48000,channels=2 ! "
+ "mux. "
+ "videotestsrc num-buffers=100 ! "
+ "video/x-raw-yuv,format=(GstFourcc)v308,width=1920,height=1080,framerate=25/1 ! "
+ "mux. "
+ "audiotestsrc num-buffers=100 ! "
+ "audioconvert ! "
+ "audio/x-raw-int,rate=48000,channels=2 ! "
+ "mux. "
+ "audiotestsrc num-buffers=250 ! "
+ "audioconvert ! " "audio/x-raw-int,rate=48000,channels=2 ! " "mux. ");
+
+ run_test (pipeline, 5);
+ g_free (pipeline);
+}
+
+GST_END_TEST;
+
+static Suite *
+mxf_suite (void)
+{
+ Suite *s = suite_create ("mxf");
+ TCase *tc_chain = tcase_create ("general");
+
+ suite_add_tcase (s, tc_chain);
+ tcase_set_timeout (tc_chain, 180);
+
+ tcase_add_test (tc_chain, test_mpeg2);
+ tcase_add_test (tc_chain, test_raw_video_raw_audio);
+ tcase_add_test (tc_chain, test_raw_video_stride_transform);
+ tcase_add_test (tc_chain, test_jpeg2000_alaw);
+ tcase_add_test (tc_chain, test_dnxhd_mp3);
+ tcase_add_test (tc_chain, test_multiple_av_streams);
+
+ return s;
+}
+
+GST_CHECK_MAIN (mxf);