2006-05-30 09:42:09 +00:00
|
|
|
/*
|
2012-04-17 12:38:01 +00:00
|
|
|
* collectpads.c - GstCollectPads testsuite
|
2006-05-30 09:42:09 +00:00
|
|
|
* Copyright (C) 2006 Alessandro Decina <alessandro@nnva.org>
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Alessandro Decina <alessandro@nnva.org>
|
|
|
|
*
|
|
|
|
* 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>
|
2012-04-17 12:38:01 +00:00
|
|
|
#include <gst/base/gstcollectpads.h>
|
2006-05-30 09:42:09 +00:00
|
|
|
|
2006-06-01 09:02:23 +00:00
|
|
|
#define fail_unless_collected(expected) \
|
|
|
|
G_STMT_START { \
|
|
|
|
g_mutex_lock (lock); \
|
|
|
|
while (expected == TRUE && collected == FALSE) \
|
|
|
|
g_cond_wait (cond, lock); \
|
|
|
|
fail_unless_equals_int (collected, expected); \
|
|
|
|
g_mutex_unlock (lock); \
|
|
|
|
} G_STMT_END;
|
|
|
|
|
2006-05-30 09:42:09 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
char foo;
|
2012-04-17 12:38:01 +00:00
|
|
|
} BadCollectData;
|
2006-05-30 09:42:09 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2012-04-17 12:38:01 +00:00
|
|
|
GstCollectData data;
|
2006-05-30 09:42:09 +00:00
|
|
|
GstPad *pad;
|
|
|
|
GstBuffer *buffer;
|
|
|
|
GstEvent *event;
|
|
|
|
} TestData;
|
|
|
|
|
|
|
|
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS_ANY);
|
|
|
|
|
|
|
|
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS_ANY);
|
|
|
|
|
2012-04-17 12:38:01 +00:00
|
|
|
static GstCollectPads *collect;
|
2006-05-30 09:42:09 +00:00
|
|
|
static gboolean collected;
|
|
|
|
static GstPad *srcpad1, *srcpad2;
|
|
|
|
static GstPad *sinkpad1, *sinkpad2;
|
|
|
|
static TestData *data1, *data2;
|
|
|
|
|
Correct all relevant warnings found by the sparse semantic code analyzer. This include marking several symbols static...
Original commit message from CVS:
* gst/gstconfig.h.in:
* libs/gst/base/gstcollectpads.c: (gst_collect_pads_read_buffer):
* libs/gst/check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_drop_buffers),
(gst_check_element_push_buffer_list):
* libs/gst/controller/gstcontroller.c: (gst_controller_get),
(gst_controller_get_type):
* libs/gst/controller/gsthelper.c: (gst_object_control_properties),
(gst_object_get_controller), (gst_object_get_control_source):
* libs/gst/controller/gstinterpolationcontrolsource.c:
(gst_interpolation_control_source_new):
* libs/gst/controller/gstlfocontrolsource.c:
(gst_lfo_control_source_new):
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_event_from_packet_0_2):
* plugins/elements/gstfdsrc.c:
* plugins/elements/gstmultiqueue.c:
* plugins/elements/gsttee.c:
* plugins/elements/gsttypefindelement.c:
* plugins/indexers/gstfileindex.c: (_file_index_id_save_xml),
(gst_file_index_add_association):
* plugins/indexers/gstmemindex.c:
* tests/benchmarks/gstpollstress.c: (mess_some_more):
* tests/check/elements/queue.c: (setup_queue):
* tests/check/gst/gstpipeline.c:
* tests/check/libs/collectpads.c: (setup), (teardown),
(gst_collect_pads_suite):
* tests/examples/adapter/adapter_test.c:
* tests/examples/metadata/read-metadata.c: (make_pipeline):
* tests/examples/xml/createxml.c:
* tests/examples/xml/runxml.c:
* tools/gst-inspect.c:
* tools/gst-run.c:
Correct all relevant warnings found by the sparse semantic code
analyzer. This include marking several symbols static, using
NULL instead of 0 for pointers, not using variable sized arrays
on the stack, moving variable declarations to the beginning of
a block and using "foo (void)" instead of "foo ()" for declarations.
2008-02-29 12:41:33 +00:00
|
|
|
static GMutex *lock;
|
|
|
|
static GCond *cond;
|
2006-05-30 09:42:09 +00:00
|
|
|
|
|
|
|
static GstFlowReturn
|
2012-04-17 12:38:01 +00:00
|
|
|
collected_cb (GstCollectPads * pads, gpointer user_data)
|
2006-05-30 09:42:09 +00:00
|
|
|
{
|
|
|
|
g_mutex_lock (lock);
|
|
|
|
collected = TRUE;
|
|
|
|
g_cond_signal (cond);
|
|
|
|
g_mutex_unlock (lock);
|
|
|
|
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gpointer
|
|
|
|
push_buffer (gpointer user_data)
|
|
|
|
{
|
|
|
|
TestData *test_data = (TestData *) user_data;
|
|
|
|
|
|
|
|
fail_unless (gst_pad_push (test_data->pad, test_data->buffer)
|
|
|
|
== GST_FLOW_OK);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gpointer
|
|
|
|
push_event (gpointer user_data)
|
|
|
|
{
|
|
|
|
TestData *test_data = (TestData *) user_data;
|
|
|
|
|
|
|
|
fail_unless (gst_pad_push_event (test_data->pad, test_data->event) == TRUE);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
Correct all relevant warnings found by the sparse semantic code analyzer. This include marking several symbols static...
Original commit message from CVS:
* gst/gstconfig.h.in:
* libs/gst/base/gstcollectpads.c: (gst_collect_pads_read_buffer):
* libs/gst/check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_drop_buffers),
(gst_check_element_push_buffer_list):
* libs/gst/controller/gstcontroller.c: (gst_controller_get),
(gst_controller_get_type):
* libs/gst/controller/gsthelper.c: (gst_object_control_properties),
(gst_object_get_controller), (gst_object_get_control_source):
* libs/gst/controller/gstinterpolationcontrolsource.c:
(gst_interpolation_control_source_new):
* libs/gst/controller/gstlfocontrolsource.c:
(gst_lfo_control_source_new):
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_event_from_packet_0_2):
* plugins/elements/gstfdsrc.c:
* plugins/elements/gstmultiqueue.c:
* plugins/elements/gsttee.c:
* plugins/elements/gsttypefindelement.c:
* plugins/indexers/gstfileindex.c: (_file_index_id_save_xml),
(gst_file_index_add_association):
* plugins/indexers/gstmemindex.c:
* tests/benchmarks/gstpollstress.c: (mess_some_more):
* tests/check/elements/queue.c: (setup_queue):
* tests/check/gst/gstpipeline.c:
* tests/check/libs/collectpads.c: (setup), (teardown),
(gst_collect_pads_suite):
* tests/examples/adapter/adapter_test.c:
* tests/examples/metadata/read-metadata.c: (make_pipeline):
* tests/examples/xml/createxml.c:
* tests/examples/xml/runxml.c:
* tools/gst-inspect.c:
* tools/gst-run.c:
Correct all relevant warnings found by the sparse semantic code
analyzer. This include marking several symbols static, using
NULL instead of 0 for pointers, not using variable sized arrays
on the stack, moving variable declarations to the beginning of
a block and using "foo (void)" instead of "foo ()" for declarations.
2008-02-29 12:41:33 +00:00
|
|
|
setup (void)
|
2006-05-30 09:42:09 +00:00
|
|
|
{
|
2012-04-17 12:38:01 +00:00
|
|
|
collect = gst_collect_pads_new ();
|
|
|
|
gst_collect_pads_set_function (collect, collected_cb, NULL);
|
2006-05-30 09:42:09 +00:00
|
|
|
|
|
|
|
srcpad1 = gst_pad_new_from_static_template (&srctemplate, "src1");
|
|
|
|
srcpad2 = gst_pad_new_from_static_template (&srctemplate, "src2");
|
|
|
|
sinkpad1 = gst_pad_new_from_static_template (&sinktemplate, "sink1");
|
|
|
|
sinkpad2 = gst_pad_new_from_static_template (&sinktemplate, "sink2");
|
|
|
|
fail_unless (gst_pad_link (srcpad1, sinkpad1) == GST_PAD_LINK_OK);
|
|
|
|
fail_unless (gst_pad_link (srcpad2, sinkpad2) == GST_PAD_LINK_OK);
|
|
|
|
|
2012-01-26 10:40:53 +00:00
|
|
|
gst_pad_set_active (sinkpad1, TRUE);
|
|
|
|
gst_pad_set_active (sinkpad2, TRUE);
|
|
|
|
gst_pad_set_active (srcpad1, TRUE);
|
|
|
|
gst_pad_set_active (srcpad2, TRUE);
|
|
|
|
|
2006-05-30 09:42:09 +00:00
|
|
|
cond = g_cond_new ();
|
|
|
|
lock = g_mutex_new ();
|
|
|
|
data1 = NULL;
|
|
|
|
data2 = NULL;
|
|
|
|
collected = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
Correct all relevant warnings found by the sparse semantic code analyzer. This include marking several symbols static...
Original commit message from CVS:
* gst/gstconfig.h.in:
* libs/gst/base/gstcollectpads.c: (gst_collect_pads_read_buffer):
* libs/gst/check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_drop_buffers),
(gst_check_element_push_buffer_list):
* libs/gst/controller/gstcontroller.c: (gst_controller_get),
(gst_controller_get_type):
* libs/gst/controller/gsthelper.c: (gst_object_control_properties),
(gst_object_get_controller), (gst_object_get_control_source):
* libs/gst/controller/gstinterpolationcontrolsource.c:
(gst_interpolation_control_source_new):
* libs/gst/controller/gstlfocontrolsource.c:
(gst_lfo_control_source_new):
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_event_from_packet_0_2):
* plugins/elements/gstfdsrc.c:
* plugins/elements/gstmultiqueue.c:
* plugins/elements/gsttee.c:
* plugins/elements/gsttypefindelement.c:
* plugins/indexers/gstfileindex.c: (_file_index_id_save_xml),
(gst_file_index_add_association):
* plugins/indexers/gstmemindex.c:
* tests/benchmarks/gstpollstress.c: (mess_some_more):
* tests/check/elements/queue.c: (setup_queue):
* tests/check/gst/gstpipeline.c:
* tests/check/libs/collectpads.c: (setup), (teardown),
(gst_collect_pads_suite):
* tests/examples/adapter/adapter_test.c:
* tests/examples/metadata/read-metadata.c: (make_pipeline):
* tests/examples/xml/createxml.c:
* tests/examples/xml/runxml.c:
* tools/gst-inspect.c:
* tools/gst-run.c:
Correct all relevant warnings found by the sparse semantic code
analyzer. This include marking several symbols static, using
NULL instead of 0 for pointers, not using variable sized arrays
on the stack, moving variable declarations to the beginning of
a block and using "foo (void)" instead of "foo ()" for declarations.
2008-02-29 12:41:33 +00:00
|
|
|
teardown (void)
|
2006-05-30 09:42:09 +00:00
|
|
|
{
|
|
|
|
gst_object_unref (sinkpad1);
|
|
|
|
gst_object_unref (sinkpad2);
|
|
|
|
gst_object_unref (collect);
|
|
|
|
g_cond_free (cond);
|
|
|
|
g_mutex_free (lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_START_TEST (test_pad_add_remove)
|
|
|
|
{
|
2012-04-17 12:38:01 +00:00
|
|
|
ASSERT_CRITICAL (gst_collect_pads_add_pad (collect, sinkpad1,
|
|
|
|
sizeof (BadCollectData)));
|
2006-05-30 09:42:09 +00:00
|
|
|
|
2012-04-17 12:38:01 +00:00
|
|
|
data1 = (TestData *) gst_collect_pads_add_pad (collect,
|
2012-01-26 10:38:29 +00:00
|
|
|
sinkpad1, sizeof (TestData));
|
2006-05-30 09:42:09 +00:00
|
|
|
fail_unless (data1 != NULL);
|
|
|
|
|
2012-04-17 12:38:01 +00:00
|
|
|
fail_unless (gst_collect_pads_remove_pad (collect, sinkpad2) == FALSE);
|
|
|
|
fail_unless (gst_collect_pads_remove_pad (collect, sinkpad1) == TRUE);
|
2006-05-30 09:42:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_collect)
|
|
|
|
{
|
|
|
|
GstBuffer *buf1, *buf2, *tmp;
|
|
|
|
GThread *thread1, *thread2;
|
|
|
|
|
2012-04-17 12:38:01 +00:00
|
|
|
data1 = (TestData *) gst_collect_pads_add_pad (collect,
|
2012-01-26 10:38:29 +00:00
|
|
|
sinkpad1, sizeof (TestData));
|
2006-05-30 09:42:09 +00:00
|
|
|
fail_unless (data1 != NULL);
|
|
|
|
|
2012-04-17 12:38:01 +00:00
|
|
|
data2 = (TestData *) gst_collect_pads_add_pad (collect,
|
2012-01-26 10:38:29 +00:00
|
|
|
sinkpad2, sizeof (TestData));
|
2006-05-30 09:42:09 +00:00
|
|
|
fail_unless (data2 != NULL);
|
|
|
|
|
|
|
|
buf1 = gst_buffer_new ();
|
|
|
|
buf2 = gst_buffer_new ();
|
|
|
|
|
|
|
|
/* start collect pads */
|
2012-04-17 12:38:01 +00:00
|
|
|
gst_collect_pads_start (collect);
|
2006-05-30 09:42:09 +00:00
|
|
|
|
|
|
|
/* push buffers on the pads */
|
|
|
|
data1->pad = srcpad1;
|
|
|
|
data1->buffer = buf1;
|
|
|
|
thread1 = g_thread_create (push_buffer, data1, TRUE, NULL);
|
|
|
|
/* here thread1 is blocked and srcpad1 has a queued buffer */
|
2006-06-01 09:02:23 +00:00
|
|
|
fail_unless_collected (FALSE);
|
2006-05-30 09:42:09 +00:00
|
|
|
|
|
|
|
data2->pad = srcpad2;
|
|
|
|
data2->buffer = buf2;
|
|
|
|
thread2 = g_thread_create (push_buffer, data2, TRUE, NULL);
|
|
|
|
|
|
|
|
/* now both pads have a buffer */
|
2006-06-01 09:02:23 +00:00
|
|
|
fail_unless_collected (TRUE);
|
2006-05-30 09:42:09 +00:00
|
|
|
|
2012-04-17 12:38:01 +00:00
|
|
|
tmp = gst_collect_pads_pop (collect, (GstCollectData *) data1);
|
2006-05-30 09:42:09 +00:00
|
|
|
fail_unless (tmp == buf1);
|
2012-04-17 12:38:01 +00:00
|
|
|
tmp = gst_collect_pads_pop (collect, (GstCollectData *) data2);
|
2006-05-30 09:42:09 +00:00
|
|
|
fail_unless (tmp == buf2);
|
|
|
|
|
|
|
|
/* these will return immediately as at this point the threads have been
|
|
|
|
* unlocked and are finished */
|
|
|
|
g_thread_join (thread1);
|
|
|
|
g_thread_join (thread2);
|
|
|
|
|
2012-04-17 12:38:01 +00:00
|
|
|
gst_collect_pads_stop (collect);
|
2006-05-30 09:42:09 +00:00
|
|
|
|
|
|
|
gst_buffer_unref (buf1);
|
|
|
|
gst_buffer_unref (buf2);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_collect_eos)
|
|
|
|
{
|
|
|
|
GstBuffer *buf1, *tmp;
|
|
|
|
GThread *thread1, *thread2;
|
|
|
|
|
2012-04-17 12:38:01 +00:00
|
|
|
data1 = (TestData *) gst_collect_pads_add_pad (collect,
|
2012-01-26 10:38:29 +00:00
|
|
|
sinkpad1, sizeof (TestData));
|
2006-05-30 09:42:09 +00:00
|
|
|
fail_unless (data1 != NULL);
|
|
|
|
|
2012-04-17 12:38:01 +00:00
|
|
|
data2 = (TestData *) gst_collect_pads_add_pad (collect,
|
2012-01-26 10:38:29 +00:00
|
|
|
sinkpad2, sizeof (TestData));
|
2006-05-30 09:42:09 +00:00
|
|
|
fail_unless (data2 != NULL);
|
|
|
|
|
|
|
|
buf1 = gst_buffer_new ();
|
|
|
|
|
|
|
|
/* start collect pads */
|
2012-04-17 12:38:01 +00:00
|
|
|
gst_collect_pads_start (collect);
|
2006-05-30 09:42:09 +00:00
|
|
|
|
|
|
|
/* push a buffer on srcpad1 and EOS on srcpad2 */
|
|
|
|
data1->pad = srcpad1;
|
|
|
|
data1->buffer = buf1;
|
|
|
|
thread1 = g_thread_create (push_buffer, data1, TRUE, NULL);
|
|
|
|
/* here thread1 is blocked and srcpad1 has a queued buffer */
|
2006-06-01 09:02:23 +00:00
|
|
|
fail_unless_collected (FALSE);
|
2006-05-30 09:42:09 +00:00
|
|
|
|
|
|
|
data2->pad = srcpad2;
|
|
|
|
data2->event = gst_event_new_eos ();
|
|
|
|
thread2 = g_thread_create (push_event, data2, TRUE, NULL);
|
|
|
|
/* now sinkpad1 has a buffer and sinkpad2 has EOS */
|
2006-06-01 09:02:23 +00:00
|
|
|
fail_unless_collected (TRUE);
|
2006-05-30 09:42:09 +00:00
|
|
|
|
2012-04-17 12:38:01 +00:00
|
|
|
tmp = gst_collect_pads_pop (collect, (GstCollectData *) data1);
|
2006-05-30 09:42:09 +00:00
|
|
|
fail_unless (tmp == buf1);
|
|
|
|
/* sinkpad2 has EOS so a NULL buffer is returned */
|
2012-04-17 12:38:01 +00:00
|
|
|
tmp = gst_collect_pads_pop (collect, (GstCollectData *) data2);
|
2006-05-30 09:42:09 +00:00
|
|
|
fail_unless (tmp == NULL);
|
|
|
|
|
|
|
|
/* these will return immediately as when the data is popped the threads are
|
|
|
|
* unlocked and will terminate */
|
|
|
|
g_thread_join (thread1);
|
|
|
|
g_thread_join (thread2);
|
|
|
|
|
2012-04-17 12:38:01 +00:00
|
|
|
gst_collect_pads_stop (collect);
|
2006-05-30 09:42:09 +00:00
|
|
|
|
|
|
|
gst_buffer_unref (buf1);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2006-06-01 09:02:23 +00:00
|
|
|
GST_START_TEST (test_collect_twice)
|
|
|
|
{
|
|
|
|
GstBuffer *buf1, *buf2, *tmp;
|
|
|
|
GThread *thread1, *thread2;
|
|
|
|
|
2012-04-17 12:38:01 +00:00
|
|
|
data1 = (TestData *) gst_collect_pads_add_pad (collect,
|
2012-01-26 10:38:29 +00:00
|
|
|
sinkpad1, sizeof (TestData));
|
2006-06-01 09:02:23 +00:00
|
|
|
fail_unless (data1 != NULL);
|
|
|
|
|
2012-04-17 12:38:01 +00:00
|
|
|
data2 = (TestData *) gst_collect_pads_add_pad (collect,
|
2012-01-26 10:38:29 +00:00
|
|
|
sinkpad2, sizeof (TestData));
|
2006-06-01 09:02:23 +00:00
|
|
|
fail_unless (data2 != NULL);
|
|
|
|
|
|
|
|
buf1 = gst_buffer_new ();
|
|
|
|
|
|
|
|
/* start collect pads */
|
2012-04-17 12:38:01 +00:00
|
|
|
gst_collect_pads_start (collect);
|
2006-06-01 09:02:23 +00:00
|
|
|
|
|
|
|
/* queue a buffer */
|
|
|
|
data1->pad = srcpad1;
|
|
|
|
data1->buffer = buf1;
|
|
|
|
thread1 = g_thread_create (push_buffer, data1, TRUE, NULL);
|
|
|
|
/* here thread1 is blocked and srcpad1 has a queued buffer */
|
|
|
|
fail_unless_collected (FALSE);
|
|
|
|
|
|
|
|
/* push EOS on the other pad */
|
|
|
|
data2->pad = srcpad2;
|
|
|
|
data2->event = gst_event_new_eos ();
|
|
|
|
thread2 = g_thread_create (push_event, data2, TRUE, NULL);
|
|
|
|
|
|
|
|
/* one of the pads has a buffer, the other has EOS */
|
|
|
|
fail_unless_collected (TRUE);
|
|
|
|
|
2012-04-17 12:38:01 +00:00
|
|
|
tmp = gst_collect_pads_pop (collect, (GstCollectData *) data1);
|
2006-06-01 09:02:23 +00:00
|
|
|
fail_unless (tmp == buf1);
|
|
|
|
/* there's nothing to pop from the one which received EOS */
|
2012-04-17 12:38:01 +00:00
|
|
|
tmp = gst_collect_pads_pop (collect, (GstCollectData *) data2);
|
2006-06-01 09:02:23 +00:00
|
|
|
fail_unless (tmp == NULL);
|
|
|
|
|
|
|
|
/* these will return immediately as at this point the threads have been
|
|
|
|
* unlocked and are finished */
|
|
|
|
g_thread_join (thread1);
|
|
|
|
g_thread_join (thread2);
|
|
|
|
|
2012-04-17 12:38:01 +00:00
|
|
|
gst_collect_pads_stop (collect);
|
2006-06-01 09:02:23 +00:00
|
|
|
collected = FALSE;
|
|
|
|
|
|
|
|
buf2 = gst_buffer_new ();
|
|
|
|
|
|
|
|
/* start collect pads */
|
2012-04-17 12:38:01 +00:00
|
|
|
gst_collect_pads_start (collect);
|
2006-06-01 09:02:23 +00:00
|
|
|
|
|
|
|
/* push buffers on the pads */
|
|
|
|
data1->pad = srcpad1;
|
|
|
|
data1->buffer = buf1;
|
|
|
|
thread1 = g_thread_create (push_buffer, data1, TRUE, NULL);
|
|
|
|
/* here thread1 is blocked and srcpad1 has a queued buffer */
|
|
|
|
fail_unless_collected (FALSE);
|
|
|
|
|
|
|
|
data2->pad = srcpad2;
|
|
|
|
data2->buffer = buf2;
|
|
|
|
thread2 = g_thread_create (push_buffer, data2, TRUE, NULL);
|
|
|
|
|
|
|
|
/* now both pads have a buffer */
|
|
|
|
fail_unless_collected (TRUE);
|
|
|
|
|
2012-04-17 12:38:01 +00:00
|
|
|
tmp = gst_collect_pads_pop (collect, (GstCollectData *) data1);
|
2006-06-01 09:02:23 +00:00
|
|
|
fail_unless (tmp == buf1);
|
2012-04-17 12:38:01 +00:00
|
|
|
tmp = gst_collect_pads_pop (collect, (GstCollectData *) data2);
|
2006-06-01 09:02:23 +00:00
|
|
|
fail_unless (tmp == buf2);
|
|
|
|
|
|
|
|
/* these will return immediately as at this point the threads have been
|
|
|
|
* unlocked and are finished */
|
|
|
|
g_thread_join (thread1);
|
|
|
|
g_thread_join (thread2);
|
|
|
|
|
2012-04-17 12:38:01 +00:00
|
|
|
gst_collect_pads_stop (collect);
|
2006-06-01 09:02:23 +00:00
|
|
|
|
|
|
|
gst_buffer_unref (buf1);
|
|
|
|
gst_buffer_unref (buf2);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2006-05-30 09:42:09 +00:00
|
|
|
static Suite *
|
2012-04-17 12:38:01 +00:00
|
|
|
gst_collect_pads_suite (void)
|
2006-05-30 09:42:09 +00:00
|
|
|
{
|
|
|
|
Suite *suite;
|
|
|
|
TCase *general;
|
|
|
|
|
2012-04-17 12:38:01 +00:00
|
|
|
suite = suite_create ("GstCollectPads");
|
2006-05-30 09:42:09 +00:00
|
|
|
general = tcase_create ("general");
|
|
|
|
suite_add_tcase (suite, general);
|
|
|
|
tcase_add_checked_fixture (general, setup, teardown);
|
|
|
|
tcase_add_test (general, test_pad_add_remove);
|
|
|
|
tcase_add_test (general, test_collect);
|
|
|
|
tcase_add_test (general, test_collect_eos);
|
2006-06-01 09:02:23 +00:00
|
|
|
tcase_add_test (general, test_collect_twice);
|
2006-05-30 09:42:09 +00:00
|
|
|
|
|
|
|
return suite;
|
|
|
|
}
|
|
|
|
|
2012-04-17 12:38:01 +00:00
|
|
|
GST_CHECK_MAIN (gst_collect_pads);
|