libvlc: media: add projection in libvlc_video_track_t
authorThomas Guillem <thomas@gllm.fr>
Thu, 24 Nov 2016 17:03:32 +0000 (18:03 +0100)
committerThomas Guillem <thomas@gllm.fr>
Mon, 28 Nov 2016 15:36:44 +0000 (16:36 +0100)
include/vlc/libvlc_media.h
lib/media.c

index c94acb0..01e571c 100644 (file)
@@ -184,6 +184,14 @@ typedef enum libvlc_video_orient_t
     libvlc_video_orient_right_bottom    /**< Anti-transposed */
 } libvlc_video_orient_t;
 
+typedef enum libvlc_video_projection_t
+{
+    libvlc_video_projection_rectangular,
+    libvlc_video_projection_equirectangular, /**< 360 spherical */
+
+    libvlc_video_projection_cubemap_layout_standard = 0x100,
+} libvlc_video_projection_t;
+
 typedef struct libvlc_video_track_t
 {
     unsigned    i_height;
@@ -194,6 +202,13 @@ typedef struct libvlc_video_track_t
     unsigned    i_frame_rate_den;
 
     libvlc_video_orient_t       i_orientation;
+    libvlc_video_projection_t   i_projection;
+    struct {
+        float f_yaw_degrees;    /**< View point yaw in degrees ]-180;180] */
+        float f_pitch_degrees;  /**< View point pitch in degrees ]-90;90] */
+        float f_roll_degrees;   /**< View point roll in degrees ]-180;180] */
+        float f_fov_degrees;    /**< View point fov in degrees ]0;180[ */
+    } pose; /**< Initial view point */
 } libvlc_video_track_t;
 
 typedef struct libvlc_subtitle_track_t
index ac837a2..fdd2445 100644 (file)
@@ -117,6 +117,12 @@ static_assert(
     ORIENT_RIGHT_BOTTOM == (int) libvlc_video_orient_right_bottom,
     "Mismatch between libvlc_video_orient_t and video_orientation_t" );
 
+static_assert(
+    PROJECTION_MODE_RECTANGULAR             == (int) libvlc_video_projection_rectangular &&
+    PROJECTION_MODE_EQUIRECTANGULAR         == (int) libvlc_video_projection_equirectangular &&
+    PROJECTION_MODE_CUBEMAP_LAYOUT_STANDARD == (int) libvlc_video_projection_cubemap_layout_standard,
+    "Mismatch between libvlc_video_projection_t and video_projection_mode_t" );
+
 static libvlc_media_list_t *media_get_subitems( libvlc_media_t * p_md,
                                                 bool b_create )
 {
@@ -1010,6 +1016,15 @@ libvlc_media_tracks_get( libvlc_media_t *p_md, libvlc_media_track_t *** pp_es )
                     p_es->video.orientation <= ORIENT_RIGHT_BOTTOM );
             p_mes->video->i_orientation = (int) p_es->video.orientation;
 
+            assert( ( p_es->video.projection_mode >= PROJECTION_MODE_RECTANGULAR &&
+                    p_es->video.projection_mode <= PROJECTION_MODE_EQUIRECTANGULAR ) ||
+                    ( p_es->video.projection_mode == PROJECTION_MODE_CUBEMAP_LAYOUT_STANDARD ) );
+            p_mes->video->i_projection = (int) p_es->video.projection_mode;
+
+            p_mes->video->pose.f_yaw_degrees = p_es->video.pose.f_yaw_degrees;
+            p_mes->video->pose.f_pitch_degrees = p_es->video.pose.f_pitch_degrees;
+            p_mes->video->pose.f_roll_degrees = p_es->video.pose.f_roll_degrees;
+            p_mes->video->pose.f_fov_degrees = p_es->video.pose.f_fov_degrees;
             break;
         case AUDIO_ES:
             p_mes->i_type = libvlc_track_audio;