Commit 9a00da44 authored by Pierre's avatar Pierre

meta: Make vlc_meta_t an opaque structure and move a bunch of static inline...

meta: Make vlc_meta_t an opaque structure and move a bunch of static inline function to their private .c files.
parent b25b7890
/*****************************************************************************
* vlc_decrapifier.h: Modules supposed to filter out bad meta or file names.
*****************************************************************************
* Copyright (C) 2009 Rémi Denis-Courmont
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef VLC_DECRAPIFIER_H
#define VLC_DECRAPIFIER_H 1
typedef struct decrapifier_t
{
VLC_COMMON_MEMBERS
input_item_t *p_item;
} decrapifier_t;
#endif
......@@ -45,30 +45,30 @@
static inline void vlc_audio_replay_gain_MergeFromMeta( audio_replay_gain_t *p_dst,
const vlc_meta_t *p_meta )
{
char * psz_value;
const char * psz_value;
if( !p_meta )
return;
if( (psz_value = (char *)vlc_dictionary_value_for_key( &p_meta->extra_tags, "REPLAYGAIN_TRACK_GAIN" )) ||
(psz_value = (char *)vlc_dictionary_value_for_key( &p_meta->extra_tags, "RG_RADIO" )) )
if( (psz_value = vlc_meta_GetExtra(p_meta, "REPLAYGAIN_TRACK_GAIN")) ||
(psz_value = vlc_meta_GetExtra(p_meta, "RG_RADIO")) )
{
p_dst->pb_gain[AUDIO_REPLAY_GAIN_TRACK] = true;
p_dst->pf_gain[AUDIO_REPLAY_GAIN_TRACK] = atof( psz_value );
}
else if( (psz_value = (char *)vlc_dictionary_value_for_key( &p_meta->extra_tags, "REPLAYGAIN_TRACK_PEAK" )) ||
(psz_value = (char *)vlc_dictionary_value_for_key( &p_meta->extra_tags, "RG_PEAK" )) )
else if( (psz_value = vlc_meta_GetExtra(p_meta, "REPLAYGAIN_TRACK_PEAK" )) ||
(psz_value = vlc_meta_GetExtra(p_meta, "RG_PEAK" )) )
{
p_dst->pb_peak[AUDIO_REPLAY_GAIN_TRACK] = true;
p_dst->pf_peak[AUDIO_REPLAY_GAIN_TRACK] = atof( psz_value );
}
else if( (psz_value = (char *)vlc_dictionary_value_for_key( &p_meta->extra_tags, "REPLAYGAIN_ALBUM_GAIN" )) ||
(psz_value = (char *)vlc_dictionary_value_for_key( &p_meta->extra_tags, "RG_AUDIOPHILE" )) )
else if( (psz_value = vlc_meta_GetExtra(p_meta, "REPLAYGAIN_ALBUM_GAIN" )) ||
(psz_value = vlc_meta_GetExtra(p_meta, "RG_AUDIOPHILE" )) )
{
p_dst->pb_gain[AUDIO_REPLAY_GAIN_ALBUM] = true;
p_dst->pf_gain[AUDIO_REPLAY_GAIN_ALBUM] = atof( psz_value );
}
else if( (psz_value = (char *)vlc_dictionary_value_for_key( &p_meta->extra_tags, "REPLAYGAIN_ALBUM_PEAK" )) )
else if( (psz_value = vlc_meta_GetExtra(p_meta, "REPLAYGAIN_ALBUM_PEAK" )) )
{
p_dst->pb_peak[AUDIO_REPLAY_GAIN_ALBUM] = true;
p_dst->pf_peak[AUDIO_REPLAY_GAIN_ALBUM] = atof( psz_value );
......
......@@ -30,8 +30,6 @@
*
*/
#include <vlc_arrays.h>
typedef enum vlc_meta_type_t
{
vlc_meta_Title,
......@@ -55,23 +53,59 @@ typedef enum vlc_meta_type_t
#define VLC_META_TYPE_COUNT 17
/* Returns a localizes string describing the meta */
VLC_EXPORT(const char *, input_MetaTypeToLocalizedString, ( vlc_meta_type_t meta_type ) );
typedef enum vlc_meta_status_e {
ITEM_PREPARSED = 1,
ITEM_ARTURL_FETCHED = 2,
ITEM_ART_FETCHED = 4,
ITEM_ART_NOTFOUND = 8
} vlc_meta_status_e;
#define ITEM_PREPARSED 0x01
#define ITEM_ARTURL_FETCHED 0x02
#define ITEM_ART_FETCHED 0x04
#define ITEM_ART_NOTFOUND 0x08
/**
* Basic function to deal with meta
*/
struct vlc_meta_t;
struct vlc_meta_t
{
char * ppsz_meta[VLC_META_TYPE_COUNT];
VLC_EXPORT(vlc_meta_t *, vlc_meta_New, ( void ));
VLC_EXPORT(void, vlc_meta_Delete, ( vlc_meta_t *m ));
VLC_EXPORT(void, vlc_meta_Set, ( vlc_meta_t *p_meta, vlc_meta_type_t meta_type, const char *psz_val ));
VLC_EXPORT(const char *, vlc_meta_Get, ( const vlc_meta_t *p_meta, vlc_meta_type_t meta_type ));
vlc_dictionary_t extra_tags;
VLC_EXPORT(void, vlc_meta_AddExtra, ( vlc_meta_t *m, const char *psz_name, const char *psz_value ));
VLC_EXPORT(const char *, vlc_meta_GetExtra, ( const vlc_meta_t *m, const char *psz_name ));
VLC_EXPORT(unsigned, vlc_meta_GetExtraCount, ( const vlc_meta_t *m ));
/**
* Allocate a copy of all extra meta names and a table with it.
* Be sure to free both the returned pointers and its name.
*/
VLC_EXPORT(char **, vlc_meta_CopyExtraNames, ( const vlc_meta_t *m ));
int i_status;
VLC_EXPORT(void, vlc_meta_Merge, ( vlc_meta_t *dst, const vlc_meta_t *src ));
VLC_EXPORT(vlc_meta_status_e, vlc_meta_GetStatus, ( vlc_meta_t *m ));
VLC_EXPORT(void, vlc_meta_SetStatus, ( vlc_meta_t *m, vlc_meta_status_e status ));
/**
* Returns a localizes string describing the meta
*/
VLC_EXPORT(const char *, vlc_meta_TypeToLocalizedString, ( vlc_meta_type_t meta_type ) );
enum {
ALBUM_ART_WHEN_ASKED,
ALBUM_ART_WHEN_PLAYED,
ALBUM_ART_ALL
};
typedef struct meta_export_t
{
VLC_COMMON_MEMBERS
input_item_t *p_item;
const char *psz_file;
} meta_export_t;
VLC_EXPORT( int, input_item_WriteMeta, (vlc_object_t *, input_item_t *) );
/* Setters for meta.
* Warning: Make sure to use the input_item meta setters (defined in vlc_input.h)
* instead of those one. */
......@@ -93,115 +127,23 @@ struct vlc_meta_t
#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 )
/* Free a dictonary key allocated by strdup() in vlc_meta_AddExtra() */
static inline void vlc_meta_FreeExtraKey( void *p_data, void *p_obj )
{
VLC_UNUSED( p_obj );
free( p_data );
}
static inline void vlc_meta_Set( vlc_meta_t *p_meta, vlc_meta_type_t meta_type, const char *psz_val )
{
free( p_meta->ppsz_meta[meta_type] );
p_meta->ppsz_meta[meta_type] = psz_val ? strdup( psz_val ) : NULL;
}
#define VLC_META_TITLE vlc_meta_TypeToLocalizedString( vlc_meta_Title )
#define VLC_META_ARTIST vlc_meta_TypeToLocalizedString( vlc_meta_Artist )
#define VLC_META_GENRE vlc_meta_TypeToLocalizedString( vlc_meta_Genre )
#define VLC_META_COPYRIGHT vlc_meta_TypeToLocalizedString( vlc_meta_Copyright )
#define VLC_META_ALBUM vlc_meta_TypeToLocalizedString( vlc_meta_Album )
#define VLC_META_TRACK_NUMBER vlc_meta_TypeToLocalizedString( vlc_meta_TrackNumber )
#define VLC_META_DESCRIPTION vlc_meta_TypeToLocalizedString( vlc_meta_Description )
#define VLC_META_RATING vlc_meta_TypeToLocalizedString( vlc_meta_Rating )
#define VLC_META_DATE vlc_meta_TypeToLocalizedString( vlc_meta_Date )
#define VLC_META_SETTING vlc_meta_TypeToLocalizedString( vlc_meta_Setting )
#define VLC_META_URL vlc_meta_TypeToLocalizedString( vlc_meta_URL )
#define VLC_META_LANGUAGE vlc_meta_TypeToLocalizedString( vlc_meta_Language )
#define VLC_META_NOW_PLAYING vlc_meta_TypeToLocalizedString( vlc_meta_NowPlaying )
#define VLC_META_PUBLISHER vlc_meta_TypeToLocalizedString( vlc_meta_Publisher )
#define VLC_META_ENCODED_BY vlc_meta_TypeToLocalizedString( vlc_meta_EncodedBy )
#define VLC_META_ART_URL vlc_meta_TypeToLocalizedString( vlc_meta_ArtworkURL )
#define VLC_META_TRACKID vlc_meta_TypeToLocalizedString( vlc_meta_TrackID )
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(*m) );
if( !m )
return NULL;
memset( m->ppsz_meta, 0, sizeof(m->ppsz_meta) );
m->i_status = 0;
vlc_dictionary_init( &m->extra_tags, 0 );
return m;
}
static inline void vlc_meta_Delete( vlc_meta_t *m )
{
int i;
for( i = 0; i < VLC_META_TYPE_COUNT ; i++ )
free( m->ppsz_meta[i] );
vlc_dictionary_clear( &m->extra_tags, vlc_meta_FreeExtraKey, NULL );
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 );
if( psz_oldvalue != kVLCDictionaryNotFound )
vlc_dictionary_remove_value_for_key( &m->extra_tags, psz_name,
vlc_meta_FreeExtraKey, NULL );
vlc_dictionary_insert( &m->extra_tags, psz_name, strdup(psz_value) );
}
static inline void vlc_meta_Merge( vlc_meta_t *dst, const vlc_meta_t *src )
{
char **ppsz_all_keys;
int i;
if( !dst || !src )
return;
for( i = 0; i < VLC_META_TYPE_COUNT; i++ )
{
if( src->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 && ppsz_all_keys[i]; i++ )
{
/* Always try to remove the previous value */
vlc_dictionary_remove_value_for_key( &dst->extra_tags, ppsz_all_keys[i], vlc_meta_FreeExtraKey, NULL );
void *p_value = vlc_dictionary_value_for_key( &src->extra_tags, ppsz_all_keys[i] );
vlc_dictionary_insert( &dst->extra_tags, ppsz_all_keys[i], strdup( (const char*)p_value ) );
free( ppsz_all_keys[i] );
}
free( ppsz_all_keys );
}
#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_ALBUM input_MetaTypeToLocalizedString( vlc_meta_Album )
#define VLC_META_TRACK_NUMBER 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_TRACKID input_MetaTypeToLocalizedString( vlc_meta_TrackID )
enum {
ALBUM_ART_WHEN_ASKED,
ALBUM_ART_WHEN_PLAYED,
ALBUM_ART_ALL
};
typedef struct meta_export_t
{
VLC_COMMON_MEMBERS
input_item_t *p_item;
const char *psz_file;
} meta_export_t;
VLC_EXPORT( int, input_item_WriteMeta, (vlc_object_t *, input_item_t *) );
#endif
......@@ -1169,7 +1169,7 @@ static void EsOutProgramMeta( es_out_t *out, int i_group, const vlc_meta_t *p_me
if( !vlc_meta_Get( p_meta, vlc_meta_Title) &&
!vlc_meta_Get( p_meta, vlc_meta_NowPlaying) &&
!vlc_meta_Get( p_meta, vlc_meta_Publisher) &&
vlc_dictionary_keys_count( &p_meta->extra_tags ) <= 0 )
vlc_meta_GetExtraCount( p_meta ) <= 0 )
{
return;
}
......@@ -1227,15 +1227,14 @@ static void EsOutProgramMeta( es_out_t *out, int i_group, const vlc_meta_t *p_me
input_item_SetPublisher( p_input->p->p_item, psz_provider );
input_SendEventMeta( p_input );
}
input_Control( p_input, INPUT_ADD_INFO, psz_cat, input_MetaTypeToLocalizedString(vlc_meta_Publisher), psz_provider );
input_Control( p_input, INPUT_ADD_INFO, psz_cat, vlc_meta_TypeToLocalizedString(vlc_meta_Publisher), psz_provider );
}
char ** ppsz_all_keys = vlc_dictionary_all_keys( &p_meta->extra_tags );
char ** ppsz_all_keys = vlc_meta_CopyExtraNames(p_meta );
for( i = 0; ppsz_all_keys[i]; i++ )
{
input_Control( p_input, INPUT_ADD_INFO, psz_cat,
vlc_gettext(ppsz_all_keys[i]),
vlc_dictionary_value_for_key( &p_meta->extra_tags,
ppsz_all_keys[i] ) );
vlc_meta_GetExtra( &p_meta, ppsz_all_keys[i] ) );
free( ppsz_all_keys[i] );
}
free( ppsz_all_keys );
......@@ -1296,13 +1295,13 @@ static void EsOutProgramEpg( es_out_t *out, int i_group, const vlc_epg_t *p_epg
if( p_pgrm->psz_now_playing )
{
input_Control( p_input, INPUT_ADD_INFO, psz_cat,
input_MetaTypeToLocalizedString(vlc_meta_NowPlaying),
vlc_meta_TypeToLocalizedString(vlc_meta_NowPlaying),
p_pgrm->psz_now_playing );
}
else
{
input_Control( p_input, INPUT_DEL_INFO, psz_cat,
input_MetaTypeToLocalizedString(vlc_meta_NowPlaying) );
vlc_meta_TypeToLocalizedString(vlc_meta_NowPlaying) );
}
free( psz_cat );
......@@ -2871,11 +2870,11 @@ static void EsOutUpdateInfo( es_out_t *out, es_out_id_t *es, const es_format_t *
/* Append generic meta */
if( p_meta )
{
char **ppsz_all_keys = vlc_dictionary_all_keys( &p_meta->extra_tags );
char **ppsz_all_keys = vlc_meta_CopyExtraNames( p_meta );
for( int i = 0; ppsz_all_keys && ppsz_all_keys[i]; i++ )
{
char *psz_key = ppsz_all_keys[i];
char *psz_value = vlc_dictionary_value_for_key( &p_meta->extra_tags, psz_key );
char *psz_value = vlc_meta_GetExtra( p_meta, psz_key );
if( psz_value )
input_Control( p_input, INPUT_ADD_INFO, psz_cat,
......
......@@ -151,14 +151,15 @@ void input_item_SetPreparsed( input_item_t *p_i, bool b_preparsed )
if( !p_i->p_meta )
p_i->p_meta = vlc_meta_New();
int i_new_status;
int status = vlc_meta_GetStatus(p_i->p_meta);
int new_status;
if( b_preparsed )
i_new_status = p_i->p_meta->i_status | ITEM_PREPARSED;
new_status = status | ITEM_PREPARSED;
else
i_new_status = p_i->p_meta->i_status & ~ITEM_PREPARSED;
if( p_i->p_meta->i_status != i_new_status )
new_status = status & ~ITEM_PREPARSED;
if( status != new_status )
{
p_i->p_meta->i_status = i_new_status;
vlc_meta_SetStatus(p_i->p_meta, new_status);
b_send_event = true;
}
......@@ -168,10 +169,11 @@ void input_item_SetPreparsed( input_item_t *p_i, bool b_preparsed )
{
vlc_event_t event;
event.type = vlc_InputItemPreparsedChanged;
event.u.input_item_preparsed_changed.new_status = i_new_status;
event.u.input_item_preparsed_changed.new_status = new_status;
vlc_event_send( &p_i->event_manager, &event );
}
}
void input_item_SetArtNotFound( input_item_t *p_i, bool b_not_found )
{
vlc_mutex_lock( &p_i->lock );
......@@ -179,13 +181,18 @@ void input_item_SetArtNotFound( input_item_t *p_i, bool b_not_found )
if( !p_i->p_meta )
p_i->p_meta = vlc_meta_New();
int status = vlc_meta_GetStatus(p_i->p_meta);
if( b_not_found )
p_i->p_meta->i_status |= ITEM_ART_NOTFOUND;
status |= ITEM_ART_NOTFOUND;
else
p_i->p_meta->i_status &= ~ITEM_ART_NOTFOUND;
status &= ~ITEM_ART_NOTFOUND;
vlc_meta_SetStatus(p_i->p_meta, status);
vlc_mutex_unlock( &p_i->lock );
}
void input_item_SetArtFetched( input_item_t *p_i, bool b_art_fetched )
{
vlc_mutex_lock( &p_i->lock );
......@@ -193,10 +200,14 @@ void input_item_SetArtFetched( input_item_t *p_i, bool b_art_fetched )
if( !p_i->p_meta )
p_i->p_meta = vlc_meta_New();
int status = vlc_meta_GetStatus(p_i->p_meta);
if( b_art_fetched )
p_i->p_meta->i_status |= ITEM_ART_FETCHED;
status |= ITEM_ART_FETCHED;
else
p_i->p_meta->i_status &= ~ITEM_ART_FETCHED;
status &= ~ITEM_ART_FETCHED;
vlc_meta_SetStatus(p_i->p_meta, status);
vlc_mutex_unlock( &p_i->lock );
}
......@@ -454,7 +465,7 @@ void input_item_SetDuration( input_item_t *p_i, mtime_t i_duration )
bool input_item_IsPreparsed( input_item_t *p_item )
{
vlc_mutex_lock( &p_item->lock );
bool b_preparsed = p_item->p_meta ? ( p_item->p_meta->i_status & ITEM_PREPARSED ) != 0 : false;
bool b_preparsed = p_item->p_meta ? ( vlc_meta_GetStatus(p_item->p_meta) & ITEM_PREPARSED ) != 0 : false;
vlc_mutex_unlock( &p_item->lock );
return b_preparsed;
......@@ -463,7 +474,7 @@ bool input_item_IsPreparsed( input_item_t *p_item )
bool input_item_IsArtFetched( input_item_t *p_item )
{
vlc_mutex_lock( &p_item->lock );
bool b_fetched = p_item->p_meta ? ( p_item->p_meta->i_status & ITEM_ART_FETCHED ) != 0 : false;
bool b_fetched = p_item->p_meta ? ( vlc_meta_GetStatus(p_item->p_meta) & ITEM_ART_FETCHED ) != 0 : false;
vlc_mutex_unlock( &p_item->lock );
return b_fetched;
......
......@@ -29,12 +29,22 @@
#include <vlc_common.h>
#include <vlc_playlist.h>
#include <vlc_url.h>
#include <vlc_arrays.h>
#include "input_internal.h"
#include "../playlist/art.h"
struct vlc_meta_t
{
char * ppsz_meta[VLC_META_TYPE_COUNT];
vlc_dictionary_t extra_tags;
int i_status;
};
/* FIXME bad name convention */
const char * input_MetaTypeToLocalizedString( vlc_meta_type_t meta_type )
const char * vlc_meta_TypeToLocalizedString( vlc_meta_type_t meta_type )
{
switch( meta_type )
{
......@@ -60,6 +70,128 @@ const char * input_MetaTypeToLocalizedString( vlc_meta_type_t meta_type )
}
};
/**
* vlc_meta contructor.
* vlc_meta_Delete() will free the returned pointer.
*/
vlc_meta_t *vlc_meta_New( void )
{
vlc_meta_t *m = (vlc_meta_t*)malloc( sizeof(*m) );
if( !m )
return NULL;
memset( m->ppsz_meta, 0, sizeof(m->ppsz_meta) );
m->i_status = 0;
vlc_dictionary_init( &m->extra_tags, 0 );
return m;
}
/* Free a dictonary key allocated by strdup() in vlc_meta_AddExtra() */
static void vlc_meta_FreeExtraKey( void *p_data, void *p_obj )
{
VLC_UNUSED( p_obj );
free( p_data );
}
void vlc_meta_Delete( vlc_meta_t *m )
{
int i;
for( i = 0; i < VLC_META_TYPE_COUNT ; i++ )
free( m->ppsz_meta[i] );
vlc_dictionary_clear( &m->extra_tags, vlc_meta_FreeExtraKey, NULL );
free( m );
}
/**
* vlc_meta has two kinds of meta, the one in a table, and the one in a
* dictionary.
* FIXME - Why don't we merge those two?
*/
void vlc_meta_Set( vlc_meta_t *p_meta, vlc_meta_type_t meta_type, const char *psz_val )
{
free( p_meta->ppsz_meta[meta_type] );
p_meta->ppsz_meta[meta_type] = psz_val ? strdup( psz_val ) : NULL;
}
const char *vlc_meta_Get( const vlc_meta_t *p_meta, vlc_meta_type_t meta_type )
{
return p_meta->ppsz_meta[meta_type];
}
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 );
if( psz_oldvalue != kVLCDictionaryNotFound )
vlc_dictionary_remove_value_for_key( &m->extra_tags, psz_name,
vlc_meta_FreeExtraKey, NULL );
vlc_dictionary_insert( &m->extra_tags, psz_name, strdup(psz_value) );
}
const char * vlc_meta_GetExtra( const vlc_meta_t *m, const char *psz_name )
{
return (char *)vlc_dictionary_value_for_key(&m->extra_tags, psz_name);
}
unsigned vlc_meta_GetExtraCount( const vlc_meta_t *m )
{
return vlc_dictionary_keys_count(&m->extra_tags);
}
char** vlc_meta_CopyExtraNames( const vlc_meta_t *m )
{
return vlc_dictionary_all_keys(&m->extra_tags);
}
/**
* vlc_meta status (see vlc_meta_status_e)
*/
vlc_meta_status_e vlc_meta_GetStatus( vlc_meta_t *m )
{
return m->i_status;
}
void vlc_meta_SetStatus( vlc_meta_t *m, vlc_meta_status_e status )
{
m->i_status = status;
}
/**
* Merging meta
*/
void vlc_meta_Merge( vlc_meta_t *dst, const vlc_meta_t *src )
{
char **ppsz_all_keys;
int i;
if( !dst || !src )
return;
for( i = 0; i < VLC_META_TYPE_COUNT; i++ )
{
if( src->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 && ppsz_all_keys[i]; i++ )
{
/* Always try to remove the previous value */
vlc_dictionary_remove_value_for_key( &dst->extra_tags, ppsz_all_keys[i], vlc_meta_FreeExtraKey, NULL );
void *p_value = vlc_dictionary_value_for_key( &src->extra_tags, ppsz_all_keys[i] );
vlc_dictionary_insert( &dst->extra_tags, ppsz_all_keys[i], strdup( (const char*)p_value ) );
free( ppsz_all_keys[i] );
}
free( ppsz_all_keys );
}
void input_ExtractAttachmentAndCacheArt( input_thread_t *p_input )
{
input_item_t *p_item = p_input->p->p_item;
......
......@@ -205,7 +205,6 @@ input_item_SetMeta
input_item_SetName
input_item_SetURI
input_item_WriteMeta
input_MetaTypeToLocalizedString
__input_Read
input_resource_Delete
input_SplitMRL
......@@ -510,6 +509,16 @@ __vlc_list_children
vlc_list_release
vlc_memcpy
vlc_memset
vlc_meta_AddExtra
vlc_meta_CopyExtraNames
vlc_meta_Delete
vlc_meta_Get
vlc_meta_GetExtra
vlc_meta_GetExtraCount
vlc_meta_Merge
vlc_meta_New
vlc_meta_Set
vlc_meta_TypeToLocalizedString
vlc_mutex_destroy
vlc_mutex_init
vlc_mutex_init_recursive
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment