gst/mpegstream/gstmpegparse.c (gst_mpeg_parse_adjust_ts)

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.
This commit is contained in:
Martin Soto 2006-01-05 21:36:49 +00:00
parent b528f778d0
commit 216917d0b1
4 changed files with 75 additions and 27 deletions

View file

@ -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):

View 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;
}
}

View 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;
};

View 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);
}