#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_input.h> /* for attachment_new */
+#include <vlc_demux.h> /* demux_meta_t */
+#include <vlc_strings.h> /* vlc_b64_decode_binary */
+#include <vlc_input.h> /* for attachment_new */
#ifdef WIN32
+# include <vlc_charset.h>
# include <io.h>
#else
# include <unistd.h>
#include <mpegfile.h>
#include <oggfile.h>
#include <oggflacfile.h>
+#include "../demux/vorbis.h"
#if TAGLIB_VERSION >= VERSION_INT(1,6,0)
# define TAGLIB_HAVE_AIFF_WAV_H
# include <aifffile.h>
# include <wavfile.h>
+#else
+# include <id3v2tag.h>
#endif
#if TAGLIB_VERSION >= VERSION_INT(1,6,1) && defined(TAGLIB_WITH_MP4)
APE::Item item;
#define SET( keyName, metaName ) \
item = tag->itemListMap()[keyName]; \
- vlc_meta_Set##metaName( p_meta, item.toString().toCString( true ) );\
+ if( !item.isEmpty() ) vlc_meta_Set##metaName( p_meta, item.toString().toCString( true ) ); \
SET( "COPYRIGHT", Copyright );
SET( "LANGUAGE", Language );
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 )
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";
+ if( mime_list.size() != 0 && art_list.size() != 0 )
+ {
+ // 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() );
- uint8_t *p_data;
- int i_data = vlc_b64_decode_binary( &p_data, art_list[0].toCString(true) );
+ const char* psz_name = "cover";
+ const char* psz_mime = mime_list[0].toCString(true);
+ const char* psz_description = "cover";
- msg_Dbg( p_demux_meta, "Found embedded art: %s (%s) is %i bytes",
- psz_name, psz_mime, i_data );
+ uint8_t *p_data;
+ int i_data = vlc_b64_decode_binary( &p_data, art_list[0].toCString(true) );
- 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 );
+ msg_Dbg( p_demux_meta, "Found embedded art: %s (%s) is %i bytes",
+ psz_name, psz_mime, i_data );
+ p_attachment = vlc_input_attachment_New( psz_name, psz_mime,
+ psz_description, p_data, i_data );
+ free( p_data );
+ }
+ else
+ {
+ art_list = tag->fieldListMap()[ "METADATA_BLOCK_PICTURE" ];
+ if( art_list.size() == 0 )
+ return;
+
+ uint8_t *p_data;
+ int type;
+ int i_data = vlc_b64_decode_binary( &p_data, art_list[0].toCString(true) );
+ p_attachment = ParseFlacPicture( p_data, i_data, 0, &type );
+ }
+
+ TAB_INIT( p_demux_meta->i_attachments, p_demux_meta->attachments );
TAB_APPEND_CAST( (input_attachment_t**),
p_demux_meta->i_attachments, p_demux_meta->attachments,
p_attachment );
- vlc_meta_SetArtURL( p_meta, "attachment://cover" );
+ char *psz_url;
+ if( asprintf( &psz_url, "attachment://%s", p_attachment->psz_name ) != -1 ) {
+ vlc_meta_SetArtURL( p_meta, psz_url );
+ free( psz_url );
+ }
}
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 )
- {
- free( psz_path );
- return VLC_EGENERIC;
- }
- f = FileRef( local_name );
- LocaleFree( local_name );
+ f = FileRef( psz_path );
#endif
free( psz_path );
}
#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 )
- return VLC_EGENERIC;
- f = FileRef( local_name );
- LocaleFree( local_name );
+ f = FileRef( p_export->psz_file );
#endif
if( f.isNull() || !f.tag() || f.file()->readOnly() )