88 cursor_view {0, 0, 0, 0, 0.0f, 1.0f} {};
90 void set_pos(LONG topleft_x, LONG topleft_y, LONG display_width, LONG display_height, DXGI_MODE_ROTATION display_rotation,
bool visible) {
91 this->topleft_x = topleft_x;
92 this->topleft_y = topleft_y;
93 this->display_width = display_width;
94 this->display_height = display_height;
95 this->display_rotation = display_rotation;
96 this->visible = visible;
100 void set_texture(LONG texture_width, LONG texture_height,
texture2d_t &&texture) {
101 this->texture = std::move(texture);
102 this->texture_width = texture_width;
103 this->texture_height = texture_height;
107 void update_viewport() {
108 switch (display_rotation) {
109 case DXGI_MODE_ROTATION_UNSPECIFIED:
110 case DXGI_MODE_ROTATION_IDENTITY:
111 cursor_view.TopLeftX = topleft_x;
112 cursor_view.TopLeftY = topleft_y;
113 cursor_view.Width = texture_width;
114 cursor_view.Height = texture_height;
117 case DXGI_MODE_ROTATION_ROTATE90:
118 cursor_view.TopLeftX = topleft_y;
119 cursor_view.TopLeftY = display_width - texture_width - topleft_x;
120 cursor_view.Width = texture_height;
121 cursor_view.Height = texture_width;
124 case DXGI_MODE_ROTATION_ROTATE180:
125 cursor_view.TopLeftX = display_width - texture_width - topleft_x;
126 cursor_view.TopLeftY = display_height - texture_height - topleft_y;
127 cursor_view.Width = texture_width;
128 cursor_view.Height = texture_height;
131 case DXGI_MODE_ROTATION_ROTATE270:
132 cursor_view.TopLeftX = display_height - texture_height - topleft_y;
133 cursor_view.TopLeftY = topleft_x;
134 cursor_view.Width = texture_height;
135 cursor_view.Height = texture_width;
149 DXGI_MODE_ROTATION display_rotation;
153 D3D11_VIEWPORT cursor_view;
160 int init(const ::video::config_t &config,
const std::string &display_name);
169 DXGI_RATIONAL display_refresh_rate;
170 int display_refresh_rate_rounded;
172 DXGI_MODE_ROTATION display_rotation = DXGI_MODE_ROTATION_UNSPECIFIED;
173 int width_before_rotation;
174 int height_before_rotation;
176 int client_frame_rate;
177 DXGI_RATIONAL client_frame_rate_strict;
179 DXGI_FORMAT capture_format;
180 D3D_FEATURE_LEVEL feature_level;
191 } D3DKMT_SCHEDULINGPRIORITYCLASS;
193 typedef UINT D3DKMT_HANDLE;
197 D3DKMT_HANDLE hAdapter;
204 UINT HwSchSupported : 1;
205 UINT HwSchEnabled : 1;
206 UINT HwSchEnabledByDefault : 1;
207 UINT IndependentVidPnVSyncControl : 1;
216 D3DKMT_HANDLE hAdapter;
218 VOID *pPrivateDriverData;
219 UINT PrivateDriverDataSize;
222 const UINT KMTQAITYPE_WDDM_2_7_CAPS = 70;
225 D3DKMT_HANDLE hAdapter;
228 typedef NTSTATUS(WINAPI *PD3DKMTSetProcessSchedulingPriorityClass)(HANDLE, D3DKMT_SCHEDULINGPRIORITYCLASS);
233 virtual bool is_hdr()
override;
234 virtual bool get_hdr_metadata(SS_HDR_METADATA &metadata)
override;
236 const char *dxgi_format_to_string(DXGI_FORMAT format);
237 const char *colorspace_to_string(DXGI_COLOR_SPACE_TYPE type);
238 virtual std::vector<DXGI_FORMAT> get_supported_capture_formats() = 0;
241 int get_pixel_pitch() {
242 return (capture_format == DXGI_FORMAT_R16G16B16A16_FLOAT) ? 8 : 4;
245 virtual capture_e snapshot(
const pull_free_image_cb_t &pull_free_image_cb, std::shared_ptr<platf::img_t> &img_out, std::chrono::milliseconds timeout,
bool cursor_visible) = 0;
246 virtual capture_e release_snapshot() = 0;
247 virtual int complete_img(
img_t *img,
bool dummy) = 0;
271 std::shared_ptr<img_t> alloc_img()
override;
272 int dummy_img(
img_t *img_base)
override;
273 int complete_img(
img_t *img_base,
bool dummy)
override;
274 std::vector<DXGI_FORMAT> get_supported_capture_formats()
override;
276 bool is_codec_supported(std::string_view name, const ::video::config_t &config)
override;
278 std::unique_ptr<avcodec_encode_device_t> make_avcodec_encode_device(
pix_fmt_e pix_fmt)
override;
280 std::unique_ptr<nvenc_encode_device_t> make_nvenc_encode_device(
pix_fmt_e pix_fmt)
override;
282 std::atomic<uint32_t> next_image_id;
292 std::chrono::steady_clock::time_point last_protected_content_warning_time {};
295 capture_e next_frame(DXGI_OUTDUPL_FRAME_INFO &frame_info, std::chrono::milliseconds
timeout, resource_t::pointer *res_p);
296 capture_e reset(dup_t::pointer dup_p = dup_t::pointer());
320 int init(const ::video::config_t &config,
const std::string &display_name);
338 std::chrono::steady_clock::time_point old_surface_timestamp;
339 std::variant<std::monostate, texture2d_t, std::shared_ptr<platf::img_t>> last_frame_variant;
346 winrt::Windows::Graphics::DirectX::Direct3D11::IDirect3DDevice uwp_device {
nullptr};
347 winrt::Windows::Graphics::Capture::GraphicsCaptureItem item {
nullptr};
348 winrt::Windows::Graphics::Capture::Direct3D11CaptureFramePool frame_pool {
nullptr};
349 winrt::Windows::Graphics::Capture::GraphicsCaptureSession capture_session {
nullptr};
350 winrt::Windows::Graphics::Capture::Direct3D11CaptureFrame produced_frame {
nullptr};
351 winrt::Windows::Graphics::Capture::Direct3D11CaptureFrame consumed_frame {
nullptr};
352 SRWLOCK frame_lock = SRWLOCK_INIT;
353 CONDITION_VARIABLE frame_present_cv;
355 void on_frame_arrived(winrt::Windows::Graphics::Capture::Direct3D11CaptureFramePool
const &sender, winrt::Windows::Foundation::IInspectable
const &);
364 int set_cursor_visible(
bool);
std::function< bool(std::shared_ptr< img_t > &&img, bool frame_captured)> push_captured_image_cb_t
Callback for when a new image is ready. When display has a new image ready or a timeout occurs,...
Definition common.h:476
capture_e capture(const push_captured_image_cb_t &push_captured_image_cb, const pull_free_image_cb_t &pull_free_image_cb, bool *cursor) override
Capture a frame.
Definition display_base.cpp:206
bool is_codec_supported(std::string_view name, const ::video::config_t &config) override
Check that a given codec is supported by the display device.
Definition display_vram.cpp:1841
capture_e snapshot(const pull_free_image_cb_t &pull_free_image_cb, std::shared_ptr< platf::img_t > &img_out, std::chrono::milliseconds timeout, bool cursor_visible) override
Get the next frame from the Windows.Graphics.Capture API and copy it into a new snapshot texture.
Definition display_wgc.cpp:256
capture_e snapshot(const pull_free_image_cb_t &pull_free_image_cb, std::shared_ptr< platf::img_t > &img_out, std::chrono::milliseconds timeout, bool cursor_visible) override
Definition display_vram.cpp:1646
capture_e next_frame(std::chrono::milliseconds timeout, ID3D11Texture2D **out, uint64_t &out_time)
Get the next frame from the producer thread. If not available, the capture thread blocks until one is...
Definition display_wgc.cpp:190
std::shared_ptr< display_t > display(mem_type_e hwdevice_type, const std::string &display_name, const video::config_t &config)
Get the display_t instance for the given hwdevice_type. If display_name is empty, use the first monit...
Definition misc.cpp:985