From fce10c44ae531d5f07bb0fbc8154275cd19c9c9e Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Tue, 5 Jan 2016 17:41:23 -0300 Subject: [PATCH] tests: dashdemux: add tests for post-seek segment boundaries check Checks if the post seek segment is what is expected. Also makes it easy to add more tests with different seeking flags using the same functions. --- tests/check/elements/dash_demux.c | 107 ++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) diff --git a/tests/check/elements/dash_demux.c b/tests/check/elements/dash_demux.c index b628b0d129..8ee40b685b 100644 --- a/tests/check/elements/dash_demux.c +++ b/tests/check/elements/dash_demux.c @@ -503,6 +503,111 @@ GST_START_TEST (testSeek) GST_END_TEST; + +static void +run_seek_position_test (gdouble rate, guint64 seek_start, GstSeekType stop_type, + guint64 seek_stop, GstSeekFlags flags, guint64 segment_start, + guint64 segment_stop, gint segments) +{ + const gchar *mpd = + "" + "" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " "; + GstDashDemuxTestInputData inputTestData[] = { + {"http://unit.test/test.mpd", (guint8 *) mpd, 0}, + {"http://unit.test/init-audio.mp4", NULL, 10000}, + {"http://unit.test/audio-1.mp4", NULL, 10000}, + {"http://unit.test/audio-2.mp4", NULL, 10000}, + {"http://unit.test/audio-3.mp4", NULL, 10000}, + {"http://unit.test/audio-4.mp4", NULL, 10000}, + {NULL, NULL, 0}, + }; + GstTestHTTPSrcCallbacks http_src_callbacks = { 0 }; + GstAdaptiveDemuxTestExpectedOutput outputTestData[] = { + /* 1 from the init segment */ + {"audio_00", (1 + segments) * 10000, NULL}, + }; + GstAdaptiveDemuxTestCase *testData; + + testData = gst_adaptive_demux_test_case_new (); + + http_src_callbacks.src_start = gst_dashdemux_http_src_start; + http_src_callbacks.src_create = gst_dashdemux_http_src_create; + COPY_OUTPUT_TEST_DATA (outputTestData, testData); + + /* media segment starts at 4687 + * Issue a seek request after media segment has started to be downloaded + * on the first pad listed in GstAdaptiveDemuxTestOutputStreamData and the + * first chunk of at least one byte has already arrived in AppSink + */ + testData->threshold_for_seek = 4687 + 1; + + /* FIXME hack to avoid having a 0 seqnum */ + gst_util_seqnum_next (); + + /* 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 (rate, GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, + seek_start, stop_type, seek_stop); + + gst_test_http_src_install_callbacks (&http_src_callbacks, inputTestData); + gst_adaptive_demux_test_seek (DEMUX_ELEMENT_NAME, + "http://unit.test/test.mpd", testData); + gst_object_unref (testData); +} + +GST_START_TEST (testSeekKeyUnitPosition) +{ + /* Seek to 1.5s with key unit, it should go back to 1.0s. 3 segments will be + * pushed */ + run_seek_position_test (1.0, 1500 * GST_MSECOND, GST_SEEK_TYPE_NONE, 0, + GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT, 1000 * GST_MSECOND, -1, 3); +} + +GST_END_TEST; + +GST_START_TEST (testSeekPosition) +{ + /* Seek to 1.5s without key unit, it should keep the 1.5s, but still push + * from the 1st segment, so 3 segments will be + * pushed */ + run_seek_position_test (1.0, 1500 * GST_MSECOND, GST_SEEK_TYPE_NONE, 0, + GST_SEEK_FLAG_FLUSH, 1500 * GST_MSECOND, -1, 3); +} + +GST_END_TEST; + static void testDownloadErrorMessageCallback (GstAdaptiveDemuxTestEngine * engine, GstMessage * msg, gpointer user_data) @@ -826,6 +931,8 @@ dash_demux_suite (void) tcase_add_test (tc_basicTest, testTwoPeriods); tcase_add_test (tc_basicTest, testParameters); tcase_add_test (tc_basicTest, testSeek); + tcase_add_test (tc_basicTest, testSeekKeyUnitPosition); + tcase_add_test (tc_basicTest, testSeekPosition); tcase_add_test (tc_basicTest, testDownloadError); tcase_add_test (tc_basicTest, testFragmentDownloadError); tcase_add_test (tc_basicTest, testQuery);