X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Finput%2Fes_out.c;h=c7dac8e5177460848284f14e5f9d84c73b5953ca;hb=10a6bde56813620846826fed6979b2548a6457ea;hp=b6cd646299cad7a439096fabc285d431b59f58bb;hpb=2e48e65740b878f69c1fea62fcfd44ef1dafd81d;p=vlc diff --git a/src/input/es_out.c b/src/input/es_out.c index b6cd646299..c7dac8e517 100644 --- a/src/input/es_out.c +++ b/src/input/es_out.c @@ -29,7 +29,7 @@ # include "config.h" #endif -#include +#include #include @@ -40,8 +40,7 @@ #include "input_internal.h" -#include "vlc_playlist.h" -#include "iso_lang.h" +#include /* FIXME we should find a better way than including that */ #include "../text/iso-639_def.h" @@ -178,17 +177,25 @@ static inline int EsOutGetClosedCaptionsChannel( vlc_fourcc_t fcc ) *****************************************************************************/ es_out_t *input_EsOutNew( input_thread_t *p_input, int i_rate ) { - es_out_t *out = malloc( sizeof( es_out_t ) ); - es_out_sys_t *p_sys = malloc( sizeof( es_out_sys_t ) ); vlc_value_t val; int i; + es_out_t *out = malloc( sizeof( es_out_t ) ); + if( !out ) return NULL; + + es_out_sys_t *p_sys = malloc( sizeof( es_out_sys_t ) ); + if( !p_sys ) + { + free( out ); + return NULL; + } + out->pf_add = EsOutAdd; out->pf_send = EsOutSend; out->pf_del = EsOutDel; out->pf_control = EsOutControl; out->p_sys = p_sys; - out->b_sout = (p_input->p->p_sout != NULL ? true : false); + out->b_sout = p_input->p->p_sout != NULL; p_sys->p_input = p_input; @@ -416,6 +423,7 @@ static void EsOutESVarUpdateGeneric( es_out_t *out, int i_id, es_format_t *fmt, { es_out_sys_t *p_sys = out->p_sys; input_thread_t *p_input = p_sys->p_input; + const bool b_teletext = fmt->i_cat == SPU_ES && fmt->i_codec == VLC_FOURCC( 't', 'e', 'l', 'x' ); vlc_value_t val, text; const char *psz_var; @@ -431,8 +439,12 @@ static void EsOutESVarUpdateGeneric( es_out_t *out, int i_id, es_format_t *fmt, if( b_delete ) { + if( b_teletext ) + var_SetInteger( p_sys->p_input, "teletext-es", -1 ); + val.i_int = i_id; var_Change( p_input, psz_var, VLC_VAR_DELCHOICE, &val, NULL ); + var_SetBool( p_sys->p_input, "intf-change", true ); return; } @@ -465,17 +477,13 @@ static void EsOutESVarUpdateGeneric( es_out_t *out, int i_id, es_format_t *fmt, { if( psz_language && *psz_language ) { - char *temp; - text.psz_string = malloc( strlen( _("Track %i") )+ - strlen( psz_language ) + 30 ); - asprintf( &temp, _("Track %i"), val.i_int ); - sprintf( text.psz_string, "%s - [%s]", temp, psz_language ); - free( temp ); + if( asprintf( &text.psz_string, "%s %i - [%s]", _( "Track" ), val.i_int, psz_language ) == -1 ) + text.psz_string = NULL; } else { - text.psz_string = malloc( strlen( _("Track %i") ) + 20 ); - sprintf( text.psz_string, _("Track %i"), val.i_int ); + if( asprintf( &text.psz_string, "%s %i", _( "Track" ), val.i_int ) == -1 ) + text.psz_string = NULL; } } @@ -484,6 +492,9 @@ static void EsOutESVarUpdateGeneric( es_out_t *out, int i_id, es_format_t *fmt, free( text.psz_string ); + if( b_teletext ) + var_SetInteger( p_sys->p_input, "teletext-es", i_id ); + var_SetBool( p_sys->p_input, "intf-change", true ); } @@ -544,6 +555,7 @@ static void EsOutProgramSelect( es_out_t *out, es_out_pgrm_t *p_pgrm ) var_Change( p_input, "audio-es", VLC_VAR_CLEARCHOICES, NULL, NULL ); var_Change( p_input, "video-es", VLC_VAR_CLEARCHOICES, NULL, NULL ); var_Change( p_input, "spu-es", VLC_VAR_CLEARCHOICES, NULL, NULL ); + var_SetInteger( p_input, "teletext-es", -1 ); for( i = 0; i < p_sys->i_es; i++ ) { if( p_sys->es[i]->p_pgrm == p_sys->p_pgrm ) @@ -570,6 +582,7 @@ static es_out_pgrm_t *EsOutProgramAdd( es_out_t *out, int i_group ) vlc_value_t val; es_out_pgrm_t *p_pgrm = malloc( sizeof( es_out_pgrm_t ) ); + if( !p_pgrm ) return NULL; /* Init */ p_pgrm->i_id = i_group; @@ -889,9 +902,12 @@ static es_out_id_t *EsOutAdd( es_out_t *out, es_format_t *fmt ) es_out_pgrm_t *p_pgrm = NULL; int i; + if( !es ) return NULL; + if( fmt->i_group < 0 ) { msg_Err( p_input, "invalid group number" ); + free( es ); return NULL; } @@ -1046,8 +1062,7 @@ static void EsSelect( es_out_t *out, es_out_id_t *es ) { if( es->fmt.i_cat == VIDEO_ES || es->fmt.i_cat == SPU_ES ) { - if( !var_GetBool( p_input, "video" ) || - ( p_input->p->p_sout && !var_GetBool( p_input, "sout-video" ) ) ) + if( !var_GetBool( p_input, out->b_sout ? "sout-video" : "video" ) ) { msg_Dbg( p_input, "video is disabled, not selecting ES 0x%x", es->i_id ); @@ -1057,8 +1072,7 @@ static void EsSelect( es_out_t *out, es_out_id_t *es ) else if( es->fmt.i_cat == AUDIO_ES ) { var_Get( p_input, "audio", &val ); - if( !var_GetBool( p_input, "audio" ) || - ( p_input->p->p_sout && !var_GetBool( p_input, "sout-audio" ) ) ) + if( !var_GetBool( p_input, out->b_sout ? "sout-audio" : "audio" ) ) { msg_Dbg( p_input, "audio is disabled, not selecting ES 0x%x", es->i_id ); @@ -1068,8 +1082,7 @@ static void EsSelect( es_out_t *out, es_out_id_t *es ) if( es->fmt.i_cat == SPU_ES ) { var_Get( p_input, "spu", &val ); - if( !var_GetBool( p_input, "spu" ) || - ( p_input->p->p_sout && !var_GetBool( p_input, "sout-spu" ) ) ) + if( !var_GetBool( p_input, out->b_sout ? "sout-spu" : "spu" ) ) { msg_Dbg( p_input, "spu is disabled, not selecting ES 0x%x", es->i_id ); @@ -1362,7 +1375,7 @@ static int EsOutSend( es_out_t *out, es_out_id_t *es, block_t *p_block ) else i_delay = 0; - if( p_input->p_libvlc->b_stats ) + if( libvlc_stats (p_input) ) { vlc_mutex_lock( &p_input->p->counters.counters_lock ); stats_UpdateInteger( p_input, p_input->p->counters.p_demux_read, @@ -1403,7 +1416,8 @@ static int EsOutSend( es_out_t *out, es_out_id_t *es, block_t *p_block ) p_block->i_pts = input_ClockGetTS( p_input, &p_pgrm->clock, p_block->i_pts ) + i_delay; } - if ( es->fmt.i_codec == VLC_FOURCC( 't', 'e', 'l', 'x' ) ) + if ( p_block->i_rate == INPUT_RATE_DEFAULT && + es->fmt.i_codec == VLC_FOURCC( 't', 'e', 'l', 'x' ) ) { mtime_t current_date = mdate(); if( !p_block->i_pts @@ -1440,7 +1454,7 @@ static int EsOutSend( es_out_t *out, es_out_id_t *es, block_t *p_block ) VLC_FOURCC('c', 'c', '3', ' '), VLC_FOURCC('c', 'c', '4', ' '), }; - static const char *ppsz_description[4] = { + static const char ppsz_description[4][18] = { N_("Closed captions 1"), N_("Closed captions 2"), N_("Closed captions 3"), @@ -1680,17 +1694,9 @@ static int EsOutControl( es_out_t *out, int i_query, va_list args ) } } { - /* FIXME: we don't want to depend on the playlist */ - playlist_t * p_playlist = vlc_object_find( p_sys->p_input, - VLC_OBJECT_PLAYLIST, FIND_PARENT ); - if( p_playlist ) - { - PL_LOCK; - p_playlist->gc_date = mdate(); - vlc_object_signal_unlocked( p_playlist ); - PL_UNLOCK; - vlc_object_release( p_playlist ); - } + vlc_event_t event; + event.type = vlc_InputSelectedStreamChanged; + vlc_event_send( &p_sys->p_input->p->event_manager, &event ); } return VLC_SUCCESS;