[vlc-devel] [PATCH 2/2] input: add INPUT_SET_VIEWPOINT
Rémi Denis-Courmont
remi at remlab.net
Thu Nov 10 19:56:59 CET 2016
Le torstaina 10. marraskuuta 2016, 18.24.18 EET Thomas Guillem a écrit :
> This new control allows us to change the viewpoint of a given input thread.
> The viewpoint will be applied to all vouts (and later all aouts) of the
> input.
>
> The current viewpoint is stored by the input thread.
> ---
> include/vlc_input.h | 1 +
> src/input/control.c | 12 ++++++++++++
> src/input/input.c | 30 ++++++++++++++++++++++++++++++
> src/input/input_internal.h | 9 +++++++++
> 4 files changed, 52 insertions(+)
>
> diff --git a/include/vlc_input.h b/include/vlc_input.h
> index a2ddaad..83cf6fe 100644
> --- a/include/vlc_input.h
> +++ b/include/vlc_input.h
> @@ -472,6 +472,7 @@ enum input_query_e
>
> /* ES */
> INPUT_RESTART_ES, /* arg1=int (-AUDIO/VIDEO/SPU_ES for the whole
> category) */ + INPUT_SET_VIEWPOINT, /* arg1=(const vlc_viewpoint_t*),
> arg2=bool b_absolute */
>
> /* Input ressources
> * XXX You must call vlc_object_release as soon as possible */
> diff --git a/src/input/control.c b/src/input/control.c
> index bb5100c..2e37f25 100644
> --- a/src/input/control.c
> +++ b/src/input/control.c
> @@ -519,6 +519,18 @@ int input_vaControl( input_thread_t *p_input, int
> i_query, va_list args ) input_ControlPush( p_input,
> INPUT_CONTROL_RESTART_ES, &val ); return VLC_SUCCESS;
>
> + case INPUT_SET_VIEWPOINT:
> + {
> + struct input_viewpoint_req *p_req = malloc( sizeof(*p_req) );
> + if( unlikely(p_req == NULL) )
> + return VLC_ENOMEM;
> + p_req->vp = *va_arg( args, const vlc_viewpoint_t* );
> + p_req->absolute = va_arg( args, int );
> + val.p_address = p_req;
> + input_ControlPush( p_input, INPUT_CONTROL_SET_VIEWPOINT, &val
> ); + return VLC_SUCCESS;
> + }
> +
> case INPUT_GET_AOUT:
> {
> audio_output_t *p_aout = input_resource_HoldAout(
> priv->p_resource ); diff --git a/src/input/input.c b/src/input/input.c
> index fcba5f2..649f69a 100644
> --- a/src/input/input.c
> +++ b/src/input/input.c
> @@ -323,6 +323,7 @@ static input_thread_t *Create( vlc_object_t *p_parent,
> input_item_t *p_item, priv->attachment_demux = NULL;
> priv->p_sout = NULL;
> priv->b_out_pace_control = false;
> + vlc_viewpoint_init( &priv->viewpoint );
>
> vlc_gc_incref( p_item ); /* Released in Destructor() */
> priv->p_item = p_item;
> @@ -1655,6 +1656,9 @@ static void ControlRelease( int i_type, vlc_value_t
> val ) if( val.p_address )
> input_item_slave_Delete( val.p_address );
> break;
> + case INPUT_CONTROL_SET_VIEWPOINT:
> + free( val.p_address );
> + break;
>
> default:
> break;
> @@ -1918,6 +1922,32 @@ static bool Control( input_thread_t *p_input,
> ES_OUT_RESTART_ES_BY_ID, (int)val.i_int );
> break;
>
> + case INPUT_CONTROL_SET_VIEWPOINT:
> + {
> + input_thread_private_t *priv = input_priv(p_input);
> + struct input_viewpoint_req *p_req = val.p_address;
> + if( p_req->absolute )
> + priv->viewpoint = p_req->vp;
> + else
> + {
> + priv->viewpoint.yaw += p_req->vp.yaw;
> + priv->viewpoint.pitch += p_req->vp.pitch;
> + priv->viewpoint.roll += p_req->vp.roll;
> + priv->viewpoint.fov += p_req->vp.fov;
> + priv->viewpoint.zoom += p_req->vp.zoom;
> + }
> + vout_thread_t **pp_vout;
> + size_t i_vout;
> + input_resource_HoldVouts( priv->p_resource, &pp_vout, &i_vout
> ); +
> + for( size_t i = 0; i < i_vout; ++i )
> + {
> + vout_SetViewpoint( pp_vout[i], &priv->viewpoint );
> + vlc_object_release( pp_vout[i] );
> + }
> + break;
> + }
> +
> case INPUT_CONTROL_SET_AUDIO_DELAY:
> input_SendEventAudioDelay( p_input, val.i_int );
> UpdatePtsDelay( p_input );
> diff --git a/src/input/input_internal.h b/src/input/input_internal.h
> index 0bc1de0..437979f 100644
> --- a/src/input/input_internal.h
> +++ b/src/input/input_internal.h
> @@ -29,6 +29,7 @@
> #include <vlc_access.h>
> #include <vlc_demux.h>
> #include <vlc_input.h>
> +#include <vlc_vout.h>
> #include <libvlc.h>
> #include "input_interface.h"
> #include "misc/interrupt.h"
> @@ -80,6 +81,12 @@ typedef struct
> vlc_value_t val;
> } input_control_t;
>
> +struct input_viewpoint_req
> +{
> + vlc_viewpoint_t vp;
> + bool absolute;
> +};
> +
You could use separate controls instead of a boolean. Or even a ditch the
control and make a function with a separate boolean parameter.
But then again, doing this at input thread level will prevent cross-input
persistence, which is likely desirable. So that seems too "low level" to me.
> /** Private input fields */
> typedef struct input_thread_private_t
> {
> @@ -109,6 +116,7 @@ typedef struct input_thread_private_t
> sout_instance_t *p_sout; /* Idem ? */
> es_out_t *p_es_out;
> es_out_t *p_es_out_display;
> + vlc_viewpoint_t viewpoint;
>
> /* Title infos FIXME multi-input (not easy) ? */
> int i_title;
> @@ -214,6 +222,7 @@ enum input_control_e
>
> INPUT_CONTROL_SET_ES,
> INPUT_CONTROL_RESTART_ES,
> + INPUT_CONTROL_SET_VIEWPOINT,
>
> INPUT_CONTROL_SET_AUDIO_DELAY,
> INPUT_CONTROL_SET_SPU_DELAY,
--
Rémi Denis-Courmont
https://www.remlab.net/
More information about the vlc-devel
mailing list