hlsdemux: query the uri upstream before updating the playlist
authorAndoni Morales Alastruey <ylatuya@gmail.com>
Tue, 15 Feb 2011 01:13:56 +0000 (02:13 +0100)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Wed, 30 Mar 2011 07:19:20 +0000 (09:19 +0200)
gst/hls/gsthlsdemux.c

index a8bae2b7850eef96174ada3325eaca165c48e3dd..ec0f3a1ac9cefdcbbe6506282ebe3a8d5bf08027 100644 (file)
@@ -304,6 +304,7 @@ gst_hls_demux_sink_event (GstPad * pad, GstEvent * event)
 {
   GstHLSDemux *demux = GST_HLS_DEMUX (gst_pad_get_parent (pad));
   GstQuery *query;
+  gboolean ret;
   gchar *uri;
 
 
@@ -318,17 +319,20 @@ gst_hls_demux_sink_event (GstPad * pad, GstEvent * event)
 
       GST_DEBUG_OBJECT (demux, "Got EOS on the sink pad: main playlist fetched");
 
+      query = gst_query_new_uri ();
+      ret = gst_pad_peer_query (demux->sinkpad, query);
+      if (ret) {
+        gst_query_parse_uri (query, &uri);
+        gst_hls_demux_set_location (demux, uri);
+        g_free (uri);
+      }
+
       playlist = g_strndup ((gchar *) GST_BUFFER_DATA (demux->playlist),
           GST_BUFFER_SIZE (demux->playlist));
       gst_m3u8_client_update (demux->client, playlist);
       gst_buffer_unref (demux->playlist);
 
-      query = gst_query_new_uri ();
-      if (gst_pad_peer_query (demux->sinkpad, query)) {
-        gst_query_parse_uri (query, &uri);
-        gst_hls_demux_set_location (demux, uri);
-        g_free (uri);
-      } else if (gst_m3u8_client_is_live (demux->client)) {
+      if (!ret && gst_m3u8_client_is_live (demux->client)) {
         GST_ELEMENT_ERROR (demux, RESOURCE, NOT_FOUND,
             ("Failed querying the playlist uri, "
                 "required for live sources."), NULL);