Commit 80b3ba7b authored by Edward Hervey's avatar Edward Hervey 🤘 Committed by GStreamer Marge Bot
Browse files

tsdemux: Clear all streams when rewinding

This avoids sending out partial invalid data downstream which could cause
decoders (ex: `dvdlpmdec`) to error out.

Part-of: <!2301>
parent 74f81a1a
Pipeline #332099 waiting for manual action with stages
in 1 minute and 7 seconds
...@@ -3122,16 +3122,30 @@ gst_ts_demux_push_pending_data (GstTSDemux * demux, TSDemuxStream * stream, ...@@ -3122,16 +3122,30 @@ gst_ts_demux_push_pending_data (GstTSDemux * demux, TSDemuxStream * stream,
stream->seeked_dts = stream->dts; stream->seeked_dts = stream->dts;
stream->needs_keyframe = FALSE; stream->needs_keyframe = FALSE;
} else { } else {
GList *tmp;
GST_DEBUG_OBJECT (stream->pad, "Rewinding after keyframe seek failure");
base->seek_offset = demux->last_seek_offset - 200 * base->packetsize; base->seek_offset = demux->last_seek_offset - 200 * base->packetsize;
if (demux->last_seek_offset < 200 * base->packetsize) if (demux->last_seek_offset < 200 * base->packetsize)
base->seek_offset = 0; base->seek_offset = 0;
demux->last_seek_offset = base->seek_offset; demux->last_seek_offset = base->seek_offset;
mpegts_packetizer_flush (base->packetizer, FALSE); mpegts_packetizer_flush (base->packetizer, FALSE);
/* Reset all streams accordingly */
for (tmp = demux->program->stream_list; tmp; tmp = tmp->next) {
TSDemuxStream *cand = tmp->data;
GST_DEBUG_OBJECT (cand->pad, "Clearing stream");
cand->continuity_counter = CONTINUITY_UNSET;
cand->state = PENDING_PACKET_EMPTY;
if (cand->data)
g_free (cand->data);
cand->data = NULL;
cand->allocated_size = 0;
cand->current_size = 0;
}
base->mode = BASE_MODE_SEEKING; base->mode = BASE_MODE_SEEKING;
stream->continuity_counter = CONTINUITY_UNSET;
res = GST_FLOW_REWINDING; res = GST_FLOW_REWINDING;
g_free (stream->data);
goto beach; goto beach;
} }
} else { } else {
...@@ -3337,8 +3351,11 @@ gst_ts_demux_handle_packet (GstTSDemux * demux, TSDemuxStream * stream, ...@@ -3337,8 +3351,11 @@ gst_ts_demux_handle_packet (GstTSDemux * demux, TSDemuxStream * stream,
FLAGS_HAS_PAYLOAD (packet->scram_afc_cc)) { FLAGS_HAS_PAYLOAD (packet->scram_afc_cc)) {
/* Flush previous data */ /* Flush previous data */
res = gst_ts_demux_push_pending_data (demux, stream, NULL); res = gst_ts_demux_push_pending_data (demux, stream, NULL);
/* Tell the data collecting to expect this header */ if (res != GST_FLOW_REWINDING) {
stream->state = PENDING_PACKET_HEADER; /* Tell the data collecting to expect this header. We don't do this when
* rewinding since the states will have been resetted accordingly */
stream->state = PENDING_PACKET_HEADER;
}
} }
if (packet->payload && (res == GST_FLOW_OK || res == GST_FLOW_NOT_LINKED) if (packet->payload && (res == GST_FLOW_OK || res == GST_FLOW_NOT_LINKED)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment