mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-19 16:21:17 +00:00
basesink: Add test for checking that EOS always comes after the state change to PLAYING
https://bugzilla.gnome.org/show_bug.cgi?id=727949
This commit is contained in:
parent
40c8208ad2
commit
19eca381f5
1 changed files with 75 additions and 0 deletions
|
@ -168,6 +168,80 @@ GST_START_TEST (basesink_test_gap)
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
||||||
|
static gpointer
|
||||||
|
send_eos_event (gpointer data)
|
||||||
|
{
|
||||||
|
GstPad *pad = data;
|
||||||
|
GstEvent *ev;
|
||||||
|
GstSegment segment;
|
||||||
|
|
||||||
|
ev = gst_event_new_stream_start ("test");
|
||||||
|
fail_unless (gst_pad_send_event (pad, ev));
|
||||||
|
|
||||||
|
gst_segment_init (&segment, GST_FORMAT_TIME);
|
||||||
|
ev = gst_event_new_segment (&segment);
|
||||||
|
fail_unless (gst_pad_send_event (pad, ev));
|
||||||
|
|
||||||
|
ev = gst_event_new_eos ();
|
||||||
|
gst_pad_send_event (pad, ev);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_START_TEST (basesink_test_eos_after_playing)
|
||||||
|
{
|
||||||
|
GstElement *pipeline, *sink;
|
||||||
|
GstPad *pad;
|
||||||
|
GstBus *bus;
|
||||||
|
GstMessage *msg;
|
||||||
|
GThread *thread;
|
||||||
|
gboolean reached_playing = FALSE;
|
||||||
|
|
||||||
|
sink = gst_element_factory_make ("fakesink", "sink");
|
||||||
|
g_object_set (sink, "sync", TRUE, NULL);
|
||||||
|
pipeline = gst_pipeline_new (NULL);
|
||||||
|
|
||||||
|
gst_bin_add (GST_BIN (pipeline), sink);
|
||||||
|
|
||||||
|
pad = gst_element_get_static_pad (sink, "sink");
|
||||||
|
|
||||||
|
bus = gst_element_get_bus (pipeline);
|
||||||
|
|
||||||
|
gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
||||||
|
|
||||||
|
thread = g_thread_new ("push-thread", send_eos_event, pad);
|
||||||
|
|
||||||
|
while ((msg = gst_bus_timed_pop (bus, -1))) {
|
||||||
|
if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_STATE_CHANGED
|
||||||
|
&& GST_MESSAGE_SRC (msg) == GST_OBJECT (pipeline)) {
|
||||||
|
GstState new_state;
|
||||||
|
|
||||||
|
gst_message_parse_state_changed (msg, NULL, &new_state, NULL);
|
||||||
|
if (new_state == GST_STATE_PLAYING)
|
||||||
|
reached_playing = TRUE;
|
||||||
|
} else if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ASYNC_DONE) {
|
||||||
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||||
|
} else if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_EOS) {
|
||||||
|
fail_unless (reached_playing);
|
||||||
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
||||||
|
gst_message_unref (msg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
gst_message_unref (msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_thread_join (thread);
|
||||||
|
|
||||||
|
gst_object_unref (pad);
|
||||||
|
gst_object_unref (bus);
|
||||||
|
gst_object_unref (pipeline);
|
||||||
|
|
||||||
|
GST_INFO ("stopped");
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST;
|
||||||
|
|
||||||
static Suite *
|
static Suite *
|
||||||
gst_basesrc_suite (void)
|
gst_basesrc_suite (void)
|
||||||
{
|
{
|
||||||
|
@ -178,6 +252,7 @@ gst_basesrc_suite (void)
|
||||||
tcase_add_test (tc, basesink_last_sample_enabled);
|
tcase_add_test (tc, basesink_last_sample_enabled);
|
||||||
tcase_add_test (tc, basesink_last_sample_disabled);
|
tcase_add_test (tc, basesink_last_sample_disabled);
|
||||||
tcase_add_test (tc, basesink_test_gap);
|
tcase_add_test (tc, basesink_test_gap);
|
||||||
|
tcase_add_test (tc, basesink_test_eos_after_playing);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue