[vlc-devel] [RFC PATCH 5/8] input: Allow demux_filter to be changed during playback

Hugo Beauzée-Luyssen hugo at beauzee.fr
Thu Jul 6 19:14:28 CEST 2017


---
 src/input/demux.c | 28 ++++++++++++++++++++++++++++
 src/input/demux.h |  1 +
 src/input/input.c | 10 ++++++++++
 3 files changed, 39 insertions(+)

diff --git a/src/input/demux.c b/src/input/demux.c
index ecc81e9dac..d85eb0fd53 100644
--- a/src/input/demux.c
+++ b/src/input/demux.c
@@ -719,3 +719,31 @@ demux_t *demux_FilterChainNew( demux_t *p_demux, const char *psz_chain )
 
     return NULL;
 }
+
+demux_t *demux_FilterRemoveFromChain( demux_t *p_demux_chain, const char* psz_demux )
+{
+    demux_t *p_demux = p_demux_chain;
+    demux_t *p_prev = NULL;
+    while ( p_demux )
+    {
+        if( strcmp( module_get_name( p_demux->p_module, false ), psz_demux) == 0 ||
+            strcmp( module_get_name( p_demux->p_module, true ), psz_demux ) == 0 )
+        {
+            demux_t* p_ret = NULL;
+            if( p_prev == NULL )
+                p_ret = p_demux->p_next;
+            else
+            {
+                p_prev->p_next = p_demux->p_next;
+                p_ret = p_demux_chain;
+            }
+            module_unneed( p_demux, p_demux->p_module );
+            vlc_object_release( p_demux );
+            return p_ret;
+        }
+        p_prev = p_demux;
+        p_demux = p_demux->p_next;
+    }
+    msg_Warn( p_demux_chain, "Failed to remove demux filter %s", psz_demux );
+    return p_demux_chain;
+}
diff --git a/src/input/demux.h b/src/input/demux.h
index 24d5ad58bd..8f6a041041 100644
--- a/src/input/demux.h
+++ b/src/input/demux.h
@@ -41,6 +41,7 @@ int demux_GetTitle( demux_t * );
 int demux_GetSeekpoint( demux_t * );
 
 demux_t *demux_FilterChainNew( demux_t *p_demux, const char *psz_name );
+demux_t *demux_FilterRemoveFromChain( demux_t *p_demux_chain, const char* psz_old_chain );
 
 static inline bool demux_IsDemuxFilter( const demux_t* p_demux )
 {
diff --git a/src/input/input.c b/src/input/input.c
index a70caa2fa7..670afbebc0 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -1754,6 +1754,16 @@ static void ControlUpdateSout( input_thread_t *p_input, const char* psz_chain )
     es_out_Control( input_priv(p_input)->p_es_out, ES_OUT_RESTART_ALL_ES );
 }
 
+static void ControlInsertDemuxFilter( input_thread_t* p_input, const char* psz_demux_chain )
+{
+    input_source_t *p_inputSource = input_priv(p_input)->master;
+    demux_t *p_filtered_demux = demux_FilterChainNew( p_inputSource->p_demux, psz_demux_chain );
+    if ( p_filtered_demux != NULL )
+        p_inputSource->p_demux = p_filtered_demux;
+    else if ( psz_demux_chain != NULL )
+        msg_Dbg(p_input, "Failed to create demux filter %s", psz_demux_chain);
+}
+
 static bool Control( input_thread_t *p_input,
                      int i_type, vlc_value_t val )
 {
-- 
2.11.0



More information about the vlc-devel mailing list