From 12f2841efee3323ee1f904bcead43b42fae5fee0 Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Tue, 14 Dec 2004 20:45:22 +0000 Subject: - add tracknumber meta info (patch by Brian J. Tarricone ) - add utf-8 support for id3v2 (sort of tested...) CVS patchset: 7253 CVS date: 2004/12/14 20:45:22 --- include/xine.h.in | 3 ++- src/demuxers/id3.c | 56 ++++++++++++++++++++++++++++++++++---------- src/libvorbis/xine_decoder.c | 3 ++- 3 files changed, 47 insertions(+), 15 deletions(-) diff --git a/include/xine.h.in b/include/xine.h.in index 609173612..5965b4d96 100644 --- a/include/xine.h.in +++ b/include/xine.h.in @@ -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: xine.h.in,v 1.135 2004/12/10 09:52:23 mroi Exp $ + * $Id: xine.h.in,v 1.136 2004/12/14 20:45:22 miguelfreitas Exp $ * * public xine-lib (libxine) interface and documentation * @@ -908,6 +908,7 @@ const char *xine_get_meta_info (xine_stream_t *stream, int info); #define XINE_META_INFO_SYSTEMLAYER 8 #define XINE_META_INFO_INPUT_PLUGIN 9 #define XINE_META_INFO_CDINDEX_DISCID 10 +#define XINE_META_INFO_TRACK_NUMBER 11 /********************************************************************* diff --git a/src/demuxers/id3.c b/src/demuxers/id3.c index 652708abb..229bf5588 100644 --- a/src/demuxers/id3.c +++ b/src/demuxers/id3.c @@ -32,7 +32,7 @@ * * ID3v2 specs: http://www.id3.org/ * - * $Id: id3.c,v 1.6 2003/12/09 00:55:10 tmattern Exp $ + * $Id: id3.c,v 1.7 2004/12/14 20:45:24 miguelfreitas Exp $ */ #ifdef HAVE_CONFIG_H @@ -79,10 +79,18 @@ static const char* const id3_genre[] = "Duet", "Punk Rock", "Drum Solo", "A capella", "Euro-House", "Dance Hall" }; +#define ID3_ENCODING_COUNT 4 +static const char* const id3_encoding[] = { + "ISO-8859-1", /* 0x00 */ + "UTF-16", /* 0x01 */ + "UTF-16BE", /* 0x02 */ + "UTF-8"}; /* 0x03 */ + int id3v1_parse_tag (input_plugin_t *input, xine_stream_t *stream) { off_t len; id3v1_tag_t tag; + char track[4]; /* id3v1 */ len = input->read (input, (char *)&tag, 128); @@ -96,7 +104,13 @@ int id3v1_parse_tag (input_plugin_t *input, xine_stream_t *stream) { _x_meta_info_n_set(stream, XINE_META_INFO_ARTIST, tag.artist, 30); _x_meta_info_n_set(stream, XINE_META_INFO_ALBUM, tag.album, 30); _x_meta_info_n_set(stream, XINE_META_INFO_COMMENT, tag.comment, 30); - + + /* check for a track number: ID3v1.1, which is a clever hack on ID3v1 */ + if (tag.comment[28] == 0 && tag.comment[29] != 0) { + snprintf(track, 4, "%d", (unsigned char)tag.comment[29]); + _x_meta_info_set(stream, XINE_META_INFO_TRACK_NUMBER, track); + } + if (tag.genre < ID3_GENRE_COUNT) { _x_meta_info_set(stream, XINE_META_INFO_GENRE, id3_genre[tag.genre]); } @@ -266,6 +280,7 @@ static int id3v22_interp_frame(input_plugin_t *input, * FIXME: supports unicode */ char buf[4096]; + int enc; if (frame_header->size >= 4096) { lprintf("too long\n"); @@ -274,6 +289,9 @@ static int id3v22_interp_frame(input_plugin_t *input, if (input->read (input, buf, frame_header->size) == frame_header->size) { buf[frame_header->size] = 0; + enc = buf[0]; + if( enc >= ID3_ENCODING_COUNT ) + enc = 0; switch (frame_header->id) { case ( FOURCC_TAG(0, 'T', 'C', 'O') ): @@ -287,23 +305,27 @@ static int id3v22_interp_frame(input_plugin_t *input, break; case ( FOURCC_TAG(0, 'T', 'T', '2') ): - _x_meta_info_set(stream, XINE_META_INFO_TITLE, buf + 1); + _x_meta_info_set_generic(stream, XINE_META_INFO_TITLE, buf + 1, id3_encoding[enc]); break; case ( FOURCC_TAG(0, 'T', 'P', '1') ): - _x_meta_info_set(stream, XINE_META_INFO_ARTIST, buf + 1); + _x_meta_info_set_generic(stream, XINE_META_INFO_ARTIST, buf + 1, id3_encoding[enc]); break; case ( FOURCC_TAG(0, 'T', 'A', 'L') ): - _x_meta_info_set(stream, XINE_META_INFO_ALBUM, buf + 1); + _x_meta_info_set_generic(stream, XINE_META_INFO_ALBUM, buf + 1, id3_encoding[enc]); break; case ( FOURCC_TAG(0, 'T', 'Y', 'E') ): - _x_meta_info_set(stream, XINE_META_INFO_YEAR, buf + 1); + _x_meta_info_set_generic(stream, XINE_META_INFO_YEAR, buf + 1, id3_encoding[enc]); break; case ( FOURCC_TAG(0, 'C', 'O', 'M') ): - _x_meta_info_set(stream, XINE_META_INFO_COMMENT, buf + 1 + 3); + _x_meta_info_set_generic(stream, XINE_META_INFO_COMMENT, buf + 1 + 3, id3_encoding[enc]); + break; + + case ( FOURCC_TAG(0, 'T', 'R', 'K') ): + _x_meta_info_set(stream, XINE_META_INFO_TRACK_NUMBER, buf + 1); break; default: @@ -455,7 +477,8 @@ static int id3v23_interp_frame(input_plugin_t *input, * FIXME: supports unicode */ char buf[4096]; - + int enc; + if (frame_header->size >= 4096) { lprintf("too long\n"); return 1; @@ -463,6 +486,9 @@ static int id3v23_interp_frame(input_plugin_t *input, if (input->read (input, buf, frame_header->size) == frame_header->size) { buf[frame_header->size] = 0; + enc = buf[0]; + if( enc >= ID3_ENCODING_COUNT ) + enc = 0; switch (frame_header->id) { case ( FOURCC_TAG('T', 'C', 'O', 'N') ): @@ -476,23 +502,27 @@ static int id3v23_interp_frame(input_plugin_t *input, break; case ( FOURCC_TAG('T', 'I', 'T', '2') ): - _x_meta_info_set(stream, XINE_META_INFO_TITLE, buf + 1); + _x_meta_info_set_generic(stream, XINE_META_INFO_TITLE, buf + 1, id3_encoding[enc]); break; case ( FOURCC_TAG('T', 'P', 'E', '1') ): - _x_meta_info_set(stream, XINE_META_INFO_ARTIST, buf + 1); + _x_meta_info_set_generic(stream, XINE_META_INFO_ARTIST, buf + 1, id3_encoding[enc]); break; case ( FOURCC_TAG('T', 'A', 'L', 'B') ): - _x_meta_info_set(stream, XINE_META_INFO_ALBUM, buf + 1); + _x_meta_info_set_generic(stream, XINE_META_INFO_ALBUM, buf + 1, id3_encoding[enc]); break; case ( FOURCC_TAG('T', 'Y', 'E', 'R') ): - _x_meta_info_set(stream, XINE_META_INFO_YEAR, buf + 1); + _x_meta_info_set_generic(stream, XINE_META_INFO_YEAR, buf + 1, id3_encoding[enc]); break; case ( FOURCC_TAG('C', 'O', 'M', 'M') ): - _x_meta_info_set(stream, XINE_META_INFO_COMMENT, buf + 1 + 3); + _x_meta_info_set_generic(stream, XINE_META_INFO_COMMENT, buf + 1 + 3, id3_encoding[enc]); + break; + + case ( FOURCC_TAG('T', 'R', 'C', 'K') ): + _x_meta_info_set(stream, XINE_META_INFO_TRACK_NUMBER, buf + 1); break; default: diff --git a/src/libvorbis/xine_decoder.c b/src/libvorbis/xine_decoder.c index e06c61a50..9f63f0a1a 100644 --- a/src/libvorbis/xine_decoder.c +++ b/src/libvorbis/xine_decoder.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: xine_decoder.c,v 1.39 2004/01/12 17:35:17 miguelfreitas Exp $ + * $Id: xine_decoder.c,v 1.40 2004/12/14 20:45:24 miguelfreitas Exp $ * * (ogg/)vorbis audio decoder plugin (libvorbis wrapper) for xine */ @@ -101,6 +101,7 @@ static struct { {"GENRE=", XINE_META_INFO_GENRE}, {"DESCRIPTION=", XINE_META_INFO_COMMENT}, {"DATE=", XINE_META_INFO_YEAR}, + {"TRACKNUMBER=", XINE_META_INFO_TRACK_NUMBER}, {NULL, 0} }; -- cgit v1.2.3