gst/mpegstream/gstmpegdemux.c: Bridge gaps in stream by NEWSEGMENT sending. Fixes...
authorMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
Wed, 2 Jul 2008 07:49:19 +0000 (07:49 +0000)
committerMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
Wed, 2 Jul 2008 07:49:19 +0000 (07:49 +0000)
Original commit message from CVS:
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_send_subbuffer),
(gst_mpeg_demux_sync_stream_to_time):
Bridge gaps in stream by NEWSEGMENT sending.  Fixes #540194.

ChangeLog
common
gst/mpegstream/gstmpegdemux.c

index 47a5e06e9454c7013fc6220180dc74a42b7f3fe5..97f9a0d622a4a8b969ef9ef28fab64eb9147c95b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-07-02  Mark Nauwelaerts  <mark.nauwelaerts@collabora.co.uk>
+
+       * gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_send_subbuffer),
+       (gst_mpeg_demux_sync_stream_to_time):
+       Bridge gaps in stream by NEWSEGMENT sending.  Fixes #540194.
+
 2008-06-27  Mark Nauwelaerts  <mark.nauwelaerts@collabora.co.uk>
 
        * ext/dvdread/dvdreadsrc.c: (gst_dvd_read_src_read),
diff --git a/common b/common
index d9cd98b46aebaf143dc43d8563a3bff650be6a7e..593bb114c6f5c32b529aa6443be4c2d60d6484c7 160000 (submodule)
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit d9cd98b46aebaf143dc43d8563a3bff650be6a7e
+Subproject commit 593bb114c6f5c32b529aa6443be4c2d60d6484c7
index 057b9fe0f8c6f35a9d43ae2de8fba9736cf652da..ccabdaa5c9dab7c915d48ba9245447b316dbd273 100644 (file)
@@ -1041,6 +1041,37 @@ gst_mpeg_demux_send_subbuffer (GstMPEGDemux * mpeg_demux,
 
   GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
   GST_BUFFER_OFFSET (outbuf) = GST_BUFFER_OFFSET (buffer) + offset;
+
+  if (GST_CLOCK_TIME_IS_VALID (timestamp) &&
+      GST_CLOCK_TIME_IS_VALID (mpeg_parse->current_segment.last_stop)) {
+    GstClockTimeDiff diff;
+    guint64 update_time;
+
+    update_time = MIN (timestamp, mpeg_parse->current_segment.stop);
+    update_time = MAX (timestamp, mpeg_parse->current_segment.start);
+    diff = GST_CLOCK_DIFF (mpeg_parse->current_segment.last_stop, update_time);
+    if (diff > GST_SECOND * 2) {
+      GST_DEBUG_OBJECT (mpeg_demux, "Gap of %" GST_TIME_FORMAT " detected in "
+          "stream %d. Sending updated NEWSEGMENT events", GST_TIME_ARGS (diff),
+          outstream->number);
+      PARSE_CLASS (mpeg_parse)->send_event (mpeg_parse,
+          gst_event_new_new_segment (TRUE, mpeg_parse->current_segment.rate,
+              GST_FORMAT_TIME, mpeg_parse->current_segment.last_stop,
+              mpeg_parse->current_segment.last_stop,
+              mpeg_parse->current_segment.last_stop));
+      gst_segment_set_newsegment (&mpeg_parse->current_segment,
+          FALSE, mpeg_parse->current_segment.rate, GST_FORMAT_TIME,
+          update_time, mpeg_parse->current_segment.stop, update_time);
+      PARSE_CLASS (mpeg_parse)->send_event (mpeg_parse,
+          gst_event_new_new_segment (FALSE, mpeg_parse->current_segment.rate,
+              GST_FORMAT_TIME, update_time,
+              mpeg_parse->current_segment.stop, update_time));
+      GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
+    }
+    gst_segment_set_last_stop (&mpeg_parse->current_segment,
+        GST_FORMAT_TIME, update_time);
+  }
+
   ret = gst_pad_push (outstream->pad, outbuf);
   GST_LOG_OBJECT (outstream->pad, "flow: %s", gst_flow_get_name (ret));
   ++outstream->buffers_sent;
@@ -1135,8 +1166,6 @@ gst_mpeg_demux_sync_stream_to_time (GstMPEGDemux * mpeg_demux,
   gst_pad_push_event (stream->pad, gst_event_new_new_segment (TRUE,
           mpeg_parse->current_segment.rate, GST_FORMAT_TIME,
           update_time, mpeg_parse->current_segment.stop, update_time));
-
-  mpeg_parse->current_segment.last_stop = update_time;
 }
 
 #if 0