[vlc-commits] taglib: template the extension fix, remove contribs patch

Francois Cartegnie git at videolan.org
Fri Feb 19 11:33:20 CET 2016


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Feb 19 11:30:09 2016 +0100| [7d0fec2c72d32f5e3566d8001c45a8e73ac7ce4a] | committer: Francois Cartegnie

taglib: template the extension fix, remove contribs patch

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

 contrib/src/taglib/m4v.patch   |   20 --------------------
 contrib/src/taglib/rules.mak   |    1 -
 modules/meta_engine/taglib.cpp |   37 +++++++++++++++++++++++++++++--------
 3 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/contrib/src/taglib/m4v.patch b/contrib/src/taglib/m4v.patch
deleted file mode 100644
index 827b929..0000000
--- a/contrib/src/taglib/m4v.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- taglib/taglib/fileref.cpp   2015-08-10 18:32:56.961588900 +0200
-+++ taglib/taglib/fileref.cpp.m4v       2015-08-12 11:00:44.933793600 +0200
-@@ -160,6 +160,7 @@
-   l.append("m4p");
-   l.append("3g2");
-   l.append("mp4");
-+  l.append("m4v");
-   l.append("wma");
-   l.append("asf");
-   l.append("aif");
-@@ -266,7 +267,7 @@
-       return new Ogg::Opus::File(fileName, readAudioProperties, audioPropertiesStyle);
-     if(ext == "TTA")
-       return new TrueAudio::File(fileName, readAudioProperties, audioPropertiesStyle);
--    if(ext == "M4A" || ext == "M4R" || ext == "M4B" || ext == "M4P" || ext == "MP4" || ext == "3G2")
-+    if(ext == "M4A" || ext == "M4R" || ext == "M4B" || ext == "M4P" || ext == "MP4" || ext == "3G2" || ext == "M4V")
-       return new MP4::File(fileName, readAudioProperties, audioPropertiesStyle);
-     if(ext == "WMA" || ext == "ASF")
-       return new ASF::File(fileName, readAudioProperties, audioPropertiesStyle);
-
diff --git a/contrib/src/taglib/rules.mak b/contrib/src/taglib/rules.mak
index 02ea427..8c6afb4 100644
--- a/contrib/src/taglib/rules.mak
+++ b/contrib/src/taglib/rules.mak
@@ -15,7 +15,6 @@ $(TARBALLS)/taglib-$(TAGLIB_VERSION).tar.gz:
 
 taglib: taglib-$(TAGLIB_VERSION).tar.gz .sum-taglib
 	$(UNPACK)
-	$(APPLY) $(SRC)/taglib/m4v.patch
 	$(MOVE)
 
 .taglib: taglib toolchain.cmake
diff --git a/modules/meta_engine/taglib.cpp b/modules/meta_engine/taglib.cpp
index 61cb967..b9d657c 100644
--- a/modules/meta_engine/taglib.cpp
+++ b/modules/meta_engine/taglib.cpp
@@ -100,28 +100,47 @@
 using namespace TagLib;
 
 #define TAGLIB_SYNCDECODE_FIXED_VERSION VERSION_INT(1,11,0)
-#if TAGLIB_VERSION >= TAGLIB_SYNCDECODE_FIXED_VERSION
+
+#include <algorithm>
+
 namespace VLCTagLib
 {
-    class FileAAC : public FileRef::FileTypeResolver
+    template <class T>
+    class ExtResolver : public FileRef::FileTypeResolver
     {
         public:
+            ExtResolver(const std::string &);
+            ~ExtResolver() {}
             virtual File *createFile(FileName, bool, AudioProperties::ReadStyle) const;
+
+        protected:
+            std::string ext;
     };
 }
 
-File *VLCTagLib::FileAAC::createFile(FileName fileName, bool, AudioProperties::ReadStyle) const
+template <class T>
+VLCTagLib::ExtResolver<T>::ExtResolver(const std::string & ext) : FileTypeResolver()
+{
+    this->ext = ext;
+    std::transform(this->ext.begin(), this->ext.end(), this->ext.begin(), ::toupper);
+}
+
+template <class T>
+File *VLCTagLib::ExtResolver<T>::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);
+    if (namesize > ext.length())
+    {
+        std::string fext = filename.substr(namesize - ext.length(), ext.length());
+        std::transform(fext.begin(), fext.end(), fext.begin(), ::toupper);
+        if(fext == ext)
+            return new T(fileName, false, AudioProperties::ReadStyle::Fast);
+    }
 
     return 0;
 }
-#endif
 
 // taglib is not thread safe
 static vlc_mutex_t taglib_lock = VLC_STATIC_MUTEX;
@@ -719,9 +738,11 @@ static int ReadMeta( vlc_object_t* p_this)
         return VLC_EGENERIC;
 
 #if TAGLIB_VERSION >= TAGLIB_SYNCDECODE_FIXED_VERSION
-    FileRef::addFileTypeResolver( new VLCTagLib::FileAAC );
+    FileRef::addFileTypeResolver( new VLCTagLib::ExtResolver<MPEG::File>(".aac") );
 #endif
 
+    FileRef::addFileTypeResolver( new VLCTagLib::ExtResolver<MP4::File>(".m4v") );
+
 #if defined(_WIN32)
     wchar_t *wpath = ToWide( psz_path );
     if( wpath == NULL )



More information about the vlc-commits mailing list