/*****************************************************************************
* Preamble
*****************************************************************************/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include <vlc/vlc.h>
#include <stdio.h>
/* delay */
int64_t i_audio_delay;
int64_t i_spu_delay;
+
+ /* Rate used to rescale ES ts */
+ int i_rate;
};
static es_out_id_t *EsOutAdd ( es_out_t *, es_format_t * );
static void EsOutAddInfo( es_out_t *, es_out_id_t *es );
-static vlc_bool_t EsIsSelected( es_out_t *out, es_out_id_t *es );
+static vlc_bool_t EsIsSelected( es_out_id_t *es );
static void EsSelect( es_out_t *out, es_out_id_t *es );
static void EsUnselect( es_out_t *out, es_out_id_t *es, vlc_bool_t b_update );
static char *LanguageGetName( const char *psz_code );
static char *EsOutProgramGetMetaName( es_out_pgrm_t *p_pgrm );
+static const vlc_fourcc_t EsOutFourccClosedCaptions[4] = {
+ VLC_FOURCC('c', 'c', '1', ' '),
+ VLC_FOURCC('c', 'c', '2', ' '),
+ VLC_FOURCC('c', 'c', '3', ' '),
+ VLC_FOURCC('c', 'c', '4', ' '),
+};
+static inline int EsOutGetClosedCaptionsChannel( vlc_fourcc_t fcc )
+{
+ int i;
+ for( i = 0; i < 4; i++ )
+ {
+ if( fcc == EsOutFourccClosedCaptions[i] )
+ return i;
+ }
+ return -1;
+}
+
+
/*****************************************************************************
* input_EsOutNew:
*****************************************************************************/
-es_out_t *input_EsOutNew( input_thread_t *p_input )
+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 ) );
msg_Dbg( p_input, "selected audio language[%d] %s",
i, p_sys->ppsz_audio_language[i] );
}
- if( val.psz_string ) free( val.psz_string );
+ free( val.psz_string );
var_Get( p_input, "sub-language", &val );
p_sys->ppsz_sub_language = LanguageSplit(val.psz_string);
msg_Dbg( p_input, "selected subtitle language[%d] %s",
i, p_sys->ppsz_sub_language[i] );
}
- if( val.psz_string ) free( val.psz_string );
+ free( val.psz_string );
}
else
{
p_sys->i_audio_delay= 0;
p_sys->i_spu_delay = 0;
+ p_sys->i_rate = i_rate;
+
return out;
}
{
input_DecoderDelete( p_sys->es[i]->p_dec );
}
- if( p_sys->es[i]->psz_language )
- free( p_sys->es[i]->psz_language );
- if( p_sys->es[i]->psz_language_code )
- free( p_sys->es[i]->psz_language_code );
+ free( p_sys->es[i]->psz_language );
+ free( p_sys->es[i]->psz_language_code );
es_format_Clean( &p_sys->es[i]->fmt );
free( p_sys->es[i] );
free( p_sys->ppsz_sub_language );
}
- if( p_sys->es )
- free( p_sys->es );
+ free( p_sys->es );
/* FIXME duplicate work EsOutProgramDel (but we cannot use it) add a EsOutProgramClean ? */
for( i = 0; i < p_sys->i_pgrm; i++ )
{
es_out_pgrm_t *p_pgrm = p_sys->pgrm[i];
- if( p_pgrm->psz_now_playing )
- free( p_pgrm->psz_now_playing );
- if( p_pgrm->psz_publisher )
- free( p_pgrm->psz_publisher );
- if( p_pgrm->psz_name )
- free( p_pgrm->psz_name );
+ free( p_pgrm->psz_now_playing );
+ free( p_pgrm->psz_publisher );
+ free( p_pgrm->psz_name );
if( p_pgrm->p_epg )
vlc_epg_Delete( p_pgrm->p_epg );
input_DecoderDiscontinuity( es->p_dec, b_flush );
}
}
-void input_EsOutChangeRate( es_out_t *out )
+void input_EsOutChangeRate( es_out_t *out, int i_rate )
{
es_out_sys_t *p_sys = out->p_sys;
int i;
+ p_sys->i_rate = i_rate;
EsOutDiscontinuity( out, VLC_FALSE, VLC_FALSE );
for( i = 0; i < p_sys->i_pgrm; i++ )
- input_ClockSetRate( p_sys->p_input, &p_sys->pgrm[i]->clock );
+ input_ClockSetRate( &p_sys->pgrm[i]->clock, i_rate );
}
void input_EsOutSetDelay( es_out_t *out, int i_cat, int64_t i_delay )
for( i = 0; i < p_sys->i_es; i++ )
{
- if( p_sys->es[i]->p_pgrm == old && EsIsSelected( out, p_sys->es[i] ) &&
+ if( p_sys->es[i]->p_pgrm == old && EsIsSelected( p_sys->es[i] ) &&
p_sys->i_mode != ES_OUT_MODE_ALL )
EsUnselect( out, p_sys->es[i], VLC_TRUE );
}
p_pgrm->psz_now_playing = NULL;
p_pgrm->psz_publisher = NULL;
p_pgrm->p_epg = NULL;
- input_ClockInit( p_input, &p_pgrm->clock, VLC_FALSE, p_input->p->input.i_cr_average );
+ input_ClockInit( &p_pgrm->clock, VLC_FALSE, p_input->p->input.i_cr_average, p_sys->i_rate );
/* Append it */
TAB_APPEND( p_sys->i_pgrm, p_sys->pgrm, p_pgrm );
/* If program is selected we need to unselect it */
if( p_sys->p_pgrm == p_pgrm ) p_sys->p_pgrm = NULL;
- if( p_pgrm->psz_name ) free( p_pgrm->psz_name );
- if( p_pgrm->psz_now_playing ) free( p_pgrm->psz_now_playing );
- if( p_pgrm->psz_publisher ) free( p_pgrm->psz_publisher );
+ free( p_pgrm->psz_name );
+ free( p_pgrm->psz_now_playing );
+ free( p_pgrm->psz_publisher );
if( p_pgrm->p_epg )
vlc_epg_Delete( p_pgrm->p_epg );
free( p_pgrm );
!vlc_meta_Get( p_meta, vlc_meta_NowPlaying) &&
!vlc_meta_Get( p_meta, vlc_meta_Publisher) &&
vlc_dictionary_keys_count( &p_meta->extra_tags ) <= 0 )
- return;
+ {
+ return;
+ }
/* Find program */
for( i = 0; i < p_sys->i_pgrm; i++ )
{
/* TODO update epg name */
free( psz_cat );
}
- if( p_pgrm->psz_name ) free( p_pgrm->psz_name );
+ free( p_pgrm->psz_name );
p_pgrm->psz_name = strdup( psz_title );
/* ugly but it works */
free( psz_epg );
#endif
/* Update now playing */
- if( p_pgrm->psz_now_playing )
- free( p_pgrm->psz_now_playing );
+ free( p_pgrm->psz_now_playing );
p_pgrm->psz_now_playing = NULL;
if( p_epg->p_current && p_epg->p_current->psz_name && *p_epg->p_current->psz_name )
p_pgrm->psz_now_playing = strdup( p_epg->p_current->psz_name );
return es;
}
-static vlc_bool_t EsIsSelected( es_out_t *out, es_out_id_t *es )
+static vlc_bool_t EsIsSelected( es_out_id_t *es )
{
if( es->p_master )
{
vlc_bool_t b_decode = VLC_FALSE;
if( es->p_master->p_dec )
- input_DecoderGetCcState( es->p_master->p_dec, &b_decode,
- es->fmt.i_codec == VLC_FOURCC('c','c','1',' ') ? 0 : 1 );
+ {
+ int i_channel = EsOutGetClosedCaptionsChannel( es->fmt.i_codec );
+ if( i_channel != -1 )
+ input_DecoderGetCcState( es->p_master->p_dec, &b_decode, i_channel );
+ }
return b_decode;
}
else
vlc_value_t val;
const char *psz_var;
- if( EsIsSelected( out, es ) )
+ if( EsIsSelected( es ) )
{
msg_Warn( p_input, "ES 0x%x is already selected", es->i_id );
return;
if( es->p_master )
{
+ int i_channel;
if( !es->p_master->p_dec )
return;
- if( input_DecoderSetCcState( es->p_master->p_dec, VLC_TRUE,
- es->fmt.i_codec == VLC_FOURCC('c','c','1',' ') ? 0 : 1 ) )
+ i_channel = EsOutGetClosedCaptionsChannel( es->fmt.i_codec );
+ if( i_channel == -1 || input_DecoderSetCcState( es->p_master->p_dec, VLC_TRUE, i_channel ) )
return;
}
else
vlc_value_t val;
const char *psz_var;
- if( !EsIsSelected( out, es ) )
+ if( !EsIsSelected( es ) )
{
msg_Warn( p_input, "ES 0x%x is already unselected", es->i_id );
return;
if( es->p_master )
{
if( es->p_master->p_dec )
- input_DecoderSetCcState( es->p_master->p_dec, VLC_FALSE, es->fmt.i_codec == VLC_FOURCC('c','c','1',' ') ? 0 : 1 );
+ {
+ int i_channel = EsOutGetClosedCaptionsChannel( es->fmt.i_codec );
+ if( i_channel != -1 )
+ input_DecoderSetCcState( es->p_master->p_dec, VLC_FALSE, i_channel );
+ }
}
else
{
if( p_sys->i_mode == ES_OUT_MODE_ALL || b_force )
{
- if( !EsIsSelected( out, es ) )
+ if( !EsIsSelected( es ) )
EsSelect( out, es );
}
else if( p_sys->i_mode == ES_OUT_MODE_PARTIAL )
{
if ( val.p_list->p_values[i].i_int == es->p_pgrm->i_id || b_force )
{
- if( !EsIsSelected( out, es ) )
+ if( !EsIsSelected( es ) )
EsSelect( out, es );
break;
}
i_wanted = es->i_channel;
}
- if( i_wanted == es->i_channel && !EsIsSelected( out, es ) )
+ if( i_wanted == es->i_channel && !EsIsSelected( es ) )
EsSelect( out, es );
}
/* FIXME TODO handle priority here */
- if( EsIsSelected( out, es ) )
+ if( EsIsSelected( es ) )
{
if( i_cat == AUDIO_ES )
{
if( p_sys->i_mode == ES_OUT_MODE_AUTO &&
p_sys->p_es_audio &&
p_sys->p_es_audio != es &&
- EsIsSelected( out, p_sys->p_es_audio ) )
+ EsIsSelected( p_sys->p_es_audio ) )
{
EsUnselect( out, p_sys->p_es_audio, VLC_FALSE );
}
if( p_sys->i_mode == ES_OUT_MODE_AUTO &&
p_sys->p_es_sub &&
p_sys->p_es_sub != es &&
- EsIsSelected( out, p_sys->p_es_sub ) )
+ EsIsSelected( p_sys->p_es_sub ) )
{
EsUnselect( out, p_sys->p_es_sub, VLC_FALSE );
}
}
}
- p_block->i_rate = p_input->p->i_rate;
+ p_block->i_rate = p_sys->i_rate;
/* TODO handle mute */
if( es->p_dec &&
( es->fmt.i_cat != AUDIO_ES ||
- ( p_input->p->i_rate >= INPUT_RATE_DEFAULT/AOUT_MAX_INPUT_RATE &&
- p_input->p->i_rate <= INPUT_RATE_DEFAULT*AOUT_MAX_INPUT_RATE ) ) )
+ ( p_sys->i_rate >= INPUT_RATE_DEFAULT/AOUT_MAX_INPUT_RATE &&
+ p_sys->i_rate <= INPUT_RATE_DEFAULT*AOUT_MAX_INPUT_RATE ) ) )
{
vlc_bool_t pb_cc[4];
vlc_bool_t b_cc_new = VLC_FALSE;
EsOutSelect( out, p_sys->es[i], VLC_FALSE );
}
- if( es->psz_language )
- free( es->psz_language );
- if( es->psz_language_code )
- free( es->psz_language_code );
+ free( es->psz_language );
+ free( es->psz_language_code );
es_format_Clean( &es->fmt );
{
case ES_OUT_SET_ES_STATE:
es = (es_out_id_t*) va_arg( args, es_out_id_t * );
- b = (vlc_bool_t) va_arg( args, vlc_bool_t );
- if( b && !EsIsSelected( out, es ) )
+ b = (bool) va_arg( args, int );
+ if( b && !EsIsSelected( es ) )
{
EsSelect( out, es );
- return EsIsSelected( out, es ) ? VLC_SUCCESS : VLC_EGENERIC;
+ return EsIsSelected( es ) ? VLC_SUCCESS : VLC_EGENERIC;
}
- else if( !b && EsIsSelected( out, es ) )
+ else if( !b && EsIsSelected( es ) )
{
EsUnselect( out, es, es->p_pgrm == p_sys->p_pgrm );
return VLC_SUCCESS;
es = (es_out_id_t*) va_arg( args, es_out_id_t * );
pb = (vlc_bool_t*) va_arg( args, vlc_bool_t * );
- *pb = EsIsSelected( out, es );
+ *pb = EsIsSelected( es );
return VLC_SUCCESS;
case ES_OUT_SET_ACTIVE:
{
- b = (vlc_bool_t) va_arg( args, vlc_bool_t );
+ b = (bool) va_arg( args, int );
p_sys->b_active = b;
/* Needed ? */
if( b )
/* Reapply policy mode */
for( i = 0; i < p_sys->i_es; i++ )
{
- if( EsIsSelected( out, p_sys->es[i] ) )
+ if( EsIsSelected( p_sys->es[i] ) )
{
EsUnselect( out, p_sys->es[i],
p_sys->es[i]->p_pgrm == p_sys->p_pgrm );
{
for( i = 0; i < p_sys->i_es; i++ )
{
- if( EsIsSelected( out, p_sys->es[i] ) )
+ if( EsIsSelected( p_sys->es[i] ) )
EsUnselect( out, p_sys->es[i],
p_sys->es[i]->p_pgrm == p_sys->p_pgrm );
}
for( i = 0; i < p_sys->i_es; i++ )
{
if( p_sys->es[i]->fmt.i_cat == AUDIO_ES &&
- EsIsSelected( out, p_sys->es[i] ) )
+ EsIsSelected( p_sys->es[i] ) )
EsUnselect( out, p_sys->es[i],
p_sys->es[i]->p_pgrm == p_sys->p_pgrm );
}
for( i = 0; i < p_sys->i_es; i++ )
{
if( p_sys->es[i]->fmt.i_cat == VIDEO_ES &&
- EsIsSelected( out, p_sys->es[i] ) )
+ EsIsSelected( p_sys->es[i] ) )
EsUnselect( out, p_sys->es[i],
p_sys->es[i]->p_pgrm == p_sys->p_pgrm );
}
for( i = 0; i < p_sys->i_es; i++ )
{
if( p_sys->es[i]->fmt.i_cat == SPU_ES &&
- EsIsSelected( out, p_sys->es[i] ) )
+ EsIsSelected( p_sys->es[i] ) )
EsUnselect( out, p_sys->es[i],
p_sys->es[i]->p_pgrm == p_sys->p_pgrm );
}
case ES_OUT_RESET_PCR:
for( i = 0; i < p_sys->i_pgrm; i++ )
- input_ClockResetPCR( p_sys->p_input, &p_sys->pgrm[i]->clock );
+ input_ClockResetPCR( &p_sys->pgrm[i]->clock );
return VLC_SUCCESS;
case ES_OUT_GET_TS:
psz = strchr(psz_parser, ',' );
if( psz ) *psz++ = '\0';
- psz_code = LanguageGetCode( psz_parser );
- if( strcmp( psz_code, "??" ) )
+ if( !strcmp( psz_parser, "any" ) )
+ {
+ TAB_APPEND( i_psz, ppsz, strdup("any") );
+ }
+ else
{
- TAB_APPEND( i_psz, ppsz, psz_code );
+ psz_code = LanguageGetCode( psz_parser );
+ if( strcmp( psz_code, "??" ) )
+ {
+ TAB_APPEND( i_psz, ppsz, psz_code );
+ }
+ else
+ {
+ free( psz_code );
+ }
}
psz_parser = psz;
if( !ppsz_langs || !psz_lang ) return -1;
for( i = 0; ppsz_langs[i]; i++ )
- if( !strcasecmp( ppsz_langs[i], psz_lang ) ) return i;
+ {
+ if( !strcasecmp( ppsz_langs[i], psz_lang ) ||
+ !strcasecmp( ppsz_langs[i], "any" ) )
+ {
+ return i;
+ }
+ }
return -1;
}