Browse Source

VLCMediaPlayer: Add viewpoint handling

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
Soomin Lee 8 years ago
parent
commit
b3d92edbf4
2 changed files with 34 additions and 0 deletions
  1. 13 0
      Headers/Public/VLCMediaPlayer.h
  2. 21 0
      Sources/VLCMediaPlayer.m

+ 13 - 0
Headers/Public/VLCMediaPlayer.h

@@ -8,6 +8,7 @@
  *
  * Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
  *          Felix Paul Kühne <fkuehne # videolan.org>
+ *          Soomin Lee <TheHungryBu # gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published by
@@ -753,6 +754,18 @@ extern NSString *const VLCTitleDescriptionIsMenu;
  */
 - (void)performNavigationAction:(VLCMediaPlaybackNavigationAction)action;
 
+/**
+ * Updates viewpoint with given values.
+ * \param yaw new yaw.
+ * \param pitch new pitch.
+ * \param roll new roll.
+ * \param fov new field of view.
+ * \param absolute if true replace the old viewpoint with the new one. If
+ * false, increase/decrease it.
+ * \note This will create a viewpoint instance if not present.
+ */
+- (BOOL)updateViewpoint:(CGFloat)yaw pitch:(CGFloat)pitch roll:(CGFloat)roll fov:(CGFloat)fov absolute:(BOOL)absolute;
+
 #pragma mark -
 #pragma mark playback information
 /**

+ 21 - 0
Sources/VLCMediaPlayer.m

@@ -9,6 +9,7 @@
  * Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
  *          Faustion Osuna <enrique.osuna # gmail.com>
  *          Felix Paul Kühne <fkuehne # videolan.org>
+ *          Soomin Lee <TheHungryBu # gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published by
@@ -218,6 +219,7 @@ static void HandleMediaPlayerSnapshot(const libvlc_event_t * event, void * self)
     VLCAudio *_audio;                           ///< The audio controller
     libvlc_equalizer_t *_equalizerInstance;     ///< The equalizer controller
     BOOL _equalizerEnabled;                     ///< Equalizer state
+    libvlc_video_viewpoint_t *_viewpoint;       ///< Current viewpoint of the media
 }
 @end
 
@@ -316,6 +318,9 @@ static void HandleMediaPlayerSnapshot(const libvlc_event_t * event, void * self)
         libvlc_audio_equalizer_release(_equalizerInstance);
     }
 
+    if (_viewpoint)
+        libvlc_free(_viewpoint);
+
     libvlc_media_player_release(_playerInstance);
     if (_privateLibrary != [VLCLibrary sharedLibrary])
         libvlc_release(_privateLibrary.instance);
@@ -1116,6 +1121,22 @@ static void HandleMediaPlayerSnapshot(const libvlc_event_t * event, void * self)
     libvlc_media_player_stop(_playerInstance);
 }
 
+- (BOOL)updateViewpoint:(CGFloat)yaw pitch:(CGFloat)pitch roll:(CGFloat)roll fov:(CGFloat)fov absolute:(BOOL)absolute
+{
+    if (_viewpoint == NULL) {
+        _viewpoint = libvlc_video_new_viewpoint();
+        if (_viewpoint == NULL)
+            return NO;
+    }
+
+    _viewpoint->f_yaw = yaw;
+    _viewpoint->f_pitch = pitch;
+    _viewpoint->f_roll = roll;
+    _viewpoint->f_field_of_view = fov;
+
+    return libvlc_video_update_viewpoint(_playerInstance, _viewpoint, absolute) == 0 ? YES : NO;
+}
+
 - (void)gotoNextFrame
 {
     libvlc_media_player_next_frame(_playerInstance);