[vlc-devel] [PATCH 5/6] libvlc: add an API to set the display configuration

Steve Lhomme robux4 at ycbcr.xyz
Fri Jan 25 16:47:04 CET 2019


---
 include/vlc/libvlc_media_player.h | 15 +++++++++++++++
 lib/libvlc.sym                    |  1 +
 lib/media_player.c                |  3 +++
 lib/video.c                       | 17 +++++++++++++++++
 4 files changed, 36 insertions(+)

diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index b7278c0360..58508463ef 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -559,6 +559,7 @@ typedef enum {
  * The \ref chroma is used to do the proper color conversions so that the
  * rendering is as accurate as possible based on the source being played.
  *
+ * \see libvlc_video_set_surface_display_config()
  * \see libvlc_video_set_surface_callbacks()
  */
 typedef struct libvlc_video_surface_cfg_t {
@@ -571,6 +572,19 @@ typedef struct libvlc_video_surface_cfg_t {
     bool limited_range; /**< full range (0-255) or studio/limited range (16-235) */
 } libvlc_video_surface_cfg_t;
 
+/**
+ * Set display configuration to use with surface rendering
+ *
+ * \param mp the media player that must use this configuration
+ * \param display_cfg the new display configuration to use.
+ * \see libvlc_video_set_surface_callbacks
+ * \libvlc_return_bool
+ * \version LibVLC 4.0.0 or later
+ */
+LIBVLC_API
+int libvlc_video_set_surface_display_config( libvlc_media_player_t *mp,
+                                             const libvlc_video_surface_cfg_t *display_cfg );
+
 /**
  * Enumeration of the Video engine to be used on output.
  * can be passed to @a libvlc_video_set_surface_callbacks
@@ -596,6 +610,7 @@ typedef enum libvlc_video_engine_t {
  * \param swap_cb callback called after rendering a video frame (cannot be NULL)
  * \param makeCurrent_cb callback called to enter/leave the opengl context (cannot be NULL for \ref libvlc_video_engine_opengl and for \ref libvlc_video_engine_gles2)
  * \param getProcAddress_cb opengl function loading callback (cannot be NULL for \ref libvlc_video_engine_opengl and for \ref libvlc_video_engine_gles2)
+ * \param initial_display is the configuration of the display to use (cannot be NULL) until the next call to \ref libvlc_video_update_surface_display_config()
  * \param opaque private pointer passed to callbacks
  * \libvlc_return_bool
  * \version LibVLC 4.0.0 or later
diff --git a/lib/libvlc.sym b/lib/libvlc.sym
index e948b57120..f0afd495ba 100644
--- a/lib/libvlc.sym
+++ b/lib/libvlc.sym
@@ -247,6 +247,7 @@ libvlc_video_set_deinterlace
 libvlc_video_set_format
 libvlc_video_set_format_callbacks
 libvlc_video_set_surface_callbacks
+libvlc_video_set_surface_display_config
 libvlc_video_set_key_input
 libvlc_video_set_logo_int
 libvlc_video_set_logo_string
diff --git a/lib/media_player.c b/lib/media_player.c
index 5b42feba37..3ebf237b5b 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -703,6 +703,9 @@ libvlc_media_player_new( libvlc_instance_t *instance )
     var_Create (mp, "saturation", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT);
     var_Create (mp, "gamma", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT);
 
+    var_Create (mp, "width", VLC_VAR_INTEGER);
+    var_Create (mp, "height", VLC_VAR_INTEGER);
+
      /* Audio */
     var_Create (mp, "aout", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
     var_Create (mp, "audio-device", VLC_VAR_STRING);
diff --git a/lib/video.c b/lib/video.c
index f3445f351b..faa72e9598 100644
--- a/lib/video.c
+++ b/lib/video.c
@@ -633,6 +633,23 @@ void libvlc_video_set_deinterlace( libvlc_media_player_t *p_mi, int deinterlace,
     free (pp_vouts);
 }
 
+int libvlc_video_set_surface_display_config( libvlc_media_player_t *mp,
+                                             const libvlc_video_surface_cfg_t *display_cfg )
+{
+    size_t n;
+
+    var_SetInteger( mp, "width", display_cfg->width );
+    var_SetInteger( mp, "height", display_cfg->height );
+
+    vout_thread_t **pp_vouts = GetVouts (mp, &n);
+    for (size_t i = 0; i < n; i++)
+    {
+        vout_thread_t *p_vout = pp_vouts[i];
+        vout_ControlChangeDisplaySize( p_vout, display_cfg->width, display_cfg->height );
+    }
+    return 1;
+}
+
 /* ************** */
 /* module helpers */
 /* ************** */
-- 
2.17.1



More information about the vlc-devel mailing list