[vlc-devel] [RFC PATCH 02/10] input: Add INPUT_CONTROL_SET_RENDERER
Hugo Beauzée-Luyssen
hugo at beauzee.fr
Thu Sep 7 15:45:58 CEST 2017
---
include/vlc_input.h | 3 +++
src/input/control.c | 8 ++++++++
src/input/input.c | 36 +++++++++++++++++++++++++++++++++++-
src/input/input_internal.h | 3 +++
4 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/include/vlc_input.h b/include/vlc_input.h
index 21e02b2c7b..3641f13295 100644
--- a/include/vlc_input.h
+++ b/include/vlc_input.h
@@ -480,6 +480,9 @@ enum input_query_e
INPUT_GET_VOUTS, /* arg1=vout_thread_t ***, size_t * res=can fail */
INPUT_GET_ES_OBJECTS, /* arg1=int id, vlc_object_t **dec, vout_thread_t **, audio_output_t ** */
+ /* Renderers */
+ INPUT_SET_RENDERER, /* arg1=vlc_renderer_item_t* */
+
/* External clock managments */
INPUT_GET_PCR_SYSTEM, /* arg1=mtime_t *, arg2=mtime_t * res=can fail */
INPUT_MODIFY_PCR_SYSTEM,/* arg1=int absolute, arg2=mtime_t res=can fail */
diff --git a/src/input/control.c b/src/input/control.c
index 1401e0893d..77e1490272 100644
--- a/src/input/control.c
+++ b/src/input/control.c
@@ -562,6 +562,14 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
return es_out_ControlModifyPcrSystem( priv->p_es_out_display, b_absolute, i_system );
}
+ case INPUT_SET_RENDERER:
+ {
+ vlc_renderer_item_t* p_item = va_arg( args, vlc_renderer_item_t* );
+ val.p_address = p_item;
+ input_ControlPush( p_input, INPUT_CONTROL_SET_RENDERER, &val );
+ return VLC_SUCCESS;
+ }
+
default:
msg_Err( p_input, "unknown query 0x%x in %s", i_query, __func__ );
return VLC_EGENERIC;
diff --git a/src/input/input.c b/src/input/input.c
index 94413449f6..95a50b1488 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -54,6 +54,7 @@
#include <vlc_modules.h>
#include <vlc_stream.h>
#include <vlc_stream_extractor.h>
+#include <vlc_renderer_discovery.h>
/*****************************************************************************
* Local prototypes
@@ -237,6 +238,8 @@ static void input_Destructor( vlc_object_t *obj )
free( psz_name );
#endif
+ if( priv->p_renderer )
+ vlc_renderer_item_release( priv->p_renderer );
if( priv->p_es_out_display )
es_out_Delete( priv->p_es_out_display );
@@ -2289,6 +2292,27 @@ static bool Control( input_thread_t *p_input,
b_force_update = Control( p_input, INPUT_CONTROL_SET_TIME, val );
break;
}
+ case INPUT_CONTROL_SET_RENDERER:
+ {
+ vlc_renderer_item_t *p_item = val.p_address;
+ input_thread_private_t *p_priv = input_priv( p_input );
+ // We do not support switching from a renderer to another for now
+ if ( p_item == NULL && p_priv->p_renderer == NULL )
+ break;
+
+ if ( p_priv->p_renderer )
+ {
+ ControlUpdateSout( p_input, NULL );
+ vlc_renderer_item_release( p_priv->p_renderer );
+ p_priv->p_renderer = NULL;
+ }
+ if( p_item != NULL )
+ {
+ p_priv->p_renderer = vlc_renderer_item_hold( p_item );
+ ControlUpdateSout( p_input, vlc_renderer_item_sout( p_item ) );
+ }
+ break;
+ }
case INPUT_CONTROL_NAV_ACTIVATE:
case INPUT_CONTROL_NAV_UP:
@@ -2500,6 +2524,7 @@ static input_source_t *InputSourceNew( input_thread_t *p_input,
const char *psz_forced_demux,
bool b_in_can_fail )
{
+ input_thread_private_t *priv = input_priv(p_input);
input_source_t *in = vlc_custom_create( p_input, sizeof( *in ),
"input source" );
if( unlikely(in == NULL) )
@@ -2600,7 +2625,16 @@ static input_source_t *InputSourceNew( input_thread_t *p_input,
return NULL;
}
- char *psz_demux_chain = var_GetNonEmptyString(p_input, "demux-filter");
+ char *psz_demux_chain = NULL;
+ if( priv->p_renderer )
+ {
+ const char* psz_renderer_demux = vlc_renderer_item_demux_filter(
+ priv->p_renderer );
+ if( psz_renderer_demux )
+ psz_demux_chain = strdup( psz_renderer_demux );
+ }
+ if( !psz_demux_chain )
+ psz_demux_chain = var_GetNonEmptyString(p_input, "demux-filter");
if( psz_demux_chain != NULL ) /* add the chain of demux filters */
{
in->p_demux = demux_FilterChainNew( in->p_demux, psz_demux_chain );
diff --git a/src/input/input_internal.h b/src/input/input_internal.h
index 3606f575f1..2958dbaa3f 100644
--- a/src/input/input_internal.h
+++ b/src/input/input_internal.h
@@ -112,6 +112,7 @@ typedef struct input_thread_private_t
es_out_t *p_es_out_display;
vlc_viewpoint_t viewpoint;
bool viewpoint_changed;
+ vlc_renderer_item_t *p_renderer;
/* Title infos FIXME multi-input (not easy) ? */
int i_title;
@@ -232,6 +233,8 @@ enum input_control_e
INPUT_CONTROL_SET_RECORD_STATE,
INPUT_CONTROL_SET_FRAME_NEXT,
+
+ INPUT_CONTROL_SET_RENDERER,
};
/* Internal helpers */
--
2.11.0
More information about the vlc-devel
mailing list