Commit 3fdd4286 authored by Thomas Guillem's avatar Thomas Guillem

input: add INPUT_SET_INITIAL_VIEWPOINT control

This new control sets an initial viewpoint (generally comming from the video
ES) to the input.

If the viewpoint had already been changed by the user, the input viewpoint
value won't change and the user viewpoint will be sent to all ESes.
parent aa9b1110
......@@ -472,6 +472,7 @@ enum input_query_e
/* Viewpoint */
INPUT_UPDATE_VIEWPOINT, /* arg1=(const vlc_viewpoint_t*), arg2=bool b_absolute */
INPUT_SET_INITIAL_VIEWPOINT, /* arg1=(const vlc_viewpoint_t*) */
/* Input ressources
* XXX You must call vlc_object_release as soon as possible */
......
......@@ -497,13 +497,17 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
return VLC_SUCCESS;
case INPUT_UPDATE_VIEWPOINT:
case INPUT_SET_INITIAL_VIEWPOINT:
{
vlc_viewpoint_t *p_viewpoint = malloc( sizeof(*p_viewpoint) );
if( unlikely(p_viewpoint == NULL) )
return VLC_ENOMEM;
val.p_address = p_viewpoint;
*p_viewpoint = *va_arg( args, const vlc_viewpoint_t* );
if ( va_arg( args, int ) )
if ( i_query == INPUT_SET_INITIAL_VIEWPOINT )
input_ControlPush( p_input, INPUT_CONTROL_SET_INITIAL_VIEWPOINT,
&val );
else if ( va_arg( args, int ) )
input_ControlPush( p_input, INPUT_CONTROL_SET_VIEWPOINT, &val );
else
input_ControlPush( p_input, INPUT_CONTROL_UPDATE_VIEWPOINT, &val );
......
......@@ -321,8 +321,10 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
priv->p_sout = NULL;
priv->b_out_pace_control = false;
priv->viewpoint_changed = false;
/* Fetch the viewpoint from the mediaplayer or the playlist if any */
vlc_viewpoint_t *p_viewpoint = var_InheritAddress( p_input, "viewpoint" );
if (likely(p_viewpoint != NULL))
if (p_viewpoint != NULL)
priv->viewpoint = *p_viewpoint;
else
vlc_viewpoint_init( &priv->viewpoint );
......@@ -1678,6 +1680,7 @@ static void ControlRelease( int i_type, vlc_value_t val )
input_item_slave_Delete( val.p_address );
break;
case INPUT_CONTROL_SET_VIEWPOINT:
case INPUT_CONTROL_SET_INITIAL_VIEWPOINT:
case INPUT_CONTROL_UPDATE_VIEWPOINT:
free( val.p_address );
break;
......@@ -1945,14 +1948,29 @@ static bool Control( input_thread_t *p_input,
break;
case INPUT_CONTROL_SET_VIEWPOINT:
case INPUT_CONTROL_SET_INITIAL_VIEWPOINT:
case INPUT_CONTROL_UPDATE_VIEWPOINT:
{
input_thread_private_t *priv = input_priv(p_input);
const vlc_viewpoint_t *p_vp = val.p_address;
if ( i_type == INPUT_CONTROL_SET_VIEWPOINT)
if ( i_type == INPUT_CONTROL_SET_INITIAL_VIEWPOINT )
{
/* Set the initial viewpoint if it had not been changed by the
* user. */
if( !priv->viewpoint_changed )
priv->viewpoint = *p_vp;
/* Update viewpoints of aout and every vouts in all cases. */
}
else if ( i_type == INPUT_CONTROL_SET_VIEWPOINT)
{
priv->viewpoint_changed = true;
priv->viewpoint = *p_vp;
}
else
{
priv->viewpoint_changed = true;
priv->viewpoint.yaw += p_vp->yaw;
priv->viewpoint.pitch += p_vp->pitch;
priv->viewpoint.roll += p_vp->roll;
......
......@@ -111,6 +111,7 @@ typedef struct input_thread_private_t
es_out_t *p_es_out;
es_out_t *p_es_out_display;
vlc_viewpoint_t viewpoint;
bool viewpoint_changed;
/* Title infos FIXME multi-input (not easy) ? */
int i_title;
......@@ -218,6 +219,7 @@ enum input_control_e
INPUT_CONTROL_RESTART_ES,
INPUT_CONTROL_SET_VIEWPOINT, // new absolute viewpoint
INPUT_CONTROL_SET_INITIAL_VIEWPOINT, // set initial viewpoint (generally from video)
INPUT_CONTROL_UPDATE_VIEWPOINT, // update viewpoint relative to current
INPUT_CONTROL_SET_AUDIO_DELAY,
......
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