From 9175a903fb201cb74f996d7a2c28b1dc497cc720 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Mon, 6 Jun 2011 18:21:04 +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}_parse_chapters https://bugzilla.gnome.org/show_bug.cgi?id=650877 --- gst/matroska/matroska-demux.c | 34 +--------------------------------- gst/matroska/matroska-parse.c | 34 +--------------------------------- gst/matroska/matroska-read-common.c | 33 +++++++++++++++++++++++++++++++++ gst/matroska/matroska-read-common.h | 2 ++ 4 files changed, 37 insertions(+), 66 deletions(-) diff --git a/gst/matroska/matroska-demux.c b/gst/matroska/matroska-demux.c index 30767bf..a6fb32f 100644 --- a/gst/matroska/matroska-demux.c +++ b/gst/matroska/matroska-demux.c @@ -2257,38 +2257,6 @@ gst_matroska_demux_parse_tracks (GstMatroskaDemux * demux, GstEbmlRead * ebml) return ret; } -static GstFlowReturn -gst_matroska_demux_parse_chapters (GstMatroskaDemux * demux, GstEbmlRead * ebml) -{ - guint32 id; - GstFlowReturn ret = GST_FLOW_OK; - - GST_WARNING_OBJECT (demux, "Parsing of chapters not implemented yet"); - - /* TODO: implement parsing of chapters */ - - DEBUG_ELEMENT_START (demux, ebml, "Chapters"); - - if ((ret = gst_ebml_read_master (ebml, &id)) != GST_FLOW_OK) { - DEBUG_ELEMENT_STOP (demux, ebml, "Chapters", ret); - return ret; - } - - while (ret == GST_FLOW_OK && gst_ebml_read_has_remaining (ebml, 1, TRUE)) { - if ((ret = gst_ebml_peek_id (ebml, &id)) != GST_FLOW_OK) - break; - - switch (id) { - default: - ret = gst_ebml_read_skip (ebml); - break; - } - } - - DEBUG_ELEMENT_STOP (demux, ebml, "Chapters", ret); - return ret; -} - /* * Read signed/unsigned "EBML" numbers. * Return: number of bytes processed. @@ -4173,7 +4141,7 @@ gst_matroska_demux_parse_id (GstMatroskaDemux * demux, guint32 id, break; case GST_MATROSKA_ID_CHAPTERS: GST_READ_CHECK (gst_matroska_demux_take (demux, read, &ebml)); - ret = gst_matroska_demux_parse_chapters (demux, &ebml); + ret = gst_matroska_read_common_parse_chapters (&demux->common, &ebml); break; case GST_MATROSKA_ID_SEEKHEAD: GST_READ_CHECK (gst_matroska_demux_take (demux, read, &ebml)); diff --git a/gst/matroska/matroska-parse.c b/gst/matroska/matroska-parse.c index 20e1248..8f8da64 100644 --- a/gst/matroska/matroska-parse.c +++ b/gst/matroska/matroska-parse.c @@ -1557,38 +1557,6 @@ gst_matroska_parse_parse_tracks (GstMatroskaParse * parse, GstEbmlRead * ebml) return ret; } -static GstFlowReturn -gst_matroska_parse_parse_chapters (GstMatroskaParse * parse, GstEbmlRead * ebml) -{ - guint32 id; - GstFlowReturn ret = GST_FLOW_OK; - - GST_WARNING_OBJECT (parse, "Parsing of chapters not implemented yet"); - - /* TODO: implement parsing of chapters */ - - DEBUG_ELEMENT_START (parse, ebml, "Chapters"); - - if ((ret = gst_ebml_read_master (ebml, &id)) != GST_FLOW_OK) { - DEBUG_ELEMENT_STOP (parse, ebml, "Chapters", ret); - return ret; - } - - while (ret == GST_FLOW_OK && gst_ebml_read_has_remaining (ebml, 1, TRUE)) { - if ((ret = gst_ebml_peek_id (ebml, &id)) != GST_FLOW_OK) - break; - - switch (id) { - default: - ret = gst_ebml_read_skip (ebml); - break; - } - } - - DEBUG_ELEMENT_STOP (parse, ebml, "Chapters", ret); - return ret; -} - /* * Read signed/unsigned "EBML" numbers. * Return: number of bytes processed. @@ -2786,7 +2754,7 @@ gst_matroska_parse_parse_id (GstMatroskaParse * parse, guint32 id, break; case GST_MATROSKA_ID_CHAPTERS: GST_READ_CHECK (gst_matroska_parse_take (parse, read, &ebml)); - ret = gst_matroska_parse_parse_chapters (parse, &ebml); + ret = gst_matroska_read_common_parse_chapters (&parse->common, &ebml); gst_matroska_parse_output (parse, ebml.buf, FALSE); break; case GST_MATROSKA_ID_SEEKHEAD: diff --git a/gst/matroska/matroska-read-common.c b/gst/matroska/matroska-read-common.c index abf9e06..fa678fd 100644 --- a/gst/matroska/matroska-read-common.c +++ b/gst/matroska/matroska-read-common.c @@ -691,6 +691,39 @@ gst_matroska_read_common_parse_attachments (GstMatroskaReadCommon * common, } GstFlowReturn +gst_matroska_read_common_parse_chapters (GstMatroskaReadCommon * common, + GstEbmlRead * ebml) +{ + guint32 id; + GstFlowReturn ret = GST_FLOW_OK; + + GST_WARNING_OBJECT (common, "Parsing of chapters not implemented yet"); + + /* TODO: implement parsing of chapters */ + + DEBUG_ELEMENT_START (common, ebml, "Chapters"); + + if ((ret = gst_ebml_read_master (ebml, &id)) != GST_FLOW_OK) { + DEBUG_ELEMENT_STOP (common, ebml, "Chapters", ret); + return ret; + } + + while (ret == GST_FLOW_OK && gst_ebml_read_has_remaining (ebml, 1, TRUE)) { + if ((ret = gst_ebml_peek_id (ebml, &id)) != GST_FLOW_OK) + break; + + switch (id) { + default: + ret = gst_ebml_read_skip (ebml); + break; + } + } + + DEBUG_ELEMENT_STOP (common, ebml, "Chapters", ret); + return ret; +} + +GstFlowReturn gst_matroska_read_common_parse_header (GstMatroskaReadCommon * common, GstEbmlRead * ebml) { diff --git a/gst/matroska/matroska-read-common.h b/gst/matroska/matroska-read-common.h index ef1e19f..68b0f6c 100644 --- a/gst/matroska/matroska-read-common.h +++ b/gst/matroska/matroska-read-common.h @@ -106,6 +106,8 @@ GstFlowReturn gst_matroska_read_common_parse_info (GstMatroskaReadCommon * common, GstElement * el, GstEbmlRead * ebml); GstFlowReturn gst_matroska_read_common_parse_attachments ( GstMatroskaReadCommon * common, GstElement * el, GstEbmlRead * ebml); +GstFlowReturn gst_matroska_read_common_parse_chapters (GstMatroskaReadCommon * + common, GstEbmlRead * ebml); GstFlowReturn gst_matroska_read_common_parse_header (GstMatroskaReadCommon * common, GstEbmlRead * ebml); GstFlowReturn gst_matroska_read_common_parse_metadata (GstMatroskaReadCommon * -- 2.7.4