[vlc-devel] [PATCH 04/18] libvlc: pass the rendering configuration update as a structure

Steve Lhomme robux4 at ycbcr.xyz
Tue Feb 4 16:25:59 CET 2020


---
 doc/libvlc/QtGL/qtvlcwidget.cpp   | 14 +++++++-------
 doc/libvlc/sdl_opengl_player.cpp  | 10 +++++-----
 include/vlc/libvlc_media_player.h | 11 ++++++++---
 modules/video_output/vgl.c        |  5 ++++-
 4 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/doc/libvlc/QtGL/qtvlcwidget.cpp b/doc/libvlc/QtGL/qtvlcwidget.cpp
index 91ed826e43b..60f6127213c 100644
--- a/doc/libvlc/QtGL/qtvlcwidget.cpp
+++ b/doc/libvlc/QtGL/qtvlcwidget.cpp
@@ -38,19 +38,19 @@ public:
     }
 
     /// this callback will create the surfaces and FBO used by VLC to perform its rendering
-    static void resizeRenderTextures(void* data, unsigned width, unsigned height,
+    static void resizeRenderTextures(void* data, const libvlc_video_render_cfg_t *cfg,
                                      libvlc_video_output_cfg_t *render_cfg)
     {
        VLCVideo* that = static_cast<VLCVideo*>(data);
-        if (width != that->m_width || height != that->m_height)
+        if (cfg->width != that->m_width || cfg->height != that->m_height)
             cleanup(data);
 
-        that->mBuffers[0] = new QOpenGLFramebufferObject(width, height);
-        that->mBuffers[1] = new QOpenGLFramebufferObject(width, height);
-        that->mBuffers[2] = new QOpenGLFramebufferObject(width, height);
+        that->mBuffers[0] = new QOpenGLFramebufferObject(cfg->width, cfg->height);
+        that->mBuffers[1] = new QOpenGLFramebufferObject(cfg->width, cfg->height);
+        that->mBuffers[2] = new QOpenGLFramebufferObject(cfg->width, cfg->height);
 
-        that->m_width = width;
-        that->m_height = height;
+        that->m_width = cfg->width;
+        that->m_height = cfg->height;
 
         that->mBuffers[that->m_idx_render]->bind();
 
diff --git a/doc/libvlc/sdl_opengl_player.cpp b/doc/libvlc/sdl_opengl_player.cpp
index 386e78e8e4c..ca86e718698 100644
--- a/doc/libvlc/sdl_opengl_player.cpp
+++ b/doc/libvlc/sdl_opengl_player.cpp
@@ -116,11 +116,11 @@ public:
     }
 
     /// this callback will create the surfaces and FBO used by VLC to perform its rendering
-    static void resize(void* data, unsigned width, unsigned height,
+    static void resize(void* data, const libvlc_video_render_cfg_t *cfg,
                        libvlc_video_output_cfg_t *render_cfg)
     {
         VLCVideo* that = static_cast<VLCVideo*>(data);
-        if (width != that->m_width || height != that->m_height)
+        if (cfg->width != that->m_width || cfg->height != that->m_height)
             cleanup(data);
 
         glGenTextures(3, that->m_tex);
@@ -128,7 +128,7 @@ public:
 
         for (int i = 0; i < 3; i++) {
             glBindTexture(GL_TEXTURE_2D, that->m_tex[i]);
-            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, cfg->width, cfg->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
             glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
             glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
             glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@@ -145,8 +145,8 @@ public:
             return;
         }
 
-        that->m_width = width;
-        that->m_height = height;
+        that->m_width = cfg->width;
+        that->m_height = cfg->height;
 
         glBindFramebuffer(GL_FRAMEBUFFER, that->m_fbo[that->m_idx_render]);
 
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 940059f044d..62224450f13 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -521,6 +521,12 @@ typedef bool (*libvlc_video_setup_cb)(void* opaque);
  */
 typedef void (*libvlc_video_cleanup_cb)(void* opaque);
 
+typedef struct
+{
+    unsigned width;                        /** rendering video width in pixel */
+    unsigned height;                      /** rendering video height in pixel */
+} libvlc_video_render_cfg_t;
+
 typedef struct
 {
     int surface_format;  /** the rendering DXGI_FORMAT for \ref libvlc_video_direct3d_engine_d3d11,
@@ -537,12 +543,11 @@ typedef struct
  * Callback prototype called on video size changes
  *
  * \param opaque private pointer passed to the @a libvlc_video_set_output_callbacks() [IN]
- * \param width video width in pixel [IN]
- * \param height video height in pixel [IN]
+ * \param cfg configuration of the video that will be rendered [IN]
  * \param output configuration describing with how the rendering is setup [OUT]
  * \version LibVLC 4.0.0 or later
  */
-typedef void (*libvlc_video_update_output_cb)(void* opaque, unsigned width, unsigned height,
+typedef void (*libvlc_video_update_output_cb)(void* opaque, const libvlc_video_render_cfg_t *cfg,
                                               libvlc_video_output_cfg_t *output );
 
 
diff --git a/modules/video_output/vgl.c b/modules/video_output/vgl.c
index 22740aa6016..783cd016938 100644
--- a/modules/video_output/vgl.c
+++ b/modules/video_output/vgl.c
@@ -82,8 +82,11 @@ static void Resize(vlc_gl_t * gl, unsigned w, unsigned h)
         return;
 
     MakeCurrent(gl);
+    libvlc_video_render_cfg_t output_cfg = {
+        w, h,
+    };
     libvlc_video_output_cfg_t render_cfg;
-    sys->resizeCb(sys->opaque, h, w, &render_cfg);
+    sys->resizeCb(sys->opaque, &output_cfg, &render_cfg);
     ReleaseCurrent(gl);
     assert(render_cfg.surface_format == GL_RGBA);
     assert(render_cfg.full_range == true);
-- 
2.17.1



More information about the vlc-devel mailing list