mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-21 07:46:38 +00:00
check: Unit test for EOS message
Make sure we get the aggregated message if and only if all sinks received an EOS event
This commit is contained in:
parent
46a4f2f6c0
commit
d14f523d4a
1 changed files with 71 additions and 0 deletions
|
@ -56,6 +56,20 @@ pop_messages (GstBus * bus, int count)
|
|||
GST_DEBUG ("popped %d messages", count);
|
||||
}
|
||||
|
||||
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS_ANY);
|
||||
|
||||
static gpointer
|
||||
push_one_eos (GstPad * pad)
|
||||
{
|
||||
GST_DEBUG_OBJECT (pad, "Pushing EOS event");
|
||||
gst_pad_push_event (pad, gst_event_new_eos ());
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GST_START_TEST (test_interface)
|
||||
{
|
||||
GstBin *bin, *bin2;
|
||||
|
@ -126,6 +140,62 @@ GST_START_TEST (test_interface)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
GST_START_TEST (test_eos)
|
||||
{
|
||||
GstBus *bus;
|
||||
GstElement *pipeline, *sink1, *sink2;
|
||||
GstMessage *message;
|
||||
GstPad *pad1, *pad2;
|
||||
GThread *thread1, *thread2;
|
||||
|
||||
pipeline = gst_pipeline_new ("test_eos");
|
||||
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
|
||||
|
||||
sink1 = gst_element_factory_make ("fakesink", "sink1");
|
||||
sink2 = gst_element_factory_make ("fakesink", "sink2");
|
||||
|
||||
gst_bin_add_many (GST_BIN (pipeline), sink1, sink2, NULL);
|
||||
|
||||
pad1 = gst_check_setup_src_pad_by_name (sink1, &srctemplate, "sink");
|
||||
pad2 = gst_check_setup_src_pad_by_name (sink2, &srctemplate, "sink");
|
||||
|
||||
gst_pad_set_active (pad1, TRUE);
|
||||
gst_pad_set_active (pad2, TRUE);
|
||||
|
||||
fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
|
||||
GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE);
|
||||
|
||||
/* Send one EOS to sink1 */
|
||||
thread1 = g_thread_new ("thread1", (GThreadFunc) push_one_eos, pad1);
|
||||
|
||||
/* Make sure the EOS message is not sent */
|
||||
message =
|
||||
gst_bus_poll (bus, GST_MESSAGE_ERROR | GST_MESSAGE_EOS, 2 * GST_SECOND);
|
||||
fail_if (message != NULL);
|
||||
|
||||
/* Send one EOS to sink2 */
|
||||
thread2 = g_thread_new ("thread2", (GThreadFunc) push_one_eos, pad2);
|
||||
|
||||
/* Make sure the EOS message is sent then */
|
||||
message = gst_bus_poll (bus, GST_MESSAGE_ERROR | GST_MESSAGE_EOS, -1);
|
||||
fail_if (message == NULL);
|
||||
fail_unless (GST_MESSAGE_TYPE (message) == GST_MESSAGE_EOS);
|
||||
gst_message_unref (message);
|
||||
|
||||
/* Cleanup */
|
||||
g_thread_join (thread1);
|
||||
g_thread_join (thread2);
|
||||
|
||||
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
|
||||
gst_pad_set_active (pad1, FALSE);
|
||||
gst_pad_set_active (pad2, FALSE);
|
||||
gst_check_teardown_src_pad (sink1);
|
||||
gst_check_teardown_src_pad (sink2);
|
||||
gst_object_unref (pipeline);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
GST_START_TEST (test_message_state_changed)
|
||||
{
|
||||
GstBin *bin;
|
||||
|
@ -1280,6 +1350,7 @@ gst_bin_suite (void)
|
|||
|
||||
suite_add_tcase (s, tc_chain);
|
||||
tcase_add_test (tc_chain, test_interface);
|
||||
tcase_add_test (tc_chain, test_eos);
|
||||
tcase_add_test (tc_chain, test_children_state_change_order_flagged_sink);
|
||||
tcase_add_test (tc_chain, test_children_state_change_order_semi_sink);
|
||||
tcase_add_test (tc_chain, test_children_state_change_order_two_sink);
|
||||
|
|
Loading…
Reference in a new issue