mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-24 02:31:03 +00:00
tests: add test for updating playback rate
Tests if a seek with both positions being GST_SEEK_TYPE_NONE is handled.
This commit is contained in:
parent
b181094798
commit
bfe5b681cc
1 changed files with 114 additions and 0 deletions
|
@ -482,6 +482,119 @@ GST_START_TEST (basesrc_eos_events_pull_live_eos)
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
newsegment_event_catcher (GstObject * pad, GstEvent * event,
|
||||||
|
gpointer * user_data)
|
||||||
|
{
|
||||||
|
GstEvent **last_event = (GstEvent **) user_data;
|
||||||
|
fail_unless (event != NULL);
|
||||||
|
fail_unless (GST_IS_EVENT (event));
|
||||||
|
fail_unless (user_data != NULL);
|
||||||
|
|
||||||
|
if (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT) {
|
||||||
|
if (*last_event)
|
||||||
|
gst_event_unref (*last_event);
|
||||||
|
*last_event = gst_event_copy (event);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* basesrc_seek_events_rate_update:
|
||||||
|
* - make sure we get expected newsegment after sending a seek event
|
||||||
|
*/
|
||||||
|
GST_START_TEST (basesrc_seek_events_rate_update)
|
||||||
|
{
|
||||||
|
GstStateChangeReturn state_ret;
|
||||||
|
GstElement *src, *sink, *pipe;
|
||||||
|
GstMessage *msg;
|
||||||
|
GstBus *bus;
|
||||||
|
GstPad *probe_pad;
|
||||||
|
guint probe;
|
||||||
|
GstEvent *newseg_event = NULL;
|
||||||
|
GstEvent *rate_seek;
|
||||||
|
gboolean event_ret;
|
||||||
|
gdouble rate = 0.5;
|
||||||
|
|
||||||
|
pipe = gst_pipeline_new ("pipeline");
|
||||||
|
sink = gst_element_factory_make ("fakesink", "sink");
|
||||||
|
src = gst_element_factory_make ("fakesrc", "src");
|
||||||
|
|
||||||
|
g_assert (pipe != NULL);
|
||||||
|
g_assert (sink != NULL);
|
||||||
|
g_assert (src != NULL);
|
||||||
|
|
||||||
|
fail_unless (gst_bin_add (GST_BIN (pipe), src) == TRUE);
|
||||||
|
fail_unless (gst_bin_add (GST_BIN (pipe), sink) == TRUE);
|
||||||
|
|
||||||
|
fail_unless (gst_element_link (src, sink) == TRUE);
|
||||||
|
|
||||||
|
bus = gst_element_get_bus (pipe);
|
||||||
|
|
||||||
|
/* set up event probe to catch new segment event */
|
||||||
|
probe_pad = gst_element_get_static_pad (sink, "sink");
|
||||||
|
fail_unless (probe_pad != NULL);
|
||||||
|
|
||||||
|
probe = gst_pad_add_event_probe (probe_pad,
|
||||||
|
G_CALLBACK (newsegment_event_catcher), &newseg_event);
|
||||||
|
|
||||||
|
/* prepare the seek */
|
||||||
|
rate_seek = gst_event_new_seek (0.5, GST_FORMAT_TIME, GST_SEEK_FLAG_NONE,
|
||||||
|
GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE,
|
||||||
|
GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
|
||||||
|
|
||||||
|
GST_INFO ("going to playing");
|
||||||
|
|
||||||
|
/* play */
|
||||||
|
gst_element_set_state (pipe, GST_STATE_PLAYING);
|
||||||
|
state_ret = gst_element_get_state (pipe, NULL, NULL, -1);
|
||||||
|
fail_unless (state_ret == GST_STATE_CHANGE_SUCCESS);
|
||||||
|
|
||||||
|
GST_INFO ("seeking");
|
||||||
|
|
||||||
|
/* seek */
|
||||||
|
event_ret = gst_element_send_event (pipe, rate_seek);
|
||||||
|
fail_unless (event_ret == TRUE);
|
||||||
|
|
||||||
|
/* wait a second, then do controlled shutdown */
|
||||||
|
g_usleep (GST_USECOND * 1);
|
||||||
|
|
||||||
|
/* shut down source only (should send EOS event) ... */
|
||||||
|
gst_element_set_state (src, GST_STATE_NULL);
|
||||||
|
state_ret = gst_element_get_state (src, NULL, NULL, -1);
|
||||||
|
fail_unless (state_ret == GST_STATE_CHANGE_SUCCESS);
|
||||||
|
|
||||||
|
fail_unless (gst_element_set_locked_state (src, TRUE) == TRUE);
|
||||||
|
|
||||||
|
/* ... and wait for the EOS message from the sink */
|
||||||
|
msg = gst_bus_poll (bus, GST_MESSAGE_EOS | GST_MESSAGE_ERROR, -1);
|
||||||
|
fail_unless (msg != NULL);
|
||||||
|
fail_unless (GST_MESSAGE_TYPE (msg) != GST_MESSAGE_ERROR);
|
||||||
|
fail_unless (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_EOS);
|
||||||
|
|
||||||
|
gst_element_set_state (pipe, GST_STATE_NULL);
|
||||||
|
gst_element_get_state (pipe, NULL, NULL, -1);
|
||||||
|
|
||||||
|
GST_INFO ("stopped");
|
||||||
|
|
||||||
|
/* check that we have go the event */
|
||||||
|
fail_unless (newseg_event != NULL);
|
||||||
|
|
||||||
|
gst_event_parse_new_segment (newseg_event, NULL, &rate, NULL, NULL, NULL,
|
||||||
|
NULL);
|
||||||
|
fail_unless (rate == 0.5);
|
||||||
|
|
||||||
|
gst_pad_remove_event_probe (probe_pad, probe);
|
||||||
|
gst_object_unref (probe_pad);
|
||||||
|
gst_message_unref (msg);
|
||||||
|
gst_object_unref (bus);
|
||||||
|
gst_object_unref (pipe);
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST;
|
||||||
|
|
||||||
|
|
||||||
static Suite *
|
static Suite *
|
||||||
gst_basesrc_suite (void)
|
gst_basesrc_suite (void)
|
||||||
{
|
{
|
||||||
|
@ -495,6 +608,7 @@ gst_basesrc_suite (void)
|
||||||
tcase_add_test (tc, basesrc_eos_events_pull_live_op);
|
tcase_add_test (tc, basesrc_eos_events_pull_live_op);
|
||||||
tcase_add_test (tc, basesrc_eos_events_push_live_eos);
|
tcase_add_test (tc, basesrc_eos_events_push_live_eos);
|
||||||
tcase_add_test (tc, basesrc_eos_events_pull_live_eos);
|
tcase_add_test (tc, basesrc_eos_events_pull_live_eos);
|
||||||
|
tcase_add_test (tc, basesrc_seek_events_rate_update);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue