mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-05 02:02:26 +00:00
matroskademux: additional parse recovery
In particular, upon parse failure in one cluster, we may forego remaining content and try resuming from next cluster onwards. Fixes #620790.
This commit is contained in:
parent
5999e8e716
commit
680eb51b68
2 changed files with 28 additions and 2 deletions
|
@ -424,6 +424,7 @@ gst_matroska_demux_reset (GstElement * element)
|
||||||
demux->offset = 0;
|
demux->offset = 0;
|
||||||
demux->cluster_time = GST_CLOCK_TIME_NONE;
|
demux->cluster_time = GST_CLOCK_TIME_NONE;
|
||||||
demux->cluster_offset = 0;
|
demux->cluster_offset = 0;
|
||||||
|
demux->next_cluster_offset = 0;
|
||||||
demux->index_offset = 0;
|
demux->index_offset = 0;
|
||||||
demux->seekable = FALSE;
|
demux->seekable = FALSE;
|
||||||
demux->need_newsegment = FALSE;
|
demux->need_newsegment = FALSE;
|
||||||
|
@ -5413,6 +5414,23 @@ gst_matroska_demux_check_read_size (GstMatroskaDemux * demux, guint64 bytes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* returns TRUE if we truely are in error state, and should give up */
|
||||||
|
static inline gboolean
|
||||||
|
gst_matroska_demux_check_parse_error (GstMatroskaDemux * demux)
|
||||||
|
{
|
||||||
|
if (!demux->streaming && demux->next_cluster_offset > 0) {
|
||||||
|
/* just repositioning to where next cluster should be and try from there */
|
||||||
|
GST_WARNING_OBJECT (demux, "parse error, trying next cluster expected at %"
|
||||||
|
G_GUINT64_FORMAT, demux->next_cluster_offset);
|
||||||
|
demux->offset = demux->next_cluster_offset;
|
||||||
|
demux->next_cluster_offset = 0;
|
||||||
|
return FALSE;
|
||||||
|
} else {
|
||||||
|
/* nowhere to try next, give up */
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* initializes @ebml with @bytes from input stream at current offset.
|
/* initializes @ebml with @bytes from input stream at current offset.
|
||||||
* Returns UNEXPECTED if insufficient available,
|
* Returns UNEXPECTED if insufficient available,
|
||||||
* ERROR if too much was attempted to read. */
|
* ERROR if too much was attempted to read. */
|
||||||
|
@ -5662,6 +5680,9 @@ gst_matroska_demux_parse_id (GstMatroskaDemux * demux, guint32 id,
|
||||||
demux->seek_block = 0;
|
demux->seek_block = 0;
|
||||||
}
|
}
|
||||||
demux->seek_first = FALSE;
|
demux->seek_first = FALSE;
|
||||||
|
/* record next cluster for recovery */
|
||||||
|
if (read != G_MAXUINT64)
|
||||||
|
demux->next_cluster_offset = demux->cluster_offset + read;
|
||||||
/* eat cluster prefix */
|
/* eat cluster prefix */
|
||||||
gst_matroska_demux_flush (demux, needed);
|
gst_matroska_demux_flush (demux, needed);
|
||||||
break;
|
break;
|
||||||
|
@ -5845,8 +5866,12 @@ gst_matroska_demux_loop (GstPad * pad)
|
||||||
ret = gst_matroska_demux_peek_id_length_pull (demux, &id, &length, &needed);
|
ret = gst_matroska_demux_peek_id_length_pull (demux, &id, &length, &needed);
|
||||||
if (ret == GST_FLOW_UNEXPECTED)
|
if (ret == GST_FLOW_UNEXPECTED)
|
||||||
goto eos;
|
goto eos;
|
||||||
if (ret != GST_FLOW_OK)
|
if (ret != GST_FLOW_OK) {
|
||||||
|
if (gst_matroska_demux_check_parse_error (demux))
|
||||||
goto pause;
|
goto pause;
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
GST_LOG_OBJECT (demux, "Offset %" G_GUINT64_FORMAT ", Element id 0x%x, "
|
GST_LOG_OBJECT (demux, "Offset %" G_GUINT64_FORMAT ", Element id 0x%x, "
|
||||||
"size %" G_GUINT64_FORMAT ", needed %d", demux->offset, id,
|
"size %" G_GUINT64_FORMAT ", needed %d", demux->offset, id,
|
||||||
|
|
|
@ -114,6 +114,7 @@ typedef struct _GstMatroskaDemux {
|
||||||
GstClockTime cluster_time;
|
GstClockTime cluster_time;
|
||||||
guint64 cluster_offset;
|
guint64 cluster_offset;
|
||||||
guint64 first_cluster_offset;
|
guint64 first_cluster_offset;
|
||||||
|
guint64 next_cluster_offset;
|
||||||
|
|
||||||
/* push based mode usual suspects */
|
/* push based mode usual suspects */
|
||||||
GstAdapter *adapter;
|
GstAdapter *adapter;
|
||||||
|
|
Loading…
Reference in a new issue