[vlc-devel] [PATCH 5/7] contrib: add the possibility to pass a stream to taglib rather than a file path

Steve Lhomme robux4 at gmail.com
Mon Sep 14 14:43:18 CEST 2015


Oops, this one slipped in the batch.
Discard.

On Mon, Sep 14, 2015 at 2:40 PM, Steve Lhomme <robux4 at gmail.com> wrote:
> ---
>  contrib/src/taglib/iostream.patch | 130 ++++++++++++++++++++++++++++++++++++++
>  contrib/src/taglib/rules.mak      |   6 ++
>  2 files changed, 136 insertions(+)
>  create mode 100644 contrib/src/taglib/iostream.patch
>
> diff --git a/contrib/src/taglib/iostream.patch b/contrib/src/taglib/iostream.patch
> new file mode 100644
> index 0000000..7a2dc4f
> --- /dev/null
> +++ b/contrib/src/taglib/iostream.patch
> @@ -0,0 +1,130 @@
> +diff --git a/taglib/fileref.cpp b/taglib/fileref.cpp
> +index 2b5d5f2..04d9a56 100644
> +--- a/taglib/fileref.cpp
> ++++ b/taglib/fileref.cpp
> +@@ -83,6 +83,11 @@ FileRef::FileRef()
> +   d = new FileRefPrivate(create(fileName, readAudioProperties, audioPropertiesStyle));
> + }
> +
> ++FileRef::FileRef(IOStream* stream, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle)
> ++{
> ++  d = new FileRefPrivate(create(stream, readAudioProperties, audioPropertiesStyle));
> ++}
> ++
> + FileRef::FileRef(File *file)
> + {
> +   d = new FileRefPrivate(file);
> +@@ -284,3 +289,77 @@ File *FileRef::create(FileName fileName, bool readAudioProperties,
> +
> +   return 0;
> + }
> ++
> ++File *FileRef::create(IOStream* ioStream, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle)
> ++{
> ++    // Ok, this is really dumb for now, but it works for testing.
> ++
> ++    String ext;
> ++    {
> ++  #ifdef _WIN32
> ++
> ++      String s = ioStream->name().toString();
> ++
> ++  #else
> ++
> ++      String s = ioStream->name();
> ++
> ++   #endif
> ++
> ++      const int pos = s.rfind(".");
> ++      if(pos != -1)
> ++        ext = s.substr(pos + 1).upper();
> ++    }
> ++
> ++    // If this list is updated, the method defaultFileExtensions() should also be
> ++    // updated.  However at some point that list should be created at the same time
> ++    // that a default file type resolver is created.
> ++
> ++    if(!ext.isEmpty()) {
> ++      if(ext == "MP3")
> ++        return new MPEG::File(ioStream, ID3v2::FrameFactory::instance(), readAudioProperties, audioPropertiesStyle);
> ++      if(ext == "OGG")
> ++        return new Ogg::Vorbis::File(ioStream, readAudioProperties, audioPropertiesStyle);
> ++      if(ext == "OGA") {
> ++        /* .oga can be any audio in the Ogg container. First try FLAC, then Vorbis. */
> ++        File *file = new Ogg::FLAC::File(ioStream, readAudioProperties, audioPropertiesStyle);
> ++        if (file->isValid())
> ++          return file;
> ++        delete file;
> ++        return new Ogg::Vorbis::File(ioStream, readAudioProperties, audioPropertiesStyle);
> ++      }
> ++      if(ext == "FLAC")
> ++        return new FLAC::File(ioStream, ID3v2::FrameFactory::instance(), readAudioProperties, audioPropertiesStyle);
> ++      if(ext == "MPC")
> ++        return new MPC::File(ioStream, readAudioProperties, audioPropertiesStyle);
> ++      if(ext == "WV")
> ++        return new WavPack::File(ioStream, readAudioProperties, audioPropertiesStyle);
> ++      if(ext == "SPX")
> ++        return new Ogg::Speex::File(ioStream, readAudioProperties, audioPropertiesStyle);
> ++      if(ext == "OPUS")
> ++        return new Ogg::Opus::File(ioStream, readAudioProperties, audioPropertiesStyle);
> ++      if(ext == "TTA")
> ++        return new TrueAudio::File(ioStream, readAudioProperties, audioPropertiesStyle);
> ++      if(ext == "M4A" || ext == "M4R" || ext == "M4B" || ext == "M4P" || ext == "MP4" || ext == "3G2")
> ++        return new MP4::File(ioStream, readAudioProperties, audioPropertiesStyle);
> ++      if(ext == "WMA" || ext == "ASF")
> ++        return new ASF::File(ioStream, readAudioProperties, audioPropertiesStyle);
> ++      if(ext == "AIF" || ext == "AIFF" || ext == "AFC" || ext == "AIFC")
> ++        return new RIFF::AIFF::File(ioStream, readAudioProperties, audioPropertiesStyle);
> ++      if(ext == "WAV")
> ++        return new RIFF::WAV::File(ioStream, readAudioProperties, audioPropertiesStyle);
> ++      if(ext == "APE")
> ++        return new APE::File(ioStream, readAudioProperties, audioPropertiesStyle);
> ++      // module, nst and wow are possible but uncommon extensions
> ++      if(ext == "MOD" || ext == "MODULE" || ext == "NST" || ext == "WOW")
> ++        return new Mod::File(ioStream, readAudioProperties, audioPropertiesStyle);
> ++      if(ext == "S3M")
> ++        return new S3M::File(ioStream, readAudioProperties, audioPropertiesStyle);
> ++      if(ext == "IT")
> ++        return new IT::File(ioStream, readAudioProperties, audioPropertiesStyle);
> ++      if(ext == "XM")
> ++        return new XM::File(ioStream, readAudioProperties, audioPropertiesStyle);
> ++    }
> ++
> ++    return 0;
> ++}
> +
> +diff --git a/taglib/fileref.h b/taglib/fileref.h
> +index 0f0c21a..3ba03af 100644
> +--- a/taglib/fileref.h
> ++++ b/taglib/fileref.h
> +@@ -128,6 +128,20 @@ namespace TagLib {
> +                      audioPropertiesStyle = AudioProperties::Average);
> +
> +     /*!
> ++     * Create a FileRef from an opened \a IOStream.  If \a readAudioProperties is true then
> ++     * the audio properties will be read using \a audioPropertiesStyle.  If
> ++     * \a readAudioProperties is false then \a audioPropertiesStyle will be
> ++     * ignored.
> ++     *
> ++     * Also see the note in the class documentation about why you may not want to
> ++     * use this method in your application.
> ++     */
> ++    explicit FileRef(IOStream* stream,
> ++                     bool readAudioProperties = true,
> ++                     AudioProperties::ReadStyle
> ++                     audioPropertiesStyle = AudioProperties::Average);
> ++
> ++    /*!
> +      * Contruct a FileRef using \a file.  The FileRef now takes ownership of the
> +      * pointer and will delete the File when it passes out of scope.
> +      */
> +@@ -252,6 +266,9 @@ namespace TagLib {
> +                         bool readAudioProperties = true,
> +                         AudioProperties::ReadStyle audioPropertiesStyle = AudioProperties::Average);
> +
> ++    static File *create(IOStream* ioStream,
> ++                        bool readAudioProperties = true,
> ++                        AudioProperties::ReadStyle audioPropertiesStyle = AudioProperties::Average);
> +
> +   private:
> +     class FileRefPrivate;
> diff --git a/contrib/src/taglib/rules.mak b/contrib/src/taglib/rules.mak
> index 055b6cf..5011e58 100644
> --- a/contrib/src/taglib/rules.mak
> +++ b/contrib/src/taglib/rules.mak
> @@ -17,6 +17,7 @@ taglib: taglib-$(TAGLIB_VERSION).tar.gz .sum-taglib
>         $(UNPACK)
>         $(APPLY) $(SRC)/taglib/taglib-pc.patch
>         $(APPLY) $(SRC)/taglib/0002-Rewrote-ByteVector-replace-simpler.patch
> +       $(APPLY) $(SRC)/taglib/iostream.patch
>         $(MOVE)
>
>  .taglib: taglib toolchain.cmake
> @@ -24,5 +25,10 @@ taglib: taglib-$(TAGLIB_VERSION).tar.gz .sum-taglib
>                 -DENABLE_STATIC:BOOL=ON \
>                 -DWITH_ASF:BOOL=ON \
>                 -DWITH_MP4:BOOL=ON .
> +ifdef HAVE_VISUALSTUDIO
> +       cd $< && msbuild.exe -p:Configuration=$(VLC_CONFIGURATION) -m -nologo INSTALL.vcxproj
> +       cd $< && cp taglib/$(VLC_CONFIGURATION)/tag.lib "$(PREFIX)/lib/libtag.a"
> +else
>         cd $< && $(MAKE) install
> +endif
>         touch $@
> --
> 2.5.1
>


More information about the vlc-devel mailing list