[vlc-commits] Support alternate TrackTotal styles in taglib.
Timothy B. Terriberry
git at videolan.org
Tue Sep 3 11:29:21 CEST 2013
vlc | branch: master | Timothy B. Terriberry <tterribe at xiph.org> | Mon Sep 2 11:15:13 2013 -0700| [0b429f0af4bebdb514aa0db75f75e2ceea7001da] | committer: Jean-Baptiste Kempf
Support alternate TrackTotal styles in taglib.
vorbis_ParseComment() supports several different methods of
specifying the total number of tracks. Update the taglib module
to support reading in the same set.
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0b429f0af4bebdb514aa0db75f75e2ceea7001da
---
modules/meta_engine/taglib.cpp | 30 +++++++++++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/modules/meta_engine/taglib.cpp b/modules/meta_engine/taglib.cpp
index 577c96f..903cd0c 100644
--- a/modules/meta_engine/taglib.cpp
+++ b/modules/meta_engine/taglib.cpp
@@ -429,12 +429,12 @@ static void ReadMetaFromId3v2( ID3v2::Tag* tag, demux_meta_t* p_demux_meta, vlc_
static void ReadMetaFromXiph( Ogg::XiphComment* tag, demux_meta_t* p_demux_meta, vlc_meta_t* p_meta )
{
StringList list;
+ bool hasTrackTotal = false;
#define SET( keyName, metaName ) \
list = tag->fieldListMap()[keyName]; \
if( !list.isEmpty() ) \
vlc_meta_Set##metaName( p_meta, (*list.begin()).toCString( true ) );
- SET( "TRACKTOTAL", TrackTotal );
SET( "COPYRIGHT", Copyright );
SET( "ORGANIZATION", Publisher );
SET( "DATE", Date );
@@ -443,6 +443,34 @@ static void ReadMetaFromXiph( Ogg::XiphComment* tag, demux_meta_t* p_demux_meta,
SET( "LANGUAGE", Language );
#undef SET
+ list = tag->fieldListMap()["TRACKNUMBER"];
+ if( !list.isEmpty() )
+ {
+ const char *psz_value;
+ unsigned short u_track;
+ unsigned short u_total;
+ psz_value = (*list.begin()).toCString( true );
+ if( sscanf( psz_value, "%hu/%hu", &u_track, &u_total ) == 2)
+ {
+ char str[6];
+ snprintf(str, 6, "%u", u_track);
+ vlc_meta_SetTrackNum( p_meta, str);
+ snprintf(str, 6, "%u", u_total);
+ vlc_meta_SetTrackTotal( p_meta, str);
+ hasTrackTotal = true;
+ }
+ else
+ vlc_meta_SetTrackNum( p_meta, psz_value);
+ }
+ if( !hasTrackTotal )
+ {
+ list = tag->fieldListMap()["TRACKTOTAL"];
+ if( list.isEmpty() )
+ list = tag->fieldListMap()["TOTALTRACKS"];
+ if( !list.isEmpty() )
+ vlc_meta_SetTrackTotal( p_meta, (*list.begin()).toCString( true ) );
+ }
+
// Try now to get embedded art
StringList mime_list = tag->fieldListMap()[ "COVERARTMIME" ];
StringList art_list = tag->fieldListMap()[ "COVERART" ];
More information about the vlc-commits
mailing list