tests: adaptive: update to allow more flexible seeking tests

Allows defining a seek event to be able to change seeking parameters
and create more seeking test scenarios
This commit is contained in:
Thiago Santos 2015-12-23 15:25:29 -03:00
parent 2784ff6693
commit 5bc6769532
4 changed files with 26 additions and 8 deletions

View file

@ -77,6 +77,7 @@ gst_adaptive_demux_test_case_clear (GstAdaptiveDemuxTestCase * testData)
testData->signal_context = NULL; testData->signal_context = NULL;
testData->test_task_state = TEST_TASK_STATE_NOT_STARTED; testData->test_task_state = TEST_TASK_STATE_NOT_STARTED;
testData->threshold_for_seek = 0; testData->threshold_for_seek = 0;
gst_event_replace (&testData->seek_event, NULL);
testData->signal_context = NULL; testData->signal_context = NULL;
} }
@ -251,6 +252,7 @@ typedef struct _SeekTaskContext
{ {
GstElement *pipeline; GstElement *pipeline;
GstTask *task; GstTask *task;
GstEvent *seek_event;
} SeekTaskContext; } SeekTaskContext;
/* function to generate a seek event. Will be run in a separate thread */ /* function to generate a seek event. Will be run in a separate thread */
@ -262,15 +264,12 @@ testSeekTaskDoSeek (gpointer user_data)
GST_DEBUG ("testSeekTaskDoSeek calling seek"); GST_DEBUG ("testSeekTaskDoSeek calling seek");
/* seek to 5ms. fail_unless (GST_IS_EVENT (context->seek_event));
* Because there is only one fragment, we expect the whole file to be fail_unless (GST_EVENT_TYPE (context->seek_event) == GST_EVENT_SEEK);
* downloaded again
*/ if (!gst_element_send_event (GST_ELEMENT (context->pipeline),
if (!gst_element_seek_simple (GST_ELEMENT (context->pipeline), context->seek_event))
GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT,
5 * GST_MSECOND)) {
fail ("Seek failed!\n"); fail ("Seek failed!\n");
}
GST_DEBUG ("seek ok"); GST_DEBUG ("seek ok");
task = context->task; task = context->task;
g_slice_free (SeekTaskContext, context); g_slice_free (SeekTaskContext, context);
@ -317,6 +316,7 @@ testSeekAdaptiveDemuxSendsData (GstAdaptiveDemuxTestEngine * engine,
seekContext = g_slice_new (SeekTaskContext); seekContext = g_slice_new (SeekTaskContext);
seekContext->pipeline = engine->pipeline; seekContext->pipeline = engine->pipeline;
seekContext->seek_event = gst_event_ref (testData->seek_event);
testData->test_task = seekContext->task = testData->test_task = seekContext->task =
gst_task_new ((GstTaskFunction) testSeekTaskDoSeek, seekContext, NULL); gst_task_new ((GstTaskFunction) testSeekTaskDoSeek, seekContext, NULL);
gst_task_set_lock (testData->test_task, &testData->test_task_lock); gst_task_set_lock (testData->test_task, &testData->test_task_lock);

View file

@ -105,6 +105,7 @@ typedef struct _GstAdaptiveDemuxTestCase
* demux to AppSink before triggering a seek request * demux to AppSink before triggering a seek request
*/ */
guint64 threshold_for_seek; guint64 threshold_for_seek;
GstEvent *seek_event;
gpointer signal_context; gpointer signal_context;
} GstAdaptiveDemuxTestCase; } GstAdaptiveDemuxTestCase;

View file

@ -486,6 +486,15 @@ GST_START_TEST (testSeek)
*/ */
testData->threshold_for_seek = 4687 + 1; testData->threshold_for_seek = 4687 + 1;
/* seek to 5ms.
* Because there is only one fragment, we expect the whole file to be
* downloaded again
*/
testData->seek_event =
gst_event_new_seek (1.0, GST_FORMAT_TIME,
GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT, GST_SEEK_TYPE_SET,
5 * GST_MSECOND, GST_SEEK_TYPE_NONE, 0);
gst_test_http_src_install_callbacks (&http_src_callbacks, inputTestData); gst_test_http_src_install_callbacks (&http_src_callbacks, inputTestData);
gst_adaptive_demux_test_seek (DEMUX_ELEMENT_NAME, gst_adaptive_demux_test_seek (DEMUX_ELEMENT_NAME,
"http://unit.test/test.mpd", testData); "http://unit.test/test.mpd", testData);

View file

@ -374,7 +374,15 @@ GST_START_TEST (testSeek)
http_src_callbacks.src_start = gst_hlsdemux_test_src_start; http_src_callbacks.src_start = gst_hlsdemux_test_src_start;
http_src_callbacks.src_create = gst_hlsdemux_test_src_create; http_src_callbacks.src_create = gst_hlsdemux_test_src_create;
/* seek to 5ms.
* Because there is only one fragment, we expect the whole file to be
* downloaded again
*/
engineTestData->threshold_for_seek = 20 * TS_PACKET_LEN; engineTestData->threshold_for_seek = 20 * TS_PACKET_LEN;
engineTestData->seek_event =
gst_event_new_seek (1.0, GST_FORMAT_TIME,
GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT, GST_SEEK_TYPE_SET,
5 * GST_MSECOND, GST_SEEK_TYPE_NONE, 0);
gst_test_http_src_install_callbacks (&http_src_callbacks, &hlsTestCase); gst_test_http_src_install_callbacks (&http_src_callbacks, &hlsTestCase);
gst_adaptive_demux_test_seek (DEMUX_ELEMENT_NAME, gst_adaptive_demux_test_seek (DEMUX_ELEMENT_NAME,