mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 08:46:40 +00:00
tests/check/gst/gstghostpad.c: Added some more ghostpad tests, mainly blocking and probes.
Original commit message from CVS: * tests/check/gst/gstghostpad.c: (block_callback), (GST_START_TEST), (gst_ghost_pad_suite): Added some more ghostpad tests, mainly blocking and probes.
This commit is contained in:
parent
0c64588a92
commit
479ef6daa5
2 changed files with 102 additions and 0 deletions
|
@ -1,3 +1,10 @@
|
|||
2006-06-20 Wim Taymans <wim@fluendo.com>
|
||||
|
||||
* tests/check/gst/gstghostpad.c: (block_callback),
|
||||
(GST_START_TEST), (gst_ghost_pad_suite):
|
||||
Added some more ghostpad tests, mainly blocking
|
||||
and probes.
|
||||
|
||||
2006-06-16 Wim Taymans <wim@fluendo.com>
|
||||
|
||||
* plugins/elements/gstfilesink.c: (gst_file_sink_open_file),
|
||||
|
|
|
@ -386,6 +386,99 @@ GST_START_TEST (test_ghost_pads_bin)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GMutex *mutex;
|
||||
GCond *cond;
|
||||
} BlockData;
|
||||
|
||||
static void
|
||||
block_callback (GstPad * pad, gboolean blocked, gpointer user_data)
|
||||
{
|
||||
BlockData *block_data = (BlockData *) user_data;
|
||||
|
||||
g_mutex_lock (block_data->mutex);
|
||||
GST_DEBUG ("blocked\n");
|
||||
g_cond_signal (block_data->cond);
|
||||
g_mutex_unlock (block_data->mutex);
|
||||
}
|
||||
|
||||
GST_START_TEST (test_ghost_pads_block)
|
||||
{
|
||||
GstBin *pipeline;
|
||||
GstBin *srcbin;
|
||||
GstElement *src;
|
||||
GstPad *srcpad;
|
||||
GstPad *srcghost;
|
||||
BlockData block_data;
|
||||
|
||||
pipeline = GST_BIN (gst_pipeline_new ("pipeline"));
|
||||
|
||||
srcbin = GST_BIN (gst_bin_new ("srcbin"));
|
||||
gst_bin_add (pipeline, GST_ELEMENT (srcbin));
|
||||
|
||||
src = gst_element_factory_make ("fakesrc", "src");
|
||||
gst_bin_add (srcbin, src);
|
||||
srcpad = gst_element_get_pad (src, "src");
|
||||
srcghost = gst_ghost_pad_new ("src", srcpad);
|
||||
gst_element_add_pad (GST_ELEMENT (srcbin), srcghost);
|
||||
gst_object_unref (srcpad);
|
||||
|
||||
block_data.mutex = g_mutex_new ();
|
||||
block_data.cond = g_cond_new ();
|
||||
|
||||
g_mutex_lock (block_data.mutex);
|
||||
gst_pad_set_blocked_async (srcghost, TRUE, block_callback, &block_data);
|
||||
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
|
||||
/* and wait now */
|
||||
g_cond_wait (block_data.cond, block_data.mutex);
|
||||
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
|
||||
g_mutex_unlock (block_data.mutex);
|
||||
|
||||
g_mutex_free (block_data.mutex);
|
||||
g_cond_free (block_data.cond);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
GST_START_TEST (test_ghost_pads_probes)
|
||||
{
|
||||
GstBin *pipeline;
|
||||
GstBin *srcbin;
|
||||
GstElement *src;
|
||||
GstPad *srcpad;
|
||||
GstPad *srcghost;
|
||||
BlockData block_data;
|
||||
|
||||
pipeline = GST_BIN (gst_pipeline_new ("pipeline"));
|
||||
|
||||
srcbin = GST_BIN (gst_bin_new ("srcbin"));
|
||||
gst_bin_add (pipeline, GST_ELEMENT (srcbin));
|
||||
|
||||
src = gst_element_factory_make ("fakesrc", "src");
|
||||
gst_bin_add (srcbin, src);
|
||||
srcpad = gst_element_get_pad (src, "src");
|
||||
srcghost = gst_ghost_pad_new ("src", srcpad);
|
||||
gst_element_add_pad (GST_ELEMENT (srcbin), srcghost);
|
||||
gst_object_unref (srcpad);
|
||||
|
||||
block_data.mutex = g_mutex_new ();
|
||||
block_data.cond = g_cond_new ();
|
||||
|
||||
g_mutex_lock (block_data.mutex);
|
||||
gst_pad_set_blocked_async (srcghost, TRUE, block_callback, &block_data);
|
||||
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
|
||||
/* and wait now */
|
||||
g_cond_wait (block_data.cond, block_data.mutex);
|
||||
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
|
||||
g_mutex_unlock (block_data.mutex);
|
||||
|
||||
g_mutex_free (block_data.mutex);
|
||||
g_cond_free (block_data.cond);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
Suite *
|
||||
gst_ghost_pad_suite (void)
|
||||
{
|
||||
|
@ -399,6 +492,8 @@ gst_ghost_pad_suite (void)
|
|||
tcase_add_test (tc_chain, test_ghost_pads);
|
||||
tcase_add_test (tc_chain, test_ghost_pads_bin);
|
||||
/* tcase_add_test (tc_chain, test_ghost_pad_notarget); */
|
||||
tcase_add_test (tc_chain, test_ghost_pads_block);
|
||||
tcase_add_test (tc_chain, test_ghost_pads_probes);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue