[vlc-devel] [PATCH 4/6] libvlc: add get/set functions for libVLC stereo mode

Steve Lhomme robux4 at ycbcr.xyz
Mon Aug 13 16:44:44 CEST 2018


From: "Mohammed (Shaan) Huzaifa Danish" <shaan3 at gmail.com>

Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>
---
 include/vlc/libvlc_media_player.h | 29 +++++++++++++++++++++++++++++
 lib/libvlc.sym                    |  2 ++
 lib/media_player.c                |  1 +
 lib/video.c                       | 28 ++++++++++++++++++++++++++++
 4 files changed, 60 insertions(+)

diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 87d3368bf3..b355443448 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -1199,6 +1199,35 @@ LIBVLC_API int libvlc_video_update_viewpoint( libvlc_media_player_t *p_mi,
                                               const libvlc_video_viewpoint_t *p_viewpoint,
                                               bool b_absolute);
 
+/**
+ * Video stereo modes
+ */
+typedef enum libvlc_video_stereo_mode_t {
+    libvlc_VideoStereoAuto = 0,
+    libvlc_VideoStereoStereo,
+    libvlc_VideoStereoLeftEye,
+    libvlc_VideoStereoRightEye,
+    libvlc_VideoStereoSideBySide,
+} libvlc_video_stereo_mode_t;
+
+/**
+ * Get current video stereo mode.
+ *
+ * \param p_mi the media player
+ * \return the video stereo mode.
+ */
+LIBVLC_API libvlc_video_stereo_mode_t libvlc_video_get_video_stereo_mode(
+                                              libvlc_media_player_t *p_mi );
+
+/**
+ * Set new video stereo mode.
+ *
+ * \param p_mi the media player
+ * \param i_mode new video stereo mode
+ */
+LIBVLC_API void libvlc_video_set_video_stereo_mode( libvlc_media_player_t *p_mi,
+                                      const libvlc_video_stereo_mode_t i_mode );
+
 /**
  * Get current video subtitle.
  *
diff --git a/lib/libvlc.sym b/lib/libvlc.sym
index cfa588be01..750bde4d99 100644
--- a/lib/libvlc.sym
+++ b/lib/libvlc.sym
@@ -235,6 +235,7 @@ libvlc_video_get_teletext
 libvlc_video_get_track
 libvlc_video_get_track_count
 libvlc_video_get_track_description
+libvlc_video_get_video_stereo_mode
 libvlc_video_set_adjust_float
 libvlc_video_set_adjust_int
 libvlc_video_set_aspect_ratio
@@ -254,6 +255,7 @@ libvlc_video_set_spu
 libvlc_video_set_spu_delay
 libvlc_video_set_teletext
 libvlc_video_set_track
+libvlc_video_set_video_stereo_mode
 libvlc_video_take_snapshot
 libvlc_video_new_viewpoint
 libvlc_video_update_viewpoint
diff --git a/lib/media_player.c b/lib/media_player.c
index 30374d4ee9..a624588bbd 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -659,6 +659,7 @@ libvlc_media_player_new( libvlc_instance_t *instance )
     var_Create (mp, "crop", VLC_VAR_STRING);
     var_Create (mp, "deinterlace", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT);
     var_Create (mp, "deinterlace-mode", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
+    var_Create (mp, "video-stereo-mode", VLC_VAR_INTEGER);
 
     var_Create (mp, "vbi-page", VLC_VAR_INTEGER);
     var_SetInteger (mp, "vbi-page", 100);
diff --git a/lib/video.c b/lib/video.c
index e5796ec2c8..5c87bf49c0 100644
--- a/lib/video.c
+++ b/lib/video.c
@@ -315,6 +315,34 @@ int libvlc_video_update_viewpoint( libvlc_media_player_t *p_mi,
     return 0;
 }
 
+libvlc_video_stereo_mode_t libvlc_video_get_video_stereo_mode(libvlc_media_player_t *p_mi)
+{
+    static_assert( libvlc_VideoStereoAuto       == VIDEO_STEREO_OUTPUT_AUTO &&
+                   libvlc_VideoStereoStereo     == VIDEO_STEREO_OUTPUT_STEREO &&
+                   libvlc_VideoStereoLeftEye    == VIDEO_STEREO_OUTPUT_LEFT_ONLY &&
+                   libvlc_VideoStereoRightEye   == VIDEO_STEREO_OUTPUT_RIGHT_ONLY &&
+                   libvlc_VideoStereoSideBySide == VIDEO_STEREO_OUTPUT_SIDE_BY_SIDE,
+                   "stereo mode mismatch" );
+
+    return var_GetInteger(p_mi, "video-stereo-mode");
+}
+
+void libvlc_video_set_video_stereo_mode(libvlc_media_player_t *p_mi,
+                                       const libvlc_video_stereo_mode_t i_mode)
+{
+    input_thread_t *p_input_thread = libvlc_get_input_thread(p_mi);
+
+    if (p_input_thread)
+    {
+        var_SetInteger(p_input_thread, "video-stereo-mode", i_mode);
+        vlc_object_release(p_input_thread);
+    }
+    else
+    {
+        libvlc_printerr("No active input");
+    }
+}
+
 int libvlc_video_get_spu( libvlc_media_player_t *p_mi )
 {
     input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi );
-- 
2.17.0



More information about the vlc-devel mailing list