]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/gst-plugins-ugly0-10.git/commitdiff
gst/mpegstream/gstmpegparse.c (gst_mpeg_parse_adjust_ts)
authorMartin Soto <martinsoto@users.sourceforge.net>
Thu, 5 Jan 2006 21:36:49 +0000 (21:36 +0000)
committerMartin Soto <martinsoto@users.sourceforge.net>
Thu, 5 Jan 2006 21:36:49 +0000 (21:36 +0000)
Original commit message from CVS:
2006-01-05  Martin Soto  <martinsoto@users.sourceforge.net>

* gst/mpegstream/gstmpegparse.c (gst_mpeg_parse_adjust_ts)
(gst_mpeg_parse_process_event, gst_mpeg_parse_pad_added): Don't
rewrite timestamps in the case segments are being set from
upstream, but use timestamps unmodified. Also send proper position
values. This allows for correct time display and makes queries
work in sink elements.

* gst/mpegstream/gstdvddemux.h:
* gst/mpegstream/gstdvddemux.c (gst_dvd_demux_init)
(gst_dvd_demux_handle_dvd_event, gst_dvd_demux_send_subbuffer):
Rename flush_filter to segment_filter, which is better represents
what the arreibute does.

* gst/mpegstream/gstdvddemux.c (gst_dvd_demux_process_event):
Activate segment filtering when a timestamp discontinuity is seen.

ChangeLog
gst/mpegstream/gstdvddemux.c
gst/mpegstream/gstdvddemux.h
gst/mpegstream/gstmpegparse.c

index 27915c023a5b16b9f1a52a3518358aca91b68e1f..1e3fd9c3b663f4874b6e8b7da717ea9d87276793 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2006-01-05  Martin Soto  <martinsoto@users.sourceforge.net>
+
+       * gst/mpegstream/gstmpegparse.c (gst_mpeg_parse_adjust_ts) 
+       (gst_mpeg_parse_process_event, gst_mpeg_parse_pad_added): Don't
+       rewrite timestamps in the case segments are being set from
+       upstream, but use timestamps unmodified. Also send proper position
+       values. This allows for correct time display and makes queries
+       work in sink elements.
+
+       * gst/mpegstream/gstdvddemux.h: 
+       * gst/mpegstream/gstdvddemux.c (gst_dvd_demux_init) 
+       (gst_dvd_demux_handle_dvd_event, gst_dvd_demux_send_subbuffer):
+       Rename flush_filter to segment_filter, which is better represents
+       what the arreibute does.
+
+       * gst/mpegstream/gstdvddemux.c (gst_dvd_demux_process_event):
+       Activate segment filtering when a timestamp discontinuity is seen.
+
 2006-01-04  Tim-Philipp Müller  <tim at centricular dot net>
 
        * ext/mad/gstmad.c: (gst_mad_chain):
index 91c014da580d3e31cc085e6bfee649d70239ca9b..aa30974ddcd65bdc02d2d679aeae5b31b4bbae72 100644 (file)
@@ -283,7 +283,7 @@ gst_dvd_demux_init (GstDVDDemux * dvd_demux, GstDVDDemuxClass * klass)
   }
 
   /* Directly after starting we operate as if we had just flushed. */
-  dvd_demux->flush_filter = TRUE;
+  dvd_demux->segment_filter = TRUE;
 
   dvd_demux->langcodes = NULL;
 }
@@ -304,8 +304,24 @@ gst_dvd_demux_process_event (GstMPEGParse * mpeg_parse, GstEvent * event)
   gboolean ret = TRUE;
 
   switch (GST_EVENT_TYPE (event)) {
+    case GST_EVENT_NEWSEGMENT:
+    {
+      gboolean update;
+
+      gst_event_parse_new_segment (event, &update, NULL, NULL,
+          NULL, NULL, NULL);
+
+      if (!update) {
+        /* This is a discontinuity in the timestamp sequence. which
+           may mean that we find some audio blocks lying outside the
+           segment. Filter them. */
+        dvd_demux->segment_filter = TRUE;
+      }
+
+      break;
+    }
     case GST_EVENT_FLUSH_STOP:
-      dvd_demux->flush_filter = TRUE;
+      dvd_demux->segment_filter = TRUE;
       ret = GST_MPEG_PARSE_CLASS (parent_class)->process_event (mpeg_parse,
           event);
       break;
@@ -373,7 +389,7 @@ gst_dvd_demux_handle_dvd_event (GstDVDDemux * dvd_demux, GstEvent * event)
     if (!gst_pad_push_event (dvd_demux->cur_audio, gst_event_new_flush_stop ())) {
       return FALSE;
     }
-    dvd_demux->flush_filter = TRUE;
+    dvd_demux->segment_filter = TRUE;
     return TRUE;
   } else if (strcmp (event_type, "dvd-spu-stream-change") == 0) {
     gint stream_nr;
@@ -930,15 +946,15 @@ gst_dvd_demux_send_subbuffer (GstMPEGDemux * mpeg_demux,
   GstPad *outpad;
   gint cur_nr;
 
-  if (dvd_demux->flush_filter &&
+  if (dvd_demux->segment_filter &&
       GST_MPEG_DEMUX_STREAM_KIND (outstream->type) ==
       GST_MPEG_DEMUX_STREAM_AUDIO) {
-    /* We are in flush_filter mode and have an audio buffer. */
+    /* We are in segment_filter mode and have an audio buffer. */
     if (GST_CLOCK_TIME_IS_VALID (timestamp)) {
       /* This is the first valid audio buffer after the flush. */
-      dvd_demux->flush_filter = FALSE;
+      dvd_demux->segment_filter = FALSE;
     } else {
-      /* Discard the buffer, */
+      /* Discard the buffer. */
       return GST_FLOW_OK;
     }
   }
index 6783292fab05ce72f564529c958511a6cffe05f1..5b96e89a7b815e562ddd823a41136cf99c5874d9 100644 (file)
@@ -104,14 +104,10 @@ struct _GstDVDDemux {
   GstMPEGStream *subpicture_stream[GST_DVD_DEMUX_NUM_SUBPICTURE_STREAMS];
                                 /* Subpicture output streams. */
 
-  gboolean flush_filter;       /* If TRUE, the demuxer refrains from
+  gboolean segment_filter;     /* If TRUE, the demuxer refrains from
                                   sending any audio packets until it
-                                  sees one with a valid
-                                  timestamp. This is used to avoid
-                                  sending audio packets that lie
-                                  outside (actually before) the
-                                  current segment, which may happen
-                                  after a seek operation. */
+                                  sees one with a timestamp lying
+                                  inside the current segment. */
 
   GstEvent *langcodes;
 };
index 4c669732474fa45e15d4e16e1ff6eb94f9dd2480..4fef0bdaee6010f57763ccadaf1d57c0b6a3f2bb 100644 (file)
@@ -291,15 +291,11 @@ gst_mpeg_parse_adjust_ts (GstMPEGParse * mpeg_parse, GstClockTime ts)
     /* Close the SCR gaps. */
     return ts + MPEGTIME_TO_GSTTIME (mpeg_parse->adjust);
   } else {
-    /* Adjust the timestamp in such a way that all segments appear to
-       be in a single continuous sequence starting at time 0. */
-    if (ts + mpeg_parse->current_segment.accum >=
-        mpeg_parse->current_segment.start) {
-      return ts + mpeg_parse->current_segment.accum -
-          mpeg_parse->current_segment.start;
+    if (ts >= mpeg_parse->current_segment.start) {
+      return ts;
     } else {
-      /* The adjustment would lead to a timestamp outside the current
-         segment. Return an invalid timestamp instead. */
+      /* The timestamp lies outside the current segment. Return an
+         invalid timestamp instead. */
       return GST_CLOCK_TIME_NONE;
     }
   }
@@ -355,16 +351,38 @@ gst_mpeg_parse_process_event (GstMPEGParse * mpeg_parse, GstEvent * event)
           &start, &stop, &time);
 
       if (format == GST_FORMAT_TIME && (GST_CLOCK_TIME_IS_VALID (time))) {
+        /* We are receiving segments from upstream. Don't try to adjust
+           SCR values. */
+        mpeg_parse->do_adjust = FALSE;
+        mpeg_parse->adjust = 0;
+
+        if (!update && mpeg_parse->current_segment.stop != -1) {
+          /* Close the current segment. */
+          if (CLASS (mpeg_parse)->send_event) {
+            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.start,
+                    mpeg_parse->current_segment.stop,
+                    mpeg_parse->current_segment.time));
+          }
+        }
+
         /* Update the current segment. */
         GST_DEBUG_OBJECT (mpeg_parse,
             "Updating current segment with newsegment");
         gst_segment_set_newsegment (&mpeg_parse->current_segment,
             update, rate, format, start, stop, time);
 
-        /* We are receiving segments from upstream. Don't try to adjust
-           SCR values. */
-        mpeg_parse->do_adjust = FALSE;
-        mpeg_parse->adjust = 0;
+        if (!update) {
+          /* Send a newsegment event for the new current segment. */
+          if (CLASS (mpeg_parse)->send_event) {
+            CLASS (mpeg_parse)->send_event (mpeg_parse,
+                gst_event_new_new_segment (FALSE, rate, GST_FORMAT_TIME,
+                    start, -1, time));
+          }
+        }
       }
       mpeg_parse->packetize->resync = TRUE;
 
@@ -455,7 +473,7 @@ gst_mpeg_parse_pad_added (GstElement * element, GstPad * pad)
   GstEvent *event = gst_event_new_new_segment (FALSE,
       mpeg_parse->current_segment.rate,
       GST_FORMAT_TIME, mpeg_parse->current_segment.start,
-      mpeg_parse->current_segment.stop, 0);
+      -1, mpeg_parse->current_segment.start);
 
   gst_pad_push_event (pad, event);
 }