Sunshine0.0.5917
Sunshine 0.0.5917
Self-hosted game stream host for Moonlight.
Loading...
Searching...
No Matches
platf::shm_attr_t Struct Reference

X11 shared-memory image dimensions and identifiers. More...

Inheritance diagram for platf::shm_attr_t:
Collaboration diagram for platf::shm_attr_t:

Public Member Functions

std::shared_ptr< img_t > alloc_img () override
 Allocate an image buffer compatible with this display backend.
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 X11 shared-memory frames until capture stops or reinitialization is needed.
void delayed_refresh ()
 Refresh X11 shared-memory capture after a scheduled delay.
int dummy_img (platf::img_t *img) override
 Populate a fallback image when real capture data is unavailable.
std::uint32_t frame_size ()
 Calculate the XCB shared-memory frame size.
int init (const std::string &display_name, const ::video::config_t &config)
 Initialize X11 shared-memory capture for the selected display.
 shm_attr_t (mem_type_e mem_type)
 Explicitly open an X11 shared-memory capture backend.
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)
 Capture a display frame into the provided image object.
Public Member Functions inherited from platf::x11_attr_t
std::shared_ptr< img_t > alloc_img () override
 Allocate an image buffer compatible with this display backend.
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 X11 frames until capture stops or the display needs reinitialization.
int dummy_img (img_t *img) override
 Populate a fallback image when real capture data is unavailable.
int init (const std::string &display_name, const ::video::config_t &config)
 Open the X11 display and cache capture window attributes.
std::unique_ptr< avcodec_encode_device_t > make_avcodec_encode_device (pix_fmt_e pix_fmt) override
 Create AVCodec encode device.
void refresh ()
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)
 Capture a display frame into the provided image object.
 x11_attr_t (mem_type_e mem_type)
 Explicitly open the X11 display and initialize capture attributes.
Public Member Functions inherited from platf::display_t
virtual bool get_hdr_metadata (SS_HDR_METADATA &metadata)
 Read HDR metadata for the active display mode.
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 bool is_hdr ()
 Report whether the active display mode is HDR.
virtual std::unique_ptr< nvenc_encode_device_t > make_nvenc_encode_device (pix_fmt_e pix_fmt)
 Create NVENC encode device.

Public Attributes

shm_data_t data
 Attached SysV shared-memory data used by XShm.
xcb_screen_t * display
 XCB screen containing the captured root window.
task_pool_util::TaskPool::task_id_t refresh_task_id
 Refresh task ID.
std::uint32_t seg
 XCB shared-memory segment ID attached to the image.
shm_id_t shm_id
 Shm ID.
x11::xdisplay_t shm_xdisplay {x11::OpenDisplay(nullptr)}
 X11 display held separately to prevent races with x11_attr_t::xdisplay.
xcb_connect_t xcb
 XCB connection used by the shared-memory capture path.
Public Attributes inherited from platf::x11_attr_t
std::chrono::nanoseconds delay
 Delay before the timer task becomes eligible to run.
mem_type_e mem_type
 Mem type.
XWindowAttributes xattr {}
 Cached X11 window attributes used to detect size changes.
x11::xdisplay_t xdisplay {x11::OpenDisplay(nullptr)}
 X11 display connection opened for capture.
Window xwindow {}
 Root window being captured.
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_offset_x {0}
 Horizontal origin of the full capture environment in native desktop coordinates.
int env_offset_y {0}
 Vertical origin of the full capture environment in native desktop coordinates.
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::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 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

X11 shared-memory image dimensions and identifiers.

Constructor & Destructor Documentation

◆ shm_attr_t()

platf::shm_attr_t::shm_attr_t ( mem_type_e mem_type)
inlineexplicit

Explicitly open an X11 shared-memory capture backend.

Parameters
mem_typeRequested memory path for the capture backend.

Member Function Documentation

◆ alloc_img()

std::shared_ptr< img_t > platf::shm_attr_t::alloc_img ( )
inlineoverridevirtual

Allocate an image buffer compatible with this display backend.

Returns
Allocated img object, or null when unavailable.

Implements platf::display_t.

◆ capture()

capture_e platf::shm_attr_t::capture ( const push_captured_image_cb_t & push_captured_image_cb,
const pull_free_image_cb_t & pull_free_image_cb,
bool * cursor )
inlineoverridevirtual

Capture X11 shared-memory frames until capture stops or reinitialization is needed.

Parameters
push_captured_image_cbCallback receiving a captured image or a capture timeout.
pull_free_image_cbCallback providing an available image buffer.
cursorWhether the cursor should be included in the captured image.
Returns
Final capture status reported to the streaming pipeline.

Implements platf::display_t.

◆ dummy_img()

int platf::shm_attr_t::dummy_img ( platf::img_t * img)
inlineoverridevirtual

Populate a fallback image when real capture data is unavailable.

Parameters
imgImage or frame object to read from or populate.
Returns
Capture status reported to the streaming pipeline.

Implements platf::display_t.

◆ frame_size()

std::uint32_t platf::shm_attr_t::frame_size ( )
inline

Calculate the XCB shared-memory frame size.

Returns
Frame size in bytes for BGRA pixels.

◆ init()

int platf::shm_attr_t::init ( const std::string & display_name,
const ::video::config_t & config )
inline

Initialize X11 shared-memory capture for the selected display.

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

◆ snapshot()

capture_e platf::shm_attr_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 )
inline

Capture a display frame into the provided image object.

Parameters
pull_free_image_cbCallback that provides an available image buffer.
img_outShared-memory captured frame returned to the streaming pipeline.
timeoutMaximum time to wait for the operation.
cursorCursor image or visibility state to composite.
Returns
Capture status reported to the streaming pipeline.

The documentation for this struct was generated from the following file: