matroska: refactor code common to matroskademux and matroskaparse
authorDebarshi Ray <rishi@gnu.org>
Fri, 27 May 2011 17:45:23 +0000 (23:15 +0530)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Mon, 30 May 2011 05:56:44 +0000 (07:56 +0200)
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

gst/matroska/matroska-demux.c
gst/matroska/matroska-parse.c
gst/matroska/matroska-read-common.c
gst/matroska/matroska-read-common.h

index 97ae2bb..70b9a54 100644 (file)
@@ -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;
index 96ded4d..b45ebea 100644 (file)
@@ -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;
index cacc180..cddb6ee 100644 (file)
@@ -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;
+}
index 92396c8..94f21c1 100644 (file)
@@ -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