Commit 6d56066a authored by Laurent Aimar's avatar Laurent Aimar

Move/clean up input event code to its own file.

There is no functionnal changes except a few missing events added.
parent 9e0f68a3
...@@ -179,7 +179,8 @@ VLC_EXPORT( void, input_item_MetaMerge, ( input_item_t *p_i, const vlc_meta_t ...@@ -179,7 +179,8 @@ VLC_EXPORT( void, input_item_MetaMerge, ( input_item_t *p_i, const vlc_meta_t
#define input_item_GetSetting( item ) input_item_GetMeta( item, vlc_meta_Setting ) #define input_item_GetSetting( item ) input_item_GetMeta( item, vlc_meta_Setting )
VLC_EXPORT( char *, input_item_GetInfo, ( input_item_t *p_i, const char *psz_cat,const char *psz_name ) ); VLC_EXPORT( char *, input_item_GetInfo, ( input_item_t *p_i, const char *psz_cat,const char *psz_name ) );
VLC_EXPORT(int, input_item_AddInfo, ( input_item_t *p_i, const char *psz_cat, const char *psz_name, const char *psz_format, ... ) LIBVLC_FORMAT( 4, 5 ) ); VLC_EXPORT( int, input_item_AddInfo, ( input_item_t *p_i, const char *psz_cat, const char *psz_name, const char *psz_format, ... ) LIBVLC_FORMAT( 4, 5 ) );
VLC_EXPORT( int, input_item_DelInfo, ( input_item_t *p_i, const char *psz_cat, const char *psz_name ) );
#define input_item_New( a,b,c ) input_item_NewExt( a, b, c, 0, NULL, -1 ) #define input_item_New( a,b,c ) input_item_NewExt( a, b, c, 0, NULL, -1 )
#define input_item_NewExt(a,b,c,d,e,f) __input_item_NewExt( VLC_OBJECT(a),b,c,d,e,f) #define input_item_NewExt(a,b,c,d,e,f) __input_item_NewExt( VLC_OBJECT(a),b,c,d,e,f)
......
...@@ -310,6 +310,7 @@ SOURCES_libvlc_common = \ ...@@ -310,6 +310,7 @@ SOURCES_libvlc_common = \
input/demux.c \ input/demux.c \
input/es_out.c \ input/es_out.c \
input/es_out_timeshift.c \ input/es_out_timeshift.c \
input/event.c \
input/input.c \ input/input.c \
input/meta.c \ input/meta.c \
input/access.h \ input/access.h \
...@@ -318,6 +319,7 @@ SOURCES_libvlc_common = \ ...@@ -318,6 +319,7 @@ SOURCES_libvlc_common = \
input/demux.h \ input/demux.h \
input/es_out.h \ input/es_out.h \
input/es_out_timeshift.h \ input/es_out_timeshift.h \
input/event.h \
input/stream.h \ input/stream.h \
input/input_internal.h \ input/input_internal.h \
input/vlm_internal.h \ input/vlm_internal.h \
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <stdlib.h> #include <stdlib.h>
#include "input_internal.h" #include "input_internal.h"
#include "event.h"
static void UpdateBookmarksOption( input_thread_t * ); static void UpdateBookmarksOption( input_thread_t * );
...@@ -139,143 +140,30 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args ) ...@@ -139,143 +140,30 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
char *psz_name = (char *)va_arg( args, char * ); char *psz_name = (char *)va_arg( args, char * );
char *psz_format = (char *)va_arg( args, char * ); char *psz_format = (char *)va_arg( args, char * );
info_category_t *p_cat; char *psz_value;
info_t *p_info;
int i;
vlc_mutex_lock( &p_input->p->input.p_item->lock );
for( i = 0; i < p_input->p->input.p_item->i_categories; i++ )
{
if( !strcmp( p_input->p->input.p_item->pp_categories[i]->psz_name,
psz_cat ) ) break;
}
if( i == p_input->p->input.p_item->i_categories ) if( vasprintf( &psz_value, psz_format, args ) == -1 )
{
p_cat = malloc( sizeof( info_category_t ) );
if( !p_cat )
{
vlc_mutex_unlock( &p_input->p->input.p_item->lock );
return VLC_EGENERIC; return VLC_EGENERIC;
}
p_cat->psz_name = strdup( psz_cat );
p_cat->i_infos = 0;
p_cat->pp_infos = NULL;
INSERT_ELEM( p_input->p->input.p_item->pp_categories,
p_input->p->input.p_item->i_categories,
p_input->p->input.p_item->i_categories, p_cat );
}
p_cat = p_input->p->input.p_item->pp_categories[i]; int i_ret = input_item_AddInfo( p_input->p->input.p_item,
psz_cat, psz_name, "%s", psz_value );
for( i = 0; i < p_cat->i_infos; i++ ) if( !p_input->b_preparsing && !i_ret )
{ input_SendEventMetaInfo( p_input );
if( !strcmp( p_cat->pp_infos[i]->psz_name, psz_name ) ) return i_ret;
{
if( p_cat->pp_infos[i]->psz_value )
free( p_cat->pp_infos[i]->psz_value );
break;
}
}
if( i == p_cat->i_infos )
{
p_info = malloc( sizeof( info_t ) );
if( !p_info )
{
vlc_mutex_unlock( &p_input->p->input.p_item->lock );
return VLC_EGENERIC;
}
INSERT_ELEM( p_cat->pp_infos, p_cat->i_infos,
p_cat->i_infos, p_info );
p_info->psz_name = strdup( psz_name );
}
p_info = p_cat->pp_infos[i];
if( vasprintf( &p_info->psz_value, psz_format, args ) == -1 )
p_info->psz_value = NULL;
vlc_mutex_unlock( &p_input->p->input.p_item->lock );
if( !p_input->b_preparsing )
{
vlc_event_t event;
event.type = vlc_InputItemInfoChanged;
vlc_event_send( &p_input->p->input.p_item->event_manager, &event );
}
} }
return VLC_SUCCESS;
case INPUT_DEL_INFO: case INPUT_DEL_INFO:
{ {
char *psz_cat = (char *)va_arg( args, char * ); char *psz_cat = (char *)va_arg( args, char * );
char *psz_name = (char *)va_arg( args, char * ); char *psz_name = (char *)va_arg( args, char * );
info_category_t *p_cat = NULL; int i_ret = input_item_DelInfo( p_input->p->input.p_item,
int i_cat; psz_cat, psz_name );
int i;
vlc_mutex_lock( &p_input->p->input.p_item->lock );
for( i_cat = 0; i_cat < p_input->p->input.p_item->i_categories; i_cat++ )
{
if( !strcmp( p_input->p->input.p_item->pp_categories[i_cat]->psz_name,
psz_cat ) )
{
p_cat = p_input->p->input.p_item->pp_categories[i_cat];
break;
}
}
if( p_cat == NULL )
{
vlc_mutex_unlock( &p_input->p->input.p_item->lock );
return VLC_EGENERIC;
}
if( psz_name )
{
/* Remove a specific info */
for( i = 0; i < p_cat->i_infos; i++ )
{
if( !strcmp( p_cat->pp_infos[i]->psz_name, psz_name ) )
{
free( p_cat->pp_infos[i]->psz_name );
if( p_cat->pp_infos[i]->psz_value )
free( p_cat->pp_infos[i]->psz_value );
free( p_cat->pp_infos[i] );
REMOVE_ELEM( p_cat->pp_infos, p_cat->i_infos, i );
break;
}
}
if( i >= p_cat->i_infos )
{
vlc_mutex_unlock( &p_input->p->input.p_item->lock );
return VLC_EGENERIC;
}
}
else
{
/* Remove the complete categorie */
for( i = 0; i < p_cat->i_infos; i++ )
{
free( p_cat->pp_infos[i]->psz_name );
if( p_cat->pp_infos[i]->psz_value )
free( p_cat->pp_infos[i]->psz_value );
free( p_cat->pp_infos[i] );
}
if( p_cat->pp_infos )
free( p_cat->pp_infos );
REMOVE_ELEM( p_input->p->input.p_item->pp_categories, p_input->p->input.p_item->i_categories, i_cat );
}
vlc_mutex_unlock( &p_input->p->input.p_item->lock );
if( !p_input->b_preparsing ) if( !p_input->b_preparsing && !i_ret )
{ input_SendEventMetaInfo( p_input );
vlc_event_t event; return i_ret;
event.type = vlc_InputItemInfoChanged;
vlc_event_send( &p_input->p->input.p_item->event_manager, &event );
}
return VLC_SUCCESS;
} }
...@@ -305,12 +193,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args ) ...@@ -305,12 +193,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
vlc_mutex_unlock( &p_input->p->input.p_item->lock ); vlc_mutex_unlock( &p_input->p->input.p_item->lock );
if( !p_input->b_preparsing ) if( !p_input->b_preparsing )
{ input_SendEventMetaName( p_input, psz_name );
vlc_event_t event;
event.type = vlc_InputItemNameChanged;
event.u.input_item_name_changed.new_name = psz_name;
vlc_event_send( &p_input->p->input.p_item->event_manager, &event );
}
return VLC_SUCCESS; return VLC_SUCCESS;
} }
......
This diff is collapsed.
/*****************************************************************************
* event.c: Events
*****************************************************************************
* Copyright (C) 2008 Laurent Aimar
* $Id$
*
* Authors: Laurent Aimar < fenrir _AT_ videolan _DOT_ org>
*
* 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.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_input.h>
#include "input_internal.h"
#include "event.h"
/*****************************************************************************
* Event for input.c
*****************************************************************************/
void input_SendEventTimes( input_thread_t *p_input, const input_event_times_t *p_times )
{
vlc_value_t val;
/* */
val.f_float = p_times->f_position;
var_Change( p_input, "position", VLC_VAR_SETVALUE, &val, NULL );
/* */
val.i_time = p_times->i_time;
var_Change( p_input, "time", VLC_VAR_SETVALUE, &val, NULL );
/* FIXME ugly + what about meta change event ? */
if( var_GetTime( p_input, "length" ) != p_times->i_length )
input_item_SetDuration( p_input->p->input.p_item, p_times->i_length );
val.i_time = p_times->i_length;
var_Change( p_input, "length", VLC_VAR_SETVALUE, &val, NULL );
//var_SetBool( p_input, "intf-change-times", true ); /* TODO */
var_TriggerCallback( p_input, "intf-change" );
}
void input_SendEventStatistics( input_thread_t *p_input )
{
var_TriggerCallback( p_input, "stats-change" ); /* FIXME rename */
}
void input_SendEventRate( input_thread_t *p_input, int i_rate )
{
vlc_value_t val;
val.i_int = i_rate;
var_Change( p_input, "rate", VLC_VAR_SETVALUE, &val, NULL );
var_TriggerCallback( p_input, "rate-change" ); /* TODO rename */
}
void input_SendEventAudioDelay( input_thread_t *p_input, mtime_t i_delay )
{
vlc_value_t val;
val.i_time = i_delay;
var_Change( p_input, "audio-delay", VLC_VAR_SETVALUE, &val, NULL );
//var_SetBool( p_input, "intf-change-delay" ); /* TODO */
}
void input_SendEventSubtitleDelay( input_thread_t *p_input, mtime_t i_delay )
{
vlc_value_t val;
val.i_time = i_delay;
var_Change( p_input, "spu-delay", VLC_VAR_SETVALUE, &val, NULL );
//var_SetBool( p_input, "intf-change-delay" ); /* TODO */
}
/* TODO and file name ? */
void input_SendEventRecord( input_thread_t *p_input, bool b_recording )
{
vlc_value_t val;
val.b_bool = b_recording;
var_Change( p_input, "record", VLC_VAR_SETVALUE, &val, NULL );
var_TriggerCallback( p_input, "intf-change" ); /* FIXME */
}
void input_SendEventTitle( input_thread_t *p_input, int i_title )
{
vlc_value_t val;
val.i_int = i_title;
var_Change( p_input, "title", VLC_VAR_SETVALUE, &val, NULL );
input_ControlVarTitle( p_input, i_title ); /* FIXME ??? */
//var_SetBool( p_input, "intf-change-title" ); /* TODO */
}
void input_SendEventSeekpoint( input_thread_t *p_input, int i_title, int i_seekpoint )
{
vlc_value_t val;
VLC_UNUSED( i_title );
val.i_int = i_seekpoint;
var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val, NULL);
//var_SetBool( p_input, "intf-change-seekpoint" ); /* TODO. Merge with intf-change-title ? */
}
void input_SendEventSignal( input_thread_t *p_input, double f_quality, double f_strength )
{
var_SetFloat( p_input, "signal-quality", f_quality );
var_SetFloat( p_input, "signal-strength", f_strength );
/* TODO use Change and then a intf-change-signal instead ? */
}
void input_SendEventState( input_thread_t *p_input, int i_state )
{
vlc_value_t val;
val.i_int = i_state;
var_Change( p_input, "state", VLC_VAR_SETVALUE, &val, NULL );
var_TriggerCallback( p_input, "intf-change" );
/* FIXME remove this ugliness */
vlc_event_t event;
event.type = vlc_InputStateChanged;
event.u.input_state_changed.new_state = i_state;
vlc_event_send( &p_input->p->event_manager, &event );
}
#warning "TODO meta"
/* FIXME: review them because vlc_event_send might be
* moved inside input_item* functions.
*/
void input_SendEventMeta( input_thread_t *p_input )
{
var_TriggerCallback( p_input, "intf-change" ); /* TODO intf-change-item-meta */
/* FIXME remove this ugliness ? */
vlc_event_t event;
event.type = vlc_InputItemMetaChanged;
event.u.input_item_meta_changed.meta_type = vlc_meta_ArtworkURL;
vlc_event_send( &p_input->p->input.p_item->event_manager, &event );
}
void input_SendEventMetaInfo( input_thread_t *p_input )
{
var_TriggerCallback( p_input, "intf-change" ); /* TODO intf-change-item-info */
/* FIXME remove this ugliness */
vlc_event_t event;
event.type = vlc_InputItemInfoChanged;
vlc_event_send( &p_input->p->input.p_item->event_manager, &event );
}
void input_SendEventMetaName( input_thread_t *p_input, const char *psz_name )
{
var_TriggerCallback( p_input, "intf-change" ); /* TODO intf-change-item-name */
/* FIXME remove this ugliness */
vlc_event_t event;
event.type = vlc_InputItemNameChanged;
event.u.input_item_name_changed.new_name = psz_name;
vlc_event_send( &p_input->p->input.p_item->event_manager, &event );
}
/*****************************************************************************
* Event for es_out.c
*****************************************************************************/
void input_SendEventProgramAdd( input_thread_t *p_input,
int i_program, const char *psz_text )
{
vlc_value_t val;
vlc_value_t text;
val.i_int = i_program;
text.psz_string = (char*)psz_text;
var_Change( p_input, "program", VLC_VAR_ADDCHOICE,
&val, psz_text ? &text : NULL );
//var_SetBool( p_input, "intf-change-program", true ); /* TODO */
var_TriggerCallback( p_input, "intf-change" );
}
void input_SendEventProgramDel( input_thread_t *p_input, int i_program )
{
vlc_value_t val;
val.i_int = i_program;
var_Change( p_input, "program", VLC_VAR_DELCHOICE, &val, NULL );
//var_SetBool( p_input, "intf-change-program", true ); /* TODO */
var_TriggerCallback( p_input, "intf-change" );
}
void input_SendEventProgramSelect( input_thread_t *p_input, int i_program )
{
vlc_value_t val;
val.i_int = i_program;
var_Change( p_input, "program", VLC_VAR_SETVALUE, &val, NULL );
//var_SetBool( p_input, "intf-change-program", true ); /* TODO */
var_TriggerCallback( p_input, "intf-change" );
}
static const char *GetEsVarName( int i_cat )
{
switch( i_cat )
{
case VIDEO_ES:
return "video-es";
case AUDIO_ES:
return "audio-es";
default:
assert( i_cat == SPU_ES );
return "spu-es";
}
}
void input_SendEventEsDel( input_thread_t *p_input, int i_cat, int i_id )
{
vlc_value_t val;
if( i_id >= 0 )
{
val.i_int = i_id;
var_Change( p_input, GetEsVarName( i_cat ), VLC_VAR_DELCHOICE, &val, NULL );
}
else
{
var_Change( p_input, GetEsVarName( i_cat ), VLC_VAR_CLEARCHOICES, NULL, NULL );
}
//var_SetBool( p_input, "intf-change-es", true ); /* TODO */
var_TriggerCallback( p_input, "intf-change" );
}
void input_SendEventEsAdd( input_thread_t *p_input, int i_cat, int i_id, const char *psz_text )
{
vlc_value_t val;
vlc_value_t text;
val.i_int = i_id;
text.psz_string = (char*)psz_text;
var_Change( p_input, GetEsVarName( i_cat ), VLC_VAR_ADDCHOICE,
&val, psz_text ? &text : NULL );
//var_SetBool( p_input, "intf-change-es", true ); /* TODO */
var_TriggerCallback( p_input, "intf-change" );
}
/* i_id == -1 will unselect */
void input_SendEventEsSelect( input_thread_t *p_input, int i_cat, int i_id )
{
vlc_value_t val;
val.i_int = i_id;
var_Change( p_input, GetEsVarName( i_cat ), VLC_VAR_SETVALUE, &val, NULL );
//var_SetBool( p_input, "intf-change-es", true ); /* TODO */
var_TriggerCallback( p_input, "intf-change" );
/* FIXME to remove this ugliness */
vlc_event_t event;
event.type = vlc_InputSelectedStreamChanged;
vlc_event_send( &p_input->p->event_manager, &event );
}
/*****************************************************************************
* event.h: Input event functions
*****************************************************************************
* Copyright (C) 2008 Laurent Aimar
* $Id$
*
* Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ fr>
*
* 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.
*****************************************************************************/
#if defined(__PLUGIN__) || defined(__BUILTIN__) || !defined(__LIBVLC__)
# error This header file can only be included from LibVLC.
#endif
#ifndef _INPUT_EVENT_H
#define _INPUT_EVENT_H 1
#include <vlc_common.h>
/*****************************************************************************
* Event for input.c
*****************************************************************************/
typedef struct
{
double f_position;
mtime_t i_time;
mtime_t i_length;
} input_event_times_t;
void input_SendEventTimes( input_thread_t *p_input, const input_event_times_t *p_times );
void input_SendEventStatistics( input_thread_t *p_input );
void input_SendEventRate( input_thread_t *p_input, int i_rate );
void input_SendEventAudioDelay( input_thread_t *p_input, mtime_t i_delay );
void input_SendEventSubtitleDelay( input_thread_t *p_input, mtime_t i_delay );
void input_SendEventRecord( input_thread_t *p_input, bool b_recording );
void input_SendEventTitle( input_thread_t *p_input, int i_title );
void input_SendEventSeekpoint( input_thread_t *p_input, int i_title, int i_seekpoint );
void input_SendEventSignal( input_thread_t *p_input, double f_quality, double f_strength );
void input_SendEventState( input_thread_t *p_input, int i_state );
/* TODO rename Item* */
void input_SendEventMeta( input_thread_t *p_input );
void input_SendEventMetaInfo( input_thread_t *p_input );
void input_SendEventMetaName( input_thread_t *p_input, const char *psz_name );
/*****************************************************************************
* Event for es_out.c
*****************************************************************************/
void input_SendEventProgramAdd( input_thread_t *p_input,
int i_program, const char *psz_text );
void input_SendEventProgramDel( input_thread_t *p_input, int i_program );
void input_SendEventProgramSelect( input_thread_t *p_input, int i_program );
void input_SendEventEsDel( input_thread_t *p_input, int i_cat, int i_id );
void input_SendEventEsAdd( input_thread_t *p_input, int i_cat, int i_id, const char *psz_text );
void input_SendEventEsSelect( input_thread_t *p_input, int i_cat, int i_id ); /* i_id == -1 will unselect */
#endif
This diff is collapsed.
...@@ -332,42 +332,6 @@ void input_ConfigVarInit ( input_thread_t * ); ...@@ -332,42 +332,6 @@ void input_ConfigVarInit ( input_thread_t * );
char **subtitles_Detect( input_thread_t *, char* path, const char *fname ); char **subtitles_Detect( input_thread_t *, char* path, const char *fname );
int subtitles_Filter( const char *); int subtitles_Filter( const char *);
static inline void input_ChangeStateWithVarCallback( input_thread_t *p_input, int i_state, bool callback )
{
const bool changed = p_input->i_state != i_state;
p_input->i_state = i_state;
if( i_state == ERROR_S )
p_input->b_error = true;
else if( i_state == END_S )
p_input->b_eof = true;
input_item_SetHasErrorWhenReading( p_input->p->input.p_item, (i_state == ERROR_S) );
if( callback )
{
var_SetInteger( p_input, "state", i_state );
}
else
{
vlc_value_t val;
val.i_int = i_state;
var_Change( p_input, "state", VLC_VAR_SETVALUE, &val, NULL );
}
if( changed )
{
vlc_event_t event;
event.type = vlc_InputStateChanged;
event.u.input_state_changed.new_state = i_state;
vlc_event_send( &p_input->p->event_manager, &event );
}
}
static inline void input_ChangeState( input_thread_t *p_input, int state )
{
input_ChangeStateWithVarCallback( p_input, state, true );
}
/* Helpers FIXME to export without input_ prefix */ /* Helpers FIXME to export without input_ prefix */
char *input_CreateFilename( vlc_object_t *p_obj, const char *psz_path, const char *psz_prefix, const char *psz_extension ); char *input_CreateFilename( vlc_object_t *p_obj, const char *psz_path, const char *psz_prefix, const char *psz_extension );
......
...@@ -312,6 +312,7 @@ bool input_item_IsArtFetched( input_item_t *p_i ) ...@@ -312,6 +312,7 @@ bool input_item_IsArtFetched( input_item_t *p_i )
return p_i->p_meta ? p_i->p_meta->i_status & ITEM_ART_FETCHED : false ; return p_i->p_meta ? p_i->p_meta->i_status & ITEM_ART_FETCHED : false ;
} }
/* FIXME dangerous, unlocked */
const vlc_meta_t * input_item_GetMetaObject( input_item_t *p_i ) const vlc_meta_t * input_item_GetMetaObject( input_item_t *p_i )
{ {
if( !p_i->p_meta ) if( !p_i->p_meta )
...@@ -320,6 +321,7 @@ const vlc_meta_t * input_item_GetMetaObject( input_item_t *p_i ) ...@@ -320,6 +321,7 @@ const vlc_meta_t * input_item_GetMetaObject( input_item_t *p_i )
return p_i->p_meta; return p_i->p_meta;
} }
/* FIXME dangerous, unlocked */
void input_item_MetaMerge( input_item_t *p_i, const vlc_meta_t * p_new_meta ) void input_item_MetaMerge( input_item_t *p_i, const vlc_meta_t * p_new_meta )
{ {
if( !p_i->p_meta ) if( !p_i->p_meta )
...@@ -472,8 +474,84 @@ int input_item_AddInfo( input_item_t *p_i, ...@@ -472,8 +474,84 @@ int input_item_AddInfo( input_item_t *p_i,
vlc_mutex_unlock( &p_i->lock ); vlc_mutex_unlock( &p_i->lock );
if( p_info->psz_value )
{
vlc_event_t event;
event.type = vlc_InputItemInfoChanged;
vlc_event_send( &p_i->event_manager, &event );
}
return p_info->psz_value ? VLC_SUCCESS : VLC_ENOMEM; return p_info->psz_value ? VLC_SUCCESS : VLC_ENOMEM;
} }
int input_item_DelInfo( input_item_t *p_i,
const char *psz_cat,
const char *psz_name )
{
info_category_t *p_cat = NULL;
int i_cat;
int i;
vlc_mutex_lock( &p_i->lock );
for( i_cat = 0; i_cat < p_i->i_categories; i_cat++ )
{
if( !strcmp( p_i->pp_categories[i_cat]->psz_name,
psz_cat ) )
{
p_cat = p_i->pp_categories[i_cat];
break;
}
}
if( p_cat == NULL )
{
vlc_mutex_unlock( &p_i->lock );
return VLC_EGENERIC;
}
if( psz_name )
{
/* Remove a specific info */
for( i = 0; i < p_cat->i_infos; i++ )
{
if( !strcmp( p_cat->pp_infos[i]->psz_name, psz_name ) )
{
free( p_cat->pp_infos[i]->psz_name );
if( p_cat->pp_infos[i]->psz_value )
free( p_cat->pp_infos[i]->psz_value );
free( p_cat->pp_infos[i] );
REMOVE_ELEM( p_cat->pp_infos, p_cat->i_infos, i );
break;
}
}
if( i >= p_cat->i_infos )
{
vlc_mutex_unlock( &p_i->lock );
return VLC_EGENERIC;
}
}
else
{
/* Remove the complete categorie */
for( i = 0; i < p_cat->i_infos; i++ )
{
free( p_cat->pp_infos[i]->psz_name );
if( p_cat->pp_infos[i]->psz_value )
free( p_cat->pp_infos[i]->psz_value );
free( p_cat->pp_infos[i] );
}
if( p_cat->pp_infos )
free( p_cat->pp_infos );
REMOVE_ELEM( p_i->pp_categories, p_i->i_categories, i_cat );
}
vlc_mutex_unlock( &p_i->lock );
vlc_event_t event;
event.type = vlc_InputItemInfoChanged;
vlc_event_send( &p_i->event_manager, &event );
return VLC_SUCCESS;
}
input_item_t *__input_item_NewExt( vlc_object_t *p_obj, const char *psz_uri, input_item_t *__input_item_NewExt( vlc_object_t *p_obj, const char *psz_uri,
const char *psz_name, const char *psz_name,
......
...@@ -232,16 +232,19 @@ void input_ControlVarInit ( input_thread_t *p_input ) ...@@ -232,16 +232,19 @@ void input_ControlVarInit ( input_thread_t *p_input )
* *
* stats-change to inform when statistics are computed * stats-change to inform when statistics are computed
* *
* TODO list all changes warn by this callbacks */ * TODO list all changes warn by these callbacks */
var_Create( p_input, "intf-change", VLC_VAR_BOOL ); static const char *ppsz_event[] = {
var_SetBool( p_input, "intf-change", true ); "intf-change",
var_Create( p_input, "rate-change", VLC_VAR_BOOL ); "rate-change",
var_SetBool( p_input, "rate-change", true ); "stats-change",
var_Create( p_input, "stats-change", VLC_VAR_BOOL ); "intf-change-vout",
var_SetBool( p_input, "stats-change", true ); NULL
};
var_Create( p_input, "intf-change-vout", VLC_VAR_BOOL ); for( int i = 0; ppsz_event[i] != NULL; i++ )
var_SetBool( p_input, "intf-change-vout", true ); {
var_Create( p_input, ppsz_event[i], VLC_VAR_BOOL );
var_SetBool( p_input, ppsz_event[i], true );
}
} }
/* Add all callbacks /* Add all callbacks
......
...@@ -167,6 +167,7 @@ input_item_AddOpt ...@@ -167,6 +167,7 @@ input_item_AddOpt
input_item_AddOption input_item_AddOption
input_item_AddSubItem input_item_AddSubItem
input_item_CopyOptions input_item_CopyOptions
input_item_DelInfo
input_item_GetDuration input_item_GetDuration
input_item_GetInfo input_item_GetInfo
input_item_GetMeta input_item_GetMeta
......
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