Commit a1561a60 authored by Steve Lhomme's avatar Steve Lhomme Committed by Thomas Guillem

input: add INPUT_UPDATE_VIEWPOINT

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.
Signed-off-by: Thomas Guillem's avatarThomas Guillem <thomas@gllm.fr>
parent 335c16ab
......@@ -473,6 +473,9 @@ enum input_query_e
/* ES */
INPUT_RESTART_ES, /* arg1=int (-AUDIO/VIDEO/SPU_ES for the whole category) */
/* Viewpoint */
INPUT_UPDATE_VIEWPOINT, /* arg1=(const vlc_viewpoint_t*), arg2=bool b_absolute */
/* Input ressources
* XXX You must call vlc_object_release as soon as possible */
INPUT_GET_AOUT, /* arg1=audio_output_t ** res=can fail */
......@@ -597,6 +600,23 @@ static inline int input_AddSlave( input_thread_t *p_input, enum slave_type type,
return input_Control( p_input, INPUT_ADD_SLAVE, type, psz_uri, b_forced );
}
/**
* Update the viewpoint of the input thread. The viewpoint will be applied to
* all vouts and aouts.
*
* @param p_input an input thread
* @param p_viewpoint the viewpoint value
* @param b_absolute if true replace the old viewpoint with the new one. If
* false, increase/decrease it.
* @return VLC_SUCCESS or a VLC error code
*/
static inline int input_UpdateViewpoint( input_thread_t *p_input,
const vlc_viewpoint_t *p_viewpoint,
bool b_absolute )
{
return input_Control( p_input, INPUT_UPDATE_VIEWPOINT, p_viewpoint,
b_absolute );
}
/**
* Return the audio output (if any) associated with an input.
......
......@@ -519,6 +519,20 @@ 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_UPDATE_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 ) )
input_ControlPush( p_input, INPUT_CONTROL_SET_VIEWPOINT, &val );
else
input_ControlPush( p_input, INPUT_CONTROL_UPDATE_VIEWPOINT, &val );
return VLC_SUCCESS;
}
case INPUT_GET_AOUT:
{
audio_output_t *p_aout = input_resource_HoldAout( priv->p_resource );
......
......@@ -324,6 +324,12 @@ 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;
vlc_viewpoint_t *p_viewpoint = var_InheritAddress( p_input, "viewpoint" );
if (likely(p_viewpoint != NULL))
priv->viewpoint = *p_viewpoint;
else
vlc_viewpoint_init( &priv->viewpoint );
vlc_gc_incref( p_item ); /* Released in Destructor() */
priv->p_item = p_item;
......@@ -1655,6 +1661,10 @@ 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:
case INPUT_CONTROL_UPDATE_VIEWPOINT:
free( val.p_address );
break;
default:
break;
......@@ -1918,6 +1928,39 @@ static bool Control( input_thread_t *p_input,
ES_OUT_RESTART_ES_BY_ID, (int)val.i_int );
break;
case INPUT_CONTROL_SET_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)
priv->viewpoint = *p_vp;
else
{
priv->viewpoint.yaw += p_vp->yaw;
priv->viewpoint.pitch += p_vp->pitch;
priv->viewpoint.roll += p_vp->roll;
priv->viewpoint.fov += p_vp->fov;
priv->viewpoint.zoom += p_vp->zoom;
}
priv->viewpoint.yaw = fmodf( priv->viewpoint.yaw, 360.f );
priv->viewpoint.pitch = fmodf( priv->viewpoint.pitch, 360.f );
priv->viewpoint.roll = fmodf( priv->viewpoint.roll, 360.f );
priv->viewpoint.fov = VLC_CLIP( priv->viewpoint.fov, 0.f, 180.f );
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 )
{
var_SetAddress( pp_vout[i], "viewpoint", &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 );
......
......@@ -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"
......@@ -109,6 +110,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;
......@@ -215,6 +217,9 @@ enum input_control_e
INPUT_CONTROL_SET_ES,
INPUT_CONTROL_RESTART_ES,
INPUT_CONTROL_SET_VIEWPOINT, // new absolute viewpoint
INPUT_CONTROL_UPDATE_VIEWPOINT, // update viewpoint relative to current
INPUT_CONTROL_SET_AUDIO_DELAY,
INPUT_CONTROL_SET_SPU_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