-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
contrib: taglib: Fix custom resolvers with IOStream
upstreamed at: taglib/taglib#1040 Fix #26602
- Loading branch information
1 parent
93842f6
commit 2f82d6b
Showing
2 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
101 changes: 101 additions & 0 deletions
101
contrib/src/taglib/0001-FileTypeResolver-Fix-IOStream-usage-with-custom-reso.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
From cb9b013217b2e77066141656029cf92cf854054d Mon Sep 17 00:00:00 2001 | ||
From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= <hugo@beauzee.fr> | ||
Date: Wed, 9 Feb 2022 13:51:42 +0100 | ||
Subject: [PATCH] FileTypeResolver: Add a StreamTypeResolver interface | ||
|
||
--- | ||
taglib/fileref.cpp | 19 ++++++++++++++++++- | ||
taglib/fileref.h | 10 ++++++++++ | ||
taglib/toolkit/taglib.h | 2 ++ | ||
tests/test_fileref.cpp | 4 ++++ | ||
4 files changed, 34 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/taglib/fileref.cpp b/taglib/fileref.cpp | ||
index f91209a0..88e53ed1 100644 | ||
--- a/taglib/fileref.cpp | ||
+++ b/taglib/fileref.cpp | ||
@@ -84,6 +84,23 @@ namespace | ||
return 0; | ||
} | ||
|
||
+ File *detectByResolvers(IOStream* stream, bool readAudioProperties, | ||
+ AudioProperties::ReadStyle audioPropertiesStyle) | ||
+ { | ||
+ ResolverList::ConstIterator it = fileTypeResolvers.begin(); | ||
+ for(; it != fileTypeResolvers.end(); ++it) { | ||
+ const FileRef::StreamTypeResolver* streamResolver = | ||
+ dynamic_cast<const FileRef::StreamTypeResolver*>(*it); | ||
+ if (!streamResolver) | ||
+ continue; | ||
+ File *file = streamResolver->createFileFromStream(stream, readAudioProperties, audioPropertiesStyle); | ||
+ if(file) | ||
+ return file; | ||
+ } | ||
+ | ||
+ return 0; | ||
+ } | ||
+ | ||
// Detect the file type based on the file extension. | ||
|
||
File* detectByExtension(IOStream *stream, bool readAudioProperties, | ||
@@ -482,7 +499,7 @@ void FileRef::parse(IOStream *stream, bool readAudioProperties, | ||
{ | ||
// Try user-defined resolvers. | ||
|
||
- d->file = detectByResolvers(stream->name(), readAudioProperties, audioPropertiesStyle); | ||
+ d->file = detectByResolvers(stream, readAudioProperties, audioPropertiesStyle); | ||
if(d->file) | ||
return; | ||
|
||
diff --git a/taglib/fileref.h b/taglib/fileref.h | ||
index 76e694e4..37f44a0e 100644 | ||
--- a/taglib/fileref.h | ||
+++ b/taglib/fileref.h | ||
@@ -108,6 +108,16 @@ namespace TagLib { | ||
audioPropertiesStyle = AudioProperties::Average) const = 0; | ||
}; | ||
|
||
+ class TAGLIB_EXPORT StreamTypeResolver : public FileTypeResolver | ||
+ { | ||
+ TAGLIB_IGNORE_MISSING_DESTRUCTOR | ||
+ public: | ||
+ virtual File *createFileFromStream(IOStream* stream, | ||
+ bool readAudioProperties = true, | ||
+ AudioProperties::ReadStyle | ||
+ audioPropertiesStyle = AudioProperties::Average) const = 0; | ||
+ }; | ||
+ | ||
/*! | ||
* Creates a null FileRef. | ||
*/ | ||
diff --git a/taglib/toolkit/taglib.h b/taglib/toolkit/taglib.h | ||
index ffce61f7..2bb56994 100644 | ||
--- a/taglib/toolkit/taglib.h | ||
+++ b/taglib/toolkit/taglib.h | ||
@@ -54,6 +54,8 @@ | ||
#define TAGLIB_DEPRECATED | ||
#endif | ||
|
||
+#define VLC_PATCHED_TAGLIB_IOSTREAM_RESOLVERS | ||
+ | ||
#include <string> | ||
|
||
//! A namespace for all TagLib related classes and functions | ||
diff --git a/tests/test_fileref.cpp b/tests/test_fileref.cpp | ||
index 1fc5def9..c8136129 100644 | ||
--- a/tests/test_fileref.cpp | ||
+++ b/tests/test_fileref.cpp | ||
@@ -59,6 +59,10 @@ namespace | ||
{ | ||
return new Ogg::Vorbis::File(fileName); | ||
} | ||
+ virtual File *createFile(IOStream* s, bool, AudioProperties::ReadStyle) const | ||
+ { | ||
+ return new Ogg::Vorbis::File(s); | ||
+ } | ||
}; | ||
} | ||
|
||
-- | ||
2.34.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters