From b437744b70d338b7efa9bf663b4d90dc9460084d Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Fri, 27 May 2011 19:30:48 +0530 Subject: [PATCH] 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 --- gst/matroska/matroska-demux.c | 17 ++--------------- gst/matroska/matroska-parse.c | 18 +++--------------- gst/matroska/matroska-read-common.c | 13 +++++++++++++ gst/matroska/matroska-read-common.h | 1 + 4 files changed, 19 insertions(+), 30 deletions(-) diff --git a/gst/matroska/matroska-demux.c b/gst/matroska/matroska-demux.c index 05cdf63a71..6386cc5a7e 100644 --- a/gst/matroska/matroska-demux.c +++ b/gst/matroska/matroska-demux.c @@ -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; diff --git a/gst/matroska/matroska-parse.c b/gst/matroska/matroska-parse.c index 9b555503d9..f89e97ca21 100644 --- a/gst/matroska/matroska-parse.c +++ b/gst/matroska/matroska-parse.c @@ -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; diff --git a/gst/matroska/matroska-read-common.c b/gst/matroska/matroska-read-common.c index 178aa365ad..6b0f44b6c1 100644 --- a/gst/matroska/matroska-read-common.c +++ b/gst/matroska/matroska-read-common.c @@ -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, diff --git a/gst/matroska/matroska-read-common.h b/gst/matroska/matroska-read-common.h index cf5416fed8..5f7cb973c0 100644 --- a/gst/matroska/matroska-read-common.h +++ b/gst/matroska/matroska-read-common.h @@ -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 * -- 2.34.1