Sunshine master
Self-hosted game stream host for Moonlight.
pipewire::pipewire_t Class Reference

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

Public Member Functions

int ensure_stream (const platf::mem_type_e mem_type, const uint32_t width, const uint32_t height, const uint32_t refresh_rate, 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.
 
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.
 

Detailed Description

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

Member Function Documentation

◆ close_img_fds()

static 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 uint32_t refresh_rate,
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.
refresh_rateRefresh rate.
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()

static 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()

static 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.

◆ 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.

◆ 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.

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