summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDave Robillard <dave@drobilla.net>2009-06-03 16:37:53 -0400
committerDave Robillard <dave@drobilla.net>2009-06-03 16:37:53 -0400
commit7f3bcd484b465d8216ac419754450adf07e9b0d2 (patch)
tree5320e188d7719d8fba29beaf7da8f6f73e51e4e8 /tests
parentb19dd5920605c0036dacf19591a6feca7a736a50 (diff)
parente14bfea0c44aafba65239cbff9c6a4a93e0ae41a (diff)
downloadgst-plugins-bad-7f3bcd484b465d8216ac419754450adf07e9b0d2.tar.gz
gst-plugins-bad-7f3bcd484b465d8216ac419754450adf07e9b0d2.tar.bz2
gst-plugins-bad-7f3bcd484b465d8216ac419754450adf07e9b0d2.zip
Merge branch 'master' of git://anongit.freedesktop.org/gstreamer/gst-plugins-bad into fdo
Diffstat (limited to 'tests')
-rw-r--r--tests/check/Makefile.am1
-rw-r--r--tests/check/elements/aacparse.c32
-rw-r--r--tests/check/elements/shapewipe.c306
3 files changed, 331 insertions, 8 deletions
diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am
index 393e032a..cbc228e2 100644
--- a/tests/check/Makefile.am
+++ b/tests/check/Makefile.am
@@ -94,6 +94,7 @@ check_PROGRAMS = \
elements/qtmux \
elements/rtpbin \
elements/selector \
+ elements/shapewipe \
elements/mxfdemux \
elements/mxfmux \
pipelines/mxf \
diff --git a/tests/check/elements/aacparse.c b/tests/check/elements/aacparse.c
index f7de288b..bc561c7e 100644
--- a/tests/check/elements/aacparse.c
+++ b/tests/check/elements/aacparse.c
@@ -29,9 +29,12 @@
#define SRC_CAPS_CDATA "audio/mpeg, framed=(boolean)false, codec_data=(buffer)1190"
#define SRC_CAPS_TMPL "audio/mpeg, framed=(boolean)false, mpegversion=(int){2,4}"
-#define SINK_CAPS "audio/mpeg, framed=(boolean)true"
-#define SINK_CAPS_MPEG2 "audio/mpeg, framed=(boolean)true, mpegversion=2"
-#define SINK_CAPS_MPEG4 "audio/mpeg, framed=(boolean)true, mpegversion=4"
+#define SINK_CAPS \
+ "audio/mpeg, framed=(boolean)true"
+#define SINK_CAPS_MPEG2 \
+ "audio/mpeg, framed=(boolean)true, mpegversion=2, rate=48000, channels=2"
+#define SINK_CAPS_MPEG4 \
+ "audio/mpeg, framed=(boolean)true, mpegversion=4, rate=96000, channels=2"
#define SINK_CAPS_TMPL "audio/mpeg, framed=(boolean)true, mpegversion=(int){2,4}"
GList *buffers;
@@ -130,6 +133,8 @@ buffer_verify_adts (void *buffer, void *user_data)
gchar *bcaps = gst_caps_to_string (GST_BUFFER_CAPS (buffer));
g_free (bcaps);
+ GST_LOG ("%" GST_PTR_FORMAT " = %" GST_PTR_FORMAT " ?",
+ GST_BUFFER_CAPS (buffer), vdata->caps);
fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), vdata->caps));
}
@@ -226,6 +231,7 @@ GST_START_TEST (test_parse_adif_normal)
/* For ADIF parser assumes that data is always version 4 */
scaps = gst_caps_from_string (SINK_CAPS_MPEG4);
sinkcaps = gst_pad_get_negotiated_caps (sinkpad);
+ GST_LOG ("%" GST_PTR_FORMAT " = %" GST_PTR_FORMAT " ?", sinkcaps, scaps);
fail_unless (gst_caps_is_equal (sinkcaps, scaps));
gst_caps_unref (sinkcaps);
gst_caps_unref (scaps);
@@ -413,6 +419,7 @@ GST_START_TEST (test_parse_adts_detect_mpeg_version)
/* Check that the negotiated caps are as expected */
sinkcaps = gst_pad_get_negotiated_caps (sinkpad);
+ GST_LOG ("%" GST_PTR_FORMAT " = %" GST_PTR_FORMAT "?", sinkcaps, vdata.caps);
fail_unless (gst_caps_is_equal (sinkcaps, vdata.caps));
gst_caps_unref (sinkcaps);
@@ -425,7 +432,10 @@ GST_START_TEST (test_parse_adts_detect_mpeg_version)
GST_END_TEST;
-
+#define structure_get_int(s,f) \
+ (g_value_get_int(gst_structure_get_value(s,f)))
+#define fail_unless_structure_field_int_equals(s,field,num) \
+ fail_unless_equals_int (structure_get_int(s,field), num)
/*
* Test if the parser handles raw stream and codec_data info properly.
*/
@@ -433,7 +443,8 @@ GST_START_TEST (test_parse_handle_codec_data)
{
GstElement *aacparse;
GstBuffer *buffer;
- GstCaps *scaps, *sinkcaps;
+ GstCaps *sinkcaps;
+ GstStructure *s;
guint datasum = 0;
guint i;
@@ -449,11 +460,16 @@ GST_START_TEST (test_parse_handle_codec_data)
/* Check that the negotiated caps are as expected */
/* When codec_data is present, parser assumes that data is version 4 */
- scaps = gst_caps_from_string (SINK_CAPS_MPEG4);
sinkcaps = gst_pad_get_negotiated_caps (sinkpad);
- fail_unless (gst_caps_is_equal (sinkcaps, scaps));
+ GST_LOG ("aac output caps: %" GST_PTR_FORMAT, sinkcaps);
+ s = gst_caps_get_structure (sinkcaps, 0);
+ fail_unless (gst_structure_has_name (s, "audio/mpeg"));
+ fail_unless_structure_field_int_equals (s, "mpegversion", 4);
+ fail_unless_structure_field_int_equals (s, "channels", 2);
+ fail_unless_structure_field_int_equals (s, "rate", 48000);
+ fail_unless (gst_structure_has_field (s, "codec_data"));
+
gst_caps_unref (sinkcaps);
- gst_caps_unref (scaps);
g_list_foreach (buffers, buffer_count_size, &datasum);
fail_unless_equals_int (datasum, 10 * 100);
diff --git a/tests/check/elements/shapewipe.c b/tests/check/elements/shapewipe.c
new file mode 100644
index 00000000..6fcb0698
--- /dev/null
+++ b/tests/check/elements/shapewipe.c
@@ -0,0 +1,306 @@
+/* GStreamer
+ *
+ * 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 <unistd.h>
+
+#include <gst/check/gstcheck.h>
+
+gboolean have_eos = FALSE;
+
+/* For ease of programming we use globals to keep refs for our floating
+ * src and sink pads we create; otherwise we always have to do get_pad,
+ * get_peer, and then remove references in every test function */
+GstPad *myvideosrcpad, *mymasksrcpad, *mysinkpad;
+
+
+#define SHAPEWIPE_VIDEO_CAPS_STRING \
+ "video/x-raw-yuv, " \
+ "format = (GstFourcc)AYUV, " \
+ "width = 400, " \
+ "height = 400, " \
+ "framerate = 0/1"
+
+#define SHAPEWIPE_MASK_CAPS_STRING \
+ "video/x-raw-gray, " \
+ "bpp = 8, " \
+ "depth = 8, " \
+ "width = 400, " \
+ "height = 400, " \
+ "framerate = 0/1"
+
+static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (SHAPEWIPE_VIDEO_CAPS_STRING)
+ );
+static GstStaticPadTemplate videosrctemplate =
+GST_STATIC_PAD_TEMPLATE ("videosrc",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (SHAPEWIPE_VIDEO_CAPS_STRING)
+ );
+static GstStaticPadTemplate masksrctemplate =
+GST_STATIC_PAD_TEMPLATE ("masksrc",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (SHAPEWIPE_MASK_CAPS_STRING)
+ );
+
+
+static GstBuffer *output = NULL;
+
+static GstFlowReturn
+on_chain (GstPad * pad, GstBuffer * buffer)
+{
+ g_return_val_if_fail (output == NULL, GST_FLOW_ERROR);
+
+ output = buffer;
+ return GST_FLOW_OK;
+}
+
+GST_START_TEST (test_general)
+{
+ GstElement *shapewipe;
+ GstPad *p;
+ GstCaps *caps;
+ GstBuffer *mask, *input;
+ guint i, j;
+ guint8 *data;
+
+ myvideosrcpad =
+ gst_pad_new_from_static_template (&videosrctemplate, "videosrc");
+ gst_pad_set_active (myvideosrcpad, TRUE);
+ caps = gst_caps_from_string (SHAPEWIPE_VIDEO_CAPS_STRING);
+ gst_pad_set_caps (myvideosrcpad, caps);
+ gst_caps_unref (caps);
+
+ mymasksrcpad = gst_pad_new_from_static_template (&masksrctemplate, "masksrc");
+ gst_pad_set_active (mymasksrcpad, TRUE);
+ caps = gst_caps_from_string (SHAPEWIPE_MASK_CAPS_STRING);
+ gst_pad_set_caps (mymasksrcpad, caps);
+ gst_caps_unref (caps);
+
+ mysinkpad = gst_pad_new_from_static_template (&sinktemplate, "sink");
+ gst_pad_set_chain_function (mysinkpad, on_chain);
+ gst_pad_set_active (mysinkpad, TRUE);
+ caps = gst_caps_from_string (SHAPEWIPE_VIDEO_CAPS_STRING);
+ gst_pad_set_caps (mysinkpad, caps);
+ gst_caps_unref (caps);
+
+ shapewipe = gst_element_factory_make ("shapewipe", NULL);
+ fail_unless (shapewipe != NULL);
+
+ p = gst_element_get_static_pad (shapewipe, "video_sink");
+ fail_unless (gst_pad_link (myvideosrcpad, p) == GST_PAD_LINK_OK);
+ gst_object_unref (p);
+ p = gst_element_get_static_pad (shapewipe, "mask_sink");
+ fail_unless (gst_pad_link (mymasksrcpad, p) == GST_PAD_LINK_OK);
+ gst_object_unref (p);
+ p = gst_element_get_static_pad (shapewipe, "src");
+ fail_unless (gst_pad_link (p, mysinkpad) == GST_PAD_LINK_OK);
+ gst_object_unref (p);
+
+ fail_unless (gst_element_set_state (shapewipe,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS);
+
+ mask = gst_buffer_new_and_alloc (400 * 400);
+ caps = gst_caps_from_string (SHAPEWIPE_MASK_CAPS_STRING);
+ gst_buffer_set_caps (mask, caps);
+ gst_caps_unref (caps);
+ data = GST_BUFFER_DATA (mask);
+ for (i = 0; i < 400; i++) {
+ for (j = 0; j < 400; j++) {
+ if (i < 100 && j < 100)
+ data[0] = 0;
+ else if (i < 200 && j < 200)
+ data[0] = 85;
+ else if (i < 300 && j < 300)
+ data[0] = 170;
+ else
+ data[0] = 254;
+ data++;
+ }
+ }
+
+ fail_unless (gst_pad_push (mymasksrcpad, mask) == GST_FLOW_OK);
+
+ input = gst_buffer_new_and_alloc (400 * 400 * 4);
+ caps = gst_caps_from_string (SHAPEWIPE_VIDEO_CAPS_STRING);
+ gst_buffer_set_caps (input, caps);
+ gst_caps_unref (caps);
+ data = GST_BUFFER_DATA (input);
+ for (i = 0; i < 400; i++) {
+ for (j = 0; j < 400; j++) {
+ /* This is green */
+ data[0] = 0; /* A */
+ data[1] = 173; /* Y */
+ data[2] = 42; /* U */
+ data[3] = 26; /* V */
+ data += 4;
+ }
+ }
+
+ g_object_set (G_OBJECT (shapewipe), "position", 0.0, NULL);
+ output = NULL;
+ fail_unless (gst_pad_push (myvideosrcpad,
+ gst_buffer_ref (input)) == GST_FLOW_OK);
+ fail_unless (output != NULL);
+ data = GST_BUFFER_DATA (output);
+ for (i = 0; i < 400; i++) {
+ for (j = 0; j < 400; j++) {
+ fail_unless (data[0] == 255); /* A */
+ fail_unless (data[1] == 173); /* Y */
+ fail_unless (data[2] == 42); /* U */
+ fail_unless (data[3] == 26); /* V */
+ data += 4;
+ }
+ }
+ gst_buffer_unref (output);
+ output = NULL;
+
+ g_object_set (G_OBJECT (shapewipe), "position", 0.1, NULL);
+ output = NULL;
+ fail_unless (gst_pad_push (myvideosrcpad,
+ gst_buffer_ref (input)) == GST_FLOW_OK);
+ fail_unless (output != NULL);
+ data = GST_BUFFER_DATA (output);
+ for (i = 0; i < 400; i++) {
+ for (j = 0; j < 400; j++) {
+ if (i < 100 && j < 100) {
+ fail_unless (data[0] == 0); /* A */
+ fail_unless (data[1] == 0); /* Y */
+ fail_unless (data[2] == 128); /* U */
+ fail_unless (data[3] == 128); /* V */
+ } else {
+ fail_unless (data[0] == 255); /* A */
+ fail_unless (data[1] == 173); /* Y */
+ fail_unless (data[2] == 42); /* U */
+ fail_unless (data[3] == 26); /* V */
+ }
+ data += 4;
+ }
+ }
+ gst_buffer_unref (output);
+ output = NULL;
+
+ g_object_set (G_OBJECT (shapewipe), "position", 0.34, NULL);
+ output = NULL;
+ fail_unless (gst_pad_push (myvideosrcpad,
+ gst_buffer_ref (input)) == GST_FLOW_OK);
+ fail_unless (output != NULL);
+ data = GST_BUFFER_DATA (output);
+ for (i = 0; i < 400; i++) {
+ for (j = 0; j < 400; j++) {
+ if (i < 200 && j < 200) {
+ fail_unless (data[0] == 0); /* A */
+ fail_unless (data[1] == 0); /* Y */
+ fail_unless (data[2] == 128); /* U */
+ fail_unless (data[3] == 128); /* V */
+ } else {
+ fail_unless (data[0] == 255); /* A */
+ fail_unless (data[1] == 173); /* Y */
+ fail_unless (data[2] == 42); /* U */
+ fail_unless (data[3] == 26); /* V */
+ }
+ data += 4;
+ }
+ }
+ gst_buffer_unref (output);
+ output = NULL;
+
+ g_object_set (G_OBJECT (shapewipe), "position", 0.67, NULL);
+ output = NULL;
+ fail_unless (gst_pad_push (myvideosrcpad,
+ gst_buffer_ref (input)) == GST_FLOW_OK);
+ fail_unless (output != NULL);
+ data = GST_BUFFER_DATA (output);
+ for (i = 0; i < 400; i++) {
+ for (j = 0; j < 400; j++) {
+ if (i < 300 && j < 300) {
+ fail_unless (data[0] == 0); /* A */
+ fail_unless (data[1] == 0); /* Y */
+ fail_unless (data[2] == 128); /* U */
+ fail_unless (data[3] == 128); /* V */
+ } else {
+ fail_unless (data[0] == 255); /* A */
+ fail_unless (data[1] == 173); /* Y */
+ fail_unless (data[2] == 42); /* U */
+ fail_unless (data[3] == 26); /* V */
+ }
+ data += 4;
+ }
+ }
+ gst_buffer_unref (output);
+ output = NULL;
+
+ g_object_set (G_OBJECT (shapewipe), "position", 1.0, NULL);
+ output = NULL;
+ fail_unless (gst_pad_push (myvideosrcpad,
+ gst_buffer_ref (input)) == GST_FLOW_OK);
+ fail_unless (output != NULL);
+ data = GST_BUFFER_DATA (output);
+ for (i = 0; i < 400; i++) {
+ for (j = 0; j < 400; j++) {
+ fail_unless (data[0] == 0); /* A */
+ fail_unless (data[1] == 0); /* Y */
+ fail_unless (data[2] == 128); /* U */
+ fail_unless (data[3] == 128); /* V */
+ data += 4;
+ }
+ }
+ gst_buffer_unref (output);
+ output = NULL;
+
+ gst_buffer_unref (input);
+
+ fail_unless (gst_element_set_state (shapewipe,
+ GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS);
+
+ p = gst_element_get_static_pad (shapewipe, "video_sink");
+ fail_unless (gst_pad_unlink (myvideosrcpad, p));
+ gst_object_unref (p);
+ p = gst_element_get_static_pad (shapewipe, "mask_sink");
+ fail_unless (gst_pad_unlink (mymasksrcpad, p));
+ gst_object_unref (p);
+ p = gst_element_get_static_pad (shapewipe, "src");
+ fail_unless (gst_pad_unlink (p, mysinkpad));
+ gst_object_unref (p);
+
+ gst_object_unref (myvideosrcpad);
+ gst_object_unref (mymasksrcpad);
+ gst_object_unref (mysinkpad);
+ gst_object_unref (shapewipe);
+}
+
+GST_END_TEST;
+
+Suite *
+shapewipe_suite (void)
+{
+ Suite *s = suite_create ("shapewipe");
+ TCase *tc_chain = tcase_create ("general");
+
+ suite_add_tcase (s, tc_chain);
+ tcase_add_test (tc_chain, test_general);
+
+ return s;
+}
+
+GST_CHECK_MAIN (shapewipe);