[vlc-devel] [PATCH 5/9] libvlc: add callbacks to render to an external D3D9 surface
Steve Lhomme
robux4 at ycbcr.xyz
Fri Jan 18 16:32:16 CET 2019
---
include/vlc/libvlc_media_player.h | 31 ++++++++++++++++++++++++++++++-
lib/media_player.c | 10 ++++++++++
2 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 6f9eb0e59f..0ef93062e9 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -429,6 +429,34 @@ void libvlc_video_set_callbacks( libvlc_media_player_t *mp,
*
* For \ref libvlc_video_engine_opengl and \ref libvlc_video_engine_gles2 it's either NULL
* on failure to setup or any other value in success.
+ *
+ * For \ref libvlc_video_engine_direct3d9 it must be a IDirect3DDevice9*.
+ * A reference to this object is held until \the ref cleanup_cb is called.
+ * the device must be created with D3DPRESENT_PARAMETERS.hDeviceWindow set to 0.
+ *
+ * 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
* \version LibVLC 4.0.0 or later
*/
typedef void *(*libvlc_video_setup_cb)(void* opaque);
@@ -506,6 +534,7 @@ 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,
} libvlc_video_engine_t;
/**
@@ -518,7 +547,7 @@ typedef enum libvlc_video_engine_t {
*
* \param mp the media player
* \param engine the GPU engine to use
- * \param setup_cb callback called to initialize user data
+ * \param setup_cb callback called to initialize user data (cannot be NULL for \ref libvlc_video_engine_direct3d9)
* \param cleanup_cb callback called to clean up user data
* \param update_output_cb callback called to get the size of the video
* \param swap_cb callback called after rendering a video frame (cannot be NULL)
diff --git a/lib/media_player.c b/lib/media_player.c
index 4264484aa3..91ae05f0c1 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -1181,6 +1181,16 @@ 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 )
+ {
+ if (setup_cb == NULL)
+ return 0;
+ 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