slomo gst-plugins-bad: gst-plugins-bad/ gst-plugins-bad/tests/check/ gst-plugins-bad/tests/check/elements/
[email protected] Tue, 16 Dec 2008 01:59:52 -0800 (PST)
| Newsgroups | gmane.comp.video.gstreamer.cvs |
|---|---|
| Message-ID | <[email protected]> |
CVS Root: /cvs/gstreamer
Module: gst-plugins-bad
Changes by: slomo
Date: Tue Dec 16 2008 09:59:52 UTC
Log message:
* tests/check/Makefile.am:
* tests/check/elements/mxfdemux.c: (_pad_added), (_sink_chain),
(_sink_event), (_create_sink_pad), (_create_src_pad_push),
(_src_getrange), (_src_query), (_create_src_pad_pull),
(GST_START_TEST), (mxfdemux_suite):
* tests/check/elements/mxfdemux.h:
Add push and pull mode unit test for mxfdemux.
Modified files:
. : ChangeLog
tests/check : Makefile.am
Added files:
tests/check/elements: mxfdemux.c mxfdemux.h
Links:
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/ChangeLog.diff?r1=1.3814&r2=1.3815
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/tests/check/Makefile.am.diff?r1=1.67&r2=1.68
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/tests/check/elements/mxfdemux.c?rev=1.1&content-type=text/vnd.viewcvs-markup
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/tests/check/elements/mxfdemux.h?rev=1.1&content-type=text/vnd.viewcvs-markup
====Begin Diffs====
Index: ChangeLog
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-bad/ChangeLog,v
retrieving revision 1.3814
retrieving revision 1.3815
diff -u -d -r1.3814 -r1.3815
--- ChangeLog 16 Dec 2008 08:35:02 -0000 1.3814
+++ ChangeLog 16 Dec 2008 09:59:36 -0000 1.3815
@@ -1,5 +1,15 @@
2008-12-16 Sebastian Dröge <[email protected]>
+ * tests/check/Makefile.am:
+ * tests/check/elements/mxfdemux.c: (_pad_added), (_sink_chain),
+ (_sink_event), (_create_sink_pad), (_create_src_pad_push),
+ (_src_getrange), (_src_query), (_create_src_pad_pull),
+ (GST_START_TEST), (mxfdemux_suite):
+ * tests/check/elements/mxfdemux.h:
+ Add push and pull mode unit test for mxfdemux.
+
+2008-12-16 Sebastian Dröge <[email protected]>
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-bad-plugins-docs.sgml:
* docs/plugins/gst-plugins-bad-plugins-sections.txt:
Index: Makefile.am
RCS file: /cvs/gstreamer/gst-plugins-bad/tests/check/Makefile.am,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- Makefile.am 27 Nov 2008 16:58:30 -0000 1.67
+++ Makefile.am 16 Dec 2008 09:59:37 -0000 1.68
@@ -92,10 +92,11 @@
elements/audioresample \
elements/qtmux \
elements/selector \
+ elements/mxfdemux \
elements/y4menc \
$(check_metadata)
-noinst_HEADERS =
+noinst_HEADERS = elements/mxfdemux.h
TESTS = $(check_PROGRAMS)
--- NEW FILE: mxfdemux.c ---
/* GStreamer
*
* unit test for mxfdemux
* Copyright (C) <2008> Sebastian Dröge <[email protected]>
* 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>
#include "mxfdemux.h"
static GstPad *mysrcpad, *mysinkpad;
static GMainLoop *loop = NULL;
static gboolean have_eos = FALSE;
static gboolean have_data = FALSE;
static GstStaticPadTemplate mysrctemplate =
GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
GST_STATIC_CAPS ("application/mxf"));
static GstStaticPadTemplate mysinktemplate =
GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
GST_STATIC_CAPS_ANY);
static void
_pad_added (GstElement * element, GstPad * pad, gpointer user_data)
{
gchar *name = gst_pad_get_name (pad);
fail_unless_equals_string (name, "track_2");
fail_unless (gst_pad_link (pad, mysinkpad) == GST_PAD_LINK_OK);
g_free (name);
}
static GstFlowReturn
_sink_chain (GstPad * pad, GstBuffer * buffer)
GstCaps *caps = gst_caps_new_simple ("audio/x-raw-int",
"rate", G_TYPE_INT, 11025,
"channels", G_TYPE_INT, 1,
"signed", G_TYPE_BOOLEAN, FALSE,
"endianness", G_TYPE_INT, G_LITTLE_ENDIAN,
"depth", G_TYPE_INT, 8,
"width", G_TYPE_INT, 8,
NULL);
fail_unless (GST_BUFFER_CAPS (buffer) != NULL);
fail_unless (gst_caps_is_always_compatible (GST_BUFFER_CAPS (buffer), caps));
fail_unless_equals_int (GST_BUFFER_SIZE (buffer), sizeof (mxf_essence));
fail_unless (memcmp (GST_BUFFER_DATA (buffer), mxf_essence,
sizeof (mxf_essence)) == 0);
fail_unless (GST_BUFFER_TIMESTAMP (buffer) == 0);
fail_unless (GST_BUFFER_DURATION (buffer) == 200 * GST_MSECOND);
fail_unless (GST_BUFFER_OFFSET (buffer) == 0);
gst_buffer_unref (buffer);
gst_caps_unref (caps);
have_data = TRUE;
return GST_FLOW_OK;
static gboolean
_sink_event (GstPad * pad, GstEvent * event)
if (GST_EVENT_TYPE (event) == GST_EVENT_EOS) {
have_eos = TRUE;
if (loop)
g_main_loop_quit (loop);
}
gst_event_unref (event);
return TRUE;
static GstPad *
_create_sink_pad (void)
mysinkpad = gst_pad_new_from_static_template (&mysinktemplate, "sink");
gst_pad_set_chain_function (mysinkpad, _sink_chain);
gst_pad_set_event_function (mysinkpad, _sink_event);
return mysinkpad;
_create_src_pad_push (void)
mysrcpad = gst_pad_new_from_static_template (&mysrctemplate, "src");
return mysrcpad;
_src_getrange (GstPad * pad, guint64 offset, guint length, GstBuffer ** buffer)
GstCaps *caps;
if (offset + length > sizeof (mxf_file))
return GST_FLOW_UNEXPECTED;
caps = gst_caps_new_simple ("application/mxf", NULL);
*buffer = gst_buffer_new ();
GST_BUFFER_DATA (*buffer) = (guint8 *) (mxf_file + offset);
GST_BUFFER_SIZE (*buffer) = length;
gst_buffer_set_caps (*buffer, caps);
_src_query (GstPad * pad, GstQuery * query)
GstFormat fmt;
if (GST_QUERY_TYPE (query) != GST_QUERY_DURATION)
return FALSE;
gst_query_parse_duration (query, &fmt, NULL);
if (fmt != GST_FORMAT_BYTES)
gst_query_set_duration (query, fmt, sizeof (mxf_file));
_create_src_pad_pull (void)
gst_pad_set_getrange_function (mysrcpad, _src_getrange);
gst_pad_set_query_function (mysrcpad, _src_query);
GST_START_TEST (test_pull)
GstElement *mxfdemux;
GstPad *sinkpad;
have_eos = FALSE;
have_data = FALSE;
loop = g_main_loop_new (NULL, FALSE);
mxfdemux = gst_element_factory_make ("mxfdemux", NULL);
fail_unless (mxfdemux != NULL);
g_signal_connect (mxfdemux, "pad-added", G_CALLBACK (_pad_added), NULL);
sinkpad = gst_element_get_static_pad (mxfdemux, "sink");
fail_unless (sinkpad != NULL);
mysinkpad = _create_sink_pad ();
fail_unless (mysinkpad != NULL);
mysrcpad = _create_src_pad_pull ();
fail_unless (mysrcpad != NULL);
fail_unless (gst_pad_link (mysrcpad, sinkpad) == GST_PAD_LINK_OK);
gst_object_unref (sinkpad);
gst_pad_set_active (mysinkpad, TRUE);
gst_pad_set_active (mysrcpad, TRUE);
gst_element_set_state (mxfdemux, GST_STATE_PLAYING);
g_main_loop_run (loop);
fail_unless (have_eos == TRUE);
fail_unless (have_data == TRUE);
gst_element_set_state (mxfdemux, GST_STATE_NULL);
gst_pad_set_active (mysinkpad, FALSE);
gst_pad_set_active (mysrcpad, FALSE);
gst_object_unref (mxfdemux);
gst_object_unref (mysinkpad);
gst_object_unref (mysrcpad);
g_main_loop_unref (loop);
loop = NULL;
GST_END_TEST;
GST_START_TEST (test_push)
GstBuffer *buffer;
buffer = gst_buffer_new ();
GST_BUFFER_DATA (buffer) = (guint8 *) mxf_file;
GST_BUFFER_SIZE (buffer) = sizeof (mxf_file);
GST_BUFFER_OFFSET (buffer) = 0;
mysrcpad = _create_src_pad_push ();
fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK);
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()));
static Suite *
mxfdemux_suite (void)
Suite *s = suite_create ("mxfdemux");
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_pull);
tcase_add_test (tc_chain, test_push);
return s;
GST_CHECK_MAIN (mxfdemux);
--- NEW FILE: mxfdemux.h ---
/* Very simple MXF file containing BWF audio. Taken
from the Ingex project.
#include <glib.h>
static const guint8 mxf_essence[] = {
0x74, 0x5d, 0x8c, 0x69, 0x74, 0x80, 0x69, 0x80,
0x5d, 0x80, 0x80, 0x74, 0x8c, 0x69, 0x80, 0x74
};
static const guint8 mxf_file[] = {
0x06, 0x0e, 0x2b, 0x34, 0x02, 0x05, 0x01, 0x01,
0x0d, 0x01, 0x02, 0x01, 0x01, 0x02, 0x04, 0x00,
0x83, 0x00, 0x00, 0x78, 0x00, 0x01, 0x00, 0x02,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x4e, 0x3f, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x4d, 0x8f, 0x00, 0x00, 0x00, 0x00,
[...2513 lines suppressed...]
0x06, 0x01, 0x00, 0x06, 0x0e, 0x2b, 0x34, 0x02,
0x53, 0x01, 0x01, 0x0d, 0x01, 0x02, 0x01, 0x01,
0x10, 0x01, 0x00, 0x83, 0x00, 0x00, 0x50, 0x3c,
0x0a, 0x00, 0x10, 0xba, 0xc8, 0x72, 0x86, 0xb4,
0xc4, 0x43, 0x30, 0x95, 0x5c, 0x3d, 0x89, 0x2a,
0x7a, 0xfc, 0x01, 0x3f, 0x0b, 0x00, 0x08, 0x00,
0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x3f,
0x0c, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x3f, 0x0d, 0x00, 0x08, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
0x05, 0x00, 0x04, 0x00, 0x00, 0x08, 0x9d, 0x3f,
0x06, 0x00, 0x04, 0x00, 0x00, 0x00, 0x81, 0x3f,
0x07, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x06,
0x0e, 0x2b, 0x34, 0x02, 0x05, 0x01, 0x01, 0x0d,
0x01, 0x02, 0x01, 0x01, 0x11, 0x01, 0x00, 0x83,
0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x01, 0x00,
0x00, 0x4e, 0x3f, 0x00, 0x00, 0x00, 0x30,
------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you. Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
gstreamer-cvs-verbose mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gstreamer-cvs-verbose