[vlc-commits] [Git][videolan/vlc][3.0.x] 2 commits: taglib: move default meta access to a function
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Sun Mar 19 07:39:48 UTC 2023
Jean-Baptiste Kempf pushed to branch 3.0.x at VideoLAN / VLC
Commits:
06dff2e5 by Alaric Senat at 2023-03-19T07:27:24+00:00
taglib: move default meta access to a function
No functional changes.
(cherry picked from commit 294cbdbaee0209bc88ca7bec9164da8da4ac44ef)
- - - - -
85868dfb by Alaric Senat at 2023-03-19T07:27:24+00:00
taglib: wav: fix RIFF INFO tags parsing
TagLib does not provide an union of both ID3v2 and INFO tags via the
usual `File::tag()` method. Their justification lies in the code for
now:
```cpp
/*!
* Returns the ID3v2 Tag for this file.
*
* \note This method does not return all the tags for this file for
* backward compatibility. Will be fixed in TagLib 2.0.
*/
ID3v2::Tag *tag() const;
```
To support WAV files providing RIFF INFO tags, we must specifically
parse them before TagLib 2.0 (not released yet).
Fixes #25690
(cherry picked from commit a26e2ba370d898dda04c718176af7d2e329dab7a)
- - - - -
1 changed file:
- modules/meta_engine/taglib.cpp
Changes:
=====================================
modules/meta_engine/taglib.cpp
=====================================
@@ -462,6 +462,31 @@ static void ReadMetaFromASF( ASF::Tag* tag, demux_meta_t* p_demux_meta, vlc_meta
}
+static void ReadMetaFromBasicTag(const Tag* tag, vlc_meta_t *dest)
+{
+#define SET( accessor, meta ) \
+ if( !tag->accessor().isNull() && !tag->accessor().isEmpty() ) \
+ vlc_meta_Set##meta( dest, tag->accessor().toCString(true) )
+#define SETINT( accessor, meta ) \
+ if( tag->accessor() ) \
+ { \
+ char tmp[10]; \
+ snprintf( tmp, 10, "%d", tag->accessor() ); \
+ vlc_meta_Set##meta( dest, tmp ); \
+ }
+
+ SET( title, Title );
+ SET( artist, Artist );
+ SET( album, Album );
+ SET( comment, Description );
+ SET( genre, Genre );
+ SETINT( year, Date );
+ SETINT( track, TrackNum );
+
+#undef SETINT
+#undef SET
+}
+
/**
* Read meta information from id3v2 tags
* @param tag: the id3v2 tag
@@ -820,6 +845,28 @@ static void ReadMetaFromMP4( MP4::Tag* tag, demux_meta_t *p_demux_meta, vlc_meta
}
}
+static int ReadWAVMeta( const RIFF::WAV::File *wav, demux_meta_t *demux_meta )
+{
+ if( !wav->hasID3v2Tag() && !wav->hasInfoTag() )
+ return VLC_EGENERIC;
+
+ demux_meta->p_meta = vlc_meta_New();
+ if( !demux_meta->p_meta )
+ return VLC_ENOMEM;
+
+ TAB_INIT( demux_meta->i_attachments, demux_meta->attachments );
+
+ if( wav->hasInfoTag() )
+ ReadMetaFromBasicTag( wav->InfoTag(), demux_meta->p_meta );
+ if( wav->hasID3v2Tag() )
+ {
+ // Re-read basic tags from id3 to prioritize it against INFO tags.
+ ReadMetaFromBasicTag( wav->ID3v2Tag(), demux_meta->p_meta );
+ ReadMetaFromId3v2( wav->ID3v2Tag(), demux_meta, demux_meta->p_meta );
+ }
+ return VLC_SUCCESS;
+}
+
/**
* Get the tags from the file using TagLib
* @param p_this: the demux object
@@ -895,6 +942,14 @@ static int ReadMeta( vlc_object_t* p_this)
if( f.isNull() )
return VLC_EGENERIC;
+
+ // XXX: Workaround a quirk in TagLib that doesn't merge id3 tags and RIFF
+ // INFO tags in `Wav::File::tag()`'s return value.
+ // This forces us to parse WAV separately for now.
+ const auto* riff_wav = dynamic_cast<RIFF::WAV::File*>(f.file());
+ if (riff_wav != nullptr)
+ return ReadWAVMeta(riff_wav, p_demux_meta);
+
if( !f.tag() || f.tag()->isEmpty() )
return VLC_EGENERIC;
@@ -902,31 +957,8 @@ static int ReadMeta( vlc_object_t* p_this)
if( !p_meta )
return VLC_ENOMEM;
-
// Read the tags from the file
- Tag* p_tag = f.tag();
-
-#define SET( tag, meta ) \
- if( !p_tag->tag().isNull() && !p_tag->tag().isEmpty() ) \
- vlc_meta_Set##meta( p_meta, p_tag->tag().toCString(true) )
-#define SETINT( tag, meta ) \
- if( p_tag->tag() ) \
- { \
- char psz_tmp[10]; \
- snprintf( psz_tmp, 10, "%d", p_tag->tag() ); \
- vlc_meta_Set##meta( p_meta, psz_tmp ); \
- }
-
- SET( title, Title );
- SET( artist, Artist );
- SET( album, Album );
- SET( comment, Description );
- SET( genre, Genre );
- SETINT( year, Date );
- SETINT( track, TrackNum );
-
-#undef SETINT
-#undef SET
+ ReadMetaFromBasicTag(f.tag(), p_meta);
TAB_INIT( p_demux_meta->i_attachments, p_demux_meta->attachments );
@@ -979,12 +1011,9 @@ static int ReadMeta( vlc_object_t* p_this)
ReadMetaFromXiph( ogg_opus->tag(), p_demux_meta, p_meta );
#endif
}
- else if( dynamic_cast<RIFF::File*>(f.file()) )
+ else if( RIFF::AIFF::File* riff_aiff = dynamic_cast<RIFF::AIFF::File*>(f.file()) )
{
- if( RIFF::AIFF::File* riff_aiff = dynamic_cast<RIFF::AIFF::File*>(f.file()) )
- ReadMetaFromId3v2( riff_aiff->tag(), p_demux_meta, p_meta );
- else if( RIFF::WAV::File* riff_wav = dynamic_cast<RIFF::WAV::File*>(f.file()) )
- ReadMetaFromId3v2( riff_wav->tag(), p_demux_meta, p_meta );
+ ReadMetaFromId3v2( riff_aiff->tag(), p_demux_meta, p_meta );
}
else if( TrueAudio::File* trueaudio = dynamic_cast<TrueAudio::File*>(f.file()) )
{
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/fdfb5bc253748466538b7d923c2b7292510b6d00...85868dfb0319dced501a78dfd2ee6432d6be90f3
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/fdfb5bc253748466538b7d923c2b7292510b6d00...85868dfb0319dced501a78dfd2ee6432d6be90f3
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list