Commit f7ef0752 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

input: Add INPUT_CONTROL_SET_RENDERER

refs #18605
parent 32354048
......@@ -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 */
......
......@@ -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 );
break;
}
default:
msg_Err( p_input, "unknown query 0x%x in %s", i_query, __func__ );
return VLC_EGENERIC;
......
......@@ -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 );
......@@ -2300,6 +2303,36 @@ 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 );
demux_FilterDisable( p_priv->master->p_demux,
vlc_renderer_item_demux_filter( p_priv->p_renderer ) );
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 ) );
if( !demux_FilterEnable( p_priv->master->p_demux,
vlc_renderer_item_demux_filter( p_priv->p_renderer ) ) )
{
ControlInsertDemuxFilter( p_input,
vlc_renderer_item_demux_filter( p_item ) );
}
input_resource_TerminateVout( p_priv->p_resource );
}
break;
}
case INPUT_CONTROL_NAV_ACTIVATE:
case INPUT_CONTROL_NAV_UP:
......@@ -2511,6 +2544,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) )
......@@ -2611,7 +2645,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 );
......
......@@ -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 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment