Commit d3db4b7f authored by Steve Lhomme's avatar Steve Lhomme Committed by Thomas Guillem

stream_output: query the stream output to know when the decoder is really empty

similar to vout_IsEmpty() for stream output
Signed-off-by: Thomas Guillem's avatarThomas Guillem <thomas@gllm.fr>
parent aeb68de1
......@@ -189,6 +189,10 @@ static inline int sout_MuxControl( sout_mux_t *p_mux, int i_query, ... )
/** @} */
enum sout_stream_query_e {
SOUT_STREAM_EMPTY, /* arg1=bool *, res=can fail (assume true) */
};
struct sout_stream_t
{
VLC_COMMON_MEMBERS
......@@ -205,6 +209,7 @@ struct sout_stream_t
void (*pf_del)( sout_stream_t *, sout_stream_id_sys_t * );
/* manage a packet */
int (*pf_send)( sout_stream_t *, sout_stream_id_sys_t *, block_t* );
int (*pf_control)( sout_stream_t *, int, va_list );
sout_stream_sys_t *p_sys;
bool pace_nocontrol;
......@@ -232,6 +237,20 @@ static inline int sout_StreamIdSend( sout_stream_t *s,
return s->pf_send( s, id, b );
}
static inline int sout_StreamControl( sout_stream_t *s, int i_query, ... )
{
va_list args;
int i_result;
va_start( args, i_query );
if ( !s->pf_control )
i_result = VLC_EGENERIC;
else
i_result = s->pf_control( s, i_query, args );
va_end( args );
return i_result;
}
/****************************************************************************
* Encoder
****************************************************************************/
......
......@@ -1948,7 +1948,9 @@ bool input_DecoderIsEmpty( decoder_t * p_dec )
bool b_empty;
vlc_mutex_lock( &p_owner->lock );
if( p_owner->fmt.i_cat == VIDEO_ES && p_owner->p_vout != NULL )
if( p_owner->p_sout_input != NULL )
b_empty = sout_InputIsEmpty( p_owner->p_sout_input );
else if( p_owner->fmt.i_cat == VIDEO_ES && p_owner->p_vout != NULL )
b_empty = vout_IsEmpty( p_owner->p_vout );
else if( p_owner->fmt.i_cat == AUDIO_ES )
b_empty = atomic_load( &p_owner->drained );
......
......@@ -211,6 +211,18 @@ int sout_InputDelete( sout_packetizer_input_t *p_input )
return( VLC_SUCCESS);
}
bool sout_InputIsEmpty( sout_packetizer_input_t *p_input )
{
sout_instance_t *p_sout = p_input->p_sout;
bool b;
vlc_mutex_lock( &p_sout->lock );
if( sout_StreamControl( p_sout->p_stream, SOUT_STREAM_EMPTY, &b ) != VLC_SUCCESS )
b = true;
vlc_mutex_unlock( &p_sout->lock );
return b;
}
/*****************************************************************************
*
*****************************************************************************/
......@@ -777,6 +789,7 @@ static sout_stream_t *sout_StreamNew( sout_instance_t *p_sout, char *psz_name,
p_stream->psz_name = psz_name;
p_stream->p_cfg = p_cfg;
p_stream->p_next = p_next;
p_stream->pf_control = NULL;
p_stream->pace_nocontrol = false;
p_stream->p_sys = NULL;
......
......@@ -49,5 +49,6 @@ void sout_DeleteInstance( sout_instance_t * );
sout_packetizer_input_t *sout_InputNew( sout_instance_t *, es_format_t * );
int sout_InputDelete( sout_packetizer_input_t * );
int sout_InputSendBuffer( sout_packetizer_input_t *, block_t* );
bool sout_InputIsEmpty(sout_packetizer_input_t *);
#endif
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