[vlc-devel] [PATCH 4/8] libvlc: add callbacks to render to an external D3D9 surface

Steve Lhomme robux4 at ycbcr.xyz
Mon Jan 21 17:38:47 CET 2019


---
 include/vlc/libvlc_media_player.h | 31 +++++++++++++++++++++++++++++++
 lib/media_player.c                |  8 ++++++++
 2 files changed, 39 insertions(+)

diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 6abba498b0..aa44f761e7 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -465,6 +465,8 @@ typedef enum libvlc_video_engine_t {
     libvlc_video_engine_opengl,
     /** OpenGL ES2 rendering engine */
     libvlc_video_engine_gles2,
+    /** Direct3D9 rendering engine */
+    libvlc_video_engine_direct3d9,
 } libvlc_video_engine_t;
 
 typedef struct
@@ -481,6 +483,10 @@ typedef enum libvlc_video_callback_control_t {
      *
      * \ref input ignored
      * \ref output pointer depending on the type of the engine
+     *
+     * For \ref libvlc_video_engine_direct3d9 the output must be a IDirect3DDevice9*.
+     * A reference to this object is held until the \ref LIBVLC_VIDEO_CLEANUP is called.
+     * the device must be created with D3DPRESENT_PARAMETERS.hDeviceWindow set to 0.
      */
     LIBVLC_VIDEO_SETUP,
 
@@ -527,6 +533,31 @@ typedef enum libvlc_video_callback_control_t {
      *
      * \ref input ignored
      * \ref output ignored
+     *
+     * Between \ref LIBVLC_VIDEO_START_RENDER and \ref LIBVLC_VIDEO_FINISHED_RENDERING
+     * of Direct3D9 the following may change on the provided IDirect3DDevice9*:
+     * - D3DSAMP_ADDRESSU
+     * - D3DSAMP_ADDRESSV
+     * - D3DSAMP_MINFILTER
+     * - D3DSAMP_MAGFILTER
+     * - D3DRS_AMBIENT
+     * - D3DRS_CULLMODE
+     * - D3DRS_ZENABLE
+     * - D3DRS_LIGHTING
+     * - D3DRS_DITHERENABLE
+     * - D3DRS_STENCILENABLE
+     * - D3DRS_ALPHABLENDENABLE
+     * - D3DRS_SRCBLEND,D3DBLEND_SRCALPHA
+     * - D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA
+     * - D3DPCMPCAPS_GREATER
+     * - D3DRS_ALPHATESTENABLE
+     * - D3DRS_ALPHAREF
+     * - D3DRS_ALPHAFUNC
+     * - D3DTSS_COLOROP
+     * - D3DTSS_COLORARG1
+     * - D3DTSS_ALPHAOP
+     * - D3DTSS_ALPHAARG1
+     * - D3DTSS_ALPHAARG2
      */
     LIBVLC_VIDEO_START_RENDER,
 
diff --git a/lib/media_player.c b/lib/media_player.c
index 81872f81d6..96f4cb7455 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -1167,6 +1167,14 @@ int libvlc_video_set_surface_callbacks( libvlc_media_player_t *mp,
     var_SetString( mp, "window", "wdummy");
 #endif
 
+#if _WIN32
+    if ( engine == libvlc_video_engine_direct3d9 )
+    {
+        var_SetString ( mp, "vout", "direct3d9" );
+        var_SetString ( mp, "avcodec-hw", "dxva2");
+    }
+    else
+#endif
     if( engine == libvlc_video_engine_gles2 )
     {
         var_SetString ( mp, "vout", "gles2" );
-- 
2.17.1



More information about the vlc-devel mailing list