[vlc-commits] MKV: support target Type for metadata
Jean-Baptiste Kempf
git at videolan.org
Fri Aug 24 01:05:14 CEST 2012
vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Fri Aug 24 01:04:06 2012 +0200| [471ffd34ff1c6a213ecca42a53143422429465ac] | committer: Jean-Baptiste Kempf
MKV: support target Type for metadata
This allows to differentiate Title and Album, for example
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=471ffd34ff1c6a213ecca42a53143422429465ac
---
modules/demux/mkv/matroska_segment.cpp | 57 +++++++++++++++++++++-----------
modules/demux/mkv/matroska_segment.hpp | 2 +-
2 files changed, 39 insertions(+), 20 deletions(-)
diff --git a/modules/demux/mkv/matroska_segment.cpp b/modules/demux/mkv/matroska_segment.cpp
index fab4929..58e660e 100644
--- a/modules/demux/mkv/matroska_segment.cpp
+++ b/modules/demux/mkv/matroska_segment.cpp
@@ -221,23 +221,25 @@ void matroska_segment_c::LoadCues( KaxCues *cues )
static const struct {
vlc_meta_type_t type;
const char *key;
-} metadata_map[] = { {vlc_meta_Title, "TITLE"},
- {vlc_meta_Artist, "ARTIST"},
- {vlc_meta_Genre, "GENRE"},
- {vlc_meta_Copyright, "COPYRIGHT"},
- {vlc_meta_TrackNumber, "PART_NUMBER"},
- {vlc_meta_Description, "DESCRIPTION"},
- {vlc_meta_Description, "COMMENT"},
- {vlc_meta_Rating, "RATING"},
- {vlc_meta_Date, "DATE_RELEASED"},
- {vlc_meta_URL, "URL"},
- {vlc_meta_Publisher, "PUBLISHER"},
- {vlc_meta_EncodedBy, "ENCODED_BY"},
- {vlc_meta_TrackTotal, "TOTAL_PARTS"},
- {vlc_meta_Title, NULL},
+ int target_type; /* 0 is valid for all target_type */
+} metadata_map[] = { {vlc_meta_Title, "TITLE", 50},
+ {vlc_meta_Album, "TITLE", 30},
+ {vlc_meta_Artist, "ARTIST", 0},
+ {vlc_meta_Genre, "GENRE", 0},
+ {vlc_meta_Copyright, "COPYRIGHT", 0},
+ {vlc_meta_TrackNumber, "PART_NUMBER", 0},
+ {vlc_meta_Description, "DESCRIPTION", 0},
+ {vlc_meta_Description, "COMMENT", 0},
+ {vlc_meta_Rating, "RATING", 0},
+ {vlc_meta_Date, "DATE_RELEASED", 0},
+ {vlc_meta_URL, "URL", 0},
+ {vlc_meta_Publisher, "PUBLISHER", 0},
+ {vlc_meta_EncodedBy, "ENCODED_BY", 0},
+ {vlc_meta_TrackTotal, "TOTAL_PARTS", 0},
+ {vlc_meta_Title, NULL, 0},
};
-void matroska_segment_c::ParseSimpleTags( KaxTagSimple *tag )
+void matroska_segment_c::ParseSimpleTags( KaxTagSimple *tag, int target_type )
{
EbmlElement *el;
EbmlParser *ep = new EbmlParser( &es, tag, &sys.demuxer );
@@ -272,7 +274,8 @@ void matroska_segment_c::ParseSimpleTags( KaxTagSimple *tag )
for( int i = 0; metadata_map[i].key; i++ )
{
- if( !strcmp( k, metadata_map[i].key ) )
+ if( !strcmp( k, metadata_map[i].key ) &&
+ (metadata_map[i].target_type == 0 || target_type == metadata_map[i].target_type ) )
{
vlc_meta_Set( sys.meta, metadata_map[i].type, v );
msg_Dbg( &sys.demuxer, "| | + Meta %s: %s", k, v);
@@ -310,10 +313,28 @@ void matroska_segment_c::LoadTags( KaxTags *tags )
{
msg_Dbg( &sys.demuxer, "+ Tag" );
ep->Down();
+ int target_type = 50;
while( ( el = ep->Get() ) != NULL )
{
if( MKV_IS_ID( el, KaxTagTargets ) )
- PARSE_TAG( "Targets" );
+ {
+ msg_Dbg( &sys.demuxer, "| + Targets" );
+ ep->Down();
+ while( ( el = ep->Get() ) != NULL )
+ {
+ if( MKV_IS_ID( el, KaxTagTargetTypeValue ) )
+ {
+ KaxTagTargetTypeValue &value = *(KaxTagTargetTypeValue*)el;
+ value.ReadData( es.I_O() );
+
+ msg_Dbg( &sys.demuxer, "| | + TargetTypeValue: %u", uint32(value));
+ target_type = uint32(value);
+ }
+ }
+ ep->Up();
+ }
+ else if( MKV_IS_ID( el, KaxTagSimple ) )
+ ParseSimpleTags( static_cast<KaxTagSimple*>( el ), target_type );
#if 0 // not valid anymore
else if( MKV_IS_ID( el, KaxTagGeneral ) )
PARSE_TAG( "General" );
@@ -352,8 +373,6 @@ void matroska_segment_c::LoadTags( KaxTags *tags )
msg_Dbg( &sys.demuxer, "| + Multi Title" );
}
#endif
- else if( MKV_IS_ID( el, KaxTagSimple ) )
- ParseSimpleTags( static_cast<KaxTagSimple*>( el ) );
else
{
msg_Dbg( &sys.demuxer, "| + LoadTag Unknown (%s)", typeid( *el ).name() );
diff --git a/modules/demux/mkv/matroska_segment.hpp b/modules/demux/mkv/matroska_segment.hpp
index 1e69016..f0ccdb7 100644
--- a/modules/demux/mkv/matroska_segment.hpp
+++ b/modules/demux/mkv/matroska_segment.hpp
@@ -125,7 +125,7 @@ private:
void ParseChapterAtom( int i_level, KaxChapterAtom *ca, chapter_item_c & chapters );
void ParseTrackEntry( KaxTrackEntry *m );
void ParseCluster( bool b_update_start_time = true );
- void ParseSimpleTags( KaxTagSimple *tag );
+ void ParseSimpleTags( KaxTagSimple *tag, int level = 50 );
void IndexAppendCluster( KaxCluster *cluster );
};
More information about the vlc-commits
mailing list