libvlc: media: add orientation in libvlc_video_track_t
authorThomas Guillem <thomas@gllm.fr>
Thu, 24 Nov 2016 17:03:03 +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 8fd13fe..c94acb0 100644 (file)
@@ -172,6 +172,18 @@ typedef struct libvlc_audio_track_t
     unsigned    i_rate;
 } libvlc_audio_track_t;
 
+typedef enum libvlc_video_orient_t
+{
+    libvlc_video_orient_top_left,       /**< Normal. Top line represents top, left column left. */
+    libvlc_video_orient_top_right,      /**< Flipped horizontally */
+    libvlc_video_orient_bottom_left,    /**< Flipped vertically */
+    libvlc_video_orient_bottom_right,   /**< Rotated 180 degrees */
+    libvlc_video_orient_left_top,       /**< Transposed */
+    libvlc_video_orient_left_bottom,    /**< Rotated 90 degrees clockwise (or 270 anti-clockwise) */
+    libvlc_video_orient_right_top,      /**< Rotated 90 degrees anti-clockwise */
+    libvlc_video_orient_right_bottom    /**< Anti-transposed */
+} libvlc_video_orient_t;
+
 typedef struct libvlc_video_track_t
 {
     unsigned    i_height;
@@ -180,6 +192,8 @@ typedef struct libvlc_video_track_t
     unsigned    i_sar_den;
     unsigned    i_frame_rate_num;
     unsigned    i_frame_rate_den;
+
+    libvlc_video_orient_t       i_orientation;
 } libvlc_video_track_t;
 
 typedef struct libvlc_subtitle_track_t
index 8e07930..ac837a2 100644 (file)
@@ -106,6 +106,17 @@ static const libvlc_meta_t vlc_to_libvlc_meta[] =
     [vlc_meta_DiscTotal]    = libvlc_meta_DiscTotal
 };
 
+static_assert(
+    ORIENT_TOP_LEFT     == (int) libvlc_video_orient_top_left &&
+    ORIENT_TOP_RIGHT    == (int) libvlc_video_orient_top_right &&
+    ORIENT_BOTTOM_LEFT  == (int) libvlc_video_orient_bottom_left &&
+    ORIENT_BOTTOM_RIGHT == (int) libvlc_video_orient_bottom_right &&
+    ORIENT_LEFT_TOP     == (int) libvlc_video_orient_left_top &&
+    ORIENT_LEFT_BOTTOM  == (int) libvlc_video_orient_left_bottom &&
+    ORIENT_RIGHT_TOP    == (int) libvlc_video_orient_right_top &&
+    ORIENT_RIGHT_BOTTOM == (int) libvlc_video_orient_right_bottom,
+    "Mismatch between libvlc_video_orient_t and video_orientation_t" );
+
 static libvlc_media_list_t *media_get_subitems( libvlc_media_t * p_md,
                                                 bool b_create )
 {
@@ -994,6 +1005,11 @@ libvlc_media_tracks_get( libvlc_media_t *p_md, libvlc_media_track_t *** pp_es )
             p_mes->video->i_sar_den = p_es->video.i_sar_den;
             p_mes->video->i_frame_rate_num = p_es->video.i_frame_rate;
             p_mes->video->i_frame_rate_den = p_es->video.i_frame_rate_base;
+
+            assert( p_es->video.orientation >= ORIENT_TOP_LEFT &&
+                    p_es->video.orientation <= ORIENT_RIGHT_BOTTOM );
+            p_mes->video->i_orientation = (int) p_es->video.orientation;
+
             break;
         case AUDIO_ES:
             p_mes->i_type = libvlc_track_audio;