plugins/elements/gsttee.c: Be a lot smarter when deciding what srcpad to use for proxying the buffer_alloc. Also hand...
Original commit message from CVS:
* plugins/elements/gsttee.c: (gst_tee_base_init),
(gst_tee_request_new_pad), (gst_tee_release_pad),
(gst_tee_find_buffer_alloc), (gst_tee_buffer_alloc),
(gst_tee_do_push), (clear_pads), (gst_tee_handle_buffer),
(gst_tee_chain):
Be a lot smarter when deciding what srcpad to use for proxying
the buffer_alloc. Also handle pad added/removed when doing so.
Fixes #357959.
Keep track of what pads we already pushed on in case we have pads
added/removed while pushing. Fixes #374639
* tests/check/Makefile.am:
* tests/check/elements/tee.c: (handoff), (GST_START_TEST),
(tee_suite):
Added unit test for pad resync.
2007-07-03 16:26:29 +00:00
|
|
|
/* GStreamer
|
|
|
|
*
|
|
|
|
* unit test for tee
|
|
|
|
*
|
|
|
|
* Copyright (C) <2007> Wim Taymans <wim dot taymans at gmail dot 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., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
|
|
#include <gst/check/gstcheck.h>
|
|
|
|
|
|
|
|
static void
|
|
|
|
handoff (GstElement * fakesink, GstBuffer * buf, GstPad * pad, guint * count)
|
|
|
|
{
|
|
|
|
*count = *count + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* construct fakesrc num-buffers=3 ! tee name=t ! queue ! fakesink t. ! queue !
|
|
|
|
* fakesink. Each fakesink should exactly receive 3 buffers.
|
|
|
|
*/
|
|
|
|
GST_START_TEST (test_num_buffers)
|
|
|
|
{
|
2007-11-01 19:19:10 +00:00
|
|
|
#define NUM_SUBSTREAMS 15
|
|
|
|
#define NUM_BUFFERS 3
|
|
|
|
GstElement *pipeline, *src, *tee;
|
|
|
|
GstElement *queues[NUM_SUBSTREAMS];
|
|
|
|
GstElement *sinks[NUM_SUBSTREAMS];
|
|
|
|
GstPad *req_pads[NUM_SUBSTREAMS];
|
|
|
|
guint counts[NUM_SUBSTREAMS];
|
plugins/elements/gsttee.c: Be a lot smarter when deciding what srcpad to use for proxying the buffer_alloc. Also hand...
Original commit message from CVS:
* plugins/elements/gsttee.c: (gst_tee_base_init),
(gst_tee_request_new_pad), (gst_tee_release_pad),
(gst_tee_find_buffer_alloc), (gst_tee_buffer_alloc),
(gst_tee_do_push), (clear_pads), (gst_tee_handle_buffer),
(gst_tee_chain):
Be a lot smarter when deciding what srcpad to use for proxying
the buffer_alloc. Also handle pad added/removed when doing so.
Fixes #357959.
Keep track of what pads we already pushed on in case we have pads
added/removed while pushing. Fixes #374639
* tests/check/Makefile.am:
* tests/check/elements/tee.c: (handoff), (GST_START_TEST),
(tee_suite):
Added unit test for pad resync.
2007-07-03 16:26:29 +00:00
|
|
|
GstBus *bus;
|
|
|
|
GstMessage *msg;
|
2007-11-01 19:19:10 +00:00
|
|
|
gint i;
|
|
|
|
|
|
|
|
pipeline = gst_pipeline_new ("pipeline");
|
|
|
|
src = gst_check_setup_element ("fakesrc");
|
|
|
|
g_object_set (src, "num-buffers", NUM_BUFFERS, 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));
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_SUBSTREAMS; ++i) {
|
|
|
|
GstPad *qpad;
|
|
|
|
gchar name[32];
|
plugins/elements/gsttee.c: Be a lot smarter when deciding what srcpad to use for proxying the buffer_alloc. Also hand...
Original commit message from CVS:
* plugins/elements/gsttee.c: (gst_tee_base_init),
(gst_tee_request_new_pad), (gst_tee_release_pad),
(gst_tee_find_buffer_alloc), (gst_tee_buffer_alloc),
(gst_tee_do_push), (clear_pads), (gst_tee_handle_buffer),
(gst_tee_chain):
Be a lot smarter when deciding what srcpad to use for proxying
the buffer_alloc. Also handle pad added/removed when doing so.
Fixes #357959.
Keep track of what pads we already pushed on in case we have pads
added/removed while pushing. Fixes #374639
* tests/check/Makefile.am:
* tests/check/elements/tee.c: (handoff), (GST_START_TEST),
(tee_suite):
Added unit test for pad resync.
2007-07-03 16:26:29 +00:00
|
|
|
|
2007-11-01 19:19:10 +00:00
|
|
|
counts[i] = 0;
|
plugins/elements/gsttee.c: Be a lot smarter when deciding what srcpad to use for proxying the buffer_alloc. Also hand...
Original commit message from CVS:
* plugins/elements/gsttee.c: (gst_tee_base_init),
(gst_tee_request_new_pad), (gst_tee_release_pad),
(gst_tee_find_buffer_alloc), (gst_tee_buffer_alloc),
(gst_tee_do_push), (clear_pads), (gst_tee_handle_buffer),
(gst_tee_chain):
Be a lot smarter when deciding what srcpad to use for proxying
the buffer_alloc. Also handle pad added/removed when doing so.
Fixes #357959.
Keep track of what pads we already pushed on in case we have pads
added/removed while pushing. Fixes #374639
* tests/check/Makefile.am:
* tests/check/elements/tee.c: (handoff), (GST_START_TEST),
(tee_suite):
Added unit test for pad resync.
2007-07-03 16:26:29 +00:00
|
|
|
|
2007-11-01 19:19:10 +00:00
|
|
|
queues[i] = gst_check_setup_element ("queue");
|
|
|
|
g_snprintf (name, 32, "queue%d", i);
|
|
|
|
gst_object_set_name (GST_OBJECT (queues[i]), name);
|
|
|
|
fail_unless (gst_bin_add (GST_BIN (pipeline), queues[i]));
|
plugins/elements/gsttee.c: Be a lot smarter when deciding what srcpad to use for proxying the buffer_alloc. Also hand...
Original commit message from CVS:
* plugins/elements/gsttee.c: (gst_tee_base_init),
(gst_tee_request_new_pad), (gst_tee_release_pad),
(gst_tee_find_buffer_alloc), (gst_tee_buffer_alloc),
(gst_tee_do_push), (clear_pads), (gst_tee_handle_buffer),
(gst_tee_chain):
Be a lot smarter when deciding what srcpad to use for proxying
the buffer_alloc. Also handle pad added/removed when doing so.
Fixes #357959.
Keep track of what pads we already pushed on in case we have pads
added/removed while pushing. Fixes #374639
* tests/check/Makefile.am:
* tests/check/elements/tee.c: (handoff), (GST_START_TEST),
(tee_suite):
Added unit test for pad resync.
2007-07-03 16:26:29 +00:00
|
|
|
|
2007-11-01 19:19:10 +00:00
|
|
|
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]);
|
plugins/elements/gsttee.c: Be a lot smarter when deciding what srcpad to use for proxying the buffer_alloc. Also hand...
Original commit message from CVS:
* plugins/elements/gsttee.c: (gst_tee_base_init),
(gst_tee_request_new_pad), (gst_tee_release_pad),
(gst_tee_find_buffer_alloc), (gst_tee_buffer_alloc),
(gst_tee_do_push), (clear_pads), (gst_tee_handle_buffer),
(gst_tee_chain):
Be a lot smarter when deciding what srcpad to use for proxying
the buffer_alloc. Also handle pad added/removed when doing so.
Fixes #357959.
Keep track of what pads we already pushed on in case we have pads
added/removed while pushing. Fixes #374639
* tests/check/Makefile.am:
* tests/check/elements/tee.c: (handoff), (GST_START_TEST),
(tee_suite):
Added unit test for pad resync.
2007-07-03 16:26:29 +00:00
|
|
|
|
2007-11-01 19:19:10 +00:00
|
|
|
req_pads[i] = gst_element_get_request_pad (tee, "src%d");
|
|
|
|
fail_unless (req_pads[i] != NULL);
|
|
|
|
|
2008-05-21 15:57:52 +00:00
|
|
|
qpad = gst_element_get_static_pad (queues[i], "sink");
|
2007-11-01 19:19:10 +00:00
|
|
|
fail_unless_equals_int (gst_pad_link (req_pads[i], qpad), GST_PAD_LINK_OK);
|
|
|
|
gst_object_unref (qpad);
|
|
|
|
}
|
plugins/elements/gsttee.c: Be a lot smarter when deciding what srcpad to use for proxying the buffer_alloc. Also hand...
Original commit message from CVS:
* plugins/elements/gsttee.c: (gst_tee_base_init),
(gst_tee_request_new_pad), (gst_tee_release_pad),
(gst_tee_find_buffer_alloc), (gst_tee_buffer_alloc),
(gst_tee_do_push), (clear_pads), (gst_tee_handle_buffer),
(gst_tee_chain):
Be a lot smarter when deciding what srcpad to use for proxying
the buffer_alloc. Also handle pad added/removed when doing so.
Fixes #357959.
Keep track of what pads we already pushed on in case we have pads
added/removed while pushing. Fixes #374639
* tests/check/Makefile.am:
* tests/check/elements/tee.c: (handoff), (GST_START_TEST),
(tee_suite):
Added unit test for pad resync.
2007-07-03 16:26:29 +00:00
|
|
|
|
|
|
|
bus = gst_element_get_bus (pipeline);
|
|
|
|
fail_if (bus == NULL);
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
|
|
|
|
|
|
|
msg = gst_bus_poll (bus, GST_MESSAGE_EOS | GST_MESSAGE_ERROR, -1);
|
|
|
|
fail_if (GST_MESSAGE_TYPE (msg) != GST_MESSAGE_EOS);
|
|
|
|
gst_message_unref (msg);
|
|
|
|
|
2007-11-01 19:19:10 +00:00
|
|
|
for (i = 0; i < NUM_SUBSTREAMS; ++i) {
|
|
|
|
fail_unless_equals_int (counts[i], NUM_BUFFERS);
|
|
|
|
}
|
plugins/elements/gsttee.c: Be a lot smarter when deciding what srcpad to use for proxying the buffer_alloc. Also hand...
Original commit message from CVS:
* plugins/elements/gsttee.c: (gst_tee_base_init),
(gst_tee_request_new_pad), (gst_tee_release_pad),
(gst_tee_find_buffer_alloc), (gst_tee_buffer_alloc),
(gst_tee_do_push), (clear_pads), (gst_tee_handle_buffer),
(gst_tee_chain):
Be a lot smarter when deciding what srcpad to use for proxying
the buffer_alloc. Also handle pad added/removed when doing so.
Fixes #357959.
Keep track of what pads we already pushed on in case we have pads
added/removed while pushing. Fixes #374639
* tests/check/Makefile.am:
* tests/check/elements/tee.c: (handoff), (GST_START_TEST),
(tee_suite):
Added unit test for pad resync.
2007-07-03 16:26:29 +00:00
|
|
|
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
|
|
|
gst_object_unref (bus);
|
2007-11-01 19:19:10 +00:00
|
|
|
|
|
|
|
for (i = 0; i < NUM_SUBSTREAMS; ++i) {
|
|
|
|
gst_element_release_request_pad (tee, req_pads[i]);
|
|
|
|
gst_object_unref (req_pads[i]);
|
|
|
|
}
|
plugins/elements/gsttee.c: Be a lot smarter when deciding what srcpad to use for proxying the buffer_alloc. Also hand...
Original commit message from CVS:
* plugins/elements/gsttee.c: (gst_tee_base_init),
(gst_tee_request_new_pad), (gst_tee_release_pad),
(gst_tee_find_buffer_alloc), (gst_tee_buffer_alloc),
(gst_tee_do_push), (clear_pads), (gst_tee_handle_buffer),
(gst_tee_chain):
Be a lot smarter when deciding what srcpad to use for proxying
the buffer_alloc. Also handle pad added/removed when doing so.
Fixes #357959.
Keep track of what pads we already pushed on in case we have pads
added/removed while pushing. Fixes #374639
* tests/check/Makefile.am:
* tests/check/elements/tee.c: (handoff), (GST_START_TEST),
(tee_suite):
Added unit test for pad resync.
2007-07-03 16:26:29 +00:00
|
|
|
gst_object_unref (pipeline);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
/* we use fakesrc ! tee ! fakesink and then randomly request/release and link
|
|
|
|
* some pads from tee. This should happily run without any errors. */
|
|
|
|
GST_START_TEST (test_stress)
|
|
|
|
{
|
|
|
|
GstElement *pipeline;
|
|
|
|
GstElement *tee;
|
|
|
|
gchar *desc;
|
|
|
|
GstBus *bus;
|
|
|
|
GstMessage *msg;
|
|
|
|
gint i;
|
|
|
|
|
2007-07-16 14:55:26 +00:00
|
|
|
/* Pump 1000 buffers (10 bytes each) per second through tee for 5 secs */
|
|
|
|
desc = "fakesrc datarate=10000 sizemin=10 sizemax=10 num-buffers=5000 ! "
|
|
|
|
"video/x-raw-rgb,framerate=25/1 ! tee name=t ! "
|
|
|
|
"queue max-size-buffers=2 ! fakesink sync=true";
|
|
|
|
|
plugins/elements/gsttee.c: Be a lot smarter when deciding what srcpad to use for proxying the buffer_alloc. Also hand...
Original commit message from CVS:
* plugins/elements/gsttee.c: (gst_tee_base_init),
(gst_tee_request_new_pad), (gst_tee_release_pad),
(gst_tee_find_buffer_alloc), (gst_tee_buffer_alloc),
(gst_tee_do_push), (clear_pads), (gst_tee_handle_buffer),
(gst_tee_chain):
Be a lot smarter when deciding what srcpad to use for proxying
the buffer_alloc. Also handle pad added/removed when doing so.
Fixes #357959.
Keep track of what pads we already pushed on in case we have pads
added/removed while pushing. Fixes #374639
* tests/check/Makefile.am:
* tests/check/elements/tee.c: (handoff), (GST_START_TEST),
(tee_suite):
Added unit test for pad resync.
2007-07-03 16:26:29 +00:00
|
|
|
pipeline = gst_parse_launch (desc, NULL);
|
|
|
|
fail_if (pipeline == NULL);
|
|
|
|
|
|
|
|
tee = gst_bin_get_by_name (GST_BIN (pipeline), "t");
|
|
|
|
fail_if (tee == NULL);
|
|
|
|
|
|
|
|
/* bring the pipeline to PLAYING, then start switching */
|
|
|
|
bus = gst_element_get_bus (pipeline);
|
|
|
|
fail_if (bus == NULL);
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
2007-07-16 14:55:26 +00:00
|
|
|
/* Wait for the pipeline to hit playing so that parse_launch can do the
|
|
|
|
* initial link, otherwise we perform linking from multiple threads and cause
|
|
|
|
* trouble */
|
|
|
|
gst_element_get_state (pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);
|
plugins/elements/gsttee.c: Be a lot smarter when deciding what srcpad to use for proxying the buffer_alloc. Also hand...
Original commit message from CVS:
* plugins/elements/gsttee.c: (gst_tee_base_init),
(gst_tee_request_new_pad), (gst_tee_release_pad),
(gst_tee_find_buffer_alloc), (gst_tee_buffer_alloc),
(gst_tee_do_push), (clear_pads), (gst_tee_handle_buffer),
(gst_tee_chain):
Be a lot smarter when deciding what srcpad to use for proxying
the buffer_alloc. Also handle pad added/removed when doing so.
Fixes #357959.
Keep track of what pads we already pushed on in case we have pads
added/removed while pushing. Fixes #374639
* tests/check/Makefile.am:
* tests/check/elements/tee.c: (handoff), (GST_START_TEST),
(tee_suite):
Added unit test for pad resync.
2007-07-03 16:26:29 +00:00
|
|
|
|
|
|
|
for (i = 0; i < 50000; i++) {
|
|
|
|
GstPad *pad;
|
|
|
|
|
|
|
|
pad = gst_element_get_request_pad (tee, "src%d");
|
|
|
|
gst_element_release_request_pad (tee, pad);
|
|
|
|
gst_object_unref (pad);
|
2007-07-16 14:55:26 +00:00
|
|
|
|
|
|
|
if ((msg = gst_bus_poll (bus, GST_MESSAGE_EOS | GST_MESSAGE_ERROR, 0)))
|
|
|
|
break;
|
plugins/elements/gsttee.c: Be a lot smarter when deciding what srcpad to use for proxying the buffer_alloc. Also hand...
Original commit message from CVS:
* plugins/elements/gsttee.c: (gst_tee_base_init),
(gst_tee_request_new_pad), (gst_tee_release_pad),
(gst_tee_find_buffer_alloc), (gst_tee_buffer_alloc),
(gst_tee_do_push), (clear_pads), (gst_tee_handle_buffer),
(gst_tee_chain):
Be a lot smarter when deciding what srcpad to use for proxying
the buffer_alloc. Also handle pad added/removed when doing so.
Fixes #357959.
Keep track of what pads we already pushed on in case we have pads
added/removed while pushing. Fixes #374639
* tests/check/Makefile.am:
* tests/check/elements/tee.c: (handoff), (GST_START_TEST),
(tee_suite):
Added unit test for pad resync.
2007-07-03 16:26:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* now wait for completion or error */
|
2007-07-16 14:55:26 +00:00
|
|
|
if (msg == NULL)
|
|
|
|
msg = gst_bus_poll (bus, GST_MESSAGE_EOS | GST_MESSAGE_ERROR, -1);
|
plugins/elements/gsttee.c: Be a lot smarter when deciding what srcpad to use for proxying the buffer_alloc. Also hand...
Original commit message from CVS:
* plugins/elements/gsttee.c: (gst_tee_base_init),
(gst_tee_request_new_pad), (gst_tee_release_pad),
(gst_tee_find_buffer_alloc), (gst_tee_buffer_alloc),
(gst_tee_do_push), (clear_pads), (gst_tee_handle_buffer),
(gst_tee_chain):
Be a lot smarter when deciding what srcpad to use for proxying
the buffer_alloc. Also handle pad added/removed when doing so.
Fixes #357959.
Keep track of what pads we already pushed on in case we have pads
added/removed while pushing. Fixes #374639
* tests/check/Makefile.am:
* tests/check/elements/tee.c: (handoff), (GST_START_TEST),
(tee_suite):
Added unit test for pad resync.
2007-07-03 16:26:29 +00:00
|
|
|
fail_if (GST_MESSAGE_TYPE (msg) != GST_MESSAGE_EOS);
|
|
|
|
gst_message_unref (msg);
|
|
|
|
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
|
|
|
gst_object_unref (tee);
|
|
|
|
gst_object_unref (bus);
|
|
|
|
gst_object_unref (pipeline);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2008-02-29 13:59:24 +00:00
|
|
|
static Suite *
|
plugins/elements/gsttee.c: Be a lot smarter when deciding what srcpad to use for proxying the buffer_alloc. Also hand...
Original commit message from CVS:
* plugins/elements/gsttee.c: (gst_tee_base_init),
(gst_tee_request_new_pad), (gst_tee_release_pad),
(gst_tee_find_buffer_alloc), (gst_tee_buffer_alloc),
(gst_tee_do_push), (clear_pads), (gst_tee_handle_buffer),
(gst_tee_chain):
Be a lot smarter when deciding what srcpad to use for proxying
the buffer_alloc. Also handle pad added/removed when doing so.
Fixes #357959.
Keep track of what pads we already pushed on in case we have pads
added/removed while pushing. Fixes #374639
* tests/check/Makefile.am:
* tests/check/elements/tee.c: (handoff), (GST_START_TEST),
(tee_suite):
Added unit test for pad resync.
2007-07-03 16:26:29 +00:00
|
|
|
tee_suite (void)
|
|
|
|
{
|
|
|
|
Suite *s = suite_create ("tee");
|
|
|
|
TCase *tc_chain = tcase_create ("general");
|
|
|
|
|
|
|
|
suite_add_tcase (s, tc_chain);
|
|
|
|
tcase_add_test (tc_chain, test_num_buffers);
|
|
|
|
tcase_add_test (tc_chain, test_stress);
|
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_CHECK_MAIN (tee);
|