Commit d6f0bd78 authored by Laurent Aimar's avatar Laurent Aimar

Clean up input events.

A new variable intf-event has been added.
It supercedes the following variables (they are still present for the
time being):
 - intf-change
 - intf-change-vout
 - rate-change
 - stats-change
and allows to have a better knowledge of the change done.

It is documented in vlc_input.h (in progress).
parent d20c8d66
...@@ -382,29 +382,6 @@ static inline void vlc_input_attachment_Delete( input_attachment_t *a ) ...@@ -382,29 +382,6 @@ static inline void vlc_input_attachment_Delete( input_attachment_t *a )
* input defines/constants. * input defines/constants.
*****************************************************************************/ *****************************************************************************/
/* "state" value */
/* NOTE: you need to update ppsz_input_state in the RC interface
* if you modify this list. */
typedef enum input_state_e
{
INIT_S = 0,
OPENING_S,
BUFFERING_S,
PLAYING_S,
PAUSE_S,
STOP_S,
END_S,
ERROR_S,
} input_state_e;
/* "rate" default, min/max
* A rate below 1000 plays the movie faster,
* A rate above 1000 plays the movie slower.
*/
#define INPUT_RATE_DEFAULT 1000
#define INPUT_RATE_MIN 32 /* Up to 32/1 */
#define INPUT_RATE_MAX 32000 /* Up to 1/32 */
/* i_update field of access_t/demux_t */ /* i_update field of access_t/demux_t */
#define INPUT_UPDATE_NONE 0x0000 #define INPUT_UPDATE_NONE 0x0000
#define INPUT_UPDATE_SIZE 0x0001 #define INPUT_UPDATE_SIZE 0x0001
...@@ -446,6 +423,147 @@ struct input_thread_t ...@@ -446,6 +423,147 @@ struct input_thread_t
input_thread_private_t *p; input_thread_private_t *p;
}; };
/*****************************************************************************
* Input events and variables
*****************************************************************************/
/**
* \defgroup inputvariable Input variables
*
* The input provides multiples variable you can write to and/or read from.
*
* TODO complete the documentation.
* The read only variables are:
* - "length"
* - "bookmarks"
* - "seekable (if you can seek, it doesn't say if 'bar display' has be shown FIXME rename can-seek
* or not, for that check position != 0.0)
* - "can-pause"
* - "can-rewind"
* - "can-record" (if a stream can be recorded while playing)
* - "teletext-es" to get the index of spu track that is teletext --1 if no teletext)
*
* The read-write variables are:
* - state (\see input_state_e)
* - rate, rate-slower, rate-faster
* - position, position-offset
* - time, time-offset
* - title,title-next,title-prev
* - chapter,chapter-next, chapter-prev
* - program, audio-es, video-es, spu-es
* - audio-delay, spu-delay
* - bookmark
* - TODO add special titles variables
*
* The variable used for event is
* - intf-event (\see input_event_type_e)
*
* The legacy variable used for event are
* - intf-change
* - intf-change-vout
* - rate-change
* - stats-change
* You are advised to change to intf-event as soon as possible.
*/
/**
* Input state
*
* This enum is used by the variable "state"
*
* NOTE: you need to update ppsz_input_state in the RC interface
* if you modify this list.
*/
typedef enum input_state_e
{
INIT_S = 0,
OPENING_S,
BUFFERING_S,
PLAYING_S,
PAUSE_S,
STOP_S,
END_S,
ERROR_S,
} input_state_e;
/**
* Input rate.
*
* It is an integer used by the variable "rate" in the
* range [INPUT_RATE_MIN, INPUT_RATE_MAX] the default value
* being INPUT_RATE_DEFAULT.
*
* A value lower than INPUT_RATE_DEFAULT plays faster.
* A value higher than INPUT_RATE_DEFAULT plays slower.
*/
/**
* Default rate value
*/
#define INPUT_RATE_DEFAULT 1000
/**
* Minimal rate value
*/
#define INPUT_RATE_MIN 32 /* Up to 32/1 */
/**
* Maximal rate value
*/
#define INPUT_RATE_MAX 32000 /* Up to 1/32 */
/**
* Input events
*
* You can catch input event by adding a callback on the variable "intf-event".
* This variable is an integer that will hold a input_event_type_e value.
*/
typedef enum input_event_type_e
{
/* "state" has changed */
INPUT_EVENT_STATE,
/* "rate" has changed */
INPUT_EVENT_RATE,
/* At least one of "position" or "time" or "length" has changed */
INPUT_EVENT_TIMES,
/* A title has been added or removed or selected.
* It imply that chapter has changed (not chapter event is sent) */
INPUT_EVENT_TITLE,
/* A chapter has been added or removed or selected. */
INPUT_EVENT_CHAPTER,
/* A program has been added or removed or selected */
INPUT_EVENT_PROGRAM,
/* A ES has been added or removed or selected */
INPUT_EVENT_ES,
/* "record" has changed */
INPUT_EVENT_RECORD,
/* A vout has been created/deleted by *the input*
* FIXME some event are not detected yet (audio visualisation) */
INPUT_EVENT_VOUT,
/* input_item_t media has changed */
INPUT_EVENT_ITEM_META,
/* input_item_t info has changed */
INPUT_EVENT_ITEM_INFO,
/* input_item_t name has changed */
INPUT_EVENT_ITEM_NAME,
/* Input statistics have been updated */
INPUT_EVENT_STATISTICS,
/* At least one of "signal-quality" or "signal-strength" has changed */
INPUT_EVENT_SIGNAL,
/* "audio-delay" has changed */
INPUT_EVENT_AUDIO_DELAY,
/* "spu-delay" has changed */
INPUT_EVENT_SUBTITLE_DELAY,
} input_event_type_e;
/** @}*/
/***************************************************************************** /*****************************************************************************
* Prototypes * Prototypes
*****************************************************************************/ *****************************************************************************/
......
...@@ -1973,7 +1973,7 @@ static void DeleteDecoder( decoder_t * p_dec ) ...@@ -1973,7 +1973,7 @@ static void DeleteDecoder( decoder_t * p_dec )
/* We are about to die. Reattach video output to p_vlc. */ /* We are about to die. Reattach video output to p_vlc. */
vout_Request( p_dec, p_owner->p_vout, NULL ); vout_Request( p_dec, p_owner->p_vout, NULL );
var_SetBool( p_owner->p_input, "intf-change-vout", true ); input_SendEventVout( p_owner->p_input );
} }
#ifdef ENABLE_SOUT #ifdef ENABLE_SOUT
...@@ -2188,7 +2188,7 @@ static picture_t *vout_new_buffer( decoder_t *p_dec ) ...@@ -2188,7 +2188,7 @@ static picture_t *vout_new_buffer( decoder_t *p_dec )
p_owner->p_vout = p_vout; p_owner->p_vout = p_vout;
vlc_mutex_unlock( &p_owner->lock ); vlc_mutex_unlock( &p_owner->lock );
var_SetBool( p_owner->p_input, "intf-change-vout", true ); input_SendEventVout( p_owner->p_input );
if( p_vout == NULL ) if( p_vout == NULL )
{ {
msg_Err( p_dec, "failed to create video output" ); msg_Err( p_dec, "failed to create video output" );
......
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
#include "input_internal.h" #include "input_internal.h"
#include "event.h" #include "event.h"
static void Trigger( input_thread_t *p_input, int i_type );
/***************************************************************************** /*****************************************************************************
* Event for input.c * Event for input.c
*****************************************************************************/ *****************************************************************************/
...@@ -54,12 +56,11 @@ void input_SendEventTimes( input_thread_t *p_input, const input_event_times_t *p ...@@ -54,12 +56,11 @@ void input_SendEventTimes( input_thread_t *p_input, const input_event_times_t *p
val.i_time = p_times->i_length; val.i_time = p_times->i_length;
var_Change( p_input, "length", VLC_VAR_SETVALUE, &val, NULL ); var_Change( p_input, "length", VLC_VAR_SETVALUE, &val, NULL );
//var_SetBool( p_input, "intf-change-times", true ); /* TODO */ Trigger( p_input, INPUT_EVENT_TIMES );
var_TriggerCallback( p_input, "intf-change" );
} }
void input_SendEventStatistics( input_thread_t *p_input ) void input_SendEventStatistics( input_thread_t *p_input )
{ {
var_TriggerCallback( p_input, "stats-change" ); /* FIXME rename */ Trigger( p_input, INPUT_EVENT_STATISTICS );
} }
void input_SendEventRate( input_thread_t *p_input, int i_rate ) void input_SendEventRate( input_thread_t *p_input, int i_rate )
{ {
...@@ -68,7 +69,7 @@ void input_SendEventRate( input_thread_t *p_input, int i_rate ) ...@@ -68,7 +69,7 @@ void input_SendEventRate( input_thread_t *p_input, int i_rate )
val.i_int = i_rate; val.i_int = i_rate;
var_Change( p_input, "rate", VLC_VAR_SETVALUE, &val, NULL ); var_Change( p_input, "rate", VLC_VAR_SETVALUE, &val, NULL );
var_TriggerCallback( p_input, "rate-change" ); /* TODO rename */ Trigger( p_input, INPUT_EVENT_RATE );
} }
void input_SendEventAudioDelay( input_thread_t *p_input, mtime_t i_delay ) void input_SendEventAudioDelay( input_thread_t *p_input, mtime_t i_delay )
{ {
...@@ -77,7 +78,7 @@ void input_SendEventAudioDelay( input_thread_t *p_input, mtime_t i_delay ) ...@@ -77,7 +78,7 @@ void input_SendEventAudioDelay( input_thread_t *p_input, mtime_t i_delay )
val.i_time = i_delay; val.i_time = i_delay;
var_Change( p_input, "audio-delay", VLC_VAR_SETVALUE, &val, NULL ); var_Change( p_input, "audio-delay", VLC_VAR_SETVALUE, &val, NULL );
//var_SetBool( p_input, "intf-change-delay" ); /* TODO */ Trigger( p_input, INPUT_EVENT_AUDIO_DELAY );
} }
void input_SendEventSubtitleDelay( input_thread_t *p_input, mtime_t i_delay ) void input_SendEventSubtitleDelay( input_thread_t *p_input, mtime_t i_delay )
...@@ -87,7 +88,7 @@ void input_SendEventSubtitleDelay( input_thread_t *p_input, mtime_t i_delay ) ...@@ -87,7 +88,7 @@ void input_SendEventSubtitleDelay( input_thread_t *p_input, mtime_t i_delay )
val.i_time = i_delay; val.i_time = i_delay;
var_Change( p_input, "spu-delay", VLC_VAR_SETVALUE, &val, NULL ); var_Change( p_input, "spu-delay", VLC_VAR_SETVALUE, &val, NULL );
//var_SetBool( p_input, "intf-change-delay" ); /* TODO */ Trigger( p_input, INPUT_EVENT_SUBTITLE_DELAY );
} }
/* TODO and file name ? */ /* TODO and file name ? */
...@@ -98,7 +99,7 @@ void input_SendEventRecord( input_thread_t *p_input, bool b_recording ) ...@@ -98,7 +99,7 @@ void input_SendEventRecord( input_thread_t *p_input, bool b_recording )
val.b_bool = b_recording; val.b_bool = b_recording;
var_Change( p_input, "record", VLC_VAR_SETVALUE, &val, NULL ); var_Change( p_input, "record", VLC_VAR_SETVALUE, &val, NULL );
var_TriggerCallback( p_input, "intf-change" ); /* FIXME */ Trigger( p_input, INPUT_EVENT_RECORD );
} }
void input_SendEventTitle( input_thread_t *p_input, int i_title ) void input_SendEventTitle( input_thread_t *p_input, int i_title )
...@@ -108,9 +109,9 @@ void input_SendEventTitle( input_thread_t *p_input, int i_title ) ...@@ -108,9 +109,9 @@ void input_SendEventTitle( input_thread_t *p_input, int i_title )
val.i_int = i_title; val.i_int = i_title;
var_Change( p_input, "title", VLC_VAR_SETVALUE, &val, NULL ); var_Change( p_input, "title", VLC_VAR_SETVALUE, &val, NULL );
input_ControlVarTitle( p_input, i_title ); /* FIXME ??? */ input_ControlVarTitle( p_input, i_title );
//var_SetBool( p_input, "intf-change-title" ); /* TODO */ Trigger( p_input, INPUT_EVENT_TITLE );
} }
void input_SendEventSeekpoint( input_thread_t *p_input, int i_title, int i_seekpoint ) void input_SendEventSeekpoint( input_thread_t *p_input, int i_title, int i_seekpoint )
...@@ -119,17 +120,22 @@ void input_SendEventSeekpoint( input_thread_t *p_input, int i_title, int i_seekp ...@@ -119,17 +120,22 @@ void input_SendEventSeekpoint( input_thread_t *p_input, int i_title, int i_seekp
VLC_UNUSED( i_title ); VLC_UNUSED( i_title );
val.i_int = i_seekpoint; val.i_int = i_seekpoint;
var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val, NULL); var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val, NULL );
//var_SetBool( p_input, "intf-change-seekpoint" ); /* TODO. Merge with intf-change-title ? */ Trigger( p_input, INPUT_EVENT_CHAPTER );
} }
void input_SendEventSignal( input_thread_t *p_input, double f_quality, double f_strength ) void input_SendEventSignal( input_thread_t *p_input, double f_quality, double f_strength )
{ {
var_SetFloat( p_input, "signal-quality", f_quality ); vlc_value_t val;
var_SetFloat( p_input, "signal-strength", f_strength );
val.f_float = f_quality;
var_Change( p_input, "signal-quality", VLC_VAR_SETVALUE, &val, NULL );
/* TODO use Change and then a intf-change-signal instead ? */ val.f_float = f_strength;
var_Change( p_input, "signal-strength", VLC_VAR_SETVALUE, &val, NULL );
Trigger( p_input, INPUT_EVENT_SIGNAL );
} }
void input_SendEventState( input_thread_t *p_input, int i_state ) void input_SendEventState( input_thread_t *p_input, int i_state )
...@@ -139,7 +145,7 @@ void input_SendEventState( input_thread_t *p_input, int i_state ) ...@@ -139,7 +145,7 @@ void input_SendEventState( input_thread_t *p_input, int i_state )
val.i_int = i_state; val.i_int = i_state;
var_Change( p_input, "state", VLC_VAR_SETVALUE, &val, NULL ); var_Change( p_input, "state", VLC_VAR_SETVALUE, &val, NULL );
var_TriggerCallback( p_input, "intf-change" ); Trigger( p_input, INPUT_EVENT_STATE );
/* FIXME remove this ugliness */ /* FIXME remove this ugliness */
vlc_event_t event; vlc_event_t event;
...@@ -149,13 +155,12 @@ void input_SendEventState( input_thread_t *p_input, int i_state ) ...@@ -149,13 +155,12 @@ void input_SendEventState( input_thread_t *p_input, int i_state )
vlc_event_send( &p_input->p->event_manager, &event ); vlc_event_send( &p_input->p->event_manager, &event );
} }
#warning "TODO meta"
/* FIXME: review them because vlc_event_send might be /* FIXME: review them because vlc_event_send might be
* moved inside input_item* functions. * moved inside input_item* functions.
*/ */
void input_SendEventMeta( input_thread_t *p_input ) void input_SendEventMeta( input_thread_t *p_input )
{ {
var_TriggerCallback( p_input, "intf-change" ); /* TODO intf-change-item-meta */ Trigger( p_input, INPUT_EVENT_ITEM_META );
/* FIXME remove this ugliness ? */ /* FIXME remove this ugliness ? */
vlc_event_t event; vlc_event_t event;
...@@ -167,7 +172,7 @@ void input_SendEventMeta( input_thread_t *p_input ) ...@@ -167,7 +172,7 @@ void input_SendEventMeta( input_thread_t *p_input )
void input_SendEventMetaInfo( input_thread_t *p_input ) void input_SendEventMetaInfo( input_thread_t *p_input )
{ {
var_TriggerCallback( p_input, "intf-change" ); /* TODO intf-change-item-info */ Trigger( p_input, INPUT_EVENT_ITEM_INFO );
/* FIXME remove this ugliness */ /* FIXME remove this ugliness */
vlc_event_t event; vlc_event_t event;
...@@ -178,7 +183,7 @@ void input_SendEventMetaInfo( input_thread_t *p_input ) ...@@ -178,7 +183,7 @@ void input_SendEventMetaInfo( input_thread_t *p_input )
void input_SendEventMetaName( input_thread_t *p_input, const char *psz_name ) void input_SendEventMetaName( input_thread_t *p_input, const char *psz_name )
{ {
var_TriggerCallback( p_input, "intf-change" ); /* TODO intf-change-item-name */ Trigger( p_input, INPUT_EVENT_ITEM_NAME );
/* FIXME remove this ugliness */ /* FIXME remove this ugliness */
vlc_event_t event; vlc_event_t event;
...@@ -203,8 +208,7 @@ void input_SendEventProgramAdd( input_thread_t *p_input, ...@@ -203,8 +208,7 @@ void input_SendEventProgramAdd( input_thread_t *p_input,
var_Change( p_input, "program", VLC_VAR_ADDCHOICE, var_Change( p_input, "program", VLC_VAR_ADDCHOICE,
&val, psz_text ? &text : NULL ); &val, psz_text ? &text : NULL );
//var_SetBool( p_input, "intf-change-program", true ); /* TODO */ Trigger( p_input, INPUT_EVENT_PROGRAM );
var_TriggerCallback( p_input, "intf-change" );
} }
void input_SendEventProgramDel( input_thread_t *p_input, int i_program ) void input_SendEventProgramDel( input_thread_t *p_input, int i_program )
{ {
...@@ -213,8 +217,7 @@ void input_SendEventProgramDel( input_thread_t *p_input, int i_program ) ...@@ -213,8 +217,7 @@ void input_SendEventProgramDel( input_thread_t *p_input, int i_program )
val.i_int = i_program; val.i_int = i_program;
var_Change( p_input, "program", VLC_VAR_DELCHOICE, &val, NULL ); var_Change( p_input, "program", VLC_VAR_DELCHOICE, &val, NULL );
//var_SetBool( p_input, "intf-change-program", true ); /* TODO */ Trigger( p_input, INPUT_EVENT_PROGRAM );
var_TriggerCallback( p_input, "intf-change" );
} }
void input_SendEventProgramSelect( input_thread_t *p_input, int i_program ) void input_SendEventProgramSelect( input_thread_t *p_input, int i_program )
{ {
...@@ -223,8 +226,7 @@ void input_SendEventProgramSelect( input_thread_t *p_input, int i_program ) ...@@ -223,8 +226,7 @@ void input_SendEventProgramSelect( input_thread_t *p_input, int i_program )
val.i_int = i_program; val.i_int = i_program;
var_Change( p_input, "program", VLC_VAR_SETVALUE, &val, NULL ); var_Change( p_input, "program", VLC_VAR_SETVALUE, &val, NULL );
//var_SetBool( p_input, "intf-change-program", true ); /* TODO */ Trigger( p_input, INPUT_EVENT_PROGRAM );
var_TriggerCallback( p_input, "intf-change" );
} }
static const char *GetEsVarName( int i_cat ) static const char *GetEsVarName( int i_cat )
...@@ -254,8 +256,7 @@ void input_SendEventEsDel( input_thread_t *p_input, int i_cat, int i_id ) ...@@ -254,8 +256,7 @@ void input_SendEventEsDel( input_thread_t *p_input, int i_cat, int i_id )
var_Change( p_input, GetEsVarName( i_cat ), VLC_VAR_CLEARCHOICES, NULL, NULL ); var_Change( p_input, GetEsVarName( i_cat ), VLC_VAR_CLEARCHOICES, NULL, NULL );
} }
//var_SetBool( p_input, "intf-change-es", true ); /* TODO */ Trigger( p_input, INPUT_EVENT_ES );
var_TriggerCallback( p_input, "intf-change" );
} }
void input_SendEventEsAdd( input_thread_t *p_input, int i_cat, int i_id, const char *psz_text ) void input_SendEventEsAdd( input_thread_t *p_input, int i_cat, int i_id, const char *psz_text )
{ {
...@@ -268,8 +269,7 @@ void input_SendEventEsAdd( input_thread_t *p_input, int i_cat, int i_id, const c ...@@ -268,8 +269,7 @@ void input_SendEventEsAdd( input_thread_t *p_input, int i_cat, int i_id, const c
var_Change( p_input, GetEsVarName( i_cat ), VLC_VAR_ADDCHOICE, var_Change( p_input, GetEsVarName( i_cat ), VLC_VAR_ADDCHOICE,
&val, psz_text ? &text : NULL ); &val, psz_text ? &text : NULL );
//var_SetBool( p_input, "intf-change-es", true ); /* TODO */ Trigger( p_input, INPUT_EVENT_ES );
var_TriggerCallback( p_input, "intf-change" );
} }
/* i_id == -1 will unselect */ /* i_id == -1 will unselect */
...@@ -280,8 +280,7 @@ void input_SendEventEsSelect( input_thread_t *p_input, int i_cat, int i_id ) ...@@ -280,8 +280,7 @@ void input_SendEventEsSelect( input_thread_t *p_input, int i_cat, int i_id )
val.i_int = i_id; val.i_int = i_id;
var_Change( p_input, GetEsVarName( i_cat ), VLC_VAR_SETVALUE, &val, NULL ); var_Change( p_input, GetEsVarName( i_cat ), VLC_VAR_SETVALUE, &val, NULL );
//var_SetBool( p_input, "intf-change-es", true ); /* TODO */ Trigger( p_input, INPUT_EVENT_ES );
var_TriggerCallback( p_input, "intf-change" );
/* FIXME to remove this ugliness */ /* FIXME to remove this ugliness */
vlc_event_t event; vlc_event_t event;
...@@ -289,3 +288,15 @@ void input_SendEventEsSelect( input_thread_t *p_input, int i_cat, int i_id ) ...@@ -289,3 +288,15 @@ void input_SendEventEsSelect( input_thread_t *p_input, int i_cat, int i_id )
vlc_event_send( &p_input->p->event_manager, &event ); vlc_event_send( &p_input->p->event_manager, &event );
} }
void input_SendEventVout( input_thread_t *p_input )
{
Trigger( p_input, INPUT_EVENT_VOUT );
}
/*****************************************************************************
*
*****************************************************************************/
static void Trigger( input_thread_t *p_input, int i_type )
{
var_SetInteger( p_input, "intf-event", i_type );
}
...@@ -67,5 +67,10 @@ void input_SendEventEsDel( input_thread_t *p_input, int i_cat, int i_id ); ...@@ -67,5 +67,10 @@ 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_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 */ void input_SendEventEsSelect( input_thread_t *p_input, int i_cat, int i_id ); /* i_id == -1 will unselect */
/*****************************************************************************
* Event for decoder.c
*****************************************************************************/
void input_SendEventVout( input_thread_t *p_input );
#endif #endif
...@@ -106,32 +106,7 @@ static void input_ChangeState( input_thread_t *p_input, int i_state ); /* TODO f ...@@ -106,32 +106,7 @@ static void input_ChangeState( input_thread_t *p_input, int i_state ); /* TODO f
* This function creates a new input, and returns a pointer * This function creates a new input, and returns a pointer
* to its description. On error, it returns NULL. * to its description. On error, it returns NULL.
* *
* Variables for _public_ use: * XXX Do not forget to update vlc_input.h if you add new variables.
* * Get and Set:
* - state
* - rate,rate-slower, rate-faster
* - position, position-offset
* - time, time-offset
* - title,title-next,title-prev
* - chapter,chapter-next, chapter-prev
* - program, audio-es, video-es, spu-es
* - audio-delay, spu-delay
* - bookmark
* * Get only:
* - length
* - bookmarks
* - seekable (if you can seek, it doesn't say if 'bar display' has be shown FIXME rename can-seek
* or not, for that check position != 0.0)
* - can-pause
* - can-record (if a stream can be recorded while playing)
* - teletext-es to get the index of spu track that is teletext --1 if no teletext)
* * For intf callback upon changes:
* - intf-change
* - intf-change-vout for when a vout is created or destroyed
* - rate-change for when playback rate changes
* - stats-change for when statistics are updated
* TODO explain when Callback is called
* TODO complete this list (?)
*****************************************************************************/ *****************************************************************************/
static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item, static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
const char *psz_header, bool b_quick, const char *psz_header, bool b_quick,
......
...@@ -68,6 +68,9 @@ static int FrameNextCallback( vlc_object_t *p_this, char const *psz_cmd, ...@@ -68,6 +68,9 @@ static int FrameNextCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, vlc_value_t oldval, vlc_value_t newval,
void *p_data ); void *p_data );
static int IntfEvent( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data );
typedef struct typedef struct
{ {
const char *psz_name; const char *psz_name;
...@@ -225,14 +228,14 @@ void input_ControlVarInit ( input_thread_t *p_input ) ...@@ -225,14 +228,14 @@ void input_ControlVarInit ( input_thread_t *p_input )
if( !p_input->b_preparsing ) if( !p_input->b_preparsing )
{ {
/* Special "intf-change" variable, it allows intf to set up a callback /* Special "intf-event" variable. */
* to be notified of some changes. var_Create( p_input, "intf-event", VLC_VAR_INTEGER );
*
* Add rate-change to inform about rate changin /* Callback for legacy variables */
* var_AddCallback( p_input, "intf-event", IntfEvent, NULL );
* stats-change to inform when statistics are computed
* /* Legacy variable
* TODO list all changes warn by these callbacks */ * TODO remove them when unused */
static const char *ppsz_event[] = { static const char *ppsz_event[] = {
"intf-change", "intf-change",
"rate-change", "rate-change",
...@@ -837,3 +840,21 @@ static int FrameNextCallback( vlc_object_t *p_this, char const *psz_cmd, ...@@ -837,3 +840,21 @@ static int FrameNextCallback( vlc_object_t *p_this, char const *psz_cmd,
return VLC_SUCCESS; return VLC_SUCCESS;
} }
static int IntfEvent( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);
switch( newval.i_int )
{
case INPUT_EVENT_RATE:
return var_SetBool( p_this, "rate-change", true );
case INPUT_EVENT_STATISTICS:
return var_SetBool( p_this, "stats-change", true );
case INPUT_EVENT_VOUT:
return var_SetBool( p_this, "intf-change-vout", true );
default:
return var_SetBool( p_this, "intf-change", true );
}
}
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