}
static inline void
-mpegts_base_flush (MpegTSBase * base)
+mpegts_base_flush (MpegTSBase * base, gboolean hard)
{
MpegTSBaseClass *klass = GST_MPEGTS_BASE_GET_CLASS (base);
if (G_UNLIKELY (klass->flush == NULL))
GST_WARNING_OBJECT (base, "Class doesn't have a 'flush' implementation !");
else
- klass->flush (base);
+ klass->flush (base, hard);
}
static gboolean
break;
case GST_EVENT_FLUSH_STOP:
res = GST_MPEGTS_BASE_GET_CLASS (base)->push_event (base, event);
- mpegts_packetizer_flush (base->packetizer);
- mpegts_base_flush (base);
+ mpegts_packetizer_flush (base->packetizer, TRUE);
+ mpegts_base_flush (base, TRUE);
gst_segment_init (&base->segment, GST_FORMAT_UNDEFINED);
base->seen_pat = FALSE;
break;
/* send a FLUSH_STOP for the sinkpad, since we need data for seeking */
GST_DEBUG_OBJECT (base, "sending flush stop");
gst_pad_push_event (base->sinkpad, gst_event_new_flush_stop (TRUE));
- /* And actually flush our pending data */
- mpegts_base_flush (base);
- mpegts_packetizer_flush (base->packetizer);
+ /* And actually flush our pending data but allow to preserve some info
+ * to perform the seek */
+ mpegts_base_flush (base, FALSE);
+ mpegts_packetizer_flush (base->packetizer, FALSE);
}
if (flags & (GST_SEEK_FLAG_SEGMENT | GST_SEEK_FLAG_SKIP)) {
/* seek is called to wait for seeking */
GstFlowReturn (*seek) (MpegTSBase * base, GstEvent * event);
- /* flush all streams */
- void (*flush) (MpegTSBase * base);
+ /* flush all streams
+ * 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 */
GstFlowReturn (*input_done) (MpegTSBase *base, GstBuffer *buffer);
}
void
-mpegts_packetizer_flush (MpegTSPacketizer2 * packetizer)
+mpegts_packetizer_flush (MpegTSPacketizer2 * packetizer, gboolean hard)
{
GST_DEBUG ("Flushing");
packetizer->priv->offset = 0;
packetizer->priv->mapped_size = 0;
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
G_GNUC_INTERNAL MpegTSPacketizer2 *mpegts_packetizer_new (void);
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 gboolean mpegts_packetizer_has_packets (MpegTSPacketizer2 *packetizer);
G_GNUC_INTERNAL MpegTSPacketizerPacketReturn mpegts_packetizer_next_packet (MpegTSPacketizer2 *packetizer,
static GstFlowReturn
gst_ts_demux_push (MpegTSBase * base, MpegTSPacketizerPacket * packet,
MpegTSPacketizerSection * section);
-static void gst_ts_demux_flush (MpegTSBase * base);
+static void gst_ts_demux_flush (MpegTSBase * base, gboolean hard);
static void
gst_ts_demux_stream_added (MpegTSBase * base, MpegTSBaseStream * stream,
MpegTSBaseProgram * program);
}
static void
-gst_ts_demux_flush (MpegTSBase * base)
+gst_ts_demux_flush (MpegTSBase * base, gboolean hard)
{
GstTSDemux *demux = GST_TS_DEMUX_CAST (base);
demux->segment_event = NULL;
}
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