From: Debarshi Ray Date: Sun, 5 Jun 2011 04:24:42 +0000 (+0530) Subject: matroska: refactor code common to matroskademux and matroskaparse X-Git-Tag: 1.19.3~509^2~7136^2~495 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=493e197588909706edf671738200b1ba53bea0eb;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}_parse_metadata_id_tag https://bugzilla.gnome.org/show_bug.cgi?id=650877 --- diff --git a/gst/matroska/matroska-demux.c b/gst/matroska/matroska-demux.c index 6e9683c..d294ecc 100644 --- a/gst/matroska/matroska-demux.c +++ b/gst/matroska/matroska-demux.c @@ -2388,45 +2388,6 @@ gst_matroska_demux_parse_info (GstMatroskaDemux * demux, GstEbmlRead * ebml) } static GstFlowReturn -gst_matroska_demux_parse_metadata_id_tag (GstMatroskaDemux * demux, - GstEbmlRead * ebml, GstTagList ** p_taglist) -{ - guint32 id; - GstFlowReturn ret; - - DEBUG_ELEMENT_START (demux, ebml, "Tag"); - - if ((ret = gst_ebml_read_master (ebml, &id)) != GST_FLOW_OK) { - DEBUG_ELEMENT_STOP (demux, ebml, "Tag", ret); - return ret; - } - - while (ret == GST_FLOW_OK && gst_ebml_read_has_remaining (ebml, 1, TRUE)) { - /* read all sub-entries */ - - if ((ret = gst_ebml_peek_id (ebml, &id)) != GST_FLOW_OK) - break; - - switch (id) { - case GST_MATROSKA_ID_SIMPLETAG: - ret = - gst_matroska_read_common_parse_metadata_id_simple_tag - (&demux->common, ebml, p_taglist); - break; - - default: - ret = gst_matroska_read_common_parse_skip (&demux->common, ebml, - "Tag", id); - break; - } - } - - DEBUG_ELEMENT_STOP (demux, ebml, "Tag", ret); - - return ret; -} - -static GstFlowReturn gst_matroska_demux_parse_metadata (GstMatroskaDemux * demux, GstEbmlRead * ebml) { GstTagList *taglist; @@ -2468,7 +2429,8 @@ gst_matroska_demux_parse_metadata (GstMatroskaDemux * demux, GstEbmlRead * ebml) switch (id) { case GST_MATROSKA_ID_TAG: - ret = gst_matroska_demux_parse_metadata_id_tag (demux, ebml, &taglist); + ret = gst_matroska_read_common_parse_metadata_id_tag (&demux->common, + ebml, &taglist); break; default: diff --git a/gst/matroska/matroska-parse.c b/gst/matroska/matroska-parse.c index 8da2d22..43c87ca 100644 --- a/gst/matroska/matroska-parse.c +++ b/gst/matroska/matroska-parse.c @@ -1690,45 +1690,6 @@ gst_matroska_parse_parse_info (GstMatroskaParse * parse, GstEbmlRead * ebml) } static GstFlowReturn -gst_matroska_parse_parse_metadata_id_tag (GstMatroskaParse * parse, - GstEbmlRead * ebml, GstTagList ** p_taglist) -{ - guint32 id; - GstFlowReturn ret; - - DEBUG_ELEMENT_START (parse, ebml, "Tag"); - - if ((ret = gst_ebml_read_master (ebml, &id)) != GST_FLOW_OK) { - DEBUG_ELEMENT_STOP (parse, ebml, "Tag", ret); - return ret; - } - - while (ret == GST_FLOW_OK && gst_ebml_read_has_remaining (ebml, 1, TRUE)) { - /* read all sub-entries */ - - if ((ret = gst_ebml_peek_id (ebml, &id)) != GST_FLOW_OK) - break; - - switch (id) { - case GST_MATROSKA_ID_SIMPLETAG: - ret = - gst_matroska_read_common_parse_metadata_id_simple_tag - (&parse->common, ebml, p_taglist); - break; - - default: - ret = gst_matroska_read_common_parse_skip (&parse->common, ebml, - "Tag", id); - break; - } - } - - DEBUG_ELEMENT_STOP (parse, ebml, "Tag", ret); - - return ret; -} - -static GstFlowReturn gst_matroska_parse_parse_metadata (GstMatroskaParse * parse, GstEbmlRead * ebml) { GstTagList *taglist; @@ -1770,7 +1731,8 @@ gst_matroska_parse_parse_metadata (GstMatroskaParse * parse, GstEbmlRead * ebml) switch (id) { case GST_MATROSKA_ID_TAG: - ret = gst_matroska_parse_parse_metadata_id_tag (parse, ebml, &taglist); + ret = gst_matroska_read_common_parse_metadata_id_tag (&parse->common, + ebml, &taglist); break; default: diff --git a/gst/matroska/matroska-read-common.c b/gst/matroska/matroska-read-common.c index 73c7f43..e58f981 100644 --- a/gst/matroska/matroska-read-common.c +++ b/gst/matroska/matroska-read-common.c @@ -953,7 +953,7 @@ gst_matroska_read_common_parse_index (GstMatroskaReadCommon * common, return ret; } -GstFlowReturn +static GstFlowReturn gst_matroska_read_common_parse_metadata_id_simple_tag (GstMatroskaReadCommon * common, GstEbmlRead * ebml, GstTagList ** p_taglist) { @@ -1076,6 +1076,43 @@ gst_matroska_read_common_parse_metadata_id_simple_tag (GstMatroskaReadCommon * return ret; } +GstFlowReturn +gst_matroska_read_common_parse_metadata_id_tag (GstMatroskaReadCommon * common, + GstEbmlRead * ebml, GstTagList ** p_taglist) +{ + guint32 id; + GstFlowReturn ret; + + DEBUG_ELEMENT_START (common, ebml, "Tag"); + + if ((ret = gst_ebml_read_master (ebml, &id)) != GST_FLOW_OK) { + DEBUG_ELEMENT_STOP (common, ebml, "Tag", ret); + return ret; + } + + while (ret == GST_FLOW_OK && gst_ebml_read_has_remaining (ebml, 1, TRUE)) { + /* read all sub-entries */ + + if ((ret = gst_ebml_peek_id (ebml, &id)) != GST_FLOW_OK) + break; + + switch (id) { + case GST_MATROSKA_ID_SIMPLETAG: + ret = gst_matroska_read_common_parse_metadata_id_simple_tag (common, + ebml, p_taglist); + break; + + default: + ret = gst_matroska_read_common_parse_skip (common, ebml, "Tag", id); + break; + } + } + + DEBUG_ELEMENT_STOP (common, ebml, "Tag", ret); + + return ret; +} + static const guint8 * gst_matroska_read_common_peek_adapter (GstMatroskaReadCommon * common, guint peek) diff --git a/gst/matroska/matroska-read-common.h b/gst/matroska/matroska-read-common.h index 2927d96..7feb6b0 100644 --- a/gst/matroska/matroska-read-common.h +++ b/gst/matroska/matroska-read-common.h @@ -93,7 +93,7 @@ GstFlowReturn gst_matroska_read_common_parse_index (GstMatroskaReadCommon * common, GstEbmlRead * ebml); GstFlowReturn gst_matroska_read_common_parse_header (GstMatroskaReadCommon * common, GstEbmlRead * ebml); -GstFlowReturn gst_matroska_read_common_parse_metadata_id_simple_tag ( +GstFlowReturn gst_matroska_read_common_parse_metadata_id_tag ( GstMatroskaReadCommon * common, GstEbmlRead * ebml, GstTagList ** p_taglist); GstFlowReturn gst_matroska_read_common_parse_skip (GstMatroskaReadCommon *