#include <mpegfile.h>
#include <oggfile.h>
#include <oggflacfile.h>
+
+#ifdef TAGLIB_WITH_ASF
+# include <aifffile.h>
+# include <wavfile.h>
+#endif
+
#include <speexfile.h>
#include <trueaudiofile.h>
#include <vorbisfile.h>
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, p_demux->psz_path, -1, wpath, MAX_PATH) )
+ 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( p_demux->psz_path );
+ 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;
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() )
return VLC_EGENERIC;
}
- char *export_file = strdup(p_export->psz_file);
- if( decode_URI( export_file ) == NULL )
- {
- free( export_file );
- return VLC_EGENERIC;
- }
-
#if defined(WIN32) || defined (UNDER_CE)
wchar_t wpath[MAX_PATH + 1];
- if( !MultiByteToWideChar( CP_UTF8, 0, export_file , -1, wpath, MAX_PATH) )
+ if( !MultiByteToWideChar( CP_UTF8, 0, p_export->psz_file, -1, wpath, MAX_PATH) )
return VLC_EGENERIC;
wpath[MAX_PATH] = L'\0';
f = FileRef( wpath );
#else
- const char* local_name = ToLocale( export_file );
+ const char* local_name = ToLocale( p_export->psz_file );
if( !local_name )
- {
- free( export_file );
return VLC_EGENERIC;
- }
f = FileRef( local_name );
LocaleFree( local_name );
#endif
if( f.isNull() || !f.tag() || f.file()->readOnly() )
{
msg_Err( p_this, "File %s can't be opened for tag writing",
- export_file );
- free( export_file );
+ p_export->psz_file );
return VLC_EGENERIC;
}
- msg_Dbg( p_this, "Writing metadata for %s", export_file );
- free( export_file );
+ msg_Dbg( p_this, "Writing metadata for %s", p_export->psz_file );
Tag *p_tag = f.tag();
char *psz_meta;
-#define SET( a, b ) \
- if( b ) \
- { \
- String* psz_tmp = new String( b, String::UTF8 ); \
- p_tag->set##a( *psz_tmp ); \
- delete psz_tmp; \
- }
+#define SET( a, b ) \
+ psz_meta = input_item_Get ## a( p_item ); \
+ if( psz_meta ) \
+ { \
+ String tmp( psz_meta, String::UTF8 ); \
+ p_tag->set##b( tmp ); \
+ } \
+ free( psz_meta );
// Saving all common fields
// If the title is empty, use the name
- psz_meta = input_item_GetTitleFbName( p_item );
- SET( Title, psz_meta );
- free( psz_meta );
-
- psz_meta = input_item_GetArtist( p_item );
- SET( Artist, psz_meta );
- free( psz_meta );
-
- psz_meta = input_item_GetAlbum( p_item );
- SET( Album, psz_meta );
- free( psz_meta );
-
- psz_meta = input_item_GetDescription( p_item );
- SET( Comment, psz_meta );
- free( psz_meta );
-
- psz_meta = input_item_GetGenre( p_item );
- SET( Genre, psz_meta );
- free( psz_meta );
+ SET( TitleFbName, Title );
+ SET( Artist, Artist );
+ SET( Album, Album );
+ SET( Description, Comment );
+ SET( Genre, Genre );
#undef SET
else if( Ogg::Vorbis::File* ogg_vorbis = dynamic_cast<Ogg::Vorbis::File*>(f.file()) )
WriteMetaToXiph( ogg_vorbis->tag(), p_item );
}
+#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()) )
+ WriteMetaToId3v2( riff_aiff->tag(), p_item );
+ else if( RIFF::WAV::File* riff_wav = dynamic_cast<RIFF::WAV::File*>(f.file()) )
+ WriteMetaToId3v2( riff_wav->tag(), p_item );
+ }
+#endif
else if( TrueAudio::File* trueaudio = dynamic_cast<TrueAudio::File*>(f.file()) )
{
if( trueaudio->ID3v2Tag() )