[vlc-commits] MP3: support TRCK total number

Jean-Baptiste Kempf git at videolan.org
Wed Jun 20 15:12:33 CEST 2012


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Wed Jun 13 01:48:57 2012 +0200| [cb4a20b9fed2f876878946d05bfcb7c4aba45ada] | committer: Jean-Baptiste Kempf

MP3: support TRCK total number

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=cb4a20b9fed2f876878946d05bfcb7c4aba45ada
---

 modules/meta_engine/taglib.cpp |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/modules/meta_engine/taglib.cpp b/modules/meta_engine/taglib.cpp
index e1f63ee..aec694a 100644
--- a/modules/meta_engine/taglib.cpp
+++ b/modules/meta_engine/taglib.cpp
@@ -108,6 +108,18 @@ vlc_module_end ()
 
 using namespace TagLib;
 
+static void ExtractTrackNumberValues( vlc_meta_t* p_meta, const char *psz_value )
+{
+    unsigned int i_trknum, i_trktot;
+    if( sscanf( psz_value, "%u/%u", &i_trknum, &i_trktot ) == 2 )
+    {
+        char psz_trck[11];
+        snprintf( psz_trck, sizeof( psz_trck ), "%u", i_trknum );
+        vlc_meta_SetTrackNum( p_meta, psz_trck );
+        snprintf( psz_trck, sizeof( psz_trck ), "%u", i_trktot );
+        vlc_meta_Set( p_meta, vlc_meta_TrackTotal, psz_trck );
+    }
+}
 
 /**
  * Read meta information from APE tags
@@ -244,6 +256,13 @@ static void ReadMetaFromId3v2( ID3v2::Tag* tag, demux_meta_t* p_demux_meta, vlc_
 
 #undef SET
 
+    /* */
+    list = tag->frameListMap()["TRCK"];
+    if( !list.isEmpty() )
+    {
+        ExtractTrackNumberValues( p_meta, (*list.begin())->toString().toCString( true ) );
+    }
+
     /* Preferred type of image
      * The 21 types are defined in id3v2 standard:
      * http://www.id3.org/id3v2.4.0-frames */



More information about the vlc-commits mailing list