tsdemux: fixes seeking in pull mode

Preserve the current segment and observations in pull mode seeks with
flushing.

https://bugzilla.gnome.org/show_bug.cgi?id=698050
This commit is contained in:
Josep Torra 2013-05-24 10:59:59 +02:00 committed by Edward Hervey
parent 0d6fc0215c
commit 28a2902a7b
5 changed files with 24 additions and 15 deletions

View file

@ -1291,7 +1291,7 @@ gst_mpegts_base_handle_eos (MpegTSBase * base)
} }
static inline void static inline void
mpegts_base_flush (MpegTSBase * base) mpegts_base_flush (MpegTSBase * base, gboolean hard)
{ {
MpegTSBaseClass *klass = GST_MPEGTS_BASE_GET_CLASS (base); MpegTSBaseClass *klass = GST_MPEGTS_BASE_GET_CLASS (base);
@ -1299,7 +1299,7 @@ mpegts_base_flush (MpegTSBase * base)
if (G_UNLIKELY (klass->flush == NULL)) if (G_UNLIKELY (klass->flush == NULL))
GST_WARNING_OBJECT (base, "Class doesn't have a 'flush' implementation !"); GST_WARNING_OBJECT (base, "Class doesn't have a 'flush' implementation !");
else else
klass->flush (base); klass->flush (base, hard);
} }
static gboolean static gboolean
@ -1337,8 +1337,8 @@ mpegts_base_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
break; break;
case GST_EVENT_FLUSH_STOP: case GST_EVENT_FLUSH_STOP:
res = GST_MPEGTS_BASE_GET_CLASS (base)->push_event (base, event); res = GST_MPEGTS_BASE_GET_CLASS (base)->push_event (base, event);
mpegts_packetizer_flush (base->packetizer); mpegts_packetizer_flush (base->packetizer, TRUE);
mpegts_base_flush (base); mpegts_base_flush (base, TRUE);
gst_segment_init (&base->segment, GST_FORMAT_UNDEFINED); gst_segment_init (&base->segment, GST_FORMAT_UNDEFINED);
base->seen_pat = FALSE; base->seen_pat = FALSE;
break; break;
@ -1684,9 +1684,10 @@ mpegts_base_handle_seek_event (MpegTSBase * base, GstPad * pad,
/* send a FLUSH_STOP for the sinkpad, since we need data for seeking */ /* send a FLUSH_STOP for the sinkpad, since we need data for seeking */
GST_DEBUG_OBJECT (base, "sending flush stop"); GST_DEBUG_OBJECT (base, "sending flush stop");
gst_pad_push_event (base->sinkpad, gst_event_new_flush_stop (TRUE)); gst_pad_push_event (base->sinkpad, gst_event_new_flush_stop (TRUE));
/* And actually flush our pending data */ /* And actually flush our pending data but allow to preserve some info
mpegts_base_flush (base); * to perform the seek */
mpegts_packetizer_flush (base->packetizer); mpegts_base_flush (base, FALSE);
mpegts_packetizer_flush (base->packetizer, FALSE);
} }
if (flags & (GST_SEEK_FLAG_SEGMENT | GST_SEEK_FLAG_SKIP)) { if (flags & (GST_SEEK_FLAG_SEGMENT | GST_SEEK_FLAG_SKIP)) {

View file

@ -165,8 +165,10 @@ struct _MpegTSBaseClass {
/* seek is called to wait for seeking */ /* seek is called to wait for seeking */
GstFlowReturn (*seek) (MpegTSBase * base, GstEvent * event); GstFlowReturn (*seek) (MpegTSBase * base, GstEvent * event);
/* flush all streams */ /* flush all streams
void (*flush) (MpegTSBase * base); * The hard inicator is used to flush completelly on FLUSH_STOP events
* or partially in pull mode seeks of tsdemux */
void (*flush) (MpegTSBase * base, gboolean hard);
/* Notifies subclasses input buffer has been handled */ /* Notifies subclasses input buffer has been handled */
GstFlowReturn (*input_done) (MpegTSBase *base, GstBuffer *buffer); GstFlowReturn (*input_done) (MpegTSBase *base, GstBuffer *buffer);

View file

@ -2480,7 +2480,7 @@ mpegts_packetizer_clear (MpegTSPacketizer2 * packetizer)
} }
void void
mpegts_packetizer_flush (MpegTSPacketizer2 * packetizer) mpegts_packetizer_flush (MpegTSPacketizer2 * packetizer, gboolean hard)
{ {
GST_DEBUG ("Flushing"); GST_DEBUG ("Flushing");
@ -2501,7 +2501,10 @@ mpegts_packetizer_flush (MpegTSPacketizer2 * packetizer)
packetizer->priv->offset = 0; packetizer->priv->offset = 0;
packetizer->priv->mapped_size = 0; packetizer->priv->mapped_size = 0;
packetizer->priv->last_in_time = GST_CLOCK_TIME_NONE; packetizer->priv->last_in_time = GST_CLOCK_TIME_NONE;
flush_observations (packetizer); if (hard) {
/* For pull mode seeks in tsdemux the observation must be preserved */
flush_observations (packetizer);
}
} }
void void

View file

@ -167,7 +167,7 @@ G_GNUC_INTERNAL GType mpegts_packetizer_get_type(void);
G_GNUC_INTERNAL MpegTSPacketizer2 *mpegts_packetizer_new (void); G_GNUC_INTERNAL MpegTSPacketizer2 *mpegts_packetizer_new (void);
G_GNUC_INTERNAL void mpegts_packetizer_clear (MpegTSPacketizer2 *packetizer); G_GNUC_INTERNAL void mpegts_packetizer_clear (MpegTSPacketizer2 *packetizer);
G_GNUC_INTERNAL void mpegts_packetizer_flush (MpegTSPacketizer2 *packetizer); G_GNUC_INTERNAL void mpegts_packetizer_flush (MpegTSPacketizer2 *packetizer, gboolean hard);
G_GNUC_INTERNAL void mpegts_packetizer_push (MpegTSPacketizer2 *packetizer, GstBuffer *buffer); G_GNUC_INTERNAL void mpegts_packetizer_push (MpegTSPacketizer2 *packetizer, GstBuffer *buffer);
G_GNUC_INTERNAL gboolean mpegts_packetizer_has_packets (MpegTSPacketizer2 *packetizer); G_GNUC_INTERNAL gboolean mpegts_packetizer_has_packets (MpegTSPacketizer2 *packetizer);
G_GNUC_INTERNAL MpegTSPacketizerPacketReturn mpegts_packetizer_next_packet (MpegTSPacketizer2 *packetizer, G_GNUC_INTERNAL MpegTSPacketizerPacketReturn mpegts_packetizer_next_packet (MpegTSPacketizer2 *packetizer,

View file

@ -228,7 +228,7 @@ static void gst_ts_demux_reset (MpegTSBase * base);
static GstFlowReturn static GstFlowReturn
gst_ts_demux_push (MpegTSBase * base, MpegTSPacketizerPacket * packet, gst_ts_demux_push (MpegTSBase * base, MpegTSPacketizerPacket * packet,
MpegTSPacketizerSection * section); MpegTSPacketizerSection * section);
static void gst_ts_demux_flush (MpegTSBase * base); static void gst_ts_demux_flush (MpegTSBase * base, gboolean hard);
static void static void
gst_ts_demux_stream_added (MpegTSBase * base, MpegTSBaseStream * stream, gst_ts_demux_stream_added (MpegTSBase * base, MpegTSBaseStream * stream,
MpegTSBaseProgram * program); MpegTSBaseProgram * program);
@ -1579,7 +1579,7 @@ gst_ts_demux_handle_packet (GstTSDemux * demux, TSDemuxStream * stream,
} }
static void static void
gst_ts_demux_flush (MpegTSBase * base) gst_ts_demux_flush (MpegTSBase * base, gboolean hard)
{ {
GstTSDemux *demux = GST_TS_DEMUX_CAST (base); GstTSDemux *demux = GST_TS_DEMUX_CAST (base);
@ -1590,7 +1590,10 @@ gst_ts_demux_flush (MpegTSBase * base)
demux->segment_event = NULL; demux->segment_event = NULL;
} }
demux->calculate_update_segment = FALSE; demux->calculate_update_segment = FALSE;
gst_segment_init (&demux->segment, GST_FORMAT_UNDEFINED); if (hard) {
/* For pull mode seeks the current segment needs to be preserved */
gst_segment_init (&demux->segment, GST_FORMAT_UNDEFINED);
}
} }
static GstFlowReturn static GstFlowReturn