Commit 2c73cfb4 authored by Laurent Aimar's avatar Laurent Aimar

Moved input_EsOutSetRecord/input_EsOutSetDelay to es_out_Control.

parent b0bcb74c
......@@ -161,10 +161,11 @@ static es_out_id_t *EsOutAdd ( es_out_t *, es_format_t * );
static int EsOutSend ( es_out_t *, es_out_id_t *, block_t * );
static void EsOutDel ( es_out_t *, es_out_id_t * );
static int EsOutControl( es_out_t *, int i_query, va_list );
static void EsOutDelete ( es_out_t *out );
static void EsOutDelete ( es_out_t * );
static void EsOutSelect( es_out_t *out, es_out_id_t *es, bool b_force );
static void EsOutSelect( es_out_t *, es_out_id_t *es, bool b_force );
static void EsOutAddInfo( es_out_t *, es_out_id_t *es );
static int EsOutSetRecord( es_out_t *, bool b_record );
static bool EsIsSelected( es_out_id_t *es );
static void EsSelect( es_out_t *out, es_out_id_t *es );
......@@ -320,91 +321,6 @@ void input_EsOutChangeRate( es_out_t *out, int i_rate )
EsOutProgramsChangeRate( out );
}
int input_EsOutSetRecord( es_out_t *out, bool b_record )
{
es_out_sys_t *p_sys = out->p_sys;
input_thread_t *p_input = p_sys->p_input;
assert( ( b_record && !p_sys->p_sout_record ) || ( !b_record && p_sys->p_sout_record ) );
if( b_record )
{
char *psz_path = var_CreateGetString( p_input, "input-record-path" );
if( !psz_path || *psz_path == '\0' )
{
free( psz_path );
psz_path = strdup( config_GetHomeDir() );
}
char *psz_sout = NULL; // TODO conf
if( !psz_sout && psz_path )
{
char *psz_file = input_CreateFilename( VLC_OBJECT(p_input), psz_path, INPUT_RECORD_PREFIX, NULL );
if( psz_file )
{
if( asprintf( &psz_sout, "#record{dst-prefix='%s'}", psz_file ) < 0 )
psz_sout = NULL;
free( psz_file );
}
}
free( psz_path );
if( !psz_sout )
return VLC_EGENERIC;
#ifdef ENABLE_SOUT
p_sys->p_sout_record = sout_NewInstance( p_input, psz_sout );
#endif
free( psz_sout );
if( !p_sys->p_sout_record )
return VLC_EGENERIC;
for( int i = 0; i < p_sys->i_es; i++ )
{
es_out_id_t *p_es = p_sys->es[i];
if( !p_es->p_dec || p_es->p_master )
continue;
p_es->p_dec_record = input_DecoderNew( p_input, &p_es->fmt, p_es->p_pgrm->p_clock, p_sys->p_sout_record );
if( p_es->p_dec_record && p_sys->b_buffering )
input_DecoderStartBuffering( p_es->p_dec_record );
}
}
else
{
for( int i = 0; i < p_sys->i_es; i++ )
{
es_out_id_t *p_es = p_sys->es[i];
if( !p_es->p_dec_record )
continue;
input_DecoderDelete( p_es->p_dec_record );
p_es->p_dec_record = NULL;
}
#ifdef ENABLE_SOUT
sout_DeleteInstance( p_sys->p_sout_record );
#endif
p_sys->p_sout_record = NULL;
}
return VLC_SUCCESS;
}
void input_EsOutSetDelay( es_out_t *out, int i_cat, int64_t i_delay )
{
es_out_sys_t *p_sys = out->p_sys;
if( i_cat == AUDIO_ES )
p_sys->i_audio_delay = i_delay;
else if( i_cat == SPU_ES )
p_sys->i_spu_delay = i_delay;
for( int i = 0; i < p_sys->i_es; i++ )
EsOutDecoderChangeDelay( out, p_sys->es[i] );
}
void input_EsOutChangePause( es_out_t *out, bool b_paused, mtime_t i_date )
{
es_out_sys_t *p_sys = out->p_sys;
......@@ -558,7 +474,7 @@ static void EsOutDelete( es_out_t *out )
int i;
if( p_sys->p_sout_record )
input_EsOutSetRecord( out, false );
EsOutSetRecord( out, false );
for( i = 0; i < p_sys->i_es; i++ )
{
......@@ -666,6 +582,93 @@ static bool EsOutDecodersIsEmpty( es_out_t *out )
return true;
}
static void EsOutSetDelay( es_out_t *out, int i_cat, int64_t i_delay )
{
es_out_sys_t *p_sys = out->p_sys;
if( i_cat == AUDIO_ES )
p_sys->i_audio_delay = i_delay;
else if( i_cat == SPU_ES )
p_sys->i_spu_delay = i_delay;
for( int i = 0; i < p_sys->i_es; i++ )
EsOutDecoderChangeDelay( out, p_sys->es[i] );
}
static int EsOutSetRecord( es_out_t *out, bool b_record )
{
es_out_sys_t *p_sys = out->p_sys;
input_thread_t *p_input = p_sys->p_input;
assert( ( b_record && !p_sys->p_sout_record ) || ( !b_record && p_sys->p_sout_record ) );
if( b_record )
{
char *psz_path = var_CreateGetString( p_input, "input-record-path" );
if( !psz_path || *psz_path == '\0' )
{
free( psz_path );
psz_path = strdup( config_GetHomeDir() );
}
char *psz_sout = NULL; // TODO conf
if( !psz_sout && psz_path )
{
char *psz_file = input_CreateFilename( VLC_OBJECT(p_input), psz_path, INPUT_RECORD_PREFIX, NULL );
if( psz_file )
{
if( asprintf( &psz_sout, "#record{dst-prefix='%s'}", psz_file ) < 0 )
psz_sout = NULL;
free( psz_file );
}
}
free( psz_path );
if( !psz_sout )
return VLC_EGENERIC;
#ifdef ENABLE_SOUT
p_sys->p_sout_record = sout_NewInstance( p_input, psz_sout );
#endif
free( psz_sout );
if( !p_sys->p_sout_record )
return VLC_EGENERIC;
for( int i = 0; i < p_sys->i_es; i++ )
{
es_out_id_t *p_es = p_sys->es[i];
if( !p_es->p_dec || p_es->p_master )
continue;
p_es->p_dec_record = input_DecoderNew( p_input, &p_es->fmt, p_es->p_pgrm->p_clock, p_sys->p_sout_record );
if( p_es->p_dec_record && p_sys->b_buffering )
input_DecoderStartBuffering( p_es->p_dec_record );
}
}
else
{
for( int i = 0; i < p_sys->i_es; i++ )
{
es_out_id_t *p_es = p_sys->es[i];
if( !p_es->p_dec_record )
continue;
input_DecoderDelete( p_es->p_dec_record );
p_es->p_dec_record = NULL;
}
#ifdef ENABLE_SOUT
sout_DeleteInstance( p_sys->p_sout_record );
#endif
p_sys->p_sout_record = NULL;
}
return VLC_SUCCESS;
}
static void EsOutDecodersStopBuffering( es_out_t *out, bool b_forced )
{
......@@ -2316,6 +2319,18 @@ static int EsOutControlLocked( es_out_t *out, int i_query, va_list args )
*pb = EsOutDecodersIsEmpty( out );
return VLC_SUCCESS;
case ES_OUT_SET_DELAY:
{
const int i_cat = (int)va_arg( args, int );
const mtime_t i_delay = (mtime_t)va_arg( args, mtime_t );
EsOutSetDelay( out, i_cat, i_delay );
return VLC_SUCCESS;
}
case ES_OUT_SET_RECORD_STATE:
b = (bool) va_arg( args, int );
return EsOutSetRecord( out, b );
default:
msg_Err( p_sys->p_input, "unknown query in es_out_Control" );
return VLC_EGENERIC;
......
......@@ -46,6 +46,12 @@ enum es_out_query_private_e
/* Check if es_out has still data to play */
ES_OUT_GET_EMPTY, /* arg1=bool* res=cannot fail */
/* */
ES_OUT_SET_DELAY, /* arg1=es_category_e, res=can fail */
/* */
ES_OUT_SET_RECORD_STATE, /* arg1=bool res=can fail */
};
static inline mtime_t es_out_GetWakeup( es_out_t *p_out )
......@@ -72,11 +78,17 @@ static inline bool es_out_GetEmpty( es_out_t *p_out )
assert( !i_ret );
return b;
}
static inline int es_out_SetDelay( es_out_t *p_out, int i_cat, mtime_t i_delay )
{
return es_out_Control( p_out, ES_OUT_SET_DELAY, i_cat, i_delay );
}
static inline int es_out_SetRecordState( es_out_t *p_out, bool b_record )
{
return es_out_Control( p_out, ES_OUT_SET_RECORD_STATE, b_record );
}
es_out_t *input_EsOutNew( input_thread_t *, int i_rate );
void input_EsOutSetDelay( es_out_t *, int i_cat, int64_t );
int input_EsOutSetRecord( es_out_t *, bool b_record );
void input_EsOutChangeRate( es_out_t *, int );
void input_EsOutChangePause( es_out_t *, bool b_paused, mtime_t i_date );
void input_EsOutChangePosition( es_out_t * );
......
......@@ -1813,15 +1813,13 @@ static bool Control( input_thread_t *p_input, int i_type,
break;
case INPUT_CONTROL_SET_AUDIO_DELAY:
input_EsOutSetDelay( p_input->p->p_es_out,
AUDIO_ES, val.i_time );
var_Change( p_input, "audio-delay", VLC_VAR_SETVALUE, &val, NULL );
if( !es_out_SetDelay( p_input->p->p_es_out, AUDIO_ES, val.i_time ) )
var_Change( p_input, "audio-delay", VLC_VAR_SETVALUE, &val, NULL );
break;
case INPUT_CONTROL_SET_SPU_DELAY:
input_EsOutSetDelay( p_input->p->p_es_out,
SPU_ES, val.i_time );
var_Change( p_input, "spu-delay", VLC_VAR_SETVALUE, &val, NULL );
if( !es_out_SetDelay( p_input->p->p_es_out, SPU_ES, val.i_time ) )
var_Change( p_input, "spu-delay", VLC_VAR_SETVALUE, &val, NULL );
break;
case INPUT_CONTROL_SET_TITLE:
......@@ -2031,7 +2029,7 @@ static bool Control( input_thread_t *p_input, int i_type,
}
else
{
if( input_EsOutSetRecord( p_input->p->p_es_out, val.b_bool ) )
if( es_out_SetRecordState( p_input->p->p_es_out, val.b_bool ) )
val.b_bool = false;
}
p_input->p->b_recording = val.b_bool;
......
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