mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 03:31:05 +00:00
tests/check/elements/tee.c: Simplify, simplify, simplify - or not. Rewrite unit test not to use gst_parse_launch(); ...
Original commit message from CVS: * tests/check/elements/tee.c: (test_num_buffers): Simplify, simplify, simplify - or not. Rewrite unit test not to use gst_parse_launch(); allow N sub-streams. Increasing the number of sub-streams seems to reproduce #474823 more easily.
This commit is contained in:
parent
3317754e3e
commit
56d428073e
2 changed files with 54 additions and 24 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2007-11-01 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
|
* tests/check/elements/tee.c: (test_num_buffers):
|
||||||
|
Simplify, simplify, simplify - or not. Rewrite unit test
|
||||||
|
not to use gst_parse_launch(); allow N sub-streams. Increasing
|
||||||
|
the number of sub-streams seems to reproduce #474823 more easily.
|
||||||
|
|
||||||
2007-10-31 Tim-Philipp Müller <tim at centricular dot net>
|
2007-10-31 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
Patch by: Ole André Vadla Ravnås <ole.andre.ravnas@tandberg.com>
|
Patch by: Ole André Vadla Ravnås <ole.andre.ravnas@tandberg.com>
|
||||||
|
|
|
@ -27,9 +27,6 @@
|
||||||
|
|
||||||
#include <gst/check/gstcheck.h>
|
#include <gst/check/gstcheck.h>
|
||||||
|
|
||||||
static gint count1;
|
|
||||||
static gint count2;
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
handoff (GstElement * fakesink, GstBuffer * buf, GstPad * pad, guint * count)
|
handoff (GstElement * fakesink, GstBuffer * buf, GstPad * pad, guint * count)
|
||||||
{
|
{
|
||||||
|
@ -41,29 +38,51 @@ handoff (GstElement * fakesink, GstBuffer * buf, GstPad * pad, guint * count)
|
||||||
*/
|
*/
|
||||||
GST_START_TEST (test_num_buffers)
|
GST_START_TEST (test_num_buffers)
|
||||||
{
|
{
|
||||||
GstElement *pipeline;
|
#define NUM_SUBSTREAMS 15
|
||||||
GstElement *f1, *f2;
|
#define NUM_BUFFERS 3
|
||||||
gchar *desc;
|
GstElement *pipeline, *src, *tee;
|
||||||
|
GstElement *queues[NUM_SUBSTREAMS];
|
||||||
|
GstElement *sinks[NUM_SUBSTREAMS];
|
||||||
|
GstPad *req_pads[NUM_SUBSTREAMS];
|
||||||
|
guint counts[NUM_SUBSTREAMS];
|
||||||
GstBus *bus;
|
GstBus *bus;
|
||||||
GstMessage *msg;
|
GstMessage *msg;
|
||||||
|
gint i;
|
||||||
|
|
||||||
desc = "fakesrc num-buffers=3 ! tee name=t ! queue ! fakesink name=f1 "
|
pipeline = gst_pipeline_new ("pipeline");
|
||||||
"t. ! queue ! fakesink name=f2";
|
src = gst_check_setup_element ("fakesrc");
|
||||||
pipeline = gst_parse_launch (desc, NULL);
|
g_object_set (src, "num-buffers", NUM_BUFFERS, NULL);
|
||||||
fail_if (pipeline == NULL);
|
tee = gst_check_setup_element ("tee");
|
||||||
|
fail_unless (gst_bin_add (GST_BIN (pipeline), src));
|
||||||
|
fail_unless (gst_bin_add (GST_BIN (pipeline), tee));
|
||||||
|
fail_unless (gst_element_link (src, tee));
|
||||||
|
|
||||||
f1 = gst_bin_get_by_name (GST_BIN (pipeline), "f1");
|
for (i = 0; i < NUM_SUBSTREAMS; ++i) {
|
||||||
fail_if (f1 == NULL);
|
GstPad *qpad;
|
||||||
f2 = gst_bin_get_by_name (GST_BIN (pipeline), "f2");
|
gchar name[32];
|
||||||
fail_if (f2 == NULL);
|
|
||||||
|
|
||||||
count1 = 0;
|
counts[i] = 0;
|
||||||
count2 = 0;
|
|
||||||
|
|
||||||
g_object_set (G_OBJECT (f1), "signal-handoffs", TRUE, NULL);
|
queues[i] = gst_check_setup_element ("queue");
|
||||||
g_signal_connect (G_OBJECT (f1), "handoff", (GCallback) handoff, &count1);
|
g_snprintf (name, 32, "queue%d", i);
|
||||||
g_object_set (G_OBJECT (f2), "signal-handoffs", TRUE, NULL);
|
gst_object_set_name (GST_OBJECT (queues[i]), name);
|
||||||
g_signal_connect (G_OBJECT (f2), "handoff", (GCallback) handoff, &count2);
|
fail_unless (gst_bin_add (GST_BIN (pipeline), queues[i]));
|
||||||
|
|
||||||
|
sinks[i] = gst_check_setup_element ("fakesink");
|
||||||
|
g_snprintf (name, 32, "sink%d", i);
|
||||||
|
gst_object_set_name (GST_OBJECT (sinks[i]), name);
|
||||||
|
fail_unless (gst_bin_add (GST_BIN (pipeline), sinks[i]));
|
||||||
|
fail_unless (gst_element_link (queues[i], sinks[i]));
|
||||||
|
g_object_set (sinks[i], "signal-handoffs", TRUE, NULL);
|
||||||
|
g_signal_connect (sinks[i], "handoff", (GCallback) handoff, &counts[i]);
|
||||||
|
|
||||||
|
req_pads[i] = gst_element_get_request_pad (tee, "src%d");
|
||||||
|
fail_unless (req_pads[i] != NULL);
|
||||||
|
|
||||||
|
qpad = gst_element_get_pad (queues[i], "sink");
|
||||||
|
fail_unless_equals_int (gst_pad_link (req_pads[i], qpad), GST_PAD_LINK_OK);
|
||||||
|
gst_object_unref (qpad);
|
||||||
|
}
|
||||||
|
|
||||||
bus = gst_element_get_bus (pipeline);
|
bus = gst_element_get_bus (pipeline);
|
||||||
fail_if (bus == NULL);
|
fail_if (bus == NULL);
|
||||||
|
@ -73,13 +92,17 @@ GST_START_TEST (test_num_buffers)
|
||||||
fail_if (GST_MESSAGE_TYPE (msg) != GST_MESSAGE_EOS);
|
fail_if (GST_MESSAGE_TYPE (msg) != GST_MESSAGE_EOS);
|
||||||
gst_message_unref (msg);
|
gst_message_unref (msg);
|
||||||
|
|
||||||
fail_if (count1 != 3);
|
for (i = 0; i < NUM_SUBSTREAMS; ++i) {
|
||||||
fail_if (count2 != 3);
|
fail_unless_equals_int (counts[i], NUM_BUFFERS);
|
||||||
|
}
|
||||||
|
|
||||||
gst_element_set_state (pipeline, GST_STATE_NULL);
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
||||||
gst_object_unref (f1);
|
|
||||||
gst_object_unref (f2);
|
|
||||||
gst_object_unref (bus);
|
gst_object_unref (bus);
|
||||||
|
|
||||||
|
for (i = 0; i < NUM_SUBSTREAMS; ++i) {
|
||||||
|
gst_element_release_request_pad (tee, req_pads[i]);
|
||||||
|
gst_object_unref (req_pads[i]);
|
||||||
|
}
|
||||||
gst_object_unref (pipeline);
|
gst_object_unref (pipeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue