matroska: refactor code common to matroskademux and matroskaparse
authorDebarshi Ray <rishi@gnu.org>
Mon, 23 May 2011 15:06:44 +0000 (18:06 +0300)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Wed, 25 May 2011 18:02:40 +0000 (20:02 +0200)
Move the following function to matroska-read-common.[ch] from
matroska-demux.c and matroska-parse.c:
    - gst_matroska_{demux,parse}_peek_pull

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 522af9a..12f7193 100644 (file)
@@ -461,23 +461,14 @@ gst_matroska_demux_reset (GstElement * element)
   }
 }
 
-static const guint8 *
-gst_matroska_demux_peek_pull (GstMatroskaDemux * demux, guint peek)
-{
-  guint8 *data = NULL;
-
-  gst_matroska_read_common_peek_bytes (&demux->common, demux->common.offset,
-      peek, NULL, &data);
-  return data;
-}
-
 static GstFlowReturn
 gst_matroska_demux_peek_id_length_pull (GstMatroskaDemux * demux, guint32 * _id,
     guint64 * _length, guint * _needed)
 {
   return gst_ebml_peek_id_length (_id, _length, _needed,
-      (GstPeekData) gst_matroska_demux_peek_pull, (gpointer) demux,
-      GST_ELEMENT_CAST (demux), demux->common.offset);
+      (GstPeekData) gst_matroska_read_common_peek_pull,
+      (gpointer) (&demux->common), GST_ELEMENT_CAST (demux),
+      demux->common.offset);
 }
 
 static gint64
index 6f30055..2b0fb02 100644 (file)
@@ -384,23 +384,14 @@ gst_matroska_parse_reset (GstElement * element)
   }
 }
 
-static const guint8 *
-gst_matroska_parse_peek_pull (GstMatroskaParse * parse, guint peek)
-{
-  guint8 *data = NULL;
-
-  gst_matroska_read_common_peek_bytes (&parse->common, parse->common.offset,
-      peek, NULL, &data);
-  return data;
-}
-
 static GstFlowReturn
 gst_matroska_parse_peek_id_length_pull (GstMatroskaParse * parse, guint32 * _id,
     guint64 * _length, guint * _needed)
 {
   return gst_ebml_peek_id_length (_id, _length, _needed,
-      (GstPeekData) gst_matroska_parse_peek_pull, (gpointer) parse,
-      GST_ELEMENT_CAST (parse), parse->common.offset);
+      (GstPeekData) gst_matroska_read_common_peek_pull,
+      (gpointer) (&parse->common), GST_ELEMENT_CAST (parse),
+      parse->common.offset);
 }
 
 static gint64
index efd0ce0..f1fb262 100644 (file)
@@ -709,6 +709,16 @@ gst_matroska_read_common_peek_bytes (GstMatroskaReadCommon * common, guint64
   return GST_FLOW_OK;
 }
 
+const guint8 *
+gst_matroska_read_common_peek_pull (GstMatroskaReadCommon * common, guint peek)
+{
+  guint8 *data = NULL;
+
+  gst_matroska_read_common_peek_bytes (common, common->offset, peek, NULL,
+      &data);
+  return data;
+}
+
 GstFlowReturn
 gst_matroska_read_common_read_track_encoding (GstMatroskaReadCommon * common,
     GstEbmlRead * ebml, GstMatroskaTrackContext * context)
index c2cf024..bd715f0 100644 (file)
@@ -80,6 +80,8 @@ GstFlowReturn gst_matroska_read_common_parse_skip (GstMatroskaReadCommon *
     common, GstEbmlRead * ebml, const gchar * parent_name, guint id);
 GstFlowReturn gst_matroska_read_common_peek_bytes (GstMatroskaReadCommon *
     common, guint64 offset, guint size, GstBuffer ** p_buf, guint8 ** bytes);
+const guint8 * gst_matroska_read_common_peek_pull (GstMatroskaReadCommon *
+    common, guint peek);
 gint gst_matroska_read_common_stream_from_num (GstMatroskaReadCommon * common,
     guint track_num);
 GstFlowReturn gst_matroska_read_common_read_track_encoding (