[vlc-commits] input: Allow demux_filter to be enabled/disabled
Hugo Beauzée-Luyssen
git at videolan.org
Tue Sep 19 11:49:07 CEST 2017
vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Wed Jun 21 13:08:49 2017 +0200| [32354048266539ff1b8ef6bae8ebe72cfd7de48b] | committer: Hugo Beauzée-Luyssen
input: Allow demux_filter to be enabled/disabled
refs #18605
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=32354048266539ff1b8ef6bae8ebe72cfd7de48b
---
include/vlc_demux.h | 7 +++++++
src/input/demux.c | 30 ++++++++++++++++++++++++++++++
src/input/demux.h | 2 ++
src/input/input.c | 10 ++++++++++
4 files changed, 49 insertions(+)
diff --git a/include/vlc_demux.h b/include/vlc_demux.h
index 4905d3e8a8..f359f547fa 100644
--- a/include/vlc_demux.h
+++ b/include/vlc_demux.h
@@ -323,6 +323,13 @@ enum demux_query_e
DEMUX_NAV_POPUP,
/** Activate disc Root Menu. Can fail */
DEMUX_NAV_MENU, /* res=can fail */
+ /** Enable/Disable a demux filter
+ * \warning This has limited support, and is likely to break if more than
+ * a single demux_filter is present in the chain. This is not guaranteed to
+ * work in future VLC versions, nor with all demux filters
+ */
+ DEMUX_FILTER_ENABLE,
+ DEMUX_FILTER_DISABLE
};
/*************************************************************************
diff --git a/src/input/demux.c b/src/input/demux.c
index 93a65e6b92..9aafc92791 100644
--- a/src/input/demux.c
+++ b/src/input/demux.c
@@ -487,6 +487,8 @@ int demux_vaControlHelper( stream_t *s,
case DEMUX_NAV_RIGHT:
case DEMUX_NAV_POPUP:
case DEMUX_NAV_MENU:
+ case DEMUX_FILTER_ENABLE:
+ case DEMUX_FILTER_DISABLE:
return VLC_EGENERIC;
case DEMUX_SET_TITLE:
@@ -629,3 +631,31 @@ demux_t *demux_FilterChainNew( demux_t *p_demux, const char *psz_chain )
return p_demux;
}
+
+static bool demux_filter_enable_disable( demux_t *p_demux_chain,
+ const char* psz_demux, bool b_enable )
+{
+ demux_t *p_demux = p_demux_chain;
+ 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_Control( p_demux,
+ b_enable ? DEMUX_FILTER_ENABLE : DEMUX_FILTER_DISABLE );
+ return true;
+ }
+ p_demux = p_demux->p_next;
+ }
+ return false;
+}
+
+bool demux_FilterEnable( demux_t *p_demux_chain, const char* psz_demux )
+{
+ return demux_filter_enable_disable( p_demux_chain, psz_demux, true );
+}
+
+bool demux_FilterDisable( demux_t *p_demux_chain, const char* psz_demux )
+{
+ return demux_filter_enable_disable( p_demux_chain, psz_demux, false );
+}
diff --git a/src/input/demux.h b/src/input/demux.h
index 25c9520de2..5a6d63a6ef 100644
--- a/src/input/demux.h
+++ b/src/input/demux.h
@@ -41,5 +41,7 @@ int demux_GetTitle( demux_t * );
int demux_GetSeekpoint( demux_t * );
demux_t *demux_FilterChainNew( demux_t *p_demux, const char *psz_name );
+bool demux_FilterEnable( demux_t *p_demux_chain, const char* psz_demux );
+bool demux_FilterDisable( demux_t *p_demux_chain, const char* psz_demux );
#endif
diff --git a/src/input/input.c b/src/input/input.c
index 542aa51475..b7a3de5315 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -1871,6 +1871,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 )
{
More information about the vlc-commits
mailing list