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

Steve Lhomme robux4 at ycbcr.xyz
Fri Jan 18 14:59:01 CET 2019


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

diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 3572714ee3..bcf9431b74 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -503,6 +503,9 @@ typedef void (*libvlc_video_end_render_cb)(void* opaque);
 typedef enum libvlc_video_engine_t {
     libvlc_video_engine_opengl,
     libvlc_video_engine_gles2,
+    libvlc_video_engine_direct3d9, /* the engine_context must be a IDirect3DDevice9*
+                                    * the device must be created with D3DPRESENT_PARAMETERS.hDeviceWindow set to 0
+                                    */
 } libvlc_video_engine_t;
 
 /**
@@ -528,6 +531,31 @@ typedef enum libvlc_video_engine_t {
  * \param opaque private pointer passed to callbacks
  * \libvlc_return_bool
  * \version LibVLC 4.0.0 or later
+ *
+ * For \ref libvlc_video_engine_direct3d9 the \ref engine_context must be a IDirect3DDevice9*.
+ * Between start_render_cb and end_render_cb of Direct3D9 the following may change:
+ * - 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_API
 int libvlc_video_set_output_callbacks( libvlc_media_player_t *mp,
diff --git a/lib/media_player.c b/lib/media_player.c
index 04dfb67302..2365c4e76c 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -1184,6 +1184,14 @@ int libvlc_video_set_output_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