mssdemux: push newsegments with same start time on bitrate switches
authorThiago Santos <thiago.sousa.santos@collabora.com>
Tue, 15 Jan 2013 20:31:25 +0000 (17:31 -0300)
committerThiago Santos <thiago.sousa.santos@collabora.com>
Wed, 8 May 2013 00:05:12 +0000 (21:05 -0300)
This keeps sinks working in sync after a bitrate switch

ext/smoothstreaming/gstmssdemux.c

index a596726..45a353f 100644 (file)
@@ -780,6 +780,7 @@ gst_mss_demux_reconfigure (GstMssDemux * mssdemux)
   gst_mss_demux_stop_tasks (mssdemux, TRUE);
   if (gst_mss_manifest_change_bitrate (mssdemux->manifest,
           mssdemux->connection_speed)) {
+    GstClockTime newseg_ts = GST_CLOCK_TIME_NONE;
 
     GST_DEBUG_OBJECT (mssdemux, "Creating new pad group");
     /* if we changed the bitrate, we need to add new pads */
@@ -819,6 +820,9 @@ gst_mss_demux_reconfigure (GstMssDemux * mssdemux)
             (stream->manifest_stream);
       }
 
+      if (ts < newseg_ts)
+        newseg_ts = ts;
+
       GST_DEBUG_OBJECT (mssdemux,
           "Seeking stream %p %s to ts %" GST_TIME_FORMAT, stream,
           GST_PAD_NAME (stream->pad), GST_TIME_ARGS (ts));
@@ -840,6 +844,13 @@ gst_mss_demux_reconfigure (GstMssDemux * mssdemux)
       gst_element_remove_pad (GST_ELEMENT (mssdemux), oldpad);
       gst_object_unref (oldpad);
     }
+    for (iter = mssdemux->streams; iter; iter = g_slist_next (iter)) {
+      GstMssDemuxStream *stream = iter->data;
+
+      stream->pending_newsegment =
+          gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, newseg_ts, -1,
+          newseg_ts);
+    }
   }
   gst_mss_demux_restart_tasks (mssdemux);
 }