[vlc-devel] [PATCH 18/18] libvlc: merge libvlc_video_direct3d_set_callbacks into libvlc_video_set_output_callbacks

Steve Lhomme robux4 at ycbcr.xyz
Tue Feb 4 16:26:13 CET 2020


The GetProcAddress callback is always NULL in that case.
---
 doc/libvlc/d3d11_player.cpp       |  7 ++--
 doc/libvlc/d3d9_player.c          |  7 ++--
 include/vlc/libvlc_media_player.h | 67 +++++--------------------------
 lib/libvlc.sym                    |  1 -
 lib/media_player.c                | 32 +--------------
 5 files changed, 20 insertions(+), 94 deletions(-)

diff --git a/doc/libvlc/d3d11_player.cpp b/doc/libvlc/d3d11_player.cpp
index 26c3aba8bfa..61180d34d23 100644
--- a/doc/libvlc/d3d11_player.cpp
+++ b/doc/libvlc/d3d11_player.cpp
@@ -581,9 +581,10 @@ int WINAPI WinMain(HINSTANCE hInstance,
     // DON'T use with callbacks libvlc_media_player_set_hwnd(p_mp, hWnd);
 
     /* Tell VLC to render into our D3D11 environment */
-    libvlc_video_direct3d_set_callbacks( p_mp, libvlc_video_direct3d_engine_d3d11,
-                                        Setup_cb, Cleanup_cb, Resize_cb, UpdateOutput_cb, Swap_cb, StartRendering_cb, SelectPlane_cb,
-                                        &Context );
+    libvlc_video_set_output_callbacks( p_mp, libvlc_video_direct3d_engine_d3d11,
+                                       Setup_cb, Cleanup_cb, Resize_cb, UpdateOutput_cb, Swap_cb, StartRendering_cb,
+                                       nullptr, SelectPlane_cb,
+                                       &Context );
 
     libvlc_media_player_play( p_mp );
 
diff --git a/doc/libvlc/d3d9_player.c b/doc/libvlc/d3d9_player.c
index ce09ff0251f..a5eeb4b9d98 100644
--- a/doc/libvlc/d3d9_player.c
+++ b/doc/libvlc/d3d9_player.c
@@ -376,9 +376,10 @@ int WINAPI WinMain(HINSTANCE hInstance,
     // DON'T use with callbacks libvlc_media_player_set_hwnd(p_mp, hWnd);
 
     /* Tell VLC to render into our D3D9 environment */
-    libvlc_video_direct3d_set_callbacks( p_mp, libvlc_video_direct3d_engine_d3d9,
-                                        Setup_cb, Cleanup_cb, Resize_cb, UpdateOutput_cb, Swap_cb, StartRendering_cb, NULL,
-                                        &Context );
+    libvlc_video_set_output_callbacks( p_mp, libvlc_video_direct3d_engine_d3d9,
+                                       Setup_cb, Cleanup_cb, Resize_cb, UpdateOutput_cb, Swap_cb, StartRendering_cb,
+                                       NULL, NULL,
+                                       &Context );
 
     libvlc_media_player_play( p_mp );
 
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index e65ea3a3b57..164dfa73b7e 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -519,10 +519,9 @@ typedef struct
  * 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_direct3d_set_callbacks()
- *               or @a libvlc_video_set_output_callbacks(). [IN/OUT]
+ *               passed to all the other callbacks set on @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
@@ -577,8 +576,7 @@ typedef struct
  * Callback prototype called on video size changes.
  * Update the rendering output setup.
  *
- * \param opaque private pointer passed to the @a libvlc_video_set_output_callbacks() or
- *         @a libvlc_video_output_setup_cb() [IN]
+ * \param opaque private pointer passed to the @a libvlc_video_set_output_callbacks() [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
@@ -620,8 +618,7 @@ typedef struct
  * 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 passed to the @a libvlc_video_set_output_callbacks() or
- *          @a libvlc_video_output_setup_cb() [IN]
+ * \param opaque private pointer passed to the @a libvlc_video_set_output_callbacks() [IN]
  * \param enter true to set the context as current, false to unset it [IN]
  * \param hdr10 libvlc_video_frame_hdr10_metadata_t* or NULL [IN]
  * \return true on success
@@ -661,6 +658,10 @@ typedef void* (*libvlc_video_getProcAddress_cb)(void* opaque, const char* fct_na
 typedef enum libvlc_video_engine_t {
     libvlc_video_engine_opengl,
     libvlc_video_engine_gles2,
+    /** Direct3D11 rendering engine */
+    libvlc_video_direct3d_engine_d3d11,
+    /** Direct3D9 rendering engine */
+    libvlc_video_direct3d_engine_d3d9,
 } libvlc_video_engine_t;
 
 /**
@@ -692,7 +693,7 @@ typedef void( *libvlc_video_output_set_resize_cb )( void *opaque,
  * \note This is only used with \ref libvlc_video_direct3d_engine_d3d11.
  *
  * The host should call OMSetRenderTargets for Direct3D11. If this callback is
- * not used (set to NULL in @a libvlc_video_direct3d_set_callbacks()) OMSetRenderTargets
+ * not used (set to NULL in @a libvlc_video_set_output_callbacks()) OMSetRenderTargets
  * has to be set during the @a libvlc_video_makeCurrent_cb()
  * entering call.
  *
@@ -708,8 +709,6 @@ typedef bool( *libvlc_video_output_select_plane_cb )( void *opaque, size_t plane
  * \warning VLC will perform video rendering in its own thread and at its own rate,
  * You need to provide your own synchronisation mechanism.
  *
- * OpenGL context need to be created before playing a media.
- *
  * \param mp the media player
  * \param engine the GPU engine to use
  * \param setup_cb callback called to initialize user data
@@ -717,7 +716,7 @@ typedef bool( *libvlc_video_output_select_plane_cb )( void *opaque, size_t plane
  * \param resize_cb callback to set the resize callback
  * \param update_output_cb callback to get the rendering format of the host (cannot be NULL)
  * \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 makeCurrent_cb callback called to enter/leave the opengl context (cannot be NULL)
  * \param getProcAddress_cb opengl function loading callback (cannot be NULL for \ref libvlc_video_engine_opengl and for \ref libvlc_video_engine_gles2)
  * \param opaque private pointer passed to callbacks
  *
@@ -738,52 +737,6 @@ bool libvlc_video_set_output_callbacks( libvlc_media_player_t *mp,
                                         libvlc_video_output_select_plane_cb select_plane_cb,
                                         void* opaque );
 
-
-/**
- * Enumeration of the Video engine to be used on output.
- * can be passed to @a libvlc_video_direct3d_set_callbacks
- */
-typedef enum libvlc_video_direct3d_engine_t {
-    /** Direct3D11 rendering engine */
-    libvlc_video_direct3d_engine_d3d11,
-    /** Direct3D9 rendering engine */
-    libvlc_video_direct3d_engine_d3d9,
-} libvlc_video_direct3d_engine_t;
-
-/**
- * Set callbacks and data to render decoded video to a custom Direct3D output
- *
- * \warning VLC will perform video rendering in its own thread and at its own rate,
- * You need to provide your own synchronisation mechanism.
- *
- * \param mp the media player
- * \param engine the GPU engine to use
- * \param setup_cb callback to setup and return the device to use (cannot be NULL)
- * \param cleanup_cb callback to cleanup the device given by the \ref setup_cb callback
- * \param resize_cb callback to set the resize callback
- * \param update_output_cb callback to notify of the source format and get the
- *                         rendering format used by the host (cannot be NULL)
- * \param swap_cb callback to tell the host it should display the rendered picture (cannot be NULL)
- * \param makeCurrent_cb callback to tell the host the rendering is starting/ended (cannot be NULL)
- * \param select_plane_cb callback to select different D3D11 rendering targets
- * \param opaque private pointer passed to the \ref cleanup_cb callback
- *
- * \retval true Direct3D selected and callbacks set
- * \retval false Direct3D version, callbacks not set
- * \version LibVLC 4.0.0 or later
- */
-LIBVLC_API
-bool libvlc_video_direct3d_set_callbacks( libvlc_media_player_t *mp,
-                                         libvlc_video_direct3d_engine_t engine,
-                                         libvlc_video_output_setup_cb setup_cb,
-                                         libvlc_video_output_cleanup_cb cleanup_cb,
-                                         libvlc_video_output_set_resize_cb resize_cb,
-                                         libvlc_video_update_output_cb update_output_cb,
-                                         libvlc_video_swap_cb swap_cb,
-                                         libvlc_video_makeCurrent_cb makeCurrent_cb,
-                                         libvlc_video_output_select_plane_cb select_plane_cb,
-                                         void* opaque );
-
 /**
  * Set the NSView handler where the media player should render its video output.
  *
diff --git a/lib/libvlc.sym b/lib/libvlc.sym
index d8fb0806bca..67e4dcf7482 100644
--- a/lib/libvlc.sym
+++ b/lib/libvlc.sym
@@ -239,7 +239,6 @@ libvlc_video_set_deinterlace
 libvlc_video_set_format
 libvlc_video_set_format_callbacks
 libvlc_video_set_output_callbacks
-libvlc_video_direct3d_set_callbacks
 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 2c662ea1356..07ed8f9062a 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -1060,36 +1060,7 @@ bool libvlc_video_set_output_callbacks(libvlc_media_player_t *mp,
         var_SetString ( mp, "vout", "gl" );
         var_SetString ( mp, "gl", "vgl");
     }
-    else
-        return false;
-
-    var_SetAddress( mp, "vout-cb-opaque", opaque );
-    var_SetAddress( mp, "vout-cb-setup", setup_cb );
-    var_SetAddress( mp, "vout-cb-cleanup", cleanup_cb );
-    var_SetAddress( mp, "vout-cb-resize-cb", resize_cb );
-    var_SetAddress( mp, "vout-cb-update-output", update_output_cb );
-    var_SetAddress( mp, "vout-cb-swap", swap_cb );
-    var_SetAddress( mp, "vout-cb-get-proc-address", getProcAddress_cb );
-    var_SetAddress( mp, "vout-cb-make-current", makeCurrent_cb );
-    var_SetAddress( mp, "vout-cb-select-plane", select_plane_cb );
-    return true;
-}
-
-
-bool libvlc_video_direct3d_set_callbacks(libvlc_media_player_t *mp,
-                                         libvlc_video_direct3d_engine_t engine,
-                                         libvlc_video_output_setup_cb setup_cb,
-                                         libvlc_video_output_cleanup_cb cleanup_cb,
-                                         libvlc_video_output_set_resize_cb resize_cb,
-                                         libvlc_video_update_output_cb update_output_cb,
-                                         libvlc_video_swap_cb swap_cb,
-                                         libvlc_video_makeCurrent_cb makeCurrent_cb,
-                                         libvlc_video_output_select_plane_cb select_plane_cb,
-                                         void *opaque)
-{
-    var_SetString( mp, "window", "wextern");
-
-    if ( engine == libvlc_video_direct3d_engine_d3d11 )
+    else if ( engine == libvlc_video_direct3d_engine_d3d11 )
     {
         var_SetString ( mp, "vout", "direct3d11" );
         var_SetString ( mp, "dec-dev", "d3d11-device" );
@@ -1108,6 +1079,7 @@ bool libvlc_video_direct3d_set_callbacks(libvlc_media_player_t *mp,
     var_SetAddress( mp, "vout-cb-resize-cb", resize_cb );
     var_SetAddress( mp, "vout-cb-update-output", update_output_cb );
     var_SetAddress( mp, "vout-cb-swap", swap_cb );
+    var_SetAddress( mp, "vout-cb-get-proc-address", getProcAddress_cb );
     var_SetAddress( mp, "vout-cb-make-current", makeCurrent_cb );
     var_SetAddress( mp, "vout-cb-select-plane", select_plane_cb );
     return true;
-- 
2.17.1



More information about the vlc-devel mailing list