dashdemux: Handle case without an initialization segment
authorOlivier CrĂȘte <olivier.crete@collabora.com>
Mon, 10 Jun 2013 22:01:14 +0000 (18:01 -0400)
committerThiago Santos <thiago.sousa.santos@collabora.com>
Tue, 2 Jul 2013 04:30:24 +0000 (01:30 -0300)
If no initialization segment is defined, then don't print a
critical or a warning, just ignore it.

https://bugzilla.gnome.org/show_bug.cgi?id=701961

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

index 0efd04a..b8a5432 100644 (file)
@@ -1728,18 +1728,24 @@ gst_dash_demux_get_next_header (GstDashDemux * demux, guint stream_idx)
       initializationURL, range_start, range_end);
 
   /* check if we have an index */
-  if (gst_mpd_client_get_next_header_index (demux->client, &initializationURL,
-          stream_idx, &range_start, &range_end)) {
-    GST_INFO_OBJECT (demux, "Fetching index %s %" G_GINT64_FORMAT "-%"
-        G_GINT64_FORMAT, initializationURL, range_start, range_end);
-    index_buffer = gst_dash_demux_download_header_fragment (demux, stream_idx,
+  if (header_buffer
+      && gst_mpd_client_get_next_header_index (demux->client,
+          &initializationURL, stream_idx, &range_start, &range_end)) {
+    GST_INFO_OBJECT (demux,
+        "Fetching index %s %" G_GINT64_FORMAT "-%" G_GINT64_FORMAT,
+        initializationURL, range_start, range_end);
+    index_buffer =
+        gst_dash_demux_download_header_fragment (demux, stream_idx,
         initializationURL, range_start, range_end);
   }
 
-  if (index_buffer && header_buffer) {
+  if (header_buffer == NULL) {
+    GST_WARNING_OBJECT (demux, "Unable to fetch header");
+    return NULL;
+  }
+
+  if (index_buffer) {
     header_buffer = gst_buffer_append (header_buffer, index_buffer);
-  } else if (index_buffer) {
-    gst_buffer_unref (index_buffer);
   }
 
   return header_buffer;
@@ -1975,9 +1981,7 @@ gst_dash_demux_get_next_fragment (GstDashDemux * demux)
       if (selected_stream->need_header) {
         /* We need to fetch a new header */
         if ((header_buffer =
-                gst_dash_demux_get_next_header (demux, stream_idx)) == NULL) {
-          GST_WARNING_OBJECT (demux, "Unable to fetch header");
-        } else {
+                gst_dash_demux_get_next_header (demux, stream_idx)) != NULL) {
           buffer = gst_buffer_append (header_buffer, buffer);
         }
         selected_stream->need_header = FALSE;
index cedb4a2..e46e741 100644 (file)
@@ -3437,9 +3437,11 @@ gst_mpd_client_get_next_header (GstMpdClient * client, gchar ** uri,
         && stream_period->period->SegmentTemplate->initialization) {
       initialization = stream_period->period->SegmentTemplate->initialization;
     }
-    *uri = gst_mpdparser_build_URL_from_template (initialization,
-        stream->cur_representation->id, 0,
-        stream->cur_representation->bandwidth, 0);
+    if (initialization) {
+      *uri = gst_mpdparser_build_URL_from_template (initialization,
+          stream->cur_representation->id, 0,
+          stream->cur_representation->bandwidth, 0);
+    }
   }
   GST_MPD_CLIENT_UNLOCK (client);