gst/mpegstream/: Send newsegment updates for sparse streams (#350778).
authorMartin Zlomek <martin.zlomek@itonis.tv>
Thu, 21 Sep 2006 13:34:59 +0000 (13:34 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Thu, 21 Sep 2006 13:34:59 +0000 (13:34 +0000)
Original commit message from CVS:
Patch by: Martin Zlomek <martin dot zlomek at itonis dot tv>
* gst/mpegstream/gstdvddemux.c: (gst_dvd_demux_reset),
(gst_dvd_demux_sync_stream_to_time):
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_send_subbuffer),
(gst_mpeg_demux_synchronise_pads),
(gst_mpeg_demux_sync_stream_to_time):
Send newsegment updates for sparse streams (#350778).

ChangeLog
gst/mpegstream/gstdvddemux.c
gst/mpegstream/gstmpegdemux.c

index bf071d4a50474b3ae8029cb958b6c6869ba58338..0d9a4eb4d2c547b4217804659b93f90d745510fb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2006-09-21  Tim-Philipp Müller  <tim at centricular dot net>
+
+       Patch by: Martin Zlomek <martin dot zlomek at itonis dot tv>
+
+       * gst/mpegstream/gstdvddemux.c: (gst_dvd_demux_reset),
+       (gst_dvd_demux_sync_stream_to_time):
+       * gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_send_subbuffer),
+       (gst_mpeg_demux_synchronise_pads),
+       (gst_mpeg_demux_sync_stream_to_time):
+         Send newsegment updates for sparse streams (#350778).
+       
 2006-09-20  Thomas Vander Stichele  <thomas at apestaart dot org>
 
        * ext/dvdread/dvdreadsrc.c: (gst_dvd_read_src_do_convert_query):
index 58d8f77efdf72f1903ef6e8951bca85ea18959e6..ed8d98853d7dd49c5160d3bdf025fdf9f9bbe8ff 100644 (file)
@@ -448,8 +448,8 @@ gst_dvd_demux_handle_dvd_event (GstDVDDemux * dvd_demux, GstEvent * event)
     gst_element_no_more_pads (GST_ELEMENT (dvd_demux));
 
     /* Keep video/audio/subtitle pads within 1/2 sec of the SCR */
-    mpeg_demux->max_gap = 0.5 * GST_SECOND;
-    mpeg_demux->max_gap_tolerance = 0.05 * GST_SECOND;
+    mpeg_demux->max_gap = GST_SECOND / 2;
+    mpeg_demux->max_gap_tolerance = GST_SECOND / 20;
   } else {
     GST_DEBUG_OBJECT (dvd_demux, "dvddemux Forwarding DVD event %s to all pads",
         event_type);
@@ -1052,7 +1052,7 @@ gst_dvd_demux_reset (GstDVDDemux * dvd_demux)
 {
   int i;
 
-  //GstMPEGDemux *mpeg_demux = GST_MPEG_DEMUX (dvd_demux);
+  GstMPEGDemux *mpeg_demux = GST_MPEG_DEMUX (dvd_demux);
 
   GST_INFO ("Resetting the dvd demuxer");
   for (i = 0; i < GST_DVD_DEMUX_NUM_SUBPICTURE_STREAMS; i++) {
@@ -1075,11 +1075,9 @@ gst_dvd_demux_reset (GstDVDDemux * dvd_demux)
   dvd_demux->cur_subpicture_nr = 0;
   dvd_demux->mpeg_version = 0;
 
-#if 0
   /* Reset max_gap handling */
-  mpeg_demux->max_gap = GST_CLOCK_TIME_NONE;
-  mpeg_demux->max_gap_tolerance = GST_CLOCK_TIME_NONE;
-#endif
+  mpeg_demux->max_gap = 0.5 * GST_SECOND;
+  mpeg_demux->max_gap_tolerance = 0.05 * GST_SECOND;
 }
 
 static void
@@ -1106,14 +1104,9 @@ gst_dvd_demux_sync_stream_to_time (GstMPEGDemux * mpeg_demux,
     GstMPEGStream * stream, GstClockTime last_ts)
 {
   GstDVDDemux *dvd_demux = GST_DVD_DEMUX (mpeg_demux);
-
-#if 0
-  GstClockTime start_ts;
-  GstEvent *filler = NULL;
-  GstFormat fmt = GST_FORMAT_TIME;
-#endif
-  GstPad *outpad = NULL;
-  gint cur_nr = 0;
+  GstMPEGParse *mpeg_parse = GST_MPEG_PARSE (mpeg_demux);
+  GstPad *outpad;
+  gint cur_nr;
 
   parent_class->sync_stream_to_time (mpeg_demux, stream, last_ts);
 
@@ -1130,27 +1123,15 @@ gst_dvd_demux_sync_stream_to_time (GstMPEGDemux * mpeg_demux,
       outpad = dvd_demux->cur_subpicture;
       cur_nr = dvd_demux->cur_subpicture_nr;
       break;
+    default:
+      return;
   }
 
-#if 0
-  /* FIXME: fillers in 0.9 aren't specified properly yet */
-  if ((outpad != NULL) && (cur_nr == stream->number)) {
-    if (GST_PAD_PEER (stream->pad)
-        && gst_pad_query_position (GST_PAD_PEER (stream->pad), &fmt,
-            (gint64 *) & start_ts)) {
-      if (start_ts < last_ts)
-        filler =
-            gst_event_new_filler_stamped (start_ts, GST_CLOCK_DIFF (last_ts,
-                start_ts));
-    } else
-      filler = gst_event_new_filler_stamped (last_ts, GST_CLOCK_TIME_NONE);
-
-    if (filler) {
-      if (!gst_pad_push_event (stream->pad, filler))
-        gst_event_unref (filler);
-    }
+  if (outpad && (cur_nr == stream->number)) {
+    gst_pad_push_event (outpad, gst_event_new_new_segment (TRUE,
+            mpeg_parse->current_segment.rate, GST_FORMAT_TIME,
+            last_ts, -1, last_ts));
   }
-#endif
 }
 
 static GstStateChangeReturn
index d53006bd633d129cd0f4b90a52d398dbdbaadaf8..37f6651c87e512812c3d867e0057a55042ac80b1 100644 (file)
@@ -892,10 +892,9 @@ gst_mpeg_demux_send_subbuffer (GstMPEGDemux * mpeg_demux,
 
   if (timestamp != GST_CLOCK_TIME_NONE) {
     outstream->cur_ts = timestamp;
-    outstream->scr_offs = GST_CLOCK_DIFF (timestamp,
-        PARSE_CLASS (mpeg_parse)->adjust_ts (mpeg_parse,
-            mpeg_parse->current_ts));
-    if (outstream->scr_offs < 0)
+    if (timestamp > mpeg_parse->current_ts)
+      outstream->scr_offs = timestamp - mpeg_parse->current_ts;
+    else
       outstream->scr_offs = 0;
 
     if (mpeg_demux->index != NULL) {
@@ -905,10 +904,8 @@ gst_mpeg_demux_send_subbuffer (GstMPEGDemux * mpeg_demux,
           GST_FORMAT_BYTES,
           GST_BUFFER_OFFSET (buffer), GST_FORMAT_TIME, timestamp, 0);
     }
-  } else {
-    outstream->cur_ts = PARSE_CLASS (mpeg_parse)->adjust_ts (mpeg_parse,
-        mpeg_parse->current_ts + outstream->scr_offs);
-  }
+  } else
+    outstream->cur_ts = mpeg_parse->current_ts + outstream->scr_offs;
 
   if (size == 0)
     return GST_FLOW_OK;
@@ -928,16 +925,10 @@ gst_mpeg_demux_send_subbuffer (GstMPEGDemux * mpeg_demux,
 
   if (GST_CLOCK_TIME_IS_VALID (mpeg_demux->max_gap) &&
       GST_CLOCK_TIME_IS_VALID (mpeg_parse->current_ts) &&
-      (PARSE_CLASS (mpeg_parse)->adjust_ts (mpeg_parse,
-              mpeg_parse->current_ts) > mpeg_demux->max_gap)) {
-    GstClockTime threshold =
-        GST_CLOCK_DIFF (PARSE_CLASS (mpeg_parse)->adjust_ts (mpeg_parse,
-            mpeg_parse->current_ts),
-        mpeg_demux->max_gap);
-
-    CLASS (mpeg_demux)->synchronise_pads (mpeg_demux, threshold,
-        PARSE_CLASS (mpeg_parse)->adjust_ts (mpeg_parse,
-            mpeg_parse->current_ts) - mpeg_demux->max_gap_tolerance);
+      (mpeg_parse->current_ts > mpeg_demux->max_gap)) {
+    CLASS (mpeg_demux)->synchronise_pads (mpeg_demux,
+        mpeg_parse->current_ts - mpeg_demux->max_gap,
+        mpeg_parse->current_ts - mpeg_demux->max_gap_tolerance);
   }
 
   return ret;
@@ -963,7 +954,7 @@ gst_mpeg_demux_synchronise_pads (GstMPEGDemux * mpeg_demux,
     GstClockTime threshold, GstClockTime new_ts)
 {
   /*
-   * Send a filler event to any pad with cur_ts < threshold to catch it up
+   * Send a new-segment event to any pad with cur_ts < threshold to catch it up
    */
   gint i;
 
@@ -992,47 +983,20 @@ gst_mpeg_demux_synchronise_pads (GstMPEGDemux * mpeg_demux,
     }
 }
 
-/* Send a filler event on the indicated pad to catch it up to
- * last_ts. Query the pad for current time, and use that time
- * to set the duration of the filler event, otherwise we use
- * the last timestamp of the stream and rely on the sinks
- * to absorb any overlap with the decoded data.
+/*
+ * Send a new-segment event on the indicated pad to catch it up to last_ts.
  */
 static void
 gst_mpeg_demux_sync_stream_to_time (GstMPEGDemux * mpeg_demux,
     GstMPEGStream * stream, GstClockTime last_ts)
 {
-  static gboolean beenhere;     /* FALSE */
-
-  if (!beenhere) {
-    g_message ("FIXME: gst_mpeg_demux_sync_stream_to_time\n");
-    beenhere = TRUE;
-  }
-#if 0
-  GstClockTime start_ts;
-  GstEvent *filler = NULL;
-  GstFormat fmt = GST_FORMAT_TIME;
-
-  if (!GST_PAD_PEER (stream->pad)
-      || !gst_pad_query (GST_PAD_PEER (stream->pad), GST_QUERY_POSITION, &fmt,
-          (gint64 *) & start_ts)) {
-    start_ts = stream->cur_ts;
-  }
-
-  if (start_ts < last_ts) {
-    filler = gst_event_new_filler_stamped (start_ts, GST_CLOCK_DIFF (last_ts,
-            start_ts));
-  }
+  GstMPEGParse *mpeg_parse = GST_MPEG_PARSE (mpeg_demux);
 
-  if (filler) {
-    GST_LOG ("Advancing %s from %llu by %lld to %llu (diff %lld)",
-        GST_PAD_NAME (stream->pad), stream->cur_ts,
-        gst_event_filler_get_duration (filler), last_ts,
-        GST_CLOCK_DIFF (last_ts, stream->cur_ts));
+  gst_pad_push_event (stream->pad, gst_event_new_new_segment (TRUE,
+          mpeg_parse->current_segment.rate, GST_FORMAT_TIME,
+          last_ts, -1, last_ts));
 
-    gst_pad_push_event (stream->pad, filler);
-  }
-#endif
+  mpeg_parse->current_segment.start = last_ts;
 }
 
 #if 0