+ APE::Item item;
+#define SET( keyName, metaName ) \
+ item = tag->itemListMap()[keyName]; \
+ vlc_meta_Set##metaName( p_meta, item.toString().toCString( true ) );\
+
+ SET( "COPYRIGHT", Copyright );
+ SET( "LANGUAGE", Language );
+ SET( "PUBLISHER", Publisher );
+
+#undef SET
+}
+
+
+
+/**
+ * Read meta information from id3v2 tags
+ * @param tag: the id3v2 tag
+ * @param p_demux; the demux object
+ * @param p_demux_meta: the demuxer meta
+ * @param p_meta: the meta
+ */
+static void ReadMetaFromId3v2( ID3v2::Tag* tag, demux_t* p_demux, demux_meta_t* p_demux_meta, vlc_meta_t* p_meta )
+{
+ // Get the unique file identifier
+ ID3v2::FrameList list = tag->frameListMap()["UFID"];
+ ID3v2::FrameList::Iterator iter;
+ for( iter = list.begin(); iter != list.end(); iter++ )
+ {
+ ID3v2::UniqueFileIdentifierFrame* p_ufid =
+ dynamic_cast<ID3v2::UniqueFileIdentifierFrame*>(*iter);
+ if( !p_ufid )
+ continue;
+ const char *owner = p_ufid->owner().toCString();
+ if (!strcmp( owner, "http://musicbrainz.org" ))
+ {
+ /* ID3v2 UFID contains up to 64 bytes binary data
+ * but in our case it will be a '\0'
+ * terminated string */
+ char psz_ufid[64];
+ int max_size = __MIN( p_ufid->identifier().size(), 63);
+ strncpy( psz_ufid, p_ufid->identifier().data(), max_size );
+ psz_ufid[max_size] = '\0';
+ vlc_meta_SetTrackID( p_meta, psz_ufid );
+ }
+ }
+
+ // Get the use text
+ list = tag->frameListMap()["TXXX"];
+ for( iter = list.begin(); iter != list.end(); iter++ )
+ {
+ ID3v2::UserTextIdentificationFrame* p_txxx =
+ dynamic_cast<ID3v2::UserTextIdentificationFrame*>(*iter);
+ if( !p_txxx )
+ continue;
+ vlc_meta_AddExtra( p_meta, p_txxx->description().toCString( true ),
+ p_txxx->fieldList().toString().toCString( true ) );
+ }
+
+ // Get some more information
+#define SET( tagName, metaName ) \
+ list = tag->frameListMap()[tagName]; \
+ if( !list.isEmpty() ) \
+ vlc_meta_Set##metaName( p_meta, \
+ (*list.begin())->toString().toCString( true ) );
+
+ SET( "TCOP", Copyright );
+ SET( "TENC", EncodedBy );
+ SET( "TLAN", Language );
+ SET( "TPUB", Publisher );
+
+#undef SET