Commit 51880eb1 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

* Protect input item's meta through setters and getters. That allows tracking...

* Protect input item's meta through setters and getters. That allows tracking of input item meta info changes.
* vlc_meta_t gains a table for accessing its non-extra meta.
parent 060d116f
......@@ -79,8 +79,8 @@ struct input_item_t
int i_nb_played; /**< Number of times played */
vlc_meta_t *p_meta;
vlc_mutex_t lock; /**< Lock for the item */
vlc_mutex_t lock; /**< Lock for the item */
};
#define ITEM_TYPE_UNKNOWN 0
......@@ -185,6 +185,132 @@ static inline void input_ItemClean( input_item_t *p_i )
vlc_mutex_destroy( &p_i->lock );
}
static inline void input_item_SetMeta( input_item_t *p_i, vlc_meta_type_t meta_type, const char *psz_val )
{
if( !p_i->p_meta )
p_i->p_meta = vlc_meta_New();
vlc_meta_Set( p_i->p_meta, meta_type, psz_val );
}
static inline const char * input_item_GetMeta( input_item_t *p_i, vlc_meta_type_t meta_type )
{
if( !p_i->p_meta )
return NULL;
return vlc_meta_Get( p_i->p_meta, meta_type );
}
static inline void input_item_SetPreparsed( input_item_t *p_i, vlc_bool_t preparsed )
{
if( !p_i->p_meta )
p_i->p_meta = vlc_meta_New();
if( preparsed )
p_i->p_meta->i_status |= ITEM_PREPARSED;
else
p_i->p_meta->i_status &= ~ITEM_PREPARSED;
}
static inline vlc_bool_t input_item_IsPreparsed( input_item_t *p_i )
{
return p_i->p_meta ? p_i->p_meta->i_status & ITEM_PREPARSED : VLC_FALSE ;
}
static inline void input_item_SetMetaFetched( input_item_t *p_i, vlc_bool_t metafetched )
{
if( !p_i->p_meta )
p_i->p_meta = vlc_meta_New();
if( metafetched )
p_i->p_meta->i_status |= ITEM_META_FETCHED;
else
p_i->p_meta->i_status &= ~ITEM_META_FETCHED;
}
static inline vlc_bool_t input_item_IsMetaFetched( input_item_t *p_i )
{
return p_i->p_meta ? p_i->p_meta->i_status & ITEM_META_FETCHED : VLC_FALSE ;
}
static inline void input_item_SetArtNotFound( input_item_t *p_i, vlc_bool_t notfound )
{
if( !p_i->p_meta )
p_i->p_meta = vlc_meta_New();
if( notfound )
p_i->p_meta->i_status |= ITEM_ART_NOTFOUND;
else
p_i->p_meta->i_status &= ~ITEM_ART_NOTFOUND;
}
static inline void input_item_SetArtFetched( input_item_t *p_i, vlc_bool_t artfetched )
{
if( !p_i->p_meta )
p_i->p_meta = vlc_meta_New();
if( artfetched )
p_i->p_meta->i_status |= ITEM_ART_FETCHED;
else
p_i->p_meta->i_status &= ~ITEM_ART_FETCHED;
}
static inline vlc_bool_t input_item_IsArtFetched( input_item_t *p_i )
{
return p_i->p_meta ? p_i->p_meta->i_status & ITEM_ART_FETCHED : VLC_FALSE ;
}
static inline const vlc_meta_t * input_item_GetMetaObject( input_item_t *p_i )
{
if( !p_i->p_meta )
p_i->p_meta = vlc_meta_New();
return p_i->p_meta;
}
static inline void input_item_MetaMerge( input_item_t *p_i, const vlc_meta_t * p_new_meta )
{
if( !p_i->p_meta )
p_i->p_meta = vlc_meta_New();
vlc_meta_Merge( p_i->p_meta, p_new_meta );
}
#define input_item_SetTitle( item, b ) input_item_SetMeta( item, vlc_meta_Title, b )
#define input_item_SetArtist( item, b ) input_item_SetMeta( item, vlc_meta_Artist, b )
#define input_item_SetGenre( item, b ) input_item_SetMeta( item, vlc_meta_Genre, b )
#define input_item_SetCopyright( item, b ) input_item_SetMeta( item, vlc_meta_Copyright, b )
#define input_item_SetAlbum( item, b ) input_item_SetMeta( item, vlc_meta_Album, b )
#define input_item_SetTrackNum( item, b ) input_item_SetMeta( item, vlc_meta_TrackNumber, b )
#define input_item_SetDescription( item, b ) input_item_SetMeta( item, vlc_meta_Description, b )
#define input_item_SetRating( item, b ) input_item_SetMeta( item, vlc_meta_Rating, b )
#define input_item_SetDate( item, b ) input_item_SetMeta( item, vlc_meta_Date, b )
#define input_item_SetSetting( item, b ) input_item_SetMeta( item, vlc_meta_Setting, b )
#define input_item_SetURL( item, b ) input_item_SetMeta( item, vlc_meta_URL, b )
#define input_item_SetLanguage( item, b ) input_item_SetMeta( item, vlc_meta_Language, b )
#define input_item_SetNowPlaying( item, b ) input_item_SetMeta( item, vlc_meta_NowPlaying, b )
#define input_item_SetPublisher( item, b ) input_item_SetMeta( item, vlc_meta_Publisher, b )
#define input_item_SetEncodedBy( item, b ) input_item_SetMeta( item, vlc_meta_EncodedBy, b )
#define input_item_SetArtURL( item, b ) input_item_SetMeta( item, vlc_meta_ArtworkURL, b )
#define input_item_SetTrackID( item, b ) input_item_SetMeta( item, vlc_meta_TrackID, b )
#define input_item_GetTitle( item ) input_item_GetMeta( item, vlc_meta_Title )
#define input_item_GetArtist( item ) input_item_GetMeta( item, vlc_meta_Artist )
#define input_item_GetGenre( item ) input_item_GetMeta( item, vlc_meta_Genre )
#define input_item_GetCopyright( item ) input_item_GetMeta( item, vlc_meta_Copyright )
#define input_item_GetAlbum( item ) input_item_GetMeta( item, vlc_meta_Album )
#define input_item_GetTrackNum( item ) input_item_GetMeta( item, vlc_meta_TrackNumber )
#define input_item_GetDescription( item ) input_item_GetMeta( item, vlc_meta_Description )
#define input_item_GetRating( item ) input_item_GetMeta( item, vlc_meta_Rating )
#define input_item_GetDate( item ) input_item_GetMeta( item, vlc_meta_Date )
#define input_item_GetGetting( item ) input_item_GetMeta( item, vlc_meta_Getting )
#define input_item_GetURL( item ) input_item_GetMeta( item, vlc_meta_URL )
#define input_item_GetLanguage( item ) input_item_GetMeta( item, vlc_meta_Language )
#define input_item_GetNowPlaying( item ) input_item_GetMeta( item, vlc_meta_NowPlaying )
#define input_item_GetPublisher( item ) input_item_GetMeta( item, vlc_meta_Publisher )
#define input_item_GetEncodedBy( item ) input_item_GetMeta( item, vlc_meta_EncodedBy )
#define input_item_GetArtURL( item ) input_item_GetMeta( item, vlc_meta_ArtworkURL )
#define input_item_GetTrackID( item ) input_item_GetMeta( item, vlc_meta_TrackID )
VLC_EXPORT( char *, input_ItemGetInfo, ( input_item_t *p_i, const char *psz_cat,const char *psz_name ) );
VLC_EXPORT(int, input_ItemAddInfo, ( input_item_t *p_i, const char *psz_cat, const char *psz_name, const char *psz_format, ... ) );
......
......@@ -30,28 +30,31 @@
#include <vlc_arrays.h>
/* VLC meta name */
#define VLC_META_INFO_CAT N_("Meta-information")
#define VLC_META_TITLE N_("Title")
#define VLC_META_ARTIST N_("Artist")
#define VLC_META_GENRE N_("Genre")
#define VLC_META_COPYRIGHT N_("Copyright")
#define VLC_META_COLLECTION N_("Album/movie/show title")
#define VLC_META_SEQ_NUM N_("Track number/position in set")
#define VLC_META_DESCRIPTION N_("Description")
#define VLC_META_RATING N_("Rating")
#define VLC_META_DATE N_("Date")
#define VLC_META_SETTING N_("Setting")
#define VLC_META_URL N_("URL")
#define VLC_META_LANGUAGE N_("Language")
#define VLC_META_NOW_PLAYING N_("Now Playing")
#define VLC_META_PUBLISHER N_("Publisher")
#define VLC_META_ENCODED_BY N_("Encoded by")
#define VLC_META_ART_URL N_("Art URL")
#define VLC_META_TYPE_COUNT 17
#define VLC_META_CODEC_NAME N_("Codec Name")
#define VLC_META_CODEC_DESCRIPTION N_("Codec Description")
typedef enum vlc_meta_type_t
{
vlc_meta_Title = 0,
vlc_meta_Artist,
vlc_meta_Genre,
vlc_meta_Copyright,
vlc_meta_Album,
vlc_meta_TrackNumber,
vlc_meta_Description,
vlc_meta_Rating,
vlc_meta_Date,
vlc_meta_Setting,
vlc_meta_URL,
vlc_meta_Language,
vlc_meta_NowPlaying,
vlc_meta_Publisher,
vlc_meta_EncodedBy,
vlc_meta_ArtworkURL,
vlc_meta_TrackID
} vlc_meta_type_t;
/* Returns a localizes string describing the meta */
VLC_EXPORT(const char *, input_MetaTypeToLocalizedString, ( vlc_meta_type_t meta_type ) );
#define ITEM_PREPARSED 0x01
#define ITEM_META_FETCHED 0x02
......@@ -61,23 +64,7 @@
struct vlc_meta_t
{
char *psz_title;
char *psz_artist;
char *psz_genre;
char *psz_copyright;
char *psz_album;
char *psz_tracknum;
char *psz_description;
char *psz_rating;
char *psz_date;
char *psz_setting;
char *psz_url;
char *psz_language;
char *psz_nowplaying;
char *psz_publisher;
char *psz_encodedby;
char *psz_arturl;
char *psz_trackid;
char * ppsz_meta[VLC_META_TYPE_COUNT];
vlc_dictionary_t extra_tags;
......@@ -85,51 +72,43 @@ struct vlc_meta_t
};
#define vlc_meta_Set( meta,var,val ) do { \
const char *str = val; \
if( meta->psz_##var ) free( meta->psz_##var ); \
meta->psz_##var = str ? strdup( str ) : NULL; } while(0)
#define vlc_meta_SetTitle( meta, b ) vlc_meta_Set( meta, title, b )
#define vlc_meta_SetArtist( meta, b ) vlc_meta_Set( meta, artist, b )
#define vlc_meta_SetGenre( meta, b ) vlc_meta_Set( meta, genre, b )
#define vlc_meta_SetCopyright( meta, b ) vlc_meta_Set( meta, copyright, b )
#define vlc_meta_SetAlbum( meta, b ) vlc_meta_Set( meta, album, b )
#define vlc_meta_SetTracknum( meta, b ) vlc_meta_Set( meta, tracknum, b )
#define vlc_meta_SetDescription( meta, b ) vlc_meta_Set( meta, description, b )
#define vlc_meta_SetRating( meta, b ) vlc_meta_Set( meta, rating, b )
#define vlc_meta_SetDate( meta, b ) vlc_meta_Set( meta, date, b )
#define vlc_meta_SetSetting( meta, b ) vlc_meta_Set( meta, setting, b )
#define vlc_meta_SetURL( meta, b ) vlc_meta_Set( meta, url, b )
#define vlc_meta_SetLanguage( meta, b ) vlc_meta_Set( meta, language, b )
#define vlc_meta_SetNowPlaying( meta, b ) vlc_meta_Set( meta, nowplaying, b )
#define vlc_meta_SetPublisher( meta, b ) vlc_meta_Set( meta, publisher, b )
#define vlc_meta_SetEncodedBy( meta, b ) vlc_meta_Set( meta, encodedby, b )
#define vlc_meta_SetArtURL( meta, b ) vlc_meta_Set( meta, arturl, b )
#define vlc_meta_SetTrackID( meta, b ) vlc_meta_Set( meta, trackid, b )
/* Setters for meta.
* Warning: Make sure to use the input_item meta setters (defined in vlc_input.h)
* instead of those one. */
#define vlc_meta_SetTitle( meta, b ) vlc_meta_Set( meta, vlc_meta_Title, b )
#define vlc_meta_SetArtist( meta, b ) vlc_meta_Set( meta, vlc_meta_Artist, b )
#define vlc_meta_SetGenre( meta, b ) vlc_meta_Set( meta, vlc_meta_Genre, b )
#define vlc_meta_SetCopyright( meta, b ) vlc_meta_Set( meta, vlc_meta_Copyright, b )
#define vlc_meta_SetAlbum( meta, b ) vlc_meta_Set( meta, vlc_meta_Album, b )
#define vlc_meta_SetTracknum( meta, b ) vlc_meta_Set( meta, vlc_meta_TrackNumber, b )
#define vlc_meta_SetDescription( meta, b ) vlc_meta_Set( meta, vlc_meta_Description, b )
#define vlc_meta_SetRating( meta, b ) vlc_meta_Set( meta, vlc_meta_Rating, b )
#define vlc_meta_SetDate( meta, b ) vlc_meta_Set( meta, vlc_meta_Date, b )
#define vlc_meta_SetSetting( meta, b ) vlc_meta_Set( meta, vlc_meta_Setting, b )
#define vlc_meta_SetURL( meta, b ) vlc_meta_Set( meta, vlc_meta_URL, b )
#define vlc_meta_SetLanguage( meta, b ) vlc_meta_Set( meta, vlc_meta_Language, b )
#define vlc_meta_SetNowPlaying( meta, b ) vlc_meta_Set( meta, vlc_meta_NowPlaying, b )
#define vlc_meta_SetPublisher( meta, b ) vlc_meta_Set( meta, vlc_meta_Publisher, b )
#define vlc_meta_SetEncodedBy( meta, b ) vlc_meta_Set( meta, vlc_meta_EncodedBy, b )
#define vlc_meta_SetArtURL( meta, b ) vlc_meta_Set( meta, vlc_meta_ArtworkURL, b )
#define vlc_meta_SetTrackID( meta, b ) vlc_meta_Set( meta, vlc_meta_TrackID, b )
static inline void vlc_meta_Set( vlc_meta_t * p_meta, vlc_meta_type_t meta_type, const char * psz_val )
{
if( p_meta->ppsz_meta[meta_type] ) free( p_meta->ppsz_meta[meta_type] );
p_meta->ppsz_meta[meta_type] = psz_val ? strdup( psz_val ) : NULL;
}
static inline const char * vlc_meta_Get( const vlc_meta_t * p_meta, vlc_meta_type_t meta_type )
{
return p_meta->ppsz_meta[meta_type];
}
static inline vlc_meta_t *vlc_meta_New( void )
{
vlc_meta_t *m = (vlc_meta_t*)malloc( sizeof( vlc_meta_t ) );
if( !m ) return NULL;
m->psz_title = NULL;
m->psz_artist = NULL;
m->psz_genre = NULL;
m->psz_copyright = NULL;
m->psz_album = NULL;
m->psz_tracknum = NULL;
m->psz_description = NULL;
m->psz_rating = NULL;
m->psz_date = NULL;
m->psz_setting = NULL;
m->psz_url = NULL;
m->psz_language = NULL;
m->psz_nowplaying = NULL;
m->psz_publisher = NULL;
m->psz_encodedby = NULL;
m->psz_arturl = NULL;
m->psz_trackid = NULL;
memset( m->ppsz_meta, 0, sizeof(m->ppsz_meta) );
m->i_status = 0;
vlc_dictionary_init( &m->extra_tags, 0 );
return m;
......@@ -137,26 +116,13 @@ static inline vlc_meta_t *vlc_meta_New( void )
static inline void vlc_meta_Delete( vlc_meta_t *m )
{
free( m->psz_title );
free( m->psz_artist );
free( m->psz_genre );
free( m->psz_copyright );
free( m->psz_album );
free( m->psz_tracknum );
free( m->psz_description );
free( m->psz_rating );
free( m->psz_date );
free( m->psz_setting );
free( m->psz_url );
free( m->psz_language );
free( m->psz_nowplaying );
free( m->psz_publisher );
free( m->psz_encodedby );
free( m->psz_trackid );
free( m->psz_arturl );
int i;
for( i = 0; i < 0; i++ )
free( m->ppsz_meta[i] );
vlc_dictionary_clear( &m->extra_tags );
free( m );
}
static inline void vlc_meta_AddExtra( vlc_meta_t *m, const char *psz_name, const char *psz_value )
{
char * psz_oldvalue = (char *)vlc_dictionary_value_for_key( &m->extra_tags, psz_name );
......@@ -170,32 +136,20 @@ static inline void vlc_meta_AddExtra( vlc_meta_t *m, const char *psz_name, const
static inline void vlc_meta_Merge( vlc_meta_t *dst, const vlc_meta_t *src )
{
if( !dst || !src ) return;
#define COPY_FIELD( a ) \
if( src->psz_ ## a ) { \
if( dst->psz_ ## a ) free( dst->psz_## a ); \
dst->psz_##a = strdup( src->psz_##a ); \
}
COPY_FIELD( title );
COPY_FIELD( artist );
COPY_FIELD( genre );
COPY_FIELD( copyright );
COPY_FIELD( album );
COPY_FIELD( tracknum );
COPY_FIELD( description );
COPY_FIELD( rating );
COPY_FIELD( date );
COPY_FIELD( setting );
COPY_FIELD( url );
COPY_FIELD( language );
COPY_FIELD( nowplaying );
COPY_FIELD( publisher );
COPY_FIELD( encodedby );
COPY_FIELD( trackid );
COPY_FIELD( arturl );
#undef COPY_FIELD
char ** ppsz_all_keys;
int i;
if( !dst || !src ) return;
for( i = 0; i < VLC_META_TYPE_COUNT; i++ )
{
if( src->ppsz_meta[i] )
{
if( dst->ppsz_meta[i] ) free( dst->ppsz_meta[i] );
dst->ppsz_meta[i] = strdup( src->ppsz_meta[i] );
}
}
/* XXX: If speed up are needed, it is possible */
ppsz_all_keys = vlc_dictionary_all_keys( &src->extra_tags );
for( i = 0; ppsz_all_keys[i]; i++ )
......@@ -209,6 +163,27 @@ static inline void vlc_meta_Merge( vlc_meta_t *dst, const vlc_meta_t *src )
free( ppsz_all_keys );
}
/* Shortcuts for the AddInfo */
#define VLC_META_INFO_CAT N_("Meta-information")
#define VLC_META_TITLE input_MetaTypeToLocalizedString( vlc_meta_Title )
#define VLC_META_ARTIST input_MetaTypeToLocalizedString( vlc_meta_Artist )
#define VLC_META_GENRE input_MetaTypeToLocalizedString( vlc_meta_Genre )
#define VLC_META_COPYRIGHT input_MetaTypeToLocalizedString( vlc_meta_Copyright )
#define VLC_META_COLLECTION input_MetaTypeToLocalizedString( vlc_meta_Album )
#define VLC_META_SEQ_NUM input_MetaTypeToLocalizedString( vlc_meta_TrackNumber )
#define VLC_META_DESCRIPTION input_MetaTypeToLocalizedString( vlc_meta_Description )
#define VLC_META_RATING input_MetaTypeToLocalizedString( vlc_meta_Rating )
#define VLC_META_DATE input_MetaTypeToLocalizedString( vlc_meta_Date )
#define VLC_META_SETTING input_MetaTypeToLocalizedString( vlc_meta_Setting )
#define VLC_META_URL input_MetaTypeToLocalizedString( vlc_meta_URL )
#define VLC_META_LANGUAGE input_MetaTypeToLocalizedString( vlc_meta_Language )
#define VLC_META_NOW_PLAYING input_MetaTypeToLocalizedString( vlc_meta_NowPlaying )
#define VLC_META_PUBLISHER input_MetaTypeToLocalizedString( vlc_meta_Publisher )
#define VLC_META_ENCODED_BY input_MetaTypeToLocalizedString( vlc_meta_EncodedBy )
#define VLC_META_ART_URL input_MetaTypeToLocalizedString( vlc_meta_ArtworkURL )
#define VLC_META_CODEC_NAME N_("Codec Name")
#define VLC_META_CODEC_DESCRIPTION N_("Codec Description")
enum {
ALBUM_ART_WHEN_ASKED,
ALBUM_ART_WHEN_PLAYED,
......
......@@ -156,11 +156,12 @@ cddb_end: ;
}
#endif /*HAVE_LIBCDDB*/
#define add_meta_val(VLC_META, VAL) \
if ( p_cdda->p_meta && VAL) { \
/*vlc_meta_Add( p_cdda->p_meta, VLC_META, VAL );*/ \
dbg_print( INPUT_DBG_META, "field %s: %s\n", VLC_META, VAL ); \
} \
#define add_meta_val(VLC_META, VAL) \
if ( p_cdda->p_meta && VAL) { \
/*vlc_meta_Add( p_cdda->p_meta, VLC_META, VAL );*/ \
dbg_print( INPUT_DBG_META, "field %s: %s\n", \
input_MetaTypeToLocalizedString(VLC_META), VAL ); \
} \
#define add_cddb_meta(FIELD, VLC_META) \
add_meta_val(VLC_META, cddb_disc_get_##FIELD(p_cdda->cddb.disc));
......@@ -289,9 +290,9 @@ CDDAMetaInfo( access_t *p_access, track_t i_track )
psz_meta_artist = (char *)cddb_disc_get_artist(p_cdda->cddb.disc);
if ( cddb_disc_get_genre(p_cdda->cddb.disc) &&
strlen(cddb_disc_get_genre(p_cdda->cddb.disc)) )
add_cddb_meta(genre, VLC_META_GENRE);
add_cddb_meta(genre, vlc_meta_Genre);
if ( 0 != cddb_disc_get_year(p_cdda->cddb.disc))
add_cddb_meta_fmt(year, "%d", VLC_META_DATE );
add_cddb_meta_fmt(year, "%d", vlc_meta_Date );
}
else
{
......@@ -300,11 +301,11 @@ CDDAMetaInfo( access_t *p_access, track_t i_track )
{
if( cddb_track_get_title(t) != NULL && ! p_cdda->b_nav_mode )
{
add_meta_val( VLC_META_TITLE, cddb_track_get_title(t) );
add_meta_val( vlc_meta_Title, cddb_track_get_title(t) );
}
if( cddb_track_get_artist(t) != NULL )
{
add_meta_val( VLC_META_ARTIST, cddb_track_get_artist(t) );
add_meta_val( vlc_meta_Artist, cddb_track_get_artist(t) );
}
}
}
......@@ -454,14 +455,14 @@ CDDAMetaInfo( access_t *p_access, track_t i_track )
{
char *psz_name = CDDAFormatTitle( p_access, i_track ) ;
if ( !p_cdda->b_nav_mode ) {
add_meta_val( VLC_META_TITLE, psz_name );
add_meta_val( vlc_meta_Title, psz_name );
} else
{
input_Control( p_cdda->p_input, INPUT_SET_NAME, psz_name );
free(psz_name);
}
if (psz_meta_artist)
add_meta_val( VLC_META_ARTIST, psz_meta_artist );
add_meta_val( vlc_meta_Artist, psz_meta_artist );
}
}
......
......@@ -548,7 +548,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
if( (NULL != title_name) && ('\0' != title_name[0]) )
{
vlc_meta_t *p_meta = (vlc_meta_t*)va_arg( args, vlc_meta_t* );
vlc_meta_SetTitle( p_meta, title_name );
vlc_meta_Set( p_meta, vlc_meta_Title, title_name );
return VLC_SUCCESS;
}
return VLC_EGENERIC;
......
......@@ -740,11 +740,11 @@ static int Control( access_t *p_access, int i_query, va_list args )
p_meta = (vlc_meta_t*)va_arg( args, vlc_meta_t* );
if( p_sys->psz_icy_name )
vlc_meta_SetTitle( p_meta, p_sys->psz_icy_name );
vlc_meta_Set( p_meta, vlc_meta_Title, p_sys->psz_icy_name );
if( p_sys->psz_icy_genre )
vlc_meta_SetGenre( p_meta, p_sys->psz_icy_genre );
vlc_meta_Set( p_meta, vlc_meta_Genre, p_sys->psz_icy_genre );
if( p_sys->psz_icy_title )
vlc_meta_SetNowPlaying( p_meta, p_sys->psz_icy_title );
vlc_meta_Set( p_meta, vlc_meta_NowPlaying, p_sys->psz_icy_title );
break;
case ACCESS_GET_TITLE_INFO:
......
......@@ -639,8 +639,7 @@ static void ParseVorbisComments( decoder_t *p_dec )
{
if( psz_value && ( *psz_value != '\0' ) )
{
vlc_meta_SetArtist( p_item->p_meta,
psz_value );
input_item_SetArtist( p_item, psz_value );
input_ItemAddInfo( p_item,
_(VLC_META_INFO_CAT),
_(VLC_META_ARTIST),
......@@ -651,8 +650,7 @@ static void ParseVorbisComments( decoder_t *p_dec )
{
if( psz_value && ( *psz_value != '\0' ) )
{
vlc_meta_SetTitle( p_item->p_meta,
psz_value );
input_item_SetTitle( p_item, psz_value );
p_item->psz_name = strdup( psz_value );
}
}
......@@ -660,16 +658,14 @@ static void ParseVorbisComments( decoder_t *p_dec )
{
if( psz_value && ( *psz_value != '\0' ) )
{
vlc_meta_SetAlbum( p_item->p_meta,
psz_value );
input_item_SetAlbum( p_item, psz_value );
}
}
else if( !strcasecmp( psz_name, "musicbrainz_trackid" ) )
{
if( psz_value && ( *psz_value != '\0' ) )
{
vlc_meta_SetTrackID( p_item->p_meta,
psz_value );
input_item_SetTrackID( p_item, psz_value );
}
}
else if( !strcasecmp( psz_name, "REPLAYGAIN_TRACK_GAIN" ) ||
......@@ -708,16 +704,14 @@ static void ParseVorbisComments( decoder_t *p_dec )
{
if( psz_value && ( *psz_value != '\0' ) )
{
vlc_meta_SetArtistID( p_item->p_meta,
psz_value );
vlc_meta_SetArtistID( p_item, psz_value );
}
}
else if( !strcasecmp( psz_name, "musicbrainz_albumid" ) )
{
if( psz_value && ( *psz_value != '\0' ) )
{
vlc_meta_SetAlbumID( p_item->p_meta,
psz_value );
input_item_SetAlbumID( p_item, psz_value );
}
}
#endif
......
......@@ -866,7 +866,7 @@ static int TrackChange( vlc_object_t *p_this, const char *psz_var,
#define ADD_VLC_META_STRING( entry, item ) \
ADD_META( entry, DBUS_TYPE_STRING, \
p_input->p_meta->psz_##item );
input_item_Get##item( p_input );
static int GetInputMeta( input_item_t* p_input,
DBusMessageIter *args )
......@@ -889,23 +889,23 @@ static int GetInputMeta( input_item_t* p_input,
dbus_message_iter_open_container( args, DBUS_TYPE_ARRAY, "{sv}", &dict );
ADD_VLC_META_STRING( 0, title );
ADD_VLC_META_STRING( 1, artist );
ADD_VLC_META_STRING( 2, genre );
ADD_VLC_META_STRING( 3, copyright );
ADD_VLC_META_STRING( 4, album );
ADD_VLC_META_STRING( 5, tracknum );
ADD_VLC_META_STRING( 6, description );
ADD_VLC_META_STRING( 7, rating );
ADD_VLC_META_STRING( 8, date );
ADD_VLC_META_STRING( 9, setting );
ADD_VLC_META_STRING( 10, url );
ADD_VLC_META_STRING( 11, language );
ADD_VLC_META_STRING( 12, nowplaying );
ADD_VLC_META_STRING( 13, publisher );
ADD_VLC_META_STRING( 14, encodedby );
ADD_VLC_META_STRING( 15, arturl );
ADD_VLC_META_STRING( 16, trackid );
ADD_VLC_META_STRING( 0, Title );
ADD_VLC_META_STRING( 1, Artist );
ADD_VLC_META_STRING( 2, Genre );
ADD_VLC_META_STRING( 3, Copyright );
ADD_VLC_META_STRING( 4, Album );
ADD_VLC_META_STRING( 5, TrackNum );
ADD_VLC_META_STRING( 6, Description );
ADD_VLC_META_STRING( 7, Rating );
ADD_VLC_META_STRING( 8, Date );
ADD_VLC_META_STRING( 9, Setting );
ADD_VLC_META_STRING( 10, URL );
ADD_VLC_META_STRING( 11, Language );
ADD_VLC_META_STRING( 12, NowPlaying );
ADD_VLC_META_STRING( 13, Publisher );
ADD_VLC_META_STRING( 14, EncodedBy );
ADD_VLC_META_STRING( 15, ArtURL );
ADD_VLC_META_STRING( 16, TrackID );
ADD_META( 17, DBUS_TYPE_INT32, p_input->p_meta->i_status );
ADD_META( 18, DBUS_TYPE_STRING, p_input->psz_uri );
......
......@@ -179,7 +179,7 @@ static int Open( vlc_object_t * p_this )
p_sys->p_meta = vlc_meta_New();
snprintf( psz_url, sizeof(psz_url), "attachment://%s",
p_sys->attachment[p_sys->i_cover_idx]->psz_name );
vlc_meta_SetArtURL( p_sys->p_meta, psz_url );
vlc_meta_Set( p_sys->p_meta, vlc_meta_ArtworkURL, psz_url );
}
vlc_audio_replay_gain_MergeFromMeta( &p_sys->replay_gain, p_sys->p_meta );
return VLC_SUCCESS;
......@@ -566,25 +566,6 @@ static void ParseSeekTable( demux_t *p_demux, const uint8_t *p_data, int i_data,
/* TODO sort it by size and remove wrong seek entry (time not increasing) */
}
static inline void astrcat( char **ppsz_dst, const char *psz_src )
{
char *psz_old = *ppsz_dst;
if( !psz_src || !psz_src[0] )
return;
if( psz_old )
{
if( asprintf( ppsz_dst, "%s,%s", psz_old, psz_src ) == -1 )
*ppsz_dst = NULL;
free( psz_old );
}
else
{
*ppsz_dst = strdup( psz_src );
}
}
#define RM(x) do { i_data -= (x); p_data += (x); } while(0)