dashdemux: new API to load the stream Period with a given index
authorGianluca Gennari <gennarone@gmail.com>
Mon, 17 Dec 2012 14:00:52 +0000 (15:00 +0100)
committerThiago Santos <thiago.sousa.santos@collabora.com>
Wed, 8 May 2013 21:14:32 +0000 (18:14 -0300)
this avoids to fiddle with stream internals in the code

ext/dash/gstdashdemux.c
ext/dash/gstmpdparser.c
ext/dash/gstmpdparser.h

index a0ff293..4cb99ec 100644 (file)
@@ -527,10 +527,9 @@ gst_dash_demux_src_event (GstPad * pad, GstEvent * event)
       }
       if (current_period != demux->client->period_idx) {
         GST_DEBUG_OBJECT (demux, "Seeking to Period %d", current_period);
-        /* FIXME: we should'nt fiddle with client internals like that */
-        demux->client->period_idx = current_period;
-        /* setup video, audio and subtitle streams */
-        if (!gst_dash_demux_setup_all_streams (demux))
+        /* setup video, audio and subtitle streams, starting from the new Period */
+        if (!gst_mpd_client_get_period_by_index (demux->client, current_period) ||
+            !gst_dash_demux_setup_all_streams (demux))
           return FALSE;
       }
 
@@ -707,11 +706,12 @@ gst_dash_demux_sink_event (GstPad * pad, GstEvent * event)
             ("Incompatible manifest file."), (NULL));
         return FALSE;
       }
-      /* start from first Period */
-      demux->client->period_idx = 0;
-      /* setup video, audio and subtitle streams */
-      if (!gst_dash_demux_setup_all_streams (demux))
+
+      /* setup video, audio and subtitle streams, starting from first Period */
+      if (!gst_mpd_client_get_period_by_index (demux->client, 0) ||
+          !gst_dash_demux_setup_all_streams (demux))
         return FALSE;
+
       /* Send duration message */
       if (!gst_mpd_client_is_live (demux->client)) {
         GstClockTime duration =
@@ -1196,9 +1196,9 @@ gst_dash_demux_download_loop (GstDashDemux * demux)
     while (!gst_dash_demux_get_next_fragment_set (demux)) {
       if (demux->end_of_period) {
         GST_INFO_OBJECT (demux, "Reached the end of the Period");
-        /* load the next Period in the Media Presentation */
-        if (!gst_mpd_client_get_next_period (demux->client)
-            || !gst_dash_demux_setup_all_streams (demux)) {
+        /* setup video, audio and subtitle streams, starting from the next Period */
+        if (!gst_mpd_client_get_period_by_index (demux->client, demux->client->period_idx + 1) ||
+            !gst_dash_demux_setup_all_streams (demux)) {
           GST_INFO_OBJECT (demux, "Reached the end of the manifest file");
           demux->end_of_manifest = TRUE;
           if (GST_STATE (demux) != GST_STATE_PLAYING) {
index 73950f9..f4c436c 100644 (file)
@@ -3054,18 +3054,18 @@ gst_mpd_client_get_media_presentation_duration (GstMpdClient * client)
 }
 
 gboolean
-gst_mpd_client_get_next_period (GstMpdClient *client)
+gst_mpd_client_get_period_by_index (GstMpdClient *client, guint period_idx)
 {
   GstStreamPeriod *next_stream_period;
 
   g_return_val_if_fail (client != NULL, FALSE);
   g_return_val_if_fail (client->periods != NULL, FALSE);
 
-  next_stream_period = g_list_nth_data (client->periods, client->period_idx + 1);
+  next_stream_period = g_list_nth_data (client->periods, period_idx);
   if (next_stream_period == NULL)
     return FALSE;
 
-  client->period_idx++;
+  client->period_idx = period_idx;
 
   return TRUE;
 }
index 8254c87..dccae1c 100644 (file)
@@ -475,7 +475,7 @@ gboolean gst_mpd_client_get_next_header (GstMpdClient *client, const gchar **uri
 gboolean gst_mpd_client_is_live (GstMpdClient * client);
 
 /* Period selection */
-gboolean gst_mpd_client_get_next_period (GstMpdClient *client);
+gboolean gst_mpd_client_get_period_by_index (GstMpdClient *client, guint period_idx);
 
 /* Representation selection */
 gint gst_mpdparser_get_rep_idx_with_max_bandwidth (GList *Representations, gint max_bandwidth);