tests: adaptive: update to allow more flexible seeking tests
authorThiago Santos <thiagoss@osg.samsung.com>
Wed, 23 Dec 2015 18:25:29 +0000 (15:25 -0300)
committerThiago Santos <thiagoss@osg.samsung.com>
Wed, 6 Jan 2016 13:23:13 +0000 (10:23 -0300)
Allows defining a seek event to be able to change seeking parameters
and create more seeking test scenarios

tests/check/elements/adaptive_demux_common.c
tests/check/elements/adaptive_demux_common.h
tests/check/elements/dash_demux.c
tests/check/elements/hls_demux.c

index 67d724d..0fedfb9 100644 (file)
@@ -77,6 +77,7 @@ gst_adaptive_demux_test_case_clear (GstAdaptiveDemuxTestCase * testData)
   testData->signal_context = NULL;
   testData->test_task_state = TEST_TASK_STATE_NOT_STARTED;
   testData->threshold_for_seek = 0;
+  gst_event_replace (&testData->seek_event, NULL);
   testData->signal_context = NULL;
 }
 
@@ -251,6 +252,7 @@ typedef struct _SeekTaskContext
 {
   GstElement *pipeline;
   GstTask *task;
+  GstEvent *seek_event;
 } SeekTaskContext;
 
 /* 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");
 
-  /* seek to 5ms.
-   * Because there is only one fragment, we expect the whole file to be
-   * downloaded again
-   */
-  if (!gst_element_seek_simple (GST_ELEMENT (context->pipeline),
-          GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT,
-          5 * GST_MSECOND)) {
+  fail_unless (GST_IS_EVENT (context->seek_event));
+  fail_unless (GST_EVENT_TYPE (context->seek_event) == GST_EVENT_SEEK);
+
+  if (!gst_element_send_event (GST_ELEMENT (context->pipeline),
+          context->seek_event))
     fail ("Seek failed!\n");
-  }
   GST_DEBUG ("seek ok");
   task = context->task;
   g_slice_free (SeekTaskContext, context);
@@ -317,6 +316,7 @@ testSeekAdaptiveDemuxSendsData (GstAdaptiveDemuxTestEngine * engine,
 
     seekContext = g_slice_new (SeekTaskContext);
     seekContext->pipeline = engine->pipeline;
+    seekContext->seek_event = gst_event_ref (testData->seek_event);
     testData->test_task = seekContext->task =
         gst_task_new ((GstTaskFunction) testSeekTaskDoSeek, seekContext, NULL);
     gst_task_set_lock (testData->test_task, &testData->test_task_lock);
index 3969582..ed7317c 100644 (file)
@@ -105,6 +105,7 @@ typedef struct _GstAdaptiveDemuxTestCase
    * demux  to AppSink before triggering a seek request
    */
   guint64 threshold_for_seek;
+  GstEvent *seek_event;
 
   gpointer signal_context;
 } GstAdaptiveDemuxTestCase;
index ce7556f..b628b0d 100644 (file)
@@ -486,6 +486,15 @@ GST_START_TEST (testSeek)
    */
   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_adaptive_demux_test_seek (DEMUX_ELEMENT_NAME,
       "http://unit.test/test.mpd", testData);
index 0918766..8953458 100644 (file)
@@ -374,7 +374,15 @@ GST_START_TEST (testSeek)
 
   http_src_callbacks.src_start = gst_hlsdemux_test_src_start;
   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->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_adaptive_demux_test_seek (DEMUX_ELEMENT_NAME,