From: Debarshi Ray Date: Fri, 27 May 2011 17:45:23 +0000 (+0530) Subject: matroska: refactor code common to matroskademux and matroskaparse X-Git-Tag: 1.19.3~509^2~7136^2~511 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1a6e658444c23dcd1926c877d22a13291b86352c;p=platform%2Fupstream%2Fgstreamer.git 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}_tracknumber_unique https://bugzilla.gnome.org/show_bug.cgi?id=650877 --- diff --git a/gst/matroska/matroska-demux.c b/gst/matroska/matroska-demux.c index 97ae2bb..70b9a54 100644 --- a/gst/matroska/matroska-demux.c +++ b/gst/matroska/matroska-demux.c @@ -495,23 +495,6 @@ gst_matroska_decode_buffer (GstMatroskaTrackContext * context, GstBuffer * buf) } } -static gboolean -gst_matroska_demux_tracknumber_unique (GstMatroskaDemux * demux, guint64 num) -{ - gint i; - - g_assert (demux->common.src->len == demux->common.num_streams); - for (i = 0; i < demux->common.src->len; i++) { - GstMatroskaTrackContext *context = g_ptr_array_index (demux->common.src, - i); - - if (context->num == num) - return FALSE; - } - - return TRUE; -} - static GstFlowReturn gst_matroska_demux_add_stream (GstMatroskaDemux * demux, GstEbmlRead * ebml) { @@ -572,7 +555,8 @@ gst_matroska_demux_add_stream (GstMatroskaDemux * demux, GstEbmlRead * ebml) GST_ERROR_OBJECT (demux, "Invalid TrackNumber 0"); ret = GST_FLOW_ERROR; break; - } else if (!gst_matroska_demux_tracknumber_unique (demux, num)) { + } else if (!gst_matroska_read_common_tracknumber_unique (&demux->common, + num)) { GST_ERROR_OBJECT (demux, "TrackNumber %" G_GUINT64_FORMAT " is not unique", num); ret = GST_FLOW_ERROR; diff --git a/gst/matroska/matroska-parse.c b/gst/matroska/matroska-parse.c index 96ded4d..b45ebea 100644 --- a/gst/matroska/matroska-parse.c +++ b/gst/matroska/matroska-parse.c @@ -384,23 +384,6 @@ gst_matroska_parse_reset (GstElement * element) } } -static gboolean -gst_matroska_parse_tracknumber_unique (GstMatroskaParse * parse, guint64 num) -{ - gint i; - - g_assert (parse->common.src->len == parse->common.num_streams); - for (i = 0; i < parse->common.src->len; i++) { - GstMatroskaTrackContext *context = g_ptr_array_index (parse->common.src, - i); - - if (context->num == num) - return FALSE; - } - - return TRUE; -} - static GstFlowReturn gst_matroska_parse_add_stream (GstMatroskaParse * parse, GstEbmlRead * ebml) { @@ -454,7 +437,8 @@ gst_matroska_parse_add_stream (GstMatroskaParse * parse, GstEbmlRead * ebml) GST_ERROR_OBJECT (parse, "Invalid TrackNumber 0"); ret = GST_FLOW_ERROR; break; - } else if (!gst_matroska_parse_tracknumber_unique (parse, num)) { + } else if (!gst_matroska_read_common_tracknumber_unique (&parse->common, + num)) { GST_ERROR_OBJECT (parse, "TrackNumber %" G_GUINT64_FORMAT " is not unique", num); ret = GST_FLOW_ERROR; diff --git a/gst/matroska/matroska-read-common.c b/gst/matroska/matroska-read-common.c index cacc180..cddb6ee 100644 --- a/gst/matroska/matroska-read-common.c +++ b/gst/matroska/matroska-read-common.c @@ -1038,3 +1038,20 @@ gst_matroska_read_common_read_track_encodings (GstMatroskaReadCommon * common, return gst_matroska_decode_content_encodings (context->encodings); } + +gboolean +gst_matroska_read_common_tracknumber_unique (GstMatroskaReadCommon * common, + guint64 num) +{ + gint i; + + g_assert (common->src->len == common->num_streams); + for (i = 0; i < common->src->len; i++) { + GstMatroskaTrackContext *context = g_ptr_array_index (common->src, i); + + if (context->num == num) + return FALSE; + } + + return TRUE; +} diff --git a/gst/matroska/matroska-read-common.h b/gst/matroska/matroska-read-common.h index 92396c8..94f21c1 100644 --- a/gst/matroska/matroska-read-common.h +++ b/gst/matroska/matroska-read-common.h @@ -95,6 +95,8 @@ gint gst_matroska_read_common_stream_from_num (GstMatroskaReadCommon * common, GstFlowReturn gst_matroska_read_common_read_track_encodings ( GstMatroskaReadCommon * common, GstEbmlRead * ebml, GstMatroskaTrackContext * context); +gboolean gst_matroska_read_common_tracknumber_unique (GstMatroskaReadCommon * + common, guint64 num); G_END_DECLS