tsdemux: Fix segment and segment event handling during seeking

Always update the segment and not only for accurate seeking and always
send a new segment event after seeks.

For non-accurate force a reset of our segment info to start from
where our seek led us as we don't need to be accurate

https://bugzilla.gnome.org/show_bug.cgi?id=743363
This commit is contained in:
Thiago Santos 2015-02-09 11:21:35 -03:00
parent 84a9493a81
commit b347ea9870
2 changed files with 9 additions and 10 deletions

View file

@ -815,14 +815,11 @@ gst_ts_demux_do_seek (MpegTSBase * base, GstEvent * event)
demux->rate = rate;
res = GST_FLOW_OK;
if (flags & GST_SEEK_FLAG_ACCURATE) {
/* keep the seek infos for our segment */
gst_segment_do_seek (&demux->segment, rate, format, flags, start_type,
start, stop_type, stop, NULL);
} else {
/* Drop segment infos, it will be recreated with actual seek infos */
gst_segment_init (&demux->segment, GST_FORMAT_UNDEFINED);
}
if (!(flags & GST_SEEK_FLAG_ACCURATE))
demux->reset_segment = TRUE;
if (demux->segment_event) {
gst_event_unref (demux->segment_event);
demux->segment_event = NULL;
@ -831,12 +828,13 @@ gst_ts_demux_do_seek (MpegTSBase * base, GstEvent * event)
for (tmp = demux->program->stream_list; tmp; tmp = tmp->next) {
TSDemuxStream *stream = tmp->data;
if (flags & GST_SEEK_FLAG_ACCURATE)
stream->needs_keyframe = TRUE;
stream->seeked_pts = GST_CLOCK_TIME_NONE;
stream->seeked_dts = GST_CLOCK_TIME_NONE;
stream->need_newsegment = TRUE;
stream->first_dts = GST_CLOCK_TIME_NONE;
}
done:
@ -1951,7 +1949,7 @@ calculate_and_push_newsegment (GstTSDemux * demux, TSDemuxStream * stream)
GST_DEBUG ("lowest_pts %" G_GUINT64_FORMAT " => clocktime %" GST_TIME_FORMAT,
lowest_pts, GST_TIME_ARGS (firstts));
if (demux->segment.format != GST_FORMAT_TIME) {
if (demux->segment.format != GST_FORMAT_TIME || demux->reset_segment) {
/* It will happen only if it's first program or after flushes. */
GST_DEBUG ("Calculating actual segment");
if (base->segment.format == GST_FORMAT_TIME) {

View file

@ -69,6 +69,7 @@ struct _GstTSDemux
/* segments to be sent */
GstSegment segment;
GstEvent *segment_event;
gboolean reset_segment;
/* global taglist */
GstTagList *global_tags;