mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-03 16:09:39 +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
|
static gboolean
|
||||||
gst_matroska_decode_data (GArray * encodings, guint8 ** data_out,
|
gst_matroska_decode_data (GArray * encodings, guint8 ** data_out,
|
||||||
guint * size_out, GstMatroskaTrackEncodingScope scope, gboolean free)
|
guint * size_out, GstMatroskaTrackEncodingScope scope, gboolean free)
|
||||||
|
@ -4570,7 +4557,7 @@ gst_matroska_demux_parse_contents_seekentry (GstMatroskaDemux * demux,
|
||||||
guint needed;
|
guint needed;
|
||||||
|
|
||||||
/* remember */
|
/* remember */
|
||||||
length = gst_matroska_demux_get_length (demux);
|
length = gst_matroska_read_common_get_length (&demux->common);
|
||||||
before_pos = demux->common.offset;
|
before_pos = demux->common.offset;
|
||||||
|
|
||||||
if (length == (guint64) - 1) {
|
if (length == (guint64) - 1) {
|
||||||
|
@ -5238,7 +5225,7 @@ gst_matroska_demux_loop (GstPad * pad)
|
||||||
|
|
||||||
next:
|
next:
|
||||||
if (G_UNLIKELY (demux->common.offset ==
|
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");
|
GST_LOG_OBJECT (demux, "Reached end of stream");
|
||||||
ret = GST_FLOW_UNEXPECTED;
|
ret = GST_FLOW_UNEXPECTED;
|
||||||
goto eos;
|
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
|
static gboolean
|
||||||
gst_matroska_decode_data (GArray * encodings, guint8 ** data_out,
|
gst_matroska_decode_data (GArray * encodings, guint8 ** data_out,
|
||||||
guint * size_out, GstMatroskaTrackEncodingScope scope, gboolean free)
|
guint * size_out, GstMatroskaTrackEncodingScope scope, gboolean free)
|
||||||
|
@ -3193,7 +3180,7 @@ gst_matroska_parse_parse_contents_seekentry (GstMatroskaParse * parse,
|
||||||
guint64 length;
|
guint64 length;
|
||||||
|
|
||||||
/* remember */
|
/* remember */
|
||||||
length = gst_matroska_parse_get_length (parse);
|
length = gst_matroska_read_common_get_length (&parse->common);
|
||||||
|
|
||||||
if (length == (guint64) - 1) {
|
if (length == (guint64) - 1) {
|
||||||
GST_DEBUG_OBJECT (parse, "no upstream length, skipping SeakHead entry");
|
GST_DEBUG_OBJECT (parse, "no upstream length, skipping SeakHead entry");
|
||||||
|
@ -3860,7 +3847,8 @@ gst_matroska_parse_loop (GstPad * pad)
|
||||||
}
|
}
|
||||||
|
|
||||||
next:
|
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");
|
GST_LOG_OBJECT (parse, "Reached end of stream");
|
||||||
ret = GST_FLOW_UNEXPECTED;
|
ret = GST_FLOW_UNEXPECTED;
|
||||||
goto eos;
|
goto eos;
|
||||||
|
|
|
@ -308,6 +308,19 @@ gst_matroska_read_common_encoding_order_unique (GArray * encodings, guint64
|
||||||
return TRUE;
|
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 */
|
/* skip unknown or alike element */
|
||||||
GstFlowReturn
|
GstFlowReturn
|
||||||
gst_matroska_read_common_parse_skip (GstMatroskaReadCommon * common,
|
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,
|
gboolean gst_matroska_decompress_data (GstMatroskaTrackEncoding * enc,
|
||||||
guint8 ** data_out, guint * size_out,
|
guint8 ** data_out, guint * size_out,
|
||||||
GstMatroskaTrackCompressionAlgorithm algo);
|
GstMatroskaTrackCompressionAlgorithm algo);
|
||||||
|
gint64 gst_matroska_read_common_get_length (GstMatroskaReadCommon * common);
|
||||||
GstFlowReturn gst_matroska_read_common_parse_index (GstMatroskaReadCommon *
|
GstFlowReturn gst_matroska_read_common_parse_index (GstMatroskaReadCommon *
|
||||||
common, GstEbmlRead * ebml);
|
common, GstEbmlRead * ebml);
|
||||||
GstFlowReturn gst_matroska_read_common_parse_skip (GstMatroskaReadCommon *
|
GstFlowReturn gst_matroska_read_common_parse_skip (GstMatroskaReadCommon *
|
||||||
|
|
Loading…
Reference in a new issue