[vlc-commits] meta_reader: taglib: parse ID3 tags on aac files

Francois Cartegnie git at videolan.org
Thu Feb 18 22:58:16 CET 2016


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Feb 15 14:36:55 2016 +0100| [fe37800bfaa637db24e5cffc530f01820a14babc] | committer: Francois Cartegnie

meta_reader: taglib: parse ID3 tags on aac files

refs #16623

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

 modules/meta_engine/taglib.cpp |   32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)

diff --git a/modules/meta_engine/taglib.cpp b/modules/meta_engine/taglib.cpp
index e4fbb93..61cb967 100644
--- a/modules/meta_engine/taglib.cpp
+++ b/modules/meta_engine/taglib.cpp
@@ -97,6 +97,32 @@
 #include <textidentificationframe.h>
 #include <uniquefileidentifierframe.h>
 
+using namespace TagLib;
+
+#define TAGLIB_SYNCDECODE_FIXED_VERSION VERSION_INT(1,11,0)
+#if TAGLIB_VERSION >= TAGLIB_SYNCDECODE_FIXED_VERSION
+namespace VLCTagLib
+{
+    class FileAAC : public FileRef::FileTypeResolver
+    {
+        public:
+            virtual File *createFile(FileName, bool, AudioProperties::ReadStyle) const;
+    };
+}
+
+File *VLCTagLib::FileAAC::createFile(FileName fileName, bool, AudioProperties::ReadStyle) const
+{
+    std::string filename = std::string(fileName);
+    std::size_t namesize = filename.size();
+
+    /* Just pass AAC file as MPEG one. Only ID3 headers will be decoded */
+    if (namesize > 4 && filename.substr(namesize - 4, 4) == ".aac")
+        return new MPEG::File(fileName, false, AudioProperties::ReadStyle::Fast);
+
+    return 0;
+}
+#endif
+
 // taglib is not thread safe
 static vlc_mutex_t taglib_lock = VLC_STATIC_MUTEX;
 
@@ -112,8 +138,6 @@ vlc_module_begin ()
         set_callbacks( WriteMeta, NULL )
 vlc_module_end ()
 
-using namespace TagLib;
-
 static int ExtractCoupleNumberValues( vlc_meta_t* p_meta, const char *psz_value,
         vlc_meta_type_t first, vlc_meta_type_t second)
 {
@@ -694,6 +718,10 @@ static int ReadMeta( vlc_object_t* p_this)
     if( psz_path == NULL )
         return VLC_EGENERIC;
 
+#if TAGLIB_VERSION >= TAGLIB_SYNCDECODE_FIXED_VERSION
+    FileRef::addFileTypeResolver( new VLCTagLib::FileAAC );
+#endif
+
 #if defined(_WIN32)
     wchar_t *wpath = ToWide( psz_path );
     if( wpath == NULL )



More information about the vlc-commits mailing list