diff options
author | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2007-03-03 00:58:52 +0000 |
---|---|---|
committer | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2007-03-03 00:58:52 +0000 |
commit | 6a16b385d3c32e412e23f9f5d44140d7afd9af79 (patch) | |
tree | 32e1451dd03c41b60ca8e5ccf68610a87a35c1b5 | |
parent | 834fb11173a04fb9febc30e8c0e6c08722114f80 (diff) | |
download | xine-lib-6a16b385d3c32e412e23f9f5d44140d7afd9af79.tar.gz xine-lib-6a16b385d3c32e412e23f9f5d44140d7afd9af79.tar.bz2 |
Add a function to parse a generic ID3v2 tag, and make both demux_aac and demux_mpgaudio use it without repeating the same code.
CVS patchset: 8636
CVS date: 2007/03/03 00:58:52
-rw-r--r-- | src/demuxers/demux_aac.c | 38 | ||||
-rw-r--r-- | src/demuxers/demux_mpgaudio.c | 33 | ||||
-rw-r--r-- | src/demuxers/id3.c | 32 | ||||
-rw-r--r-- | src/demuxers/id3.h | 8 |
4 files changed, 46 insertions, 65 deletions
diff --git a/src/demuxers/demux_aac.c b/src/demuxers/demux_aac.c index fa7f86b72..dedcaca8a 100644 --- a/src/demuxers/demux_aac.c +++ b/src/demuxers/demux_aac.c @@ -21,7 +21,7 @@ * This demuxer detects ADIF and ADTS headers in AAC files. * Then it shovels buffer-sized chunks over to the AAC decoder. * - * $Id: demux_aac.c,v 1.15 2007/03/03 00:33:51 dgp85 Exp $ + * $Id: demux_aac.c,v 1.16 2007/03/03 00:58:52 dgp85 Exp $ */ #ifdef HAVE_CONFIG_H @@ -37,9 +37,9 @@ #define LOG_MODULE "demux_aac" #define LOG_VERBOSE - +/* #define LOG - +*/ #include "xine_internal.h" #include "xineutils.h" @@ -88,37 +88,7 @@ static int open_aac_file(demux_aac_t *this) { this->input->seek(this->input, 4, SEEK_SET); - /* Now parse the tag */ - switch(peak[3]) { - case 2: /* ID3v2.2 */ - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, - LOG_MODULE ": ID3V2.2 tag\n"); - if ( ! id3v22_parse_tag(this->input, this->stream, peak) ) - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, - LOG_MODULE ": ID3V2.2 tag parsing error\n"); - return 0; - break; - - case 3: /* ID3v2.3 */ - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, - LOG_MODULE ": ID3V2.3 tag\n"); - if ( ! id3v23_parse_tag(this->input, this->stream, peak) ) - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, - LOG_MODULE ": ID3V2.3 tag parsing error\n"); - break; - - case 4: /* ID3v2.4 */ - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, - LOG_MODULE ": ID3V2.4 tag\n"); - if ( ! id3v24_parse_tag(this->input, this->stream, peak) ) - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, - LOG_MODULE ": ID3V2.4 tag parsing error\n"); - break; - - default: - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, - LOG_MODULE ": Unknown ID3v2 version: 0x%02x.\n", peak[3]); - } + id3v2_parse_tag(this->input, this->stream, peak); lprintf("ID3v2 tag encountered, skipping %u bytes.\n", id3size); } diff --git a/src/demuxers/demux_mpgaudio.c b/src/demuxers/demux_mpgaudio.c index fd79e4215..b9f35c17d 100644 --- a/src/demuxers/demux_mpgaudio.c +++ b/src/demuxers/demux_mpgaudio.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: demux_mpgaudio.c,v 1.149 2007/03/03 00:02:30 dgp85 Exp $ + * $Id: demux_mpgaudio.c,v 1.150 2007/03/03 00:58:52 dgp85 Exp $ * * demultiplexer for mpeg audio (i.e. mp3) streams * @@ -606,39 +606,14 @@ static int demux_mpgaudio_next (demux_mpgaudio_t *this, int decoder_flags, int s return parse_frame_payload(this, header_buf, decoder_flags); - } else if ((BE_32(header_buf)) == ID3V22_TAG) { - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, - LOG_MODULE ": ID3V2.2 tag\n"); - if (!id3v22_parse_tag(this->input, this->stream, header_buf)) { + } else if ( header_buf[0] == 'I' && header_buf[1] == 'D' && header_buf[2] == '3' ) { + if (!id3v2_parse_tag(this->input, this->stream, header_buf)) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, - LOG_MODULE ": ID3V2.2 tag parsing error\n"); + LOG_MODULE ": ID3V2 tag parsing error\n"); bytes = 1; /* resync */ } else { bytes = 4; } - - } else if ((BE_32(header_buf)) == ID3V23_TAG) { - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, - LOG_MODULE ": ID3V2.3 tag\n"); - if (!id3v23_parse_tag(this->input, this->stream, header_buf)) { - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, - LOG_MODULE ": ID3V2.3 tag parsing error\n"); - bytes = 1; /* resync */ - } else { - bytes = 4; - } - - } else if ((BE_32(header_buf)) == ID3V24_TAG) { - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, - LOG_MODULE ": ID3V2.4 tag\n"); - if (!id3v24_parse_tag(this->input, this->stream, header_buf)) { - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, - LOG_MODULE ": ID3V2.4 tag parsing error\n"); - bytes = 1; /* resync */ - } else { - bytes = 4; - } - } else { /* skip */ bytes = 1; diff --git a/src/demuxers/id3.c b/src/demuxers/id3.c index ffa022a59..b707166b6 100644 --- a/src/demuxers/id3.c +++ b/src/demuxers/id3.c @@ -29,7 +29,7 @@ * * ID3v2 specs: http://www.id3.org/ * - * $Id: id3.c,v 1.12 2006/04/05 22:12:18 valtri Exp $ + * $Id: id3.c,v 1.13 2007/03/03 00:58:52 dgp85 Exp $ */ #ifdef HAVE_CONFIG_H @@ -878,3 +878,33 @@ int id3v24_parse_tag(input_plugin_t *input, return 0; } } + +int id3v2_parse_tag(input_plugin_t *input, + xine_stream_t *stream, + int8_t *mp3_frame_header) { + _x_assert(mp3_frame_header[0] == 'I' && mp3_frame_header[1] == 'D' && mp3_frame_header[2] == '3'); + + int result = 0; + + switch(mp3_frame_header[3]) { + case 2: + xprintf(stream->xine, XINE_VERBOSITY_LOG, "ID3V2.2 tag\n"); + result = id3v22_parse_tag(input, stream, mp3_frame_header); + break; + + case 3: + xprintf(stream->xine, XINE_VERBOSITY_LOG, "ID3V2.3 tag\n"); + result = id3v23_parse_tag(input, stream, mp3_frame_header); + break; + + case 4: + xprintf(stream->xine, XINE_VERBOSITY_LOG, "ID3V2.3 tag\n"); + result = id3v24_parse_tag(input, stream, mp3_frame_header); + break; + + default: + xprintf(stream->xine, XINE_VERBOSITY_LOG, "Unknown ID3v2 version: 0x%02x.\n", mp3_frame_header[3]); + } + + return result; +} diff --git a/src/demuxers/id3.h b/src/demuxers/id3.h index 2d8970ea7..394488858 100644 --- a/src/demuxers/id3.h +++ b/src/demuxers/id3.h @@ -21,7 +21,7 @@ * * Supported versions: v1, v1.1, v2.2, v2.3, v2.4 * - * $Id: id3.h,v 1.4 2005/09/15 18:45:15 tmattern Exp $ + * $Id: id3.h,v 1.5 2007/03/03 00:58:52 dgp85 Exp $ */ #ifndef ID3_H @@ -38,6 +38,7 @@ #define ID3V24_TAG FOURCC_TAG('I', 'D', '3', 4) /* id3 v2.4 header tag */ #define ID3V24_FOOTER_TAG FOURCC_TAG('3', 'D', 'I', 0) /* id3 v2.4 footer tag */ + /* * ID3 v2.2 */ @@ -164,4 +165,9 @@ int id3v24_parse_tag(input_plugin_t *input, xine_stream_t *stream, int8_t *mp3_frame_header); +/* Generic function that switch between the three above */ +int id3v2_parse_tag(input_plugin_t *input, + xine_stream_t *stream, + int8_t *mp3_frame_header); + #endif /* ID3_H */ |