Commit 04ee4c9f authored by Laurent Aimar's avatar Laurent Aimar

Added a ES_OUT_SET_ES_SCRAMBLED_STATE to warn the user about scrambled es.

 The input variable "program-scrambled" will contain the state for the current
program only. If at least one es is scrambled then the whole program is.
 The associated event is INPUT_EVENT_PROGRAM.
 If necessary for a better GUI support, we could change it to a list.
parent 8e787d7f
......@@ -72,7 +72,7 @@ enum es_out_query_e
ES_OUT_SET_ES_FMT, /* arg1= es_out_id_t* arg2=es_format_t* */
/* Allow preroll of data (data with dts/pts < i_pts for all ES will be decoded but not displayed */
ES_OUT_SET_NEXT_DISPLAY_TIME, /* arg1=int64_t i_pts(microsecond) */
ES_OUT_SET_NEXT_DISPLAY_TIME, /* arg1=int64_t i_pts(microsecond) */
/* Set meta data for group (dynamic) */
ES_OUT_SET_GROUP_META, /* arg1=int i_group arg2=vlc_meta_t */
/* Set epg for group (dynamic) */
......@@ -80,6 +80,9 @@ enum es_out_query_e
/* */
ES_OUT_DEL_GROUP, /* arg1=int i_group */
/* Set scrambled state for one es */
ES_OUT_SET_ES_SCRAMBLED_STATE, /* arg1=int i_group arg2=es_out_id_t* */
/* First value usable for private control */
ES_OUT_PRIVATE_START = 0x10000,
};
......
......@@ -302,6 +302,7 @@ struct input_thread_t
* variable value being the one currently selected, -1 if no teletext)
* - "signal-quality"
* - "signal-strength"
* - "program-scrambled" (if the current program is scrambled)
* - "cache" (level of data cached [0 .. 1])
*
* The read-write variables are:
......@@ -387,7 +388,8 @@ typedef enum input_event_type_e
/* A chapter has been added or removed or selected. */
INPUT_EVENT_CHAPTER,
/* A program has been added or removed or selected */
/* A program ("program") has been added or removed or selected,
* or "program-scrambled" has changed.*/
INPUT_EVENT_PROGRAM,
/* A ES has been added or removed or selected */
INPUT_EVENT_ES,
......
......@@ -62,6 +62,7 @@ typedef struct
int i_es;
bool b_selected;
bool b_scrambled;
/* Clock for this program */
input_clock_t *p_clock;
......@@ -79,6 +80,9 @@ struct es_out_id_t
int i_id;
es_out_pgrm_t *p_pgrm;
/* */
bool b_scrambled;
/* Channel in the track type */
int i_channel;
es_format_t fmt;
......@@ -984,6 +988,7 @@ static void EsOutProgramSelect( es_out_t *out, es_out_pgrm_t *p_pgrm )
input_SendEventEsDel( p_input, VIDEO_ES, -1 );
input_SendEventEsDel( p_input, SPU_ES, -1 );
input_SendEventTeletextDel( p_input, -1 );
input_SendEventProgramScrambled( p_input, p_pgrm->i_id, p_pgrm->b_scrambled );
/* TODO event */
var_SetInteger( p_input, "teletext-es", -1 );
......@@ -1018,6 +1023,7 @@ static es_out_pgrm_t *EsOutProgramAdd( es_out_t *out, int i_group )
p_pgrm->i_id = i_group;
p_pgrm->i_es = 0;
p_pgrm->b_selected = false;
p_pgrm->b_scrambled = false;
p_pgrm->psz_name = NULL;
p_pgrm->psz_now_playing = NULL;
p_pgrm->psz_publisher = NULL;
......@@ -1163,7 +1169,8 @@ static void EsOutProgramMeta( es_out_t *out, int i_group, vlc_meta_t *p_meta )
/* Remove old entries */
input_Control( p_input, INPUT_DEL_INFO, psz_cat, NULL );
/* TODO update epg name */
/* TODO update epg name ?
* TODO update scrambled info name ? */
free( psz_cat );
}
free( p_pgrm->psz_name );
......@@ -1335,6 +1342,34 @@ static void EsOutProgramEpg( es_out_t *out, int i_group, vlc_epg_t *p_epg )
free( psz_cat );
}
static void EsOutProgramUpdateScrambled( es_out_t *p_out, es_out_pgrm_t *p_pgrm )
{
es_out_sys_t *p_sys = p_out->p_sys;
input_thread_t *p_input = p_sys->p_input;
bool b_scrambled = false;
for( int i = 0; i < p_sys->i_es; i++ )
{
if( p_sys->es[i]->p_pgrm == p_pgrm && p_sys->es[i]->b_scrambled )
{
b_scrambled = true;
break;
}
}
if( !p_pgrm->b_scrambled == !b_scrambled )
return;
p_pgrm->b_scrambled = b_scrambled;
char *psz_cat = EsOutProgramGetMetaName( p_pgrm );
if( b_scrambled )
input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Scrambled"), _("Yes") );
else
input_Control( p_input, INPUT_DEL_INFO, psz_cat, _("Scrambled") );
input_SendEventProgramScrambled( p_input, p_pgrm->i_id, b_scrambled );
}
/* EsOutAdd:
* Add an es_out
*/
......@@ -1377,6 +1412,7 @@ static es_out_id_t *EsOutAdd( es_out_t *out, const es_format_t *fmt )
es->fmt.i_id = out->p_sys->i_id;
es->i_id = es->fmt.i_id;
es->i_meta_id = out->p_sys->i_id;
es->b_scrambled = false;
switch( es->fmt.i_cat )
{
......@@ -1456,6 +1492,9 @@ static es_out_id_t *EsOutAdd( es_out_t *out, const es_format_t *fmt )
EsOutUpdateInfo( out, es, &es->fmt, NULL );
if( es->b_scrambled )
EsOutProgramUpdateScrambled( out, es->p_pgrm );
vlc_mutex_unlock( &p_sys->lock );
return es;
......@@ -1936,12 +1975,15 @@ static void EsOutDel( es_out_t *out, es_out_id_t *es )
TAB_REMOVE( p_sys->i_es, p_sys->es, es );
/* Update program */
es->p_pgrm->i_es--;
if( es->p_pgrm->i_es == 0 )
{
msg_Dbg( p_sys->p_input, "Program doesn't contain anymore ES" );
}
if( es->b_scrambled )
EsOutProgramUpdateScrambled( out, es->p_pgrm );
/* */
if( p_sys->p_es_audio == es || p_sys->p_es_video == es ||
p_sys->p_es_sub == es ) b_reselect = true;
......@@ -2245,6 +2287,19 @@ static int EsOutControlLocked( es_out_t *out, int i_query, va_list args )
return VLC_SUCCESS;
}
case ES_OUT_SET_ES_SCRAMBLED_STATE:
{
es = (es_out_id_t*) va_arg( args, es_out_id_t * );
bool b_scrambled = (bool)va_arg( args, int );
if( !es->b_scrambled != !b_scrambled )
{
es->b_scrambled = b_scrambled;
EsOutProgramUpdateScrambled( out, es->p_pgrm );
}
return VLC_SUCCESS;
}
case ES_OUT_SET_NEXT_DISPLAY_TIME:
{
const int64_t i_date = (int64_t)va_arg( args, int64_t );
......@@ -2272,6 +2327,7 @@ static int EsOutControlLocked( es_out_t *out, int i_query, va_list args )
EsOutProgramEpg( out, i_group, p_epg );
return VLC_SUCCESS;
}
case ES_OUT_DEL_GROUP:
{
int i_group = (int)va_arg( args, int );
......
......@@ -597,6 +597,7 @@ static int ControlLocked( es_out_t *p_out, int i_query, va_list args )
case ES_OUT_SET_NEXT_DISPLAY_TIME:
case ES_OUT_SET_GROUP_META:
case ES_OUT_SET_GROUP_EPG:
case ES_OUT_SET_ES_SCRAMBLED_STATE:
case ES_OUT_DEL_GROUP:
case ES_OUT_SET_ES:
case ES_OUT_RESTART_ES:
......@@ -1306,6 +1307,11 @@ static int CmdInitControl( ts_cmd_t *p_cmd, int i_query, va_list args, bool b_co
p_cmd->control.int_i64.i_i64 = (int64_t)va_arg( args, int64_t );
break;
case ES_OUT_SET_ES_SCRAMBLED_STATE:
p_cmd->control.es_bool.p_es = (es_out_id_t*)va_arg( args, es_out_id_t * );
p_cmd->control.es_bool.b_bool = (bool)va_arg( args, int );
break;
case ES_OUT_RESET_PCR: /* no arg */
break;
......@@ -1449,6 +1455,10 @@ static int CmdExecuteControl( es_out_t *p_out, ts_cmd_t *p_cmd )
return es_out_Control( p_out, i_query, p_cmd->control.int_epg.i_int,
p_cmd->control.int_epg.p_epg );
case ES_OUT_SET_ES_SCRAMBLED_STATE: /* arg1=int es_out_id_t* arg2=bool */
return es_out_Control( p_out, i_query, p_cmd->control.es_bool.p_es->p_es,
p_cmd->control.es_bool.b_bool );
/* Modified control */
case ES_OUT_SET_ES: /* arg1= es_out_id_t* */
case ES_OUT_RESTART_ES: /* arg1= es_out_id_t* */
......
......@@ -231,6 +231,14 @@ void input_SendEventProgramSelect( input_thread_t *p_input, int i_program )
{
VarListSelect( p_input, "program", INPUT_EVENT_PROGRAM, i_program );
}
void input_SendEventProgramScrambled( input_thread_t *p_input, int i_group, bool b_scrambled )
{
if( var_GetInteger( p_input, "program" ) != i_group )
return;
var_SetBool( p_input, "program-scrambled", b_scrambled );
Trigger( p_input, INPUT_EVENT_PROGRAM );
}
static const char *GetEsVarName( int i_cat )
{
......
......@@ -58,6 +58,7 @@ 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_SendEventProgramScrambled( input_thread_t *p_input, int i_group, bool b_scrambled );
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 );
......
......@@ -486,6 +486,9 @@ void input_ConfigVarInit ( input_thread_t *p_input )
var_Create( p_input, "signal-strength", VLC_VAR_FLOAT );
var_SetFloat( p_input, "signal-strength", -1 );
var_Create( p_input, "program-scrambled", VLC_VAR_BOOL );
var_SetBool( p_input, "program-scrambled", false );
var_Create( p_input, "cache", VLC_VAR_FLOAT );
var_SetFloat( p_input, "cache", 0.0 );
......
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