瀏覽代碼

VLCMediaPlayer: exposed yaw pitch and roll for viewpoint

if we want to have correct interaction between devicemotion and panGesture we need to expose the viewpoints yaw pitch and roll
Carola Nitz 7 年之前
父節點
當前提交
3650673ac6
共有 2 個文件被更改,包括 78 次插入13 次删除
  1. 33 5
      Headers/Public/VLCMediaPlayer.h
  2. 45 8
      Sources/VLCMediaPlayer.m

+ 33 - 5
Headers/Public/VLCMediaPlayer.h

@@ -754,16 +754,44 @@ extern NSString *const VLCTitleDescriptionIsMenu;
 
 /**
  * Updates viewpoint with given values.
- * \param yaw new yaw.
- * \param pitch new pitch.
- * \param roll new roll.
- * \param fov new field of view.
+ * \param view point yaw in degrees  ]-180;180]
+ * \param view point pitch in degrees  ]-90;90]
+ * \param view point roll in degrees ]-180;180]
+ * \param field of view in degrees ]0;180[ (default 80.)
  * \param absolute if true replace the old viewpoint with the new one. If
  * false, increase/decrease it.
  * \return NO in case of error, YES otherwise
  * \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;
+- (BOOL)updateViewpoint:(float)yaw pitch:(float)pitch roll:(float)roll fov:(float)fov absolute:(BOOL)absolute;
+
+/**
+* Get the view point yaw in degrees
+*
+* \return view point yaw in degrees  ]-180;180]
+*/
+@property (nonatomic) float yaw;
+
+/**
+ * Get the view point pitch in degrees
+ *
+ * \return view point pitch in degrees  ]-90;90]
+ */
+@property (nonatomic) float pitch;
+
+/**
+ * Get the view point roll in degrees
+ *
+ * \return view point roll in degrees ]-180;180]
+ */
+@property (nonatomic) float roll;
+
+/**
+ * Set/Get the adjust filter's gamma value
+ *
+ * \return field of view in degrees ]0;180[ (default 80.)
+ */
+@property (nonatomic) float fov;
 
 #pragma mark -
 #pragma mark playback information

+ 45 - 8
Sources/VLCMediaPlayer.m

@@ -1104,20 +1104,57 @@ static void HandleMediaPlayerSnapshot(const libvlc_event_t * event, void * self)
     });
 }
 
-- (BOOL)updateViewpoint:(CGFloat)yaw pitch:(CGFloat)pitch roll:(CGFloat)roll fov:(CGFloat)fov absolute:(BOOL)absolute
+- (libvlc_video_viewpoint_t *)viewPoint
 {
     if (_viewpoint == NULL) {
         _viewpoint = libvlc_video_new_viewpoint();
-        if (_viewpoint == NULL)
-            return NO;
     }
+    return _viewpoint;
+}
+
+- (BOOL)updateViewpoint:(float)yaw pitch:(float)pitch roll:(float)roll fov:(float)fov absolute:(BOOL)absolute
+{
+    if ([self viewPoint]) {
+        [self viewPoint]->f_yaw = yaw;
+        [self viewPoint]->f_pitch = pitch;
+        [self viewPoint]->f_roll = roll;
+        [self viewPoint]->f_field_of_view = fov;
+
+        return libvlc_video_update_viewpoint(_playerInstance, _viewpoint, absolute) == 0;
+    }
+    return NO;
+}
 
-    _viewpoint->f_yaw = yaw;
-    _viewpoint->f_pitch = pitch;
-    _viewpoint->f_roll = roll;
-    _viewpoint->f_field_of_view = fov;
+- (float)yaw
+{
+    if ([self viewPoint]) {
+        return [self viewPoint]->f_yaw;
+    }
+    return 0;
+}
 
-    return libvlc_video_update_viewpoint(_playerInstance, _viewpoint, absolute) == 0 ? YES : NO;
+- (float)pitch
+{
+    if ([self viewPoint]) {
+        return [self viewPoint]->f_pitch;
+    }
+    return 0;
+}
+
+- (float)roll
+{
+    if ([self viewPoint]) {
+        return [self viewPoint]->f_roll;
+    }
+    return 0;
+}
+
+- (float)fov
+{
+    if ([self viewPoint]) {
+        return [self viewPoint]->f_field_of_view;
+    }
+    return 0;
 }
 
 - (void)gotoNextFrame