vlc | branch: master | Steve Lhomme <[email protected]> | Tue Feb 11 15:29:02 2020 +0100| [3644c45e16651837eb5404450d6d01d3ae8659e2] | committer: Steve Lhomme
libvlc: add a way to disable the GPU callback engine If set to none we fallback to normal playback into a custom window. We need the variable in the regular player so the variable can be read even when desktop VLC. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3644c45e16651837eb5404450d6d01d3ae8659e2 --- include/vlc/libvlc_media_player.h | 2 ++ lib/media_player.c | 10 ++++++++++ modules/video_chroma/d3d11_fmt.c | 12 +++++++++--- modules/video_chroma/d3d9_fmt.c | 13 ++++++++++--- modules/video_output/vgl.c | 5 +++++ src/libvlc.c | 2 ++ 6 files changed, 38 insertions(+), 6 deletions(-) diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h index aa4be73418..5e0255a10a 100644 --- a/include/vlc/libvlc_media_player.h +++ b/include/vlc/libvlc_media_player.h @@ -679,6 +679,8 @@ typedef void (*libvlc_video_frameMetadata_cb)(void* opaque, libvlc_video_metadat * can be passed to @a libvlc_video_set_output_callbacks */ typedef enum libvlc_video_engine_t { + /** Disable rendering engine */ + libvlc_video_engine_disable, libvlc_video_engine_opengl, libvlc_video_engine_gles2, /** Direct3D11 rendering engine */ diff --git a/lib/media_player.c b/lib/media_player.c index 1b736da12e..96af310c34 100644 --- a/lib/media_player.c +++ b/lib/media_player.c @@ -593,6 +593,7 @@ libvlc_media_player_new( libvlc_instance_t *instance ) var_Create (mp, "vmem-height", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT); var_Create (mp, "vmem-pitch", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT); + var_Create (mp, "vout-cb-type", VLC_VAR_INTEGER ); var_Create( mp, "vout-cb-opaque", VLC_VAR_ADDRESS ); var_Create( mp, "vout-cb-setup", VLC_VAR_ADDRESS ); var_Create( mp, "vout-cb-cleanup", VLC_VAR_ADDRESS ); @@ -1045,6 +1046,7 @@ bool libvlc_video_set_output_callbacks(libvlc_media_player_t *mp, libvlc_video_output_select_plane_cb select_plane_cb, void *opaque) { + static_assert(libvlc_video_engine_disable == 0, "No engine set must default to 0"); #ifdef __ANDROID__ //use the default android window var_SetString( mp, "window", ""); @@ -1072,9 +1074,17 @@ bool libvlc_video_set_output_callbacks(libvlc_media_player_t *mp, var_SetString ( mp, "vout", "direct3d9" ); var_SetString ( mp, "dec-dev", "d3d9" ); } + else if ( engine == libvlc_video_engine_disable ) + { + // use the default display module + var_SetString ( mp, "vout", "" ); + // use the default window + var_SetString( mp, "window", ""); + } else return false; + var_SetInteger( mp, "vout-cb-type", engine ); var_SetAddress( mp, "vout-cb-opaque", opaque ); var_SetAddress( mp, "vout-cb-setup", setup_cb ); var_SetAddress( mp, "vout-cb-cleanup", cleanup_cb ); diff --git a/modules/video_chroma/d3d11_fmt.c b/modules/video_chroma/d3d11_fmt.c index 49db979efc..44ba5f7b74 100644 --- a/modules/video_chroma/d3d11_fmt.c +++ b/modules/video_chroma/d3d11_fmt.c @@ -494,8 +494,11 @@ d3d11_decoder_device_t *(D3D11_CreateDevice)(vlc_object_t *obj, else #endif { - libvlc_video_output_setup_cb setupDeviceCb = var_InheritAddress( obj, "vout-cb-setup" ); - if ( setupDeviceCb ) + libvlc_video_engine_t engineType = var_InheritInteger( obj, "vout-cb-type" ); + libvlc_video_output_setup_cb setupDeviceCb = NULL; + if (engineType == libvlc_video_engine_d3d11) + setupDeviceCb = var_InheritAddress( obj, "vout-cb-setup" ); + if ( setupDeviceCb != NULL) { /* decoder device coming from the external app */ sys->external.opaque = var_InheritAddress( obj, "vout-cb-opaque" ); @@ -512,7 +515,8 @@ d3d11_decoder_device_t *(D3D11_CreateDevice)(vlc_object_t *obj, } hr = D3D11_CreateDeviceExternal(obj, out.d3d11.device_context, true, &sys->dec_device.d3d_dev); } - else + else if ( engineType == libvlc_video_engine_disable || + engineType == libvlc_video_engine_d3d11 ) { /* internal decoder device */ #if !VLC_WINSTORE_APP @@ -530,6 +534,8 @@ d3d11_decoder_device_t *(D3D11_CreateDevice)(vlc_object_t *obj, hr = CreateDevice( obj, &sys->hd3d, adapter, hw_decoding, &sys->dec_device.d3d_dev ); } + else + goto error; } error: diff --git a/modules/video_chroma/d3d9_fmt.c b/modules/video_chroma/d3d9_fmt.c index a837fdff85..88501521aa 100644 --- a/modules/video_chroma/d3d9_fmt.c +++ b/modules/video_chroma/d3d9_fmt.c @@ -179,8 +179,11 @@ d3d9_handle_t *hd3d = &sys->dec_device.hd3d; int AdapterToUse; sys->cleanupDeviceCb = NULL; - libvlc_video_output_setup_cb setupDeviceCb = var_InheritAddress( o, "vout-cb-setup" ); - if ( setupDeviceCb ) + libvlc_video_engine_t engineType = var_InheritInteger( o, "vout-cb-type" ); + libvlc_video_output_setup_cb setupDeviceCb = NULL; + if (engineType == libvlc_video_engine_d3d9) + setupDeviceCb = var_InheritAddress( o, "vout-cb-setup" ); + if ( setupDeviceCb != NULL) { /* external rendering */ libvlc_video_setup_device_info_t extern_out = { .d3d9.adapter = -1 }; @@ -195,7 +198,9 @@ d3d9_handle_t *hd3d = &sys->dec_device.hd3d; D3D9_CloneExternal( hd3d, (IDirect3D9 *) extern_out.d3d9.device ); AdapterToUse = extern_out.d3d9.adapter; } - else + else if ( engineType == libvlc_video_engine_disable || + engineType == libvlc_video_engine_d3d9 || + engineType == libvlc_video_engine_opengl ) { /* internal rendering */ if (D3D9_Create(o, hd3d) != VLC_SUCCESS) @@ -206,6 +211,8 @@ d3d9_handle_t *hd3d = &sys->dec_device.hd3d; /* find the best adapter to use, not based on the HWND used */ AdapterToUse = -1; } + else + goto error; if (AdapterToUse == -1) { diff --git a/modules/video_output/vgl.c b/modules/video_output/vgl.c index 99cf6f747e..40487ea247 100644 --- a/modules/video_output/vgl.c +++ b/modules/video_output/vgl.c @@ -123,6 +123,11 @@ static int Open(vlc_gl_t *gl, unsigned width, unsigned height) { vout_display_sys_t * sys; + libvlc_video_engine_t engineType = var_InheritInteger( gl, "vout-cb-type" ); + if ( engineType != libvlc_video_engine_opengl && + engineType != libvlc_video_engine_gles2 ) + return VLC_EBADVAR; + /* Allocate structure */ gl->sys = sys = vlc_obj_calloc(VLC_OBJECT(gl), 1, sizeof(*sys)); if( !sys ) diff --git a/src/libvlc.c b/src/libvlc.c index c40fa19ba3..c1a6e574d4 100644 --- a/src/libvlc.c +++ b/src/libvlc.c @@ -254,6 +254,8 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, /* some default internal settings */ var_Create( p_libvlc, "window", VLC_VAR_STRING ); + var_Create( p_libvlc, "vout-cb-type", VLC_VAR_INTEGER ); + /* NOTE: Because the playlist and interfaces start before this function * returns control to the application (DESIGN BUG!), all these variables * must be created (in place of libvlc_new()) and set to VLC defaults _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
