[vlc-devel] [PATCH 15/15] core: handle the mouse navigation in VR/360° videos in the core

Steve Lhomme robux4 at gmail.com
Tue Nov 8 10:34:54 CET 2016


On Tue, Nov 8, 2016 at 10:33 AM, Thomas Guillem <thomas at gllm.fr> wrote:
>
>
> On Tue, Nov 8, 2016, at 10:22, Steve Lhomme wrote:
>> On Mon, Nov 7, 2016 at 6:32 PM, Rémi Denis-Courmont <remi at remlab.net>
>> wrote:
>> > Oh gosh no. User interaction code does not belong in the video output core.
>>
>> The only other solution I can think of is a module like vrnav I did
>> earlier that handles the interaction when the vout is using a non flat
>> projection. The question is when to load it. Should the vout load it
>> when a non-flat projection is used (maybe done in the core) ? Should
>> it be loaded all the time and only do meaningful stuff when the vout
>> is using a non flat projection ? (I think j-b doesn't like the latter,
>> hence I went in another direction)
>
> We could also do the mouse events callback handling in the hotkeys.c
> control module that is always here (maybe rename it to control.c).

I could live with that.

>>
>> > Le maanantaina 7. marraskuuta 2016, 10.52.04 EET Steve Lhomme a écrit :
>> >> --
>> >> * replaces the vrnav module
>> >> * dragging the mouse drags the "world" rather than moving in the "world"
>> >>
>> >> replaces https://patches.videolan.org/patch/14922/
>> >> * put the new fields in a union
>> >> ---
>> >>  src/video_output/display.c       | 27 ++++++++++++++++++++++++++-
>> >>  src/video_output/video_output.c  |  1 +
>> >>  src/video_output/vout_internal.h |  7 +++++++
>> >>  3 files changed, 34 insertions(+), 1 deletion(-)
>> >>
>> >> diff --git a/src/video_output/display.c b/src/video_output/display.c
>> >> index 535b3c3..5346788 100644
>> >> --- a/src/video_output/display.c
>> >> +++ b/src/video_output/display.c
>> >> @@ -1678,7 +1678,17 @@ static inline void
>> >> vout_SendEventMousePressed(vout_thread_t *vout, int button) int x, y;
>> >>          var_GetCoords(vout, "mouse-moved", &x, &y);
>> >>          var_SetCoords(vout, "mouse-clicked", x, y);
>> >> -        var_SetBool(vout->obj.libvlc, "intf-popupmenu", false);
>> >> +        if ( vout->p->display.vd &&
>> >> +             vout->p->display.vd->projection != VOUT_PROJECTION_FLAT )
>> >> +        {
>> >> +            vout->p->vr_navigation.b_enabled = true;
>> >> +            vout->p->vr_navigation.viewpoint =
>> >> +                    vout->p->display.vd->owner.sys->viewpoint;
>> >> +            vout->p->vr_navigation.x = x;
>> >> +            vout->p->vr_navigation.y = y;
>> >> +        }
>> >> +        else
>> >> +            var_SetBool(vout->obj.libvlc, "intf-popupmenu", false);
>> >>          return;
>> >>      }
>> >>      case MOUSE_BUTTON_CENTER:
>> >> @@ -1697,11 +1707,26 @@ static inline void
>> >> vout_SendEventMousePressed(vout_thread_t *vout, int button) static inline
>> >> void vout_SendEventMouseReleased(vout_thread_t *vout, int button) {
>> >>      var_NAndInteger(vout, "mouse-button-down", 1 << button);
>> >> +    if (button == MOUSE_BUTTON_LEFT && vout->p->vr_navigation.b_enabled)
>> >> +        vout->p->vr_navigation.b_enabled = false;
>> >>  }
>> >>
>> >>  static inline void vout_SendEventMouseMoved(vout_thread_t *vout, int x, int
>> >> y) {
>> >>      var_SetCoords(vout, "mouse-moved", x, y);
>> >> +
>> >> +    vout_thread_sys_t *p_sys = vout->p;
>> >> +    if( p_sys->vr_navigation.b_enabled )
>> >> +    {
>> >> +        vlc_viewpoint_t viewpoint = p_sys->vr_navigation.viewpoint;
>> >> +        int i_horizontal = x - p_sys->vr_navigation.x;
>> >> +        int i_vertical   = y - p_sys->vr_navigation.y;
>> >> +
>> >> +        viewpoint.yaw   -= (float)i_horizontal / 300;
>> >> +        viewpoint.pitch -= (float)i_vertical   / 400;
>> >> +
>> >> +        vout_SetDisplayViewpoint( vout->p->display.vd, &viewpoint);
>> >> +    }
>> >>  }
>> >>
>> >>  void vout_SendDisplayEventMouse(vout_thread_t *vout, const vlc_mouse_t *m)
>> >> diff --git a/src/video_output/video_output.c
>> >> b/src/video_output/video_output.c index f3614d2..fcb3459 100644
>> >> --- a/src/video_output/video_output.c
>> >> +++ b/src/video_output/video_output.c
>> >> @@ -1330,6 +1330,7 @@ static int ThreadStart(vout_thread_t *vout,
>> >> vout_display_state_t *state) vout->p->decoder_pool = NULL;
>> >>      vout->p->display_pool = NULL;
>> >>      vout->p->private_pool = NULL;
>> >> +    vout->p->vr_navigation.b_enabled = false;
>> >>
>> >>      vout->p->filter.configuration = NULL;
>> >>      video_format_Copy(&vout->p->filter.format, &vout->p->original);
>> >> diff --git a/src/video_output/vout_internal.h
>> >> b/src/video_output/vout_internal.h index 5ef1435..6884372 100644
>> >> --- a/src/video_output/vout_internal.h
>> >> +++ b/src/video_output/vout_internal.h
>> >> @@ -130,6 +130,13 @@ struct vout_thread_sys_t
>> >>      picture_pool_t  *decoder_pool;
>> >>      picture_fifo_t  *decoder_fifo;
>> >>      vout_chrono_t   render;           /**< picture render time estimator */
>> >> +
>> >> +    /* VR navigation */
>> >> +    union {
>> >> +        bool             b_enabled;
>> >> +        vlc_viewpoint_t  viewpoint;
>> >> +        int              x, y;
>> >> +    } vr_navigation;
>> >>  };
>> >>
>> >>  /* TODO to move them to vlc_vout.h */
>> >
>> >
>> > --
>> > Rémi Denis-Courmont
>> > http://www.remlab.net/
>> >
>> > _______________________________________________
>> > vlc-devel mailing list
>> > To unsubscribe or modify your subscription options:
>> > https://mailman.videolan.org/listinfo/vlc-devel
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list