libvlc: media: add projection in libvlc_video_track_t
[vlc.git] / lib / media.c
index e01beed..fdd2445 100644 (file)
@@ -106,6 +106,23 @@ 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_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 )
 {
@@ -533,8 +550,7 @@ void libvlc_media_release( libvlc_media_t *p_md )
     uninstall_input_item_observer( p_md );
 
     /* Cancel asynchronous parsing (if any) */
-    if( p_md->p_input_item )
-        libvlc_MetadataCancel( p_md->p_libvlc_instance->p_libvlc_int, p_md );
+    libvlc_MetadataCancel( p_md->p_libvlc_instance->p_libvlc_int, p_md );
 
     if( p_md->p_subitems )
         libvlc_media_list_release( p_md->p_subitems );
@@ -818,6 +834,12 @@ libvlc_media_parse_with_options( libvlc_media_t *media,
     return media_parse( media, true, parse_flag, timeout ) == VLC_SUCCESS ? 0 : -1;
 }
 
+void
+libvlc_media_parse_stop( libvlc_media_t *media )
+{
+    libvlc_MetadataCancel( media->p_libvlc_instance->p_libvlc_int, media );
+}
+
 /**************************************************************************
  * Get parsed status for media object.
  **************************************************************************/
@@ -989,6 +1011,20 @@ 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;
+
+            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;