Documentation
¶
Overview ¶
Package pipewire is the PipeWire video producer a ScreenCast portal streams through: a node exported over PipeWire's native protocol (a client-node, as libpipewire's pw_stream exports one), which drives its own graph: a cycle runs when a captured frame is ready, stamped with the header, transform and damage metas. The protocol, the shared memory and the realtime cycle are spoken here in Go; no libpipewire.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Application is the client's application.name, the program the
// server and its tools list the stream under. Required.
Application string
// Name is the node name the consumer sees and links to, and the
// name of the stream's shared-memory buffers. Required.
Name string
Width, Height, Stride uint32
Format VideoFormat
// FPS is the most frames a second the stream sends, advertised as its
// maximum and paced. The rate is variable: a frame goes out when the
// source has one, not on a clock. A consumer may ask for less. Required.
FPS uint32
// Transform is the constant spa_meta_videotransform value (the
// output's wl_output transform; 0 for a window).
Transform uint32
Source Source
}
Config is one producer's identity and fixed stream geometry.
type DmabufPreparer ¶
type DmabufPreparer interface {
PrepareDmabuf(Dmabuf)
}
DmabufPreparer is a DmabufSource whose fills land apart from the graph (FillDmabuf false while one runs). PrepareDmabuf starts filling the buffer the next cycle's FillDmabuf gets, so a frame goes out each cycle and not every other one. It must not block.
type DmabufSource ¶
type DmabufSource interface {
Source
Modifier() fourcc.Modifier
// DmabufVideoFormat is the GPU buffers' format, which need not be
// the shared-memory one (a GPU compositor hands out 24-bit shm and
// 32-bit dmabufs).
DmabufVideoFormat() VideoFormat
AllocDmabuf() (Dmabuf, error)
FillDmabuf(Dmabuf) (damage []Rect, ok bool)
}
DmabufSource is a Source that also fills GPU buffers: the producer offers its modifier's format first and, when the consumer takes it, binds one buffer from AllocDmabuf to each PipeWire buffer for the stream's life and fills it in place (zero copy). A consumer that takes the plain format gets producer-allocated shared memory, filled through Fill.
type FrameNotifier ¶
type FrameNotifier interface {
NotifyFrames(wake func())
}
FrameNotifier is a DmabufSource whose GPU frames land on their own time. On those buffers the producer does not poll it: it calls NotifyFrames once, before any fill, and the source calls wake, from any goroutine and without blocking, whenever FillDmabuf may now produce a frame or a copy it started has ended.
type Producer ¶
type Producer struct {
// contains filtered or unexported fields
}
Producer is one running PipeWire video output stream. Its Source is called from one goroutine at a time.
func Start ¶
Start exports the stream's node and returns once the server has registered it, so a consumer can link to NodeID.
func (*Producer) Close ¶
func (p *Producer) Close()
Close stops the stream and releases everything it holds.
func (*Producer) Done ¶
func (p *Producer) Done() <-chan struct{}
Done is closed once the stream has ended: closed, or cut off by the server (Err says why).
type Rect ¶
type Rect struct{ X, Y, Width, Height int }
Rect is a damaged region in buffer pixels.
func ClampDamage ¶
ClampDamage clips rects to the frame into out; none, none left, or more than max collapse to the whole frame. It appends at most max rects to out[:0], so an out of that capacity never grows.
type Resizable ¶
Resizable is a Source whose frames change size (a window being resized): Size is the layout of the frames it has now. When that differs from the stream's, the producer offers the new size and holds frames back until the consumer has renegotiated.
type Restarter ¶
type Restarter interface {
Restart()
}
Restarter is a Source that must know when the consumer's buffers are dropped: the buffers that replace them hold nothing, so the next fill has to produce a frame even if the source has not changed.
type ServerError ¶
type ServerError struct {
// Object is the id of the object the error is about.
Object uint32
// Errno is the server's negative errno, as a positive Errno.
Errno unix.Errno
// Message is the server's description.
Message string
}
ServerError is an error the server reported on one of the connection's objects (core error event).
func (*ServerError) Error ¶
func (e *ServerError) Error() string
type Source ¶
Source fills one frame: Fill copies stride-byte rows into dst and reports what changed (nil or empty is the whole frame); ok false skips this cycle (nothing new, or the capture failed).
type VideoFormat ¶
type VideoFormat uint32
VideoFormat is an spa_video_format.
const ( VideoRGBx VideoFormat = 7 VideoBGRx VideoFormat = 8 VideoRGBA VideoFormat = 11 VideoBGRA VideoFormat = 12 // The packed 24-bit formats GPU renderers offer over shm. VideoRGB VideoFormat = 15 VideoBGR VideoFormat = 16 )
The packed 8-bit formats compositors hand out.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package pwtest starts a private PipeWire daemon for tests, so producers and consumers link without touching the user's session, and runs libpipewire consumers against it as the reference a producer is checked by.
|
Package pwtest starts a private PipeWire daemon for tests, so producers and consumers link without touching the user's session, and runs libpipewire consumers against it as the reference a producer is checked by. |