[vlc-devel] [PATCH 02/16] stream_output: use function table for mux

Alexandre Janniaux ajanni at videolabs.io
Mon Mar 15 17:02:55 UTC 2021


---
 src/stream_output/stream_output.c | 28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/src/stream_output/stream_output.c b/src/stream_output/stream_output.c
index 49ff5017e9..6eb38c0ca3 100644
--- a/src/stream_output/stream_output.c
+++ b/src/stream_output/stream_output.c
@@ -379,6 +379,7 @@ sout_mux_t *sout_MuxNew( sout_access_out_t *p_access, const char *psz_mux )
 
     p_mux->p_sys        = NULL;
     p_mux->p_module     = NULL;
+    p_mux->ops          = NULL;
 
     p_mux->b_add_stream_any_time = false;
     p_mux->b_waiting_stream = true;
@@ -396,7 +397,7 @@ sout_mux_t *sout_MuxNew( sout_access_out_t *p_access, const char *psz_mux )
     }
 
     /* *** probe mux capacity *** */
-    if( p_mux->pf_control )
+    if( (p_mux->ops && p_mux->ops->control) || p_mux->pf_control )
     {
         int b_answer = false;
 
@@ -462,7 +463,15 @@ sout_input_t *sout_MuxAddStream( sout_mux_t *p_mux, const es_format_t *p_fmt )
     p_input->p_sys  = NULL;
 
     TAB_APPEND( p_mux->i_nb_inputs, p_mux->pp_inputs, p_input );
-    if( p_mux->pf_addstream( p_mux, p_input ) < 0 )
+
+    int ret;
+    if( p_mux->ops == NULL)
+        ret = p_mux->pf_addstream( p_mux, p_input );
+    else
+        ret = p_mux->ops->add_stream( p_mux, p_input );
+
+
+    if( ret < 0 )
     {
         msg_Err( p_mux, "cannot add this stream" );
         TAB_REMOVE( p_mux->i_nb_inputs, p_mux->pp_inputs, p_input );
@@ -488,7 +497,10 @@ void sout_MuxDeleteStream( sout_mux_t *p_mux, sout_input_t *p_input )
         /* We stop waiting, and call the muxer for taking care of the data
          * before we remove this es */
         p_mux->b_waiting_stream = false;
-        p_mux->pf_mux( p_mux );
+        if( p_mux->ops == NULL )
+            p_mux->pf_mux( p_mux );
+        else
+            p_mux->ops->mux( p_mux );
     }
 
     TAB_FIND( p_mux->i_nb_inputs, p_mux->pp_inputs, p_input, i_index );
@@ -497,7 +509,10 @@ void sout_MuxDeleteStream( sout_mux_t *p_mux, sout_input_t *p_input )
         /* remove the entry */
         TAB_ERASE( p_mux->i_nb_inputs, p_mux->pp_inputs, i_index );
 
-        p_mux->pf_delstream( p_mux, p_input );
+        if( p_mux->ops == NULL )
+            p_mux->pf_delstream( p_mux, p_input );
+        else
+            p_mux->ops->del_stream( p_mux, p_input );
 
         if( p_mux->i_nb_inputs == 0 )
         {
@@ -534,7 +549,10 @@ int sout_MuxSendBuffer( sout_mux_t *p_mux, sout_input_t *p_input,
             return VLC_SUCCESS;
         p_mux->b_waiting_stream = false;
     }
-    return p_mux->pf_mux( p_mux );
+    if( p_mux->ops == NULL )
+        return p_mux->pf_mux( p_mux );
+    else
+        return p_mux->ops->mux( p_mux );
 }
 
 void sout_MuxFlush( sout_mux_t *p_mux, sout_input_t *p_input )
-- 
2.30.2



More information about the vlc-devel mailing list