[vlc-devel] [PATCH 08/17] input: add INPUT_SET_VIEWPOINT

Steve Lhomme robux4 at videolabs.io
Mon Nov 14 16:30:32 CET 2016


From: Thomas Guillem <thomas at gllm.fr>

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.

--
replaces https://patches.videolan.org/patch/15003/
* Inherit the initial value from the "viewpoint" variable.
* add input_SetViewpoint()

replaces https://patches.videolan.org/patch/15015/
* split INPUT_CONTROL_SET_VIEWPOINT in absolute and relative controls
---
 include/vlc_input.h        |  7 +++++++
 src/input/control.c        | 14 ++++++++++++++
 src/input/input.c          | 37 +++++++++++++++++++++++++++++++++++++
 src/input/input_internal.h |  5 +++++
 4 files changed, 63 insertions(+)

diff --git a/include/vlc_input.h b/include/vlc_input.h
index a2ddaad..b93ee24 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 */
@@ -597,6 +598,12 @@ 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 );
 }
 
+static inline int input_SetViewpoint( input_thread_t *p_input,
+                                      const vlc_viewpoint_t *p_viewpoint,
+                                      int b_absolute )
+{
+    return input_Control( p_input, INPUT_SET_VIEWPOINT, p_viewpoint, b_absolute );
+}
 
 /**
  * Return the audio output (if any) associated with an input.
diff --git a/src/input/control.c b/src/input/control.c
index bb5100c..8ae6090 100644
--- a/src/input/control.c
+++ b/src/input/control.c
@@ -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_SET_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_ABS_VIEWPOINT, &val );
+            else
+                input_ControlPush( p_input, INPUT_CONTROL_SET_REL_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..e89d570 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -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_ABS_VIEWPOINT:
+    case INPUT_CONTROL_SET_REL_VIEWPOINT:
+        free( val.p_address );
+        break;
 
     default:
         break;
@@ -1918,6 +1928,33 @@ static bool Control( input_thread_t *p_input,
                             ES_OUT_RESTART_ES_BY_ID, (int)val.i_int );
             break;
 
+        case INPUT_CONTROL_SET_ABS_VIEWPOINT:
+        case INPUT_CONTROL_SET_REL_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_ABS_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;
+            }
+            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..1d80ad3 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"
@@ -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_ABS_VIEWPOINT, // new absolute viewpoint
+    INPUT_CONTROL_SET_REL_VIEWPOINT, // update viewpoint relative to current
+
     INPUT_CONTROL_SET_AUDIO_DELAY,
     INPUT_CONTROL_SET_SPU_DELAY,
 
-- 
2.10.1.windows.1



More information about the vlc-devel mailing list