mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-04 05:22:30 +00:00
matroska: refactor code common to matroskademux and matroskaparse
Move the following function to matroska-read-common.[ch] from matroska-demux.c and matroska-parse.c: - gst_matroska_{demux,parse}_get_length https://bugzilla.gnome.org/show_bug.cgi?id=650877
This commit is contained in:
parent
0a67d131b9
commit
b437744b70
4 changed files with 19 additions and 30 deletions
|
@ -461,19 +461,6 @@ gst_matroska_demux_reset (GstElement * element)
|
|||
}
|
||||
}
|
||||
|
||||
static gint64
|
||||
gst_matroska_demux_get_length (GstMatroskaDemux * demux)
|
||||
{
|
||||
GstFormat fmt = GST_FORMAT_BYTES;
|
||||
gint64 end = -1;
|
||||
|
||||
if (!gst_pad_query_peer_duration (demux->common.sinkpad, &fmt, &end) ||
|
||||
fmt != GST_FORMAT_BYTES || end < 0)
|
||||
GST_DEBUG_OBJECT (demux, "no upstream length");
|
||||
|
||||
return end;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_matroska_decode_data (GArray * encodings, guint8 ** data_out,
|
||||
guint * size_out, GstMatroskaTrackEncodingScope scope, gboolean free)
|
||||
|
@ -4570,7 +4557,7 @@ gst_matroska_demux_parse_contents_seekentry (GstMatroskaDemux * demux,
|
|||
guint needed;
|
||||
|
||||
/* remember */
|
||||
length = gst_matroska_demux_get_length (demux);
|
||||
length = gst_matroska_read_common_get_length (&demux->common);
|
||||
before_pos = demux->common.offset;
|
||||
|
||||
if (length == (guint64) - 1) {
|
||||
|
@ -5238,7 +5225,7 @@ gst_matroska_demux_loop (GstPad * pad)
|
|||
|
||||
next:
|
||||
if (G_UNLIKELY (demux->common.offset ==
|
||||
gst_matroska_demux_get_length (demux))) {
|
||||
gst_matroska_read_common_get_length (&demux->common))) {
|
||||
GST_LOG_OBJECT (demux, "Reached end of stream");
|
||||
ret = GST_FLOW_UNEXPECTED;
|
||||
goto eos;
|
||||
|
|
|
@ -384,19 +384,6 @@ gst_matroska_parse_reset (GstElement * element)
|
|||
}
|
||||
}
|
||||
|
||||
static gint64
|
||||
gst_matroska_parse_get_length (GstMatroskaParse * parse)
|
||||
{
|
||||
GstFormat fmt = GST_FORMAT_BYTES;
|
||||
gint64 end = -1;
|
||||
|
||||
if (!gst_pad_query_peer_duration (parse->common.sinkpad, &fmt, &end) ||
|
||||
fmt != GST_FORMAT_BYTES || end < 0)
|
||||
GST_DEBUG_OBJECT (parse, "no upstream length");
|
||||
|
||||
return end;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_matroska_decode_data (GArray * encodings, guint8 ** data_out,
|
||||
guint * size_out, GstMatroskaTrackEncodingScope scope, gboolean free)
|
||||
|
@ -3193,7 +3180,7 @@ gst_matroska_parse_parse_contents_seekentry (GstMatroskaParse * parse,
|
|||
guint64 length;
|
||||
|
||||
/* remember */
|
||||
length = gst_matroska_parse_get_length (parse);
|
||||
length = gst_matroska_read_common_get_length (&parse->common);
|
||||
|
||||
if (length == (guint64) - 1) {
|
||||
GST_DEBUG_OBJECT (parse, "no upstream length, skipping SeakHead entry");
|
||||
|
@ -3860,7 +3847,8 @@ gst_matroska_parse_loop (GstPad * pad)
|
|||
}
|
||||
|
||||
next:
|
||||
if (G_UNLIKELY (parse->offset == gst_matroska_parse_get_length (parse))) {
|
||||
if (G_UNLIKELY (parse->offset ==
|
||||
gst_matroska_read_common_get_length (&parse->common))) {
|
||||
GST_LOG_OBJECT (parse, "Reached end of stream");
|
||||
ret = GST_FLOW_UNEXPECTED;
|
||||
goto eos;
|
||||
|
|
|
@ -308,6 +308,19 @@ gst_matroska_read_common_encoding_order_unique (GArray * encodings, guint64
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
gint64
|
||||
gst_matroska_read_common_get_length (GstMatroskaReadCommon * common)
|
||||
{
|
||||
GstFormat fmt = GST_FORMAT_BYTES;
|
||||
gint64 end = -1;
|
||||
|
||||
if (!gst_pad_query_peer_duration (common->sinkpad, &fmt, &end) ||
|
||||
fmt != GST_FORMAT_BYTES || end < 0)
|
||||
GST_DEBUG_OBJECT (common, "no upstream length");
|
||||
|
||||
return end;
|
||||
}
|
||||
|
||||
/* skip unknown or alike element */
|
||||
GstFlowReturn
|
||||
gst_matroska_read_common_parse_skip (GstMatroskaReadCommon * common,
|
||||
|
|
|
@ -78,6 +78,7 @@ GstFlowReturn gst_matroska_decode_content_encodings (GArray * encodings);
|
|||
gboolean gst_matroska_decompress_data (GstMatroskaTrackEncoding * enc,
|
||||
guint8 ** data_out, guint * size_out,
|
||||
GstMatroskaTrackCompressionAlgorithm algo);
|
||||
gint64 gst_matroska_read_common_get_length (GstMatroskaReadCommon * common);
|
||||
GstFlowReturn gst_matroska_read_common_parse_index (GstMatroskaReadCommon *
|
||||
common, GstEbmlRead * ebml);
|
||||
GstFlowReturn gst_matroska_read_common_parse_skip (GstMatroskaReadCommon *
|
||||
|
|
Loading…
Reference in a new issue