#include <vlc_common.h>
#include <vlc_plugin.h>
-#include <vlc_meta.h>
-#include <vlc_demux.h>
-#include <vlc_strings.h>
-#include <vlc_charset.h>
-#include <vlc_url.h>
-#include <vlc_input_item.h>
-#include <vlc_input.h> /* for attachment_new */
+#include <vlc_demux.h> /* demux_meta_t */
+#include <vlc_strings.h> /* vlc_b64_decode_binary */
+#include <vlc_charset.h> /* ToLocale, LocaleFree */
+#include <vlc_input.h> /* for attachment_new */
#ifdef WIN32
# include <io.h>
#include <tag.h>
#include <tbytevector.h>
-#include <apetag.h>
-#include <id3v2tag.h>
-#include <xiphcomment.h>
-
#if TAGLIB_VERSION >= VERSION_INT(1,7,0)
# define TAGLIB_HAVE_APEFILE_H
# include <apefile.h>
+# ifdef TAGLIB_WITH_ASF // ASF pictures comes with v1.7.0
+# define TAGLIB_HAVE_ASFPICTURE_H
+# include <asffile.h>
+# endif
#endif
+
+#include <apetag.h>
#include <flacfile.h>
#include <mpcfile.h>
#include <mpegfile.h>
#include <oggflacfile.h>
#if TAGLIB_VERSION >= VERSION_INT(1,6,0)
-# define TAGLIB_HAVE_RIFF_WAV_H
+# define TAGLIB_HAVE_AIFF_WAV_H
# include <aifffile.h>
# include <wavfile.h>
+#else
+# include <id3v2tag.h>
#endif
-#ifdef TAGLIB_WITH_MP4
+#if TAGLIB_VERSION >= VERSION_INT(1,6,1) && defined(TAGLIB_WITH_MP4)
+# define TAGLIB_HAVE_MP4COVERTART_H
# include <mp4file.h>
#endif
}
+#ifdef TAGLIB_HAVE_ASFPICTURE_H
+/**
+ * Read meta information from APE tags
+ * @param tag: the APE tag
+ * @param p_demux_meta: the demuxer meta
+ * @param p_meta: the meta
+ */
+static void ReadMetaFromASF( ASF::Tag* tag, demux_meta_t* p_demux_meta, vlc_meta_t* p_meta )
+{
+ // List the pictures
+ ASF::AttributeList list = tag->attributeListMap()["WM/Picture"];
+ ASF::AttributeList::Iterator iter;
+ for( iter = list.begin(); iter != list.end(); iter++ )
+ {
+ const ASF::Picture asfPicture = (*iter).toPicture();
+ const ByteVector picture = asfPicture.picture();
+ const char *psz_mime = asfPicture.mimeType().toCString();
+ const char *p_data = picture.data();
+ const unsigned i_data = picture.size();
+ char *psz_name;
+ input_attachment_t *p_attachment;
+
+ if( asfPicture.description().size() > 0 )
+ psz_name = strdup( asfPicture.description().toCString( true ) );
+ else
+ {
+ if( asprintf( &psz_name, "%i", asfPicture.type() ) == -1 )
+ continue;
+ }
+
+ msg_Dbg( p_demux_meta, "Found embedded art: %s (%s) is %u bytes",
+ psz_name, psz_mime, i_data );
+
+ p_attachment = vlc_input_attachment_New( psz_name, psz_mime,
+ psz_name, p_data, i_data );
+ if( p_attachment )
+ TAB_APPEND_CAST( (input_attachment_t**),
+ p_demux_meta->i_attachments, p_demux_meta->attachments,
+ p_attachment );
+ free( psz_name );
+
+ char *psz_url;
+ if( asprintf( &psz_url, "attachment://%s",
+ p_attachment->psz_name ) == -1 )
+ continue;
+ vlc_meta_SetArtURL( p_meta, psz_url );
+ free( psz_url );
+ }
+}
+#endif
+
+
/**
* Read meta information from id3v2 tags
* @param tag: the id3v2 tag
}
-#if defined(TAGLIB_WITH_MP4) && defined(HAVE_TAGLIB_MP4COVERART_H)
+#ifdef TAGLIB_HAVE_MP4COVERTART_H
/**
* Read the meta information from mp4 specific tags
* @param tag: the mp4 tag
return VLC_ENOMEM;
#if defined(WIN32) || defined (UNDER_CE)
- wchar_t wpath[MAX_PATH + 1];
- if( !MultiByteToWideChar( CP_UTF8, 0, psz_path, -1, wpath, MAX_PATH) )
+ wchar_t *wpath = ToWide( psz_path );
+ if( wpath == NULL )
{
free( psz_path );
return VLC_EGENERIC;
}
- wpath[MAX_PATH] = L'\0';
f = FileRef( wpath );
+ free( wpath );
#else
const char* local_name = ToLocale( psz_path );
if( !local_name )
ReadMetaFromAPE( ape->APETag(), p_demux_meta, p_meta );
}
else
+#endif
+#ifdef TAGLIB_HAVE_ASFPICTURE_H
+ if( ASF::File* asf = dynamic_cast<ASF::File*>(f.file()) )
+ {
+ if( asf->tag() )
+ ReadMetaFromASF( asf->tag(), p_demux_meta, p_meta );
+ }
+ else
#endif
if( FLAC::File* flac = dynamic_cast<FLAC::File*>(f.file()) )
{
else if( flac->xiphComment() )
ReadMetaFromXiph( flac->xiphComment(), p_demux_meta, p_meta );
}
-#if defined(TAGLIB_WITH_MP4) && defined(HAVE_TAGLIB_MP4COVERART_H)
+#ifdef TAGLIB_HAVE_MP4COVERTART_H
else if( MP4::File *mp4 = dynamic_cast<MP4::File*>(f.file()) )
{
if( mp4->tag() )
else if( Ogg::Vorbis::File* ogg_vorbis = dynamic_cast<Ogg::Vorbis::File*>(f.file()) )
ReadMetaFromXiph( ogg_vorbis->tag(), p_demux_meta, p_meta );
}
-#ifdef TAGLIB_HAVE_RIFF_WAV_H
+#ifdef TAGLIB_HAVE_AIFF_WAV_H
else if( dynamic_cast<RIFF::File*>(f.file()) )
{
if( RIFF::AIFF::File* riff_aiff = dynamic_cast<RIFF::AIFF::File*>(f.file()) )
}
#if defined(WIN32) || defined (UNDER_CE)
- wchar_t wpath[MAX_PATH + 1];
- if( !MultiByteToWideChar( CP_UTF8, 0, p_export->psz_file, -1, wpath, MAX_PATH) )
+ wchar_t *wpath = ToWide( p_export->psz_file );
+ if( wpath == NULL )
return VLC_EGENERIC;
- wpath[MAX_PATH] = L'\0';
f = FileRef( wpath );
+ free( wpath );
#else
const char* local_name = ToLocale( p_export->psz_file );
if( !local_name )
else if( Ogg::Vorbis::File* ogg_vorbis = dynamic_cast<Ogg::Vorbis::File*>(f.file()) )
WriteMetaToXiph( ogg_vorbis->tag(), p_item );
}
-#ifdef TAGLIB_HAVE_RIFF_WAV_H
+#ifdef TAGLIB_HAVE_AIFF_WAV_H
else if( dynamic_cast<RIFF::File*>(f.file()) )
{
if( RIFF::AIFF::File* riff_aiff = dynamic_cast<RIFF::AIFF::File*>(f.file()) )