mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 11:41:09 +00:00
d3d12: Allow building without WGC support
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6435>
This commit is contained in:
parent
ce0b60b5c9
commit
6c80d2f5f8
3 changed files with 45 additions and 16 deletions
|
@ -218,6 +218,9 @@ option('d3d11-math', type : 'feature', value : 'auto', description : 'Enable Dir
|
||||||
option('d3d11-hlsl-precompile', type : 'feature', value : 'auto', description : 'Enable buildtime HLSL compile for d3d11 library/plugin')
|
option('d3d11-hlsl-precompile', type : 'feature', value : 'auto', description : 'Enable buildtime HLSL compile for d3d11 library/plugin')
|
||||||
option('d3d11-wgc', type : 'feature', value : 'auto', description : 'Windows Graphics Capture API support in d3d11 plugin')
|
option('d3d11-wgc', type : 'feature', value : 'auto', description : 'Windows Graphics Capture API support in d3d11 plugin')
|
||||||
|
|
||||||
|
# D3D12 plugin options
|
||||||
|
option('d3d12-wgc', type : 'feature', value : 'auto', description : 'Windows Graphics Capture API support in d3d12 plugin')
|
||||||
|
|
||||||
# HLS plugin options
|
# HLS plugin options
|
||||||
option('hls', type : 'feature', value : 'auto', description : 'HTTP Live Streaming plugin')
|
option('hls', type : 'feature', value : 'auto', description : 'HTTP Live Streaming plugin')
|
||||||
option('hls-crypto', type : 'combo', value : 'auto', choices : ['auto', 'nettle', 'libgcrypt', 'openssl'],
|
option('hls-crypto', type : 'combo', value : 'auto', choices : ['auto', 'nettle', 'libgcrypt', 'openssl'],
|
||||||
|
|
|
@ -36,7 +36,9 @@
|
||||||
|
|
||||||
#include "gstd3d12screencapturesrc.h"
|
#include "gstd3d12screencapturesrc.h"
|
||||||
#include "gstd3d12dxgicapture.h"
|
#include "gstd3d12dxgicapture.h"
|
||||||
|
#ifdef HAVE_WGC
|
||||||
#include "gstd3d12graphicscapture.h"
|
#include "gstd3d12graphicscapture.h"
|
||||||
|
#endif
|
||||||
#include "gstd3d12pluginutils.h"
|
#include "gstd3d12pluginutils.h"
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <wrl.h>
|
#include <wrl.h>
|
||||||
|
@ -78,6 +80,7 @@ enum GstD3D12WindowCaptureMode
|
||||||
GST_D3D12_WINDOW_CAPTURE_CLIENT,
|
GST_D3D12_WINDOW_CAPTURE_CLIENT,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef HAVE_WGC
|
||||||
/**
|
/**
|
||||||
* GstD3D11ScreenCaptureAPI:
|
* GstD3D11ScreenCaptureAPI:
|
||||||
*
|
*
|
||||||
|
@ -148,6 +151,7 @@ gst_d3d11_window_capture_mode_get_type (void)
|
||||||
|
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#define DEFAULT_MONITOR_INDEX -1
|
#define DEFAULT_MONITOR_INDEX -1
|
||||||
#define DEFAULT_SHOW_CURSOR FALSE
|
#define DEFAULT_SHOW_CURSOR FALSE
|
||||||
|
@ -302,6 +306,7 @@ gst_d3d12_screen_capture_src_class_init (GstD3D12ScreenCaptureSrcClass * klass)
|
||||||
0, G_MAXUINT, 0,
|
0, G_MAXUINT, 0,
|
||||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||||
|
|
||||||
|
#ifdef HAVE_WGC
|
||||||
if (gst_d3d12_graphics_capture_load_library ()) {
|
if (gst_d3d12_graphics_capture_load_library ()) {
|
||||||
/**
|
/**
|
||||||
* GstD3D12ScreenCaptureSrc:window-handle:
|
* GstD3D12ScreenCaptureSrc:window-handle:
|
||||||
|
@ -379,6 +384,7 @@ gst_d3d12_screen_capture_src_class_init (GstD3D12ScreenCaptureSrcClass * klass)
|
||||||
gst_type_mark_as_plugin_api (GST_TYPE_D3D12_WINDOW_CAPTURE_MODE,
|
gst_type_mark_as_plugin_api (GST_TYPE_D3D12_WINDOW_CAPTURE_MODE,
|
||||||
(GstPluginAPIFlags) 0);
|
(GstPluginAPIFlags) 0);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
element_class->provide_clock =
|
element_class->provide_clock =
|
||||||
GST_DEBUG_FUNCPTR (gst_d3d12_screen_capture_src_provide_clock);
|
GST_DEBUG_FUNCPTR (gst_d3d12_screen_capture_src_provide_clock);
|
||||||
|
@ -472,11 +478,13 @@ gst_d3d12_screen_capture_src_set_property (GObject * object, guint prop_id,
|
||||||
break;
|
break;
|
||||||
case PROP_SHOW_BORDER:
|
case PROP_SHOW_BORDER:
|
||||||
priv->show_border = g_value_get_boolean (value);
|
priv->show_border = g_value_get_boolean (value);
|
||||||
|
#ifdef HAVE_WGC
|
||||||
if (priv->capture &&
|
if (priv->capture &&
|
||||||
priv->capture_api == GST_D3D12_SCREEN_CAPTURE_API_WGC) {
|
priv->capture_api == GST_D3D12_SCREEN_CAPTURE_API_WGC) {
|
||||||
auto wgc = GST_D3D12_GRAPHICS_CAPTURE (priv->capture);
|
auto wgc = GST_D3D12_GRAPHICS_CAPTURE (priv->capture);
|
||||||
gst_d3d12_graphics_capture_show_border (wgc, priv->show_border);
|
gst_d3d12_graphics_capture_show_border (wgc, priv->show_border);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case PROP_CAPTURE_API:
|
case PROP_CAPTURE_API:
|
||||||
priv->capture_api = (GstD3D12ScreenCaptureAPI) g_value_get_enum (value);
|
priv->capture_api = (GstD3D12ScreenCaptureAPI) g_value_get_enum (value);
|
||||||
|
@ -487,12 +495,14 @@ gst_d3d12_screen_capture_src_set_property (GObject * object, guint prop_id,
|
||||||
case PROP_WINDOW_CAPTURE_MODE:
|
case PROP_WINDOW_CAPTURE_MODE:
|
||||||
priv->hwnd_capture_mode =
|
priv->hwnd_capture_mode =
|
||||||
(GstD3D12WindowCaptureMode) g_value_get_enum (value);
|
(GstD3D12WindowCaptureMode) g_value_get_enum (value);
|
||||||
|
#ifdef HAVE_WGC
|
||||||
if (priv->capture &&
|
if (priv->capture &&
|
||||||
priv->capture_api == GST_D3D12_SCREEN_CAPTURE_API_WGC) {
|
priv->capture_api == GST_D3D12_SCREEN_CAPTURE_API_WGC) {
|
||||||
auto wgc = GST_D3D12_GRAPHICS_CAPTURE (priv->capture);
|
auto wgc = GST_D3D12_GRAPHICS_CAPTURE (priv->capture);
|
||||||
gst_d3d12_graphics_capture_set_client_only (wgc,
|
gst_d3d12_graphics_capture_set_client_only (wgc,
|
||||||
priv->hwnd_capture_mode == GST_D3D12_WINDOW_CAPTURE_CLIENT);
|
priv->hwnd_capture_mode == GST_D3D12_WINDOW_CAPTURE_CLIENT);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
@ -890,11 +900,13 @@ gst_d3d12_screen_capture_src_start (GstBaseSrc * bsrc)
|
||||||
("D3D12 device is not available"), (nullptr));
|
("D3D12 device is not available"), (nullptr));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_WGC
|
||||||
if (priv->selected_capture_api == GST_D3D12_SCREEN_CAPTURE_API_WGC) {
|
if (priv->selected_capture_api == GST_D3D12_SCREEN_CAPTURE_API_WGC) {
|
||||||
capture = gst_d3d12_graphics_capture_new (self->device,
|
capture = gst_d3d12_graphics_capture_new (self->device,
|
||||||
priv->window_handle, monitor);
|
priv->window_handle, monitor);
|
||||||
} else {
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
capture = gst_d3d12_dxgi_capture_new (self->device, monitor);
|
capture = gst_d3d12_dxgi_capture_new (self->device, monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -910,6 +922,7 @@ gst_d3d12_screen_capture_src_start (GstBaseSrc * bsrc)
|
||||||
case GST_FLOW_OK:
|
case GST_FLOW_OK:
|
||||||
break;
|
break;
|
||||||
case GST_D3D12_SCREEN_CAPTURE_FLOW_UNSUPPORTED:
|
case GST_D3D12_SCREEN_CAPTURE_FLOW_UNSUPPORTED:
|
||||||
|
#ifdef HAVE_WGC
|
||||||
if (priv->selected_capture_api == GST_D3D12_SCREEN_CAPTURE_API_DXGI) {
|
if (priv->selected_capture_api == GST_D3D12_SCREEN_CAPTURE_API_DXGI) {
|
||||||
gst_clear_object (&capture);
|
gst_clear_object (&capture);
|
||||||
GST_WARNING_OBJECT (self, "DXGI capture is not available");
|
GST_WARNING_OBJECT (self, "DXGI capture is not available");
|
||||||
|
@ -921,6 +934,7 @@ gst_d3d12_screen_capture_src_start (GstBaseSrc * bsrc)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
goto unsupported;
|
goto unsupported;
|
||||||
default:
|
default:
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -930,6 +944,7 @@ gst_d3d12_screen_capture_src_start (GstBaseSrc * bsrc)
|
||||||
priv->latency = GST_CLOCK_TIME_NONE;
|
priv->latency = GST_CLOCK_TIME_NONE;
|
||||||
priv->capture = capture;
|
priv->capture = capture;
|
||||||
|
|
||||||
|
#ifdef HAVE_WGC
|
||||||
if (priv->selected_capture_api == GST_D3D12_SCREEN_CAPTURE_API_WGC) {
|
if (priv->selected_capture_api == GST_D3D12_SCREEN_CAPTURE_API_WGC) {
|
||||||
auto wgc = GST_D3D12_GRAPHICS_CAPTURE (priv->capture);
|
auto wgc = GST_D3D12_GRAPHICS_CAPTURE (priv->capture);
|
||||||
gst_d3d12_graphics_capture_show_cursor (wgc, priv->show_cursor);
|
gst_d3d12_graphics_capture_show_cursor (wgc, priv->show_cursor);
|
||||||
|
@ -937,6 +952,7 @@ gst_d3d12_screen_capture_src_start (GstBaseSrc * bsrc)
|
||||||
gst_d3d12_graphics_capture_set_client_only (wgc,
|
gst_d3d12_graphics_capture_set_client_only (wgc,
|
||||||
priv->hwnd_capture_mode == GST_D3D12_WINDOW_CAPTURE_CLIENT);
|
priv->hwnd_capture_mode == GST_D3D12_WINDOW_CAPTURE_CLIENT);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (priv->capture_api != priv->selected_capture_api) {
|
if (priv->capture_api != priv->selected_capture_api) {
|
||||||
priv->capture_api = priv->selected_capture_api;
|
priv->capture_api = priv->selected_capture_api;
|
||||||
|
@ -1055,6 +1071,7 @@ gst_d3d12_screen_capture_src_src_query (GstBaseSrc * bsrc, GstQuery * query)
|
||||||
return GST_BASE_SRC_CLASS (parent_class)->query (bsrc, query);
|
return GST_BASE_SRC_CLASS (parent_class)->query (bsrc, query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_WGC
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_d3d12_screen_capture_src_wgc_capture (GstBaseSrc * bsrc,
|
gst_d3d12_screen_capture_src_wgc_capture (GstBaseSrc * bsrc,
|
||||||
guint64 offset, guint size, GstBuffer ** buf)
|
guint64 offset, guint size, GstBuffer ** buf)
|
||||||
|
@ -1188,6 +1205,7 @@ gst_d3d12_screen_capture_src_wgc_capture (GstBaseSrc * bsrc,
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_d3d12_screen_capture_src_dxgi_capture (GstBaseSrc * bsrc,
|
gst_d3d12_screen_capture_src_dxgi_capture (GstBaseSrc * bsrc,
|
||||||
|
@ -1426,9 +1444,10 @@ gst_d3d12_screen_capture_src_create (GstBaseSrc * bsrc, guint64 offset,
|
||||||
("Couldn't configure capture object"), (nullptr));
|
("Couldn't configure capture object"), (nullptr));
|
||||||
return GST_FLOW_NOT_NEGOTIATED;
|
return GST_FLOW_NOT_NEGOTIATED;
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_WGC
|
||||||
if (priv->selected_capture_api == GST_D3D12_SCREEN_CAPTURE_API_DXGI)
|
if (priv->selected_capture_api == GST_D3D12_SCREEN_CAPTURE_API_WGC)
|
||||||
return gst_d3d12_screen_capture_src_dxgi_capture (bsrc, offset, size, buf);
|
|
||||||
|
|
||||||
return gst_d3d12_screen_capture_src_wgc_capture (bsrc, offset, size, buf);
|
return gst_d3d12_screen_capture_src_wgc_capture (bsrc, offset, size, buf);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return gst_d3d12_screen_capture_src_dxgi_capture (bsrc, offset, size, buf);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ d3d12_sources = [
|
||||||
'gstd3d12encoderbufferpool.cpp',
|
'gstd3d12encoderbufferpool.cpp',
|
||||||
'gstd3d12fencedatapool.cpp',
|
'gstd3d12fencedatapool.cpp',
|
||||||
'gstd3d12format.cpp',
|
'gstd3d12format.cpp',
|
||||||
'gstd3d12graphicscapture.cpp',
|
|
||||||
'gstd3d12h264dec.cpp',
|
'gstd3d12h264dec.cpp',
|
||||||
'gstd3d12h264enc.cpp',
|
'gstd3d12h264enc.cpp',
|
||||||
'gstd3d12h265dec.cpp',
|
'gstd3d12h265dec.cpp',
|
||||||
|
@ -52,7 +51,10 @@ extra_args = [
|
||||||
'/wd4062',
|
'/wd4062',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
extra_deps = []
|
||||||
|
|
||||||
d3d12_option = get_option('d3d12')
|
d3d12_option = get_option('d3d12')
|
||||||
|
d3d12_wgc_option = get_option('d3d12-wgc')
|
||||||
if host_system != 'windows' or d3d12_option.disabled()
|
if host_system != 'windows' or d3d12_option.disabled()
|
||||||
subdir_done()
|
subdir_done()
|
||||||
endif
|
endif
|
||||||
|
@ -68,21 +70,22 @@ d3d12_lib = cc.find_library('d3d12', required : d3d12_option)
|
||||||
d3d11_lib = cc.find_library('d3d11', required : d3d12_option)
|
d3d11_lib = cc.find_library('d3d11', required : d3d12_option)
|
||||||
d2d_dep = cc.find_library('d2d1', required: d3d12_option)
|
d2d_dep = cc.find_library('d2d1', required: d3d12_option)
|
||||||
dxgi_lib = cc.find_library('dxgi', required : d3d12_option)
|
dxgi_lib = cc.find_library('dxgi', required : d3d12_option)
|
||||||
dwmapi_lib = cc.find_library('dwmapi', required: d3d12_option)
|
dwmapi_lib = cc.find_library('dwmapi', required: d3d12_wgc_option)
|
||||||
dx_headers_dep = dependency('DirectX-Headers',
|
dx_headers_dep = dependency('DirectX-Headers',
|
||||||
version: '>= 1.611',
|
version: '>= 1.611',
|
||||||
allow_fallback: true,
|
allow_fallback: true,
|
||||||
required: d3d12_option)
|
required: d3d12_option)
|
||||||
|
|
||||||
if not gstdxva_dep.found() or not d3d12_lib.found() or not dxgi_lib.found() \
|
if not gstdxva_dep.found() or not d3d12_lib.found() or not dxgi_lib.found() \
|
||||||
or not dx_headers_dep.found() or not gstd3dshader_dep.found() or not d2d_dep.found() \
|
or not dx_headers_dep.found() or not gstd3dshader_dep.found() or not d2d_dep.found()
|
||||||
or not dwmapi_lib.found()
|
|
||||||
if d3d12_option.enabled()
|
if d3d12_option.enabled()
|
||||||
error('The d3d12 was enabled explicitly, but required dependencies were not found.')
|
error('The d3d12 was enabled explicitly, but required dependencies were not found.')
|
||||||
endif
|
endif
|
||||||
subdir_done()
|
subdir_done()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
have_wgc = false
|
||||||
|
if not d3d12_wgc_option.disabled()
|
||||||
have_wgc = cxx.compiles('''
|
have_wgc = cxx.compiles('''
|
||||||
#include<windows.h>
|
#include<windows.h>
|
||||||
#include<winstring.h>
|
#include<winstring.h>
|
||||||
|
@ -102,11 +105,9 @@ have_wgc = cxx.compiles('''
|
||||||
''',
|
''',
|
||||||
name: 'Windows Graphics Capture support in Windows SDK')
|
name: 'Windows Graphics Capture support in Windows SDK')
|
||||||
|
|
||||||
if not have_wgc
|
if d3d12_wgc_option.enabled() and not have_wgc
|
||||||
if d3d12_option.enabled()
|
error('The Windows Graphics Capture feature is enabled but not supported by Windows SDK')
|
||||||
error('Windows SDK does not support Windows Graphics Capture')
|
|
||||||
endif
|
endif
|
||||||
subdir_done()
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
d3d12_headers = [
|
d3d12_headers = [
|
||||||
|
@ -137,6 +138,12 @@ if host_machine.cpu_family() != 'x86'
|
||||||
extra_args += ['-DHAVE_DIRECTX_MATH_SIMD']
|
extra_args += ['-DHAVE_DIRECTX_MATH_SIMD']
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if have_wgc and dwmapi_lib.found()
|
||||||
|
d3d12_sources += ['gstd3d12graphicscapture.cpp']
|
||||||
|
extra_args += ['-DHAVE_WGC']
|
||||||
|
extra_deps += [dwmapi_lib]
|
||||||
|
endif
|
||||||
|
|
||||||
gstd3d12 = library('gstd3d12',
|
gstd3d12 = library('gstd3d12',
|
||||||
d3d12_sources,
|
d3d12_sources,
|
||||||
c_args : gst_plugins_bad_args + extra_args,
|
c_args : gst_plugins_bad_args + extra_args,
|
||||||
|
@ -144,7 +151,7 @@ gstd3d12 = library('gstd3d12',
|
||||||
include_directories : [configinc],
|
include_directories : [configinc],
|
||||||
dependencies : [gstbase_dep, gstvideo_dep, gstcodecs_dep, gmodule_dep,
|
dependencies : [gstbase_dep, gstvideo_dep, gstcodecs_dep, gmodule_dep,
|
||||||
gstdxva_dep, d3d12_lib, d3d11_lib, d2d_dep, dxgi_lib,
|
gstdxva_dep, d3d12_lib, d3d11_lib, d2d_dep, dxgi_lib,
|
||||||
gstd3dshader_dep, dx_headers_dep, dwmapi_lib],
|
gstd3dshader_dep, dx_headers_dep] + extra_deps,
|
||||||
install : true,
|
install : true,
|
||||||
install_dir : plugins_install_dir,
|
install_dir : plugins_install_dir,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue