Sunshine0.0.5917
Sunshine 0.0.5917
Self-hosted game stream host for Moonlight.
Loading...
Searching...
No Matches
pipewire::pipewire_t Class Reference

PipeWire core, context, and stream setup used for screencast capture. More...

Classes

struct  compositor_version_t
 Compositor type and version information. More...

Public Types

enum class  compositor_type_e { unknown , gnome , kwin }
 Compositors that require version-based checks for optimal stream setup. More...

Public Member Functions

int ensure_stream (const platf::mem_type_e mem_type, const uint32_t width, const uint32_t height, const AVRational target_framerate, const struct dmabuf_format_info_t *dmabuf_infos, const int n_dmabuf_infos, const bool display_is_nvidia)
 Create the PipeWire stream if it is not already active.
void fill_img (platf::img_t *img)
 Copy the latest PipeWire frame into Sunshine's image buffer.
std::condition_variable & frame_cv ()
 Return the condition variable signaled when frame state changes.
std::mutex & frame_mutex ()
 Return the mutex protecting PipeWire frame state.
int init (const int stream_fd, const uint32_t stream_node, const uint64_t stream_object_serial, std::shared_ptr< shared_state_t > shared_state)
 Initialize PipeWire core objects and optional stream negotiation.
bool is_frame_ready () const
 Check whether frame ready.
bool is_pacing_required (AVRational requested_framerate, std::chrono::nanoseconds requested_delay)
 Check and log whether the active session will require Sunshine to perform pacing.
void set_frame_ready (bool ready)
 Set frame ready.
void set_negotiate_maxframerate (bool negotiate_maxframerate)
 Set negotiate maxframerate.

Static Public Member Functions

static void close_img_fds (egl::img_descriptor_t *img_descriptor)
 Close img fds.
static void fill_img_dmabuf (egl::img_descriptor_t *img_descriptor, struct spa_buffer *buf, const stream_data_t &d)
 Populate a Sunshine image descriptor from PipeWire DMA-BUF planes.
static void fill_img_metadata (egl::img_descriptor_t *img_descriptor, struct spa_buffer *buf)
 Copy PipeWire metadata into the Sunshine image descriptor.
static compositor_version_t get_running_compositor ()
 Fetch compositor type and version for processing.
static std::vector< int > get_running_compositor_version (enum compositor_type_e compositor_type)
 Fetch compositor version information using DBus calls.
static bool use_pipewire_pts (const compositor_version_t &compositor, const std::string &selected_display_name)
 Determine if Pipewire's pts metadata is suitable for client pacing based on compositor type/version whitelist.
static bool use_variable_rate (const compositor_version_t &compositor)
 Determine if the active compositor is suited for variable rate capture based on type/version whitelist.

Static Public Attributes

static std::atomic negotiate_variable_rate {true}
 Whether the session should request variable rate (maxFrameRate = 0/1) capture.
static std::atomic prefer_pipewire_pts {false}
 Whether the session should directly passthrough Pipewire pts metadata for client pacing.

Detailed Description

PipeWire core, context, and stream setup used for screencast capture.

Member Enumeration Documentation

◆ compositor_type_e

Compositors that require version-based checks for optimal stream setup.

Enumerator
unknown 

Unknown.

gnome 

GNOME Shell is a proxy for Mutter.

kwin 

KWin.

Member Function Documentation

◆ close_img_fds()

void pipewire::pipewire_t::close_img_fds ( egl::img_descriptor_t * img_descriptor)
inlinestatic

Close img fds.

Parameters
img_descriptorImage descriptor whose duplicated DMA-BUF fds are closed.

◆ ensure_stream()

int pipewire::pipewire_t::ensure_stream ( const platf::mem_type_e mem_type,
const uint32_t width,
const uint32_t height,
const AVRational target_framerate,
const struct dmabuf_format_info_t * dmabuf_infos,
const int n_dmabuf_infos,
const bool display_is_nvidia )
inline

Create the PipeWire stream if it is not already active.

Parameters
mem_typeMem type.
widthFrame or display width in pixels.
heightFrame or display height in pixels.
target_framerateTarget framerate expressed as AVRational.
dmabuf_infosDmabuf infos.
n_dmabuf_infosN dmabuf infos.
display_is_nvidiaDisplay is nvidia.
Returns
0 when the PipeWire stream is configured; nonzero on negotiation failure.

◆ fill_img()

void pipewire::pipewire_t::fill_img ( platf::img_t * img)
inline

Copy the latest PipeWire frame into Sunshine's image buffer.

Parameters
imgImage or frame object to read from or populate.

◆ fill_img_dmabuf()

void pipewire::pipewire_t::fill_img_dmabuf ( egl::img_descriptor_t * img_descriptor,
struct spa_buffer * buf,
const stream_data_t & d )
inlinestatic

Populate a Sunshine image descriptor from PipeWire DMA-BUF planes.

Parameters
img_descriptorImage descriptor receiving duplicated fds and plane layout.
bufRaw byte buffer used for serialization.
dPipeWire listener data passed to the callback.

◆ fill_img_metadata()

void pipewire::pipewire_t::fill_img_metadata ( egl::img_descriptor_t * img_descriptor,
struct spa_buffer * buf )
inlinestatic

Copy PipeWire metadata into the Sunshine image descriptor.

Parameters
img_descriptorImage descriptor receiving timestamps, sequence, and damage flags.
bufRaw byte buffer used for serialization.

◆ frame_cv()

std::condition_variable & pipewire::pipewire_t::frame_cv ( )
inline

Return the condition variable signaled when frame state changes.

Returns
Condition variable used to wait for frames or shutdown.

◆ frame_mutex()

std::mutex & pipewire::pipewire_t::frame_mutex ( )
inline

Return the mutex protecting PipeWire frame state.

Returns
Mutex used by producer and capture threads.

◆ get_running_compositor()

compositor_version_t pipewire::pipewire_t::get_running_compositor ( )
inlinestatic

Fetch compositor type and version for processing.

Returns
A struct containing the compositor type and version.

◆ get_running_compositor_version()

std::vector< int > pipewire::pipewire_t::get_running_compositor_version ( enum compositor_type_e compositor_type)
inlinestatic

Fetch compositor version information using DBus calls.

Parameters
compositor_typeThe compositor we should attempt to fetch version information for.
Returns
A vector with 2-3 elements containing the major.minor.micro versions or an empty vector if the version could not be determined.

◆ init()

int pipewire::pipewire_t::init ( const int stream_fd,
const uint32_t stream_node,
const uint64_t stream_object_serial,
std::shared_ptr< shared_state_t > shared_state )
inline

Initialize PipeWire core objects and optional stream negotiation.

Parameters
stream_fdStream fd.
stream_nodeStream node.
stream_object_serialStream object serial.
shared_stateShared state.
Returns
0 on success; nonzero or negative platform status on failure.

◆ is_frame_ready()

bool pipewire::pipewire_t::is_frame_ready ( ) const
inline

Check whether frame ready.

Returns
True when PipeWire has delivered a frame ready for capture.

◆ is_pacing_required()

bool pipewire::pipewire_t::is_pacing_required ( AVRational requested_framerate,
std::chrono::nanoseconds requested_delay )
inline

Check and log whether the active session will require Sunshine to perform pacing.

Parameters
requested_framerateThe framerate that we requested.
requested_delayThe delay corresponding to the requested framerate.
Returns
True when Sunshine pacing is required.

◆ set_frame_ready()

void pipewire::pipewire_t::set_frame_ready ( bool ready)
inline

Set frame ready.

Parameters
readyWhether the PipeWire frame is ready for capture.

◆ set_negotiate_maxframerate()

void pipewire::pipewire_t::set_negotiate_maxframerate ( bool negotiate_maxframerate)
inline

Set negotiate maxframerate.

Parameters
negotiate_maxframerateNegotiate maxframerate.

◆ use_pipewire_pts()

bool pipewire::pipewire_t::use_pipewire_pts ( const compositor_version_t & compositor,
const std::string & selected_display_name )
inlinestatic

Determine if Pipewire's pts metadata is suitable for client pacing based on compositor type/version whitelist.

Parameters
compositorStruct containing compositor type and version.
selected_display_nameName of display - specifically the connector type - such as DP-1, HDMI-1, etc.
Returns
True if pts metadata is suitable.

◆ use_variable_rate()

bool pipewire::pipewire_t::use_variable_rate ( const compositor_version_t & compositor)
inlinestatic

Determine if the active compositor is suited for variable rate capture based on type/version whitelist.

Parameters
compositorStruct containing the compositor type and version.
Returns
True if variable rate capture is suitable.

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