stream_output: query the stream output to know when the decoder is really empty
authorSteve Lhomme <robux4@videolabs.io>
Fri, 18 Dec 2015 09:25:01 +0000 (10:25 +0100)
committerThomas Guillem <thomas@gllm.fr>
Tue, 22 Dec 2015 13:39:44 +0000 (14:39 +0100)
similar to vout_IsEmpty() for stream output

Signed-off-by: Thomas Guillem <thomas@gllm.fr>
include/vlc_sout.h
src/input/decoder.c
src/stream_output/stream_output.c
src/stream_output/stream_output.h

index d18be89..8147131 100644 (file)
@@ -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
  ****************************************************************************/
index e054b16..12f97a5 100644 (file)
@@ -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 );
index 113fce2..cf8c94f 100644 (file)
@@ -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;
 
index 1e48151..1429584 100644 (file)
@@ -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