[vlc-devel] [PATCH 6/6] WIP qtqlvlc: update the rendering size when changing the window size
Steve Lhomme
robux4 at ycbcr.xyz
Fri Jan 25 16:47:05 CET 2019
TODO: lock the displayed texture in Qt thread while the decoder thread may update the 3 textures
---
doc/libvlc/QtGL/qtvlcwidget.cpp | 23 +++++++++++++++++++++--
doc/libvlc/QtGL/qtvlcwidget.h | 1 +
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/doc/libvlc/QtGL/qtvlcwidget.cpp b/doc/libvlc/QtGL/qtvlcwidget.cpp
index 6ad6685e6a..eb72774370 100644
--- a/doc/libvlc/QtGL/qtvlcwidget.cpp
+++ b/doc/libvlc/QtGL/qtvlcwidget.cpp
@@ -134,6 +134,15 @@ QtVLCWidget::QtVLCWidget(QWidget *parent)
vertexBuffer(QOpenGLBuffer::VertexBuffer),
vertexIndexBuffer(QOpenGLBuffer::IndexBuffer)
{
+ m_DisplayConfig = reinterpret_cast<libvlc_video_surface_cfg_t *>(malloc( sizeof(libvlc_video_surface_cfg_t) ));
+ m_DisplayConfig->width = width();
+ m_DisplayConfig->height = height();
+ m_DisplayConfig->chroma = libvlc_video_surface_chroma_rgba8;
+ m_DisplayConfig->limited_range = false;
+ m_DisplayConfig->transfer = libvlc_video_transfer_srgb;
+ m_DisplayConfig->colorspace = libvlc_video_colorspace_bt709;
+ m_DisplayConfig->primaries = libvlc_video_primary_bt709;
+
// --transparent causes the clear color to be transparent. Therefore, on systems that
// support it, the widget will become transparent apart from the logo.
@@ -159,6 +168,9 @@ bool QtVLCWidget::playMedia(const char* url)
return false;
}
+ // setup the display
+ libvlc_video_set_surface_display_config( m_mp, m_DisplayConfig );
+
// Define the opengl rendering callbacks
libvlc_video_set_surface_callbacks(m_mp, libvlc_video_engine_opengl,
VLCVideo::setup, VLCVideo::cleanup, VLCVideo::resizeRenderTextures, VLCVideo::swap,
@@ -174,6 +186,7 @@ bool QtVLCWidget::playMedia(const char* url)
QtVLCWidget::~QtVLCWidget()
{
cleanup();
+ free( m_DisplayConfig );
}
QSize QtVLCWidget::minimumSizeHint() const
@@ -307,7 +320,13 @@ void QtVLCWidget::paintGL()
}
}
-void QtVLCWidget::resizeGL(int w, int h)
+void QtVLCWidget::resizeGL(int width, int height)
{
- /* TODO */
+ if (m_DisplayConfig->width != width || m_DisplayConfig->height != height)
+ {
+ m_DisplayConfig->width = width;
+ m_DisplayConfig->height = height;
+ if (m_mp != nullptr)
+ libvlc_video_set_surface_display_config( m_mp, m_DisplayConfig );
+ }
}
diff --git a/doc/libvlc/QtGL/qtvlcwidget.h b/doc/libvlc/QtGL/qtvlcwidget.h
index febbc6252f..9e1d7a39ed 100644
--- a/doc/libvlc/QtGL/qtvlcwidget.h
+++ b/doc/libvlc/QtGL/qtvlcwidget.h
@@ -39,6 +39,7 @@ private:
struct libvlc_instance_t* m_vlc = nullptr;
struct libvlc_media_player_t* m_mp = nullptr;
struct libvlc_media_t* m_media = nullptr;
+ struct libvlc_video_surface_cfg_t* m_DisplayConfig;
QOpenGLBuffer vertexBuffer, vertexIndexBuffer;
};
--
2.17.1
More information about the vlc-devel
mailing list