+ // Try now to get embedded art
+ StringList mime_list = tag->fieldListMap()[ "COVERARTMIME" ];
+ StringList art_list = tag->fieldListMap()[ "COVERART" ];
+
+ // We get only the first covert art
+ if( mime_list.size() > 1 || art_list.size() > 1 )
+ msg_Warn( p_demux_meta, "Found %i embedded arts, so using only the first one",
+ art_list.size() );
+ else if( mime_list.size() == 0 || art_list.size() == 0 )
+ return;
+
+ input_attachment_t *p_attachment;
+
+ const char* psz_name = "cover";
+ const char* psz_mime = mime_list[0].toCString(true);
+ const char* psz_description = "cover";
+
+ uint8_t *p_data;
+ int i_data = vlc_b64_decode_binary( &p_data, art_list[0].toCString(true) );
+
+ msg_Dbg( p_demux_meta, "Found embedded art: %s (%s) is %i bytes",
+ psz_name, psz_mime, i_data );
+
+ TAB_INIT( p_demux_meta->i_attachments, p_demux_meta->attachments );
+ p_attachment = vlc_input_attachment_New( psz_name, psz_mime,
+ psz_description, p_data, i_data );
+ free( p_data );
+
+ TAB_APPEND_CAST( (input_attachment_t**),
+ p_demux_meta->i_attachments, p_demux_meta->attachments,
+ p_attachment );
+
+ vlc_meta_SetArtURL( p_meta, "attachment://cover" );
+}
+
+
+
+/**
+ * Get the tags from the file using TagLib
+ * @param p_this: the demux object
+ * @return VLC_SUCCESS if the operation success
+ */
+static int ReadMeta( vlc_object_t* p_this)
+{
+ demux_meta_t* p_demux_meta = (demux_meta_t *)p_this;
+ demux_t* p_demux = p_demux_meta->p_demux;
+ vlc_meta_t* p_meta;
+ FileRef f;
+ char *psz_path = decode_URI_duplicate( p_demux->psz_path );
+
+ p_demux_meta->p_meta = NULL;
+ if( !psz_path )
+ return VLC_ENOMEM;
+ if( strncmp( p_demux->psz_access, "file", strlen("file") ) )
+ return VLC_EGENERIC;
+
+
+#if defined(WIN32) || defined (UNDER_CE)
+ wchar_t wpath[MAX_PATH + 1];
+ if( !MultiByteToWideChar( CP_UTF8, 0, psz_path, -1, wpath, MAX_PATH) )
+ return VLC_EGENERIC;
+ wpath[MAX_PATH] = L'\0';
+ f = FileRef( wpath );
+#else
+ const char* local_name = ToLocale( psz_path );
+ if( !local_name )
+ return VLC_EGENERIC;
+ f = FileRef( local_name );
+ LocaleFree( local_name );
+#endif
+ free( psz_path );
+
+ if( f.isNull() )
+ return VLC_EGENERIC;
+ if( !f.tag() || f.tag()->isEmpty() )
+ return VLC_EGENERIC;
+
+ p_demux_meta->p_meta = p_meta = vlc_meta_New();
+ 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
+
+
+ // Try now to read special tags
+ if( FLAC::File* flac = dynamic_cast<FLAC::File*>(f.file()) )
+ {
+ if( flac->ID3v2Tag() )
+ ReadMetaFromId3v2( flac->ID3v2Tag(), p_demux, p_demux_meta, p_meta );
+ else if( flac->xiphComment() )
+ ReadMetaFromXiph( flac->xiphComment(), p_demux, p_demux_meta, p_meta );
+ }
+ else if( MPC::File* mpc = dynamic_cast<MPC::File*>(f.file()) )
+ {
+ if( mpc->APETag() )
+ ReadMetaFromAPE( mpc->APETag(), p_demux, p_demux_meta, p_meta );
+ }
+ else if( MPEG::File* mpeg = dynamic_cast<MPEG::File*>(f.file()) )
+ {
+ if( mpeg->ID3v2Tag() )
+ ReadMetaFromId3v2( mpeg->ID3v2Tag(), p_demux, p_demux_meta, p_meta );
+ else if( mpeg->APETag() )
+ ReadMetaFromAPE( mpeg->APETag(), p_demux, p_demux_meta, p_meta );
+ }
+ else if( Ogg::File* ogg = dynamic_cast<Ogg::File*>(f.file()) )
+ {
+ if( Ogg::FLAC::File* ogg_flac = dynamic_cast<Ogg::FLAC::File*>(f.file()))
+ ReadMetaFromXiph( ogg_flac->tag(), p_demux, p_demux_meta, p_meta );
+ else if( Ogg::Speex::File* ogg_speex = dynamic_cast<Ogg::Speex::File*>(f.file()) )
+ ReadMetaFromXiph( ogg_speex->tag(), p_demux, p_demux_meta, p_meta );
+ else if( Ogg::Vorbis::File* ogg_vorbis = dynamic_cast<Ogg::Vorbis::File*>(f.file()) )
+ ReadMetaFromXiph( ogg_vorbis->tag(), p_demux, p_demux_meta, p_meta );
+ }
+#ifdef TAGLIB_WITH_ASF
+ else if( RIFF::File* riff = dynamic_cast<RIFF::File*>(f.file()) )
+ {
+ if( RIFF::AIFF::File* riff_aiff = dynamic_cast<RIFF::AIFF::File*>(f.file()) )
+ ReadMetaFromId3v2( riff_aiff->tag(), p_demux, 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, p_demux_meta, p_meta );
+ }
+#endif
+ else if( TrueAudio::File* trueaudio = dynamic_cast<TrueAudio::File*>(f.file()) )
+ {
+ if( trueaudio->ID3v2Tag() )
+ ReadMetaFromId3v2( trueaudio->ID3v2Tag(), p_demux, p_demux_meta, p_meta );
+ }
+ else if( WavPack::File* wavpack = dynamic_cast<WavPack::File*>(f.file()) )
+ {
+ if( wavpack->APETag() )
+ ReadMetaFromAPE( wavpack->APETag(), p_demux, p_demux_meta, p_meta );