Sunshine master
Self-hosted game stream host for Moonlight.
platf::dxgi::display_ddup_ram_t Class Reference

#include <src/platform/windows/display.h>

Inheritance diagram for platf::dxgi::display_ddup_ram_t:
[legend]
Collaboration diagram for platf::dxgi::display_ddup_ram_t:
[legend]

Public Member Functions

int init (const ::video::config_t &config, const std::string &display_name)
 Initialize shared D3D capture resources for a RAM frame.
 
capture_e release_snapshot () override
 Release resources associated with the last captured snapshot.
 
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
 Capture a display frame into the provided image object.
 
- Public Member Functions inherited from platf::dxgi::display_ram_t
std::shared_ptr< img_talloc_img () override
 Allocate an image buffer compatible with this display backend.
 
int complete_img (img_t *img, bool dummy) override
 Finish cursor composition into a GPU-backed image.
 
int dummy_img (img_t *img) override
 Populate a fallback image when real capture data is unavailable.
 
int dummy_img (platf::img_t *img)
 Populate a fallback image when real capture data is unavailable.
 
std::vector< DXGI_FORMAT > get_supported_capture_formats () override
 Get supported capture formats.
 
std::unique_ptr< avcodec_encode_device_tmake_avcodec_encode_device (pix_fmt_e pix_fmt) override
 Create AVCodec encode device.
 
- Public Member Functions inherited from platf::dxgi::display_base_t
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.
 
const char * colorspace_to_string (DXGI_COLOR_SPACE_TYPE type)
 Convert a DXGI colorspace enum to a diagnostic string.
 
const char * dxgi_format_to_string (DXGI_FORMAT format)
 Convert a DXGI format enum to a diagnostic string.
 
virtual bool get_hdr_metadata (SS_HDR_METADATA &metadata) override
 Read HDR metadata for the active display mode.
 
int init (const ::video::config_t &config, const std::string &display_name)
 Initialize D3D11 desktop duplication for the selected output.
 
virtual bool is_hdr () override
 Report whether the active display mode is HDR.
 
- Public Member Functions inherited from platf::display_t
virtual bool is_codec_supported (std::string_view name, const ::video::config_t &config)
 Check that a given codec is supported by the display device.
 
virtual std::unique_ptr< nvenc_encode_device_tmake_nvenc_encode_device (pix_fmt_e pix_fmt)
 Create NVENC encode device.
 

Public Attributes

cursor_t cursor
 Cursor.
 
duplication_t dup
 Desktop Duplication session used to acquire frames.
 
- Public Attributes inherited from platf::dxgi::display_ram_t
D3D11_MAPPED_SUBRESOURCE img_info
 CPU mapping information for the captured texture.
 
texture2d_t texture
 D3D11 texture backing the captured frame.
 
- Public Attributes inherited from platf::dxgi::display_base_t
adapter_t adapter
 DXGI adapter containing the selected output.
 
DXGI_FORMAT capture_format
 Capture format.
 
int client_frame_rate
 Client frame rate.
 
DXGI_RATIONAL client_frame_rate_strict
 Client frame rate strict.
 
device_t device
 D3D11 device used for desktop duplication capture.
 
device_ctx_t device_ctx
 D3D11 device context used for copy and render operations.
 
DXGI_RATIONAL display_refresh_rate
 Display refresh rate.
 
int display_refresh_rate_rounded
 Display refresh rate rounded.
 
DXGI_MODE_ROTATION display_rotation = DXGI_MODE_ROTATION_UNSPECIFIED
 Display rotation.
 
factory1_t factory
 DXGI factory used to enumerate adapters and outputs.
 
D3D_FEATURE_LEVEL feature_level
 Feature level.
 
int height_before_rotation
 Height before rotation.
 
const UINT KMTQAITYPE_WDDM_2_7_CAPS = 70
 Protocol or platform constant for kmtqaitype wddm 2 7 caps.
 
output_t output
 DXGI output duplicated for capture.
 
std::unique_ptr< high_precision_timertimer = create_high_precision_timer()
 Timer.
 
int width_before_rotation
 Width before rotation.
 
- Public Attributes inherited from platf::display_t
int env_height {0}
 Height of the full capture environment in physical pixels.
 
int env_logical_height {0}
 Height of the full capture environment after display scaling.
 
int env_logical_width {0}
 Width of the full capture environment after display scaling.
 
int env_width {0}
 Width of the full capture environment in physical pixels.
 
int height {0}
 Height of the captured display in physical pixels.
 
int logical_height {0}
 Height of the captured display after display scaling.
 
int logical_width {0}
 Width of the captured display after display scaling.
 
int offset_x {0}
 Horizontal capture offset in physical pixels.
 
int offset_y {0}
 Vertical capture offset in physical pixels.
 
int width {0}
 Width of the captured display in physical pixels.
 

Additional Inherited Members

- Public Types inherited from platf::dxgi::display_base_t
enum  _D3DKMT_SCHEDULINGPRIORITYCLASS {
  D3DKMT_SCHEDULINGPRIORITYCLASS_IDLE , D3DKMT_SCHEDULINGPRIORITYCLASS_BELOW_NORMAL , D3DKMT_SCHEDULINGPRIORITYCLASS_NORMAL , D3DKMT_SCHEDULINGPRIORITYCLASS_ABOVE_NORMAL ,
  D3DKMT_SCHEDULINGPRIORITYCLASS_HIGH , D3DKMT_SCHEDULINGPRIORITYCLASS_REALTIME
}
 Enumerates supported d3 DKMT SCHEDULINGPRIORITYCLASS options. More...
 
typedef struct platf::dxgi::display_base_t::_D3DKMT_CLOSEADAPTER D3DKMT_CLOSEADAPTER
 Win32 D3DKMT adapter-close request structure.
 
typedef UINT D3DKMT_HANDLE
 Kernel-mode D3DKMT adapter handle.
 
typedef struct platf::dxgi::display_base_t::_D3DKMT_OPENADAPTERFROMLUID D3DKMT_OPENADAPTERFROMLUID
 Win32 D3DKMT adapter-open request structure.
 
typedef struct platf::dxgi::display_base_t::_D3DKMT_QUERYADAPTERINFO D3DKMT_QUERYADAPTERINFO
 Win32 D3DKMT adapter information query.
 
typedef enum platf::dxgi::display_base_t::_D3DKMT_SCHEDULINGPRIORITYCLASS D3DKMT_SCHEDULINGPRIORITYCLASS
 Enumerates supported d3 DKMT SCHEDULINGPRIORITYCLASS options.
 
typedef struct platf::dxgi::display_base_t::_D3DKMT_WDDM_2_7_CAPS D3DKMT_WDDM_2_7_CAPS
 Win32 D3DKMT WDDM 2.7 capability flags.
 
typedef NTSTATUS(WINAPI *) PD3DKMTCloseAdapter(D3DKMT_CLOSEADAPTER *)
 Function pointer for closing a D3DKMT adapter handle.
 
typedef NTSTATUS(WINAPI *) PD3DKMTOpenAdapterFromLuid(D3DKMT_OPENADAPTERFROMLUID *)
 Function pointer for opening a D3DKMT adapter by LUID.
 
typedef NTSTATUS(WINAPI *) PD3DKMTQueryAdapterInfo(D3DKMT_QUERYADAPTERINFO *)
 Function pointer for querying D3DKMT adapter information.
 
typedef NTSTATUS(WINAPI *) PD3DKMTSetProcessSchedulingPriorityClass(HANDLE, D3DKMT_SCHEDULINGPRIORITYCLASS)
 Function pointer for setting D3DKMT process scheduling priority.
 
- Public Types inherited from platf::display_t
using pull_free_image_cb_t = std::function<bool(std::shared_ptr<img_t> &img_out)>
 Get free image from pool. Calls must be synchronized. Blocks until there is free image in the pool or capture is interrupted.
 
using push_captured_image_cb_t = std::function<bool(std::shared_ptr<img_t> &&img, bool frame_captured)>
 Callback for when a new image is ready. When display has a new image ready or a timeout occurs, this callback will be called with the image. If a frame was captured, frame_captured will be true. If a timeout occurred, it will be false.
 
- Protected Member Functions inherited from platf::dxgi::display_base_t
int get_pixel_pitch ()
 Get pixel pitch.
 
- Protected Attributes inherited from platf::display_t
logging::time_delta_periodic_logger sleep_overshoot_logger = {debug, "Frame capture sleep overshoot"}
 Periodic logger for capture sleep overshoot measurements.
 

Detailed Description

Display backend that uses DDAPI with a software encoder.

Member Function Documentation

◆ init()

int platf::dxgi::display_ddup_ram_t::init ( const ::video::config_t & config,
const std::string & display_name )

Initialize shared D3D capture resources for a RAM frame.

Parameters
configConfiguration values to apply.
display_nameDisplay name.
Returns
0 on success; nonzero or negative platform status on failure.

◆ release_snapshot()

capture_e platf::dxgi::display_ddup_ram_t::release_snapshot ( )
overridevirtual

Release resources associated with the last captured snapshot.

Returns
Capture status after releasing the current snapshot.

Implements platf::dxgi::display_base_t.

◆ snapshot()

capture_e platf::dxgi::display_ddup_ram_t::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 )
overridevirtual

Capture a display frame into the provided image object.

Parameters
pull_free_image_cbCallback that provides an available image buffer.
img_outCaptured image buffer returned to the streaming pipeline.
timeoutMaximum time to wait for the operation.
cursor_visibleCursor visible.
Returns
Capture status reported to the streaming pipeline.

Implements platf::dxgi::display_base_t.


The documentation for this class was generated from the following files: