Commit d92fffbd authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Add flags when adding an input item option

parent de534450
......@@ -142,8 +142,16 @@ static inline void input_ItemAddSubItem( input_item_t *p_parent,
vlc_event_send( &p_parent->event_manager, &event );
}
VLC_EXPORT( void, input_ItemAddOption,( input_item_t *, const char * ) );
VLC_EXPORT( void, input_ItemAddOptionNoDup,( input_item_t *, const char * ) );
#define VLC_INPUT_OPTION_UNIQUE 0x1
#define VLC_INPUT_OPTION_TRUSTED 0x2
VLC_EXPORT( void, input_ItemAddOpt, ( input_item_t *, const char *str, unsigned flags ) );
static inline
void input_ItemAddOption (input_item_t *item, const char *str)
{
input_ItemAddOpt (item, str, VLC_INPUT_OPTION_TRUSTED);
}
static inline void input_ItemClean( input_item_t *p_i )
{
......
......@@ -342,7 +342,8 @@ void libvlc_media_descriptor_add_option(
libvlc_exception_t *p_e )
{
(void)p_e;
input_ItemAddOptionNoDup( p_md->p_input_item, ppsz_option );
input_ItemAddOpt( p_md->p_input_item, ppsz_option,
VLC_INPUT_OPTION_UNIQUE|VLC_INPUT_OPTION_TRUSTED );
}
/**************************************************************************
......
......@@ -115,33 +115,25 @@ static void input_ItemDestroy ( gc_object_t *p_this )
free( p_input );
}
void input_ItemAddOption( input_item_t *p_input,
const char *psz_option )
void input_ItemAddOpt( input_item_t *p_input, const char *psz_option,
unsigned flags )
{
if( !psz_option ) return;
vlc_mutex_lock( &p_input->lock );
INSERT_ELEM( p_input->ppsz_options, p_input->i_options,
p_input->i_options, strdup( psz_option ) );
vlc_mutex_unlock( &p_input->lock );
}
if( psz_option == NULL )
return;
void input_ItemAddOptionNoDup( input_item_t *p_input,
const char *psz_option )
{
int i;
if( !psz_option ) return ;
vlc_mutex_lock( &p_input->lock );
for( i = 0 ; i< p_input->i_options; i++ )
if (flags & VLC_INPUT_OPTION_UNIQUE)
{
if( !strcmp( p_input->ppsz_options[i], psz_option ) )
{
vlc_mutex_unlock(& p_input->lock );
return;
}
for (int i = 0 ; i < p_input->i_options; i++)
if( !strcmp( p_input->ppsz_options[i], psz_option ) )
goto out;
}
TAB_APPEND( p_input->i_options, p_input->ppsz_options, strdup( psz_option)); vlc_mutex_unlock( &p_input->lock );
}
INSERT_ELEM( p_input->ppsz_options, p_input->i_options,
p_input->i_options, strdup( psz_option ) );
out:
vlc_mutex_unlock( &p_input->lock );
}
int input_ItemAddInfo( input_item_t *p_i,
const char *psz_cat,
......
......@@ -130,8 +130,7 @@ input_DecoderNew
input_DestroyThread
input_GetItem
input_ItemAddInfo
input_ItemAddOption
input_ItemAddOptionNoDup
input_ItemAddOpt
input_ItemGetById
input_ItemGetInfo
__input_ItemNewExt
......
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