[vlc-commits] stream_output: query the stream output to know when the decoder is really empty
Steve Lhomme
git at videolan.org
Tue Dec 22 14:39:55 CET 2015
vlc | branch: master | Steve Lhomme <robux4 at videolabs.io> | Fri Dec 18 10:25:01 2015 +0100| [d3db4b7fd3acabd60f61b5dd2bf7cbe3f77ce0ab] | committer: 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 <thomas at gllm.fr>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d3db4b7fd3acabd60f61b5dd2bf7cbe3f77ce0ab
---
include/vlc_sout.h | 19 +++++++++++++++++++
src/input/decoder.c | 4 +++-
src/stream_output/stream_output.c | 13 +++++++++++++
src/stream_output/stream_output.h | 1 +
4 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/include/vlc_sout.h b/include/vlc_sout.h
index d18be89..8147131 100644
--- a/include/vlc_sout.h
+++ b/include/vlc_sout.h
@@ -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
****************************************************************************/
diff --git a/src/input/decoder.c b/src/input/decoder.c
index e054b16..12f97a5 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -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 );
diff --git a/src/stream_output/stream_output.c b/src/stream_output/stream_output.c
index 113fce2..cf8c94f 100644
--- a/src/stream_output/stream_output.c
+++ b/src/stream_output/stream_output.c
@@ -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;
diff --git a/src/stream_output/stream_output.h b/src/stream_output/stream_output.h
index 1e48151..1429584 100644
--- a/src/stream_output/stream_output.h
+++ b/src/stream_output/stream_output.h
@@ -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
More information about the vlc-commits
mailing list