[vlc-commits] libvlc: merge libvlc_video_setup_cb and libvlc_video_direct3d_device_setup_cb
Steve Lhomme
git at videolan.org
Mon Feb 10 09:07:04 CET 2020
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Feb 4 15:13:28 2020 +0100| [8cbb0843c996fcedf14d8f7642a26e2b42d591c5] | committer: Steve Lhomme
libvlc: merge libvlc_video_setup_cb and libvlc_video_direct3d_device_setup_cb
For now the OpenGL setup doesn't need to get any adapter or context from the
host app.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8cbb0843c996fcedf14d8f7642a26e2b42d591c5
---
doc/libvlc/QtGL/qtvlcwidget.cpp | 3 +-
doc/libvlc/sdl_opengl_player.cpp | 3 +-
include/vlc/libvlc_media_player.h | 87 +++++++++++++++++----------------------
lib/media_player.c | 2 +-
modules/hw/d3d11/d3d11_device.c | 2 +-
modules/hw/d3d9/d3d9_device.c | 2 +-
modules/video_output/vgl.c | 6 ++-
7 files changed, 50 insertions(+), 55 deletions(-)
diff --git a/doc/libvlc/QtGL/qtvlcwidget.cpp b/doc/libvlc/QtGL/qtvlcwidget.cpp
index 3c85075f6b..276f1fcdc0 100644
--- a/doc/libvlc/QtGL/qtvlcwidget.cpp
+++ b/doc/libvlc/QtGL/qtvlcwidget.cpp
@@ -64,7 +64,8 @@ public:
}
// This callback is called during initialisation.
- static bool setup(void** data)
+ static bool setup(void** data, const libvlc_video_setup_device_cfg_t *cfg,
+ libvlc_video_setup_device_info_t *out)
{
if (!QOpenGLContext::supportsThreadedOpenGL())
return false;
diff --git a/doc/libvlc/sdl_opengl_player.cpp b/doc/libvlc/sdl_opengl_player.cpp
index acf7053a50..3378091152 100644
--- a/doc/libvlc/sdl_opengl_player.cpp
+++ b/doc/libvlc/sdl_opengl_player.cpp
@@ -160,7 +160,8 @@ public:
}
// This callback is called during initialisation.
- static bool setup(void** data)
+ static bool setup(void** data, const libvlc_video_setup_device_cfg_t *cfg,
+ libvlc_video_setup_device_info_t *out)
{
VLCVideo** that = static_cast<VLCVideo**>(data);
(*that)->m_width = 0;
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 20c738569d..9b004437f4 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -503,16 +503,44 @@ void libvlc_video_set_format_callbacks( libvlc_media_player_t *mp,
libvlc_video_cleanup_cb cleanup );
+typedef struct
+{
+ bool hardware_decoding; /** set if D3D11_CREATE_DEVICE_VIDEO_SUPPORT is needed for D3D11 */
+} libvlc_video_setup_device_cfg_t;
+
+typedef struct
+{
+ union {
+ void *device_context; /** ID3D11DeviceContext* for D3D11, IDirect3D9 * for D3D9 */
+ int adapter; /** Adapter to use with the IDirect3D9 for D3D9 */
+ };
+} libvlc_video_setup_device_info_t;
+
/**
* Callback prototype called to initialize user data.
+ * Setup the rendering environment.
*
* \param opaque private pointer passed to the @a libvlc_video_set_output_callbacks()
+ * or @a libvlc_video_direct3d_set_callbacks()
* on input. The callback can change this value on output to be
* passed to all the other callbacks set on @a libvlc_video_set_output_callbacks(). [IN/OUT]
+ * or @a libvlc_video_set_output_callbacks(). [IN/OUT]
+ * \param cfg requested configuration of the video device [IN]
+ * \param out libvlc_video_setup_device_info_t* to fill [OUT]
* \return true on success
* \version LibVLC 4.0.0 or later
+ *
+ * For \ref libvlc_video_direct3d_engine_d3d9 the output must be a IDirect3D9*.
+ * A reference to this object is held until the \ref LIBVLC_VIDEO_DEVICE_CLEANUP is called.
+ * the device must be created with D3DPRESENT_PARAMETERS.hDeviceWindow set to 0.
+ *
+ * For \ref libvlc_video_direct3d_engine_d3d11 the output must be a ID3D11DeviceContext*.
+ * A reference to this object is held until the \ref LIBVLC_VIDEO_DEVICE_CLEANUP is called.
+ * The ID3D11Device used to create ID3D11DeviceContext must have multithreading enabled.
*/
-typedef bool (*libvlc_video_setup_cb)(void** opaque);
+typedef bool (*libvlc_video_setup_cb)(void **opaque,
+ const libvlc_video_setup_device_cfg_t *cfg,
+ libvlc_video_setup_device_info_t *out);
/**
@@ -551,8 +579,7 @@ typedef struct
* Callback prototype called on video size changes.
* Update the rendering output setup.
*
- * \param opaque private pointer set on the opaque parameter of @a libvlc_video_setup_cb()
- * or @a libvlc_video_direct3d_device_setup_cb() [IN]
+ * \param opaque private pointer set on the opaque parameter of @a libvlc_video_setup_cb() [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
@@ -572,8 +599,7 @@ typedef bool (*libvlc_video_update_output_cb)(void* opaque, const libvlc_video_r
/**
* Callback prototype called after performing drawing calls.
*
- * \param opaque private pointer set on the opaque parameter of @a libvlc_video_setup_cb()
- * or @a libvlc_video_direct3d_device_setup_cb() [IN]
+ * \param opaque private pointer set on the opaque parameter of @a libvlc_video_setup_cb() [IN]
* \version LibVLC 4.0.0 or later
*/
typedef void (*libvlc_video_swap_cb)(void* opaque);
@@ -582,8 +608,7 @@ typedef void (*libvlc_video_swap_cb)(void* opaque);
* Callback prototype to set up the OpenGL context for rendering.
* Tell the host the rendering is about to start/has finished.
*
- * \param opaque private pointer set on the opaque parameter of @a libvlc_video_setup_cb()
- * or @a libvlc_video_direct3d_device_setup_cb() [IN]
+ * \param opaque private pointer set on the opaque parameter of @a libvlc_video_setup_cb() [IN]
* \param enter true to set the context as current, false to unset it [IN]
* \return true on success
* \version LibVLC 4.0.0 or later
@@ -696,44 +721,9 @@ typedef enum libvlc_video_direct3d_engine_t {
libvlc_video_direct3d_engine_d3d9,
} libvlc_video_direct3d_engine_t;
-typedef struct
-{
- bool hardware_decoding; /** set if D3D11_CREATE_DEVICE_VIDEO_SUPPORT is needed for D3D11 */
-} libvlc_video_setup_device_cfg_t;
-
-typedef struct
-{
- union {
- void *device_context; /** ID3D11DeviceContext* for D3D11, IDirect3D9 * for D3D9 */
- int adapter; /** Adapter to use with the IDirect3D9 for D3D9 */
- };
-} libvlc_video_setup_device_info_t;
-
-/** Setup the rendering environment.
+/** Cleanup the rendering environment initialized during \ref libvlc_video_setup_cb.
*
- * \param opaque private pointer passed to the @a libvlc_video_direct3d_set_callbacks()
- * on input. The callback can change this value on output to be
- * passed to all the other callbacks set on @a libvlc_video_direct3d_set_callbacks(). [IN/OUT]
- * \param cfg requested configuration of the video device [IN]
- * \param out libvlc_video_setup_device_info_t* to fill [OUT]
- * \return true on success
- * \version LibVLC 4.0.0 or later
- *
- * For \ref libvlc_video_direct3d_engine_d3d9 the output must be a IDirect3D9*.
- * A reference to this object is held until the \ref LIBVLC_VIDEO_DEVICE_CLEANUP is called.
- * the device must be created with D3DPRESENT_PARAMETERS.hDeviceWindow set to 0.
- *
- * For \ref libvlc_video_direct3d_engine_d3d11 the output must be a ID3D11DeviceContext*.
- * A reference to this object is held until the \ref LIBVLC_VIDEO_DEVICE_CLEANUP is called.
- * The ID3D11Device used to create ID3D11DeviceContext must have multithreading enabled.
- */
-typedef bool( *libvlc_video_direct3d_device_setup_cb )( void **opaque,
- const libvlc_video_setup_device_cfg_t *cfg,
- libvlc_video_setup_device_info_t *out );
-
-/** Cleanup the rendering environment initialized during \ref libvlc_video_direct3d_device_setup_cb.
- *
- * \param opaque private pointer set on the opaque parameter of @a libvlc_video_direct3d_device_setup_cb() [IN]
+ * \param opaque private pointer set on the opaque parameter of @a libvlc_video_setup_cb() [IN]
* \version LibVLC 4.0.0 or later
*/
typedef void( *libvlc_video_direct3d_device_cleanup_cb )( void *opaque );
@@ -743,9 +733,9 @@ typedef void( *libvlc_video_direct3d_device_cleanup_cb )( void *opaque );
* This allows text rendering and aspect ratio to be handled properly when the host
* rendering size changes.
*
- * It may be called before the \ref libvlc_video_direct3d_device_setup_cb callback.
+ * It may be called before the \ref libvlc_video_setup_cb callback.
*
- * \param opaque private pointer set on the opaque parameter of @a libvlc_video_direct3d_device_setup_cb() [IN]
+ * \param opaque private pointer set on the opaque parameter of @a libvlc_video_setup_cb() [IN]
* \param report_size_change callback which must be called when the host size changes. [IN]
* The callback is valid until another call to \ref libvlc_video_direct3d_set_resize_cb
* is done. This may be called from any thread.
@@ -757,8 +747,7 @@ typedef void( *libvlc_video_direct3d_set_resize_cb )( void *opaque,
/** Tell the host the rendering for the given plane is about to start
*
- * \param opaque private pointer set on the opaque parameter of @a libvlc_video_setup_cb()
- * or @a libvlc_video_direct3d_device_setup_cb() [IN]
+ * \param opaque private pointer set on the opaque parameter of @a libvlc_video_setup_cb() [IN]
* \param plane number of the rendering plane to select
* \return true on success
* \version LibVLC 4.0.0 or later
@@ -802,7 +791,7 @@ typedef bool( *libvlc_video_direct3d_select_plane_cb )( void *opaque, size_t pla
LIBVLC_API
bool libvlc_video_direct3d_set_callbacks( libvlc_media_player_t *mp,
libvlc_video_direct3d_engine_t engine,
- libvlc_video_direct3d_device_setup_cb setup_cb,
+ libvlc_video_setup_cb setup_cb,
libvlc_video_direct3d_device_cleanup_cb cleanup_cb,
libvlc_video_direct3d_set_resize_cb resize_cb,
libvlc_video_update_output_cb update_output_cb,
diff --git a/lib/media_player.c b/lib/media_player.c
index a03f42b9da..05c1b16a17 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -1075,7 +1075,7 @@ bool libvlc_video_set_output_callbacks(libvlc_media_player_t *mp,
bool libvlc_video_direct3d_set_callbacks(libvlc_media_player_t *mp,
libvlc_video_direct3d_engine_t engine,
- libvlc_video_direct3d_device_setup_cb setup_cb,
+ libvlc_video_setup_cb setup_cb,
libvlc_video_direct3d_device_cleanup_cb cleanup_cb,
libvlc_video_direct3d_set_resize_cb resize_cb,
libvlc_video_update_output_cb update_output_cb,
diff --git a/modules/hw/d3d11/d3d11_device.c b/modules/hw/d3d11/d3d11_device.c
index e80f0d8d33..25797c7c4e 100644
--- a/modules/hw/d3d11/d3d11_device.c
+++ b/modules/hw/d3d11/d3d11_device.c
@@ -92,7 +92,7 @@ static int D3D11OpenDecoderDevice(vlc_decoder_device *device, bool forced, vout_
else
#endif
{
- libvlc_video_direct3d_device_setup_cb setupDeviceCb = var_InheritAddress( device, "vout-cb-setup" );
+ libvlc_video_setup_cb setupDeviceCb = var_InheritAddress( device, "vout-cb-setup" );
if ( setupDeviceCb )
{
/* decoder device coming from the external app */
diff --git a/modules/hw/d3d9/d3d9_device.c b/modules/hw/d3d9/d3d9_device.c
index fd61303103..75ace22eb6 100644
--- a/modules/hw/d3d9/d3d9_device.c
+++ b/modules/hw/d3d9/d3d9_device.c
@@ -70,7 +70,7 @@ int D3D9OpenDecoderDevice(vlc_decoder_device *device, vout_window_t *wnd)
int adapter;
sys->cleanupDeviceCb = NULL;
- libvlc_video_direct3d_device_setup_cb setupDeviceCb = var_InheritAddress( device, "vout-cb-setup" );
+ libvlc_video_setup_cb setupDeviceCb = var_InheritAddress( device, "vout-cb-setup" );
if ( setupDeviceCb )
{
/* external rendering */
diff --git a/modules/video_output/vgl.c b/modules/video_output/vgl.c
index 75dc75a79d..cb17ab3593 100644
--- a/modules/video_output/vgl.c
+++ b/modules/video_output/vgl.c
@@ -141,11 +141,15 @@ static int Open(vlc_gl_t *gl, unsigned width, unsigned height)
gl->destroy = Close;
if( sys->setupCb )
- if( !sys->setupCb(&sys->opaque) )
+ {
+ libvlc_video_setup_device_cfg_t setup_cfg = {};
+ libvlc_video_setup_device_info_t configured_cfg;
+ if( !sys->setupCb(&sys->opaque, &setup_cfg, &configured_cfg) )
{
msg_Err( gl, "user setup failed" );
return VLC_EGENERIC;
}
+ }
Resize(gl, width, height);
return VLC_SUCCESS;
More information about the vlc-commits
mailing list