From: Hugo Beauzée-Luyssen Date: Wed, 9 Feb 2022 13:14:08 +0000 (+0100) Subject: taglib: Implement new StreamTypeResolver interface when available X-Git-Tag: archive/raspbian/3.0.21-6+rpi1^2~76 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=50b05834200909fe12040a6c438e2f31e9d66a18;p=vlc.git taglib: Implement new StreamTypeResolver interface when available refs #26602 (cherry picked from commit 268b5b8bc1f1109c4fc69b22e53095c6d81faa76) (rebased) Gbp-Pq: Name 0049-taglib-Implement-new-StreamTypeResolver-interface-wh.patch --- diff --git a/modules/meta_engine/taglib.cpp b/modules/meta_engine/taglib.cpp index a52adfe4..e3e80cc6 100644 --- a/modules/meta_engine/taglib.cpp +++ b/modules/meta_engine/taglib.cpp @@ -101,15 +101,27 @@ using namespace TagLib; #include #include +#if defined(VLC_PATCHED_TAGLIB_IOSTREAM_RESOLVERS) || \ + TAGLIB_VERSION >= VERSION_INT(1, 12, 0) +#define USE_IOSTREAM_RESOLVER 1 +#endif + namespace VLCTagLib { template +#ifdef USE_IOSTREAM_RESOLVER + class ExtResolver : public FileRef::StreamTypeResolver +#else class ExtResolver : public FileRef::FileTypeResolver +#endif { public: ExtResolver(const std::string &); ~ExtResolver() {} virtual File *createFile(FileName, bool, AudioProperties::ReadStyle) const; +#ifdef USE_IOSTREAM_RESOLVER + virtual File *createFileFromStream(IOStream*, bool, AudioProperties::ReadStyle) const; +#endif protected: std::string ext; @@ -140,6 +152,25 @@ File *VLCTagLib::ExtResolver::createFile(FileName fileName, bool, AudioProper return 0; } +#ifdef USE_IOSTREAM_RESOLVER +template +File* VLCTagLib::ExtResolver::createFileFromStream(IOStream* s, bool, AudioProperties::ReadStyle) const +{ + std::string filename = std::string(s->name()); + std::size_t namesize = filename.size(); + + 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(s, ID3v2::FrameFactory::instance(), false, AudioProperties::Fast); + } + + return nullptr; +} +#endif + #if TAGLIB_VERSION >= TAGLIB_VERSION_1_11 static VLCTagLib::ExtResolver aacresolver(".aac"); #endif