[vlc-commits] input: add INPUT_SET_INITIAL_VIEWPOINT control

Thomas Guillem git at videolan.org
Tue Jul 25 16:42:49 CEST 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Jul 24 19:17:29 2017 +0200| [3fdd4286d378d773c573cfc6f8cc58c59b64b444] | committer: 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.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3fdd4286d378d773c573cfc6f8cc58c59b64b444
---

 include/vlc_input.h        |  1 +
 src/input/control.c        |  6 +++++-
 src/input/input.c          | 22 ++++++++++++++++++++--
 src/input/input_internal.h |  2 ++
 4 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/include/vlc_input.h b/include/vlc_input.h
index 8afefafe73..21e02b2c7b 100644
--- a/include/vlc_input.h
+++ b/include/vlc_input.h
@@ -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 */
diff --git a/src/input/control.c b/src/input/control.c
index 24fe630473..1401e0893d 100644
--- a/src/input/control.c
+++ b/src/input/control.c
@@ -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 );
diff --git a/src/input/input.c b/src/input/input.c
index dc9213eb03..428f05e29d 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -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;
diff --git a/src/input/input_internal.h b/src/input/input_internal.h
index 2d5384093b..3606f575f1 100644
--- a/src/input/input_internal.h
+++ b/src/input/input_internal.h
@@ -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,



More information about the vlc-commits mailing list