detached 4c97002

video.go RawHistoryFolder

1package pipewire
2
3import (
4	"github.com/bnema/purego-pipewire/internal/core"
5	"github.com/bnema/purego-pipewire/spa"
6)
7
8// VideoFormat is a SPA raw video format (BGRx=8, BGRA=12).
9type VideoFormat = spa.VideoFormat
10
11// Supported video formats. They map to wl_shm XRGB8888 (BGRx) and ARGB8888
12// (BGRA).
13const (
14	VideoFormatBGRx = spa.VideoFormatBGRx
15	VideoFormatBGRA = spa.VideoFormatBGRA
16)
17
18// pw_stream_state values reported to VideoHandler.StateChanged.
19const (
20	StreamStateError       int32 = -1
21	StreamStateUnconnected int32 = 0
22	StreamStateConnecting  int32 = 1
23	StreamStatePaused      int32 = 2
24	StreamStateStreaming   int32 = 3
25)
26
27// Errors returned by NewVideoSource and VideoSource, for errors.Is.
28var (
29	ErrVideoConfig       = core.ErrVideoConfig
30	ErrVideoTableFull    = core.ErrVideoTableFull
31	ErrVideoStreamCreate = core.ErrVideoStreamCreate
32	ErrVideoConnect      = core.ErrVideoConnect
33	ErrVideoResize       = core.ErrVideoResize
34	ErrVideoBorrowed     = core.ErrVideoBorrowed
35)
36
37// VideoConfig configures a VideoSource: the node name, the initial size, the
38// maximum frame rate (60 when zero) and the accepted formats (BGRx when
39// empty, else BGRx and/or BGRA; the first is preferred).
40type VideoConfig = core.VideoConfig
41
42// VideoHandler receives VideoSource events. Every method runs on the loop
43// thread, inside Loop.Iterate (or, for the first events, inside the call that
44// triggered them). Implementations must not block and must not allocate.
45type VideoHandler interface {
46	// StateChanged reports a stream state change; see the StreamState
47	// constants. nodeID is the PipeWire node id once known (0 before). err
48	// carries the message when state is StreamStateError.
49	StateChanged(state int32, nodeID uint32, err string)
50	// FormatChanged reports the negotiated format and its row stride.
51	FormatChanged(f VideoFormat, w, h, stride int)
52	// BuffersChanged is called after a buffer was added or removed;
53	// Dequeue may now return a buffer.
54	BuffersChanged()
55}
56
57// VideoBuffer is a buffer handed out by VideoSource.Dequeue. Data aliases a
58// mapped memfd owned by the source; it is valid until the buffer is given back
59// with Queue or Release. The value is owned by the source: do not copy it or
60// keep it after giving it back.
61type VideoBuffer = core.VideoBuffer
62
63// VideoSource is a PipeWire Video/Source node that drives the graph and
64// exposes shared-memory (memfd) buffers. All methods run on the loop thread.
65//
66// Produce a frame with Dequeue, write Data, Queue, then Trigger — in that
67// order: the buffer must be queued before Trigger. A steady-state cycle
68// performs no heap allocation.
69//
70//	b := src.Dequeue()           // nil: no buffer is free
71//	// ... fill b.Data (b.Stride bytes per row) ...
72//	src.Queue(b, seq, pts, false)
73//	src.Trigger()
74//
75// Buffers PipeWire removes (renegotiation, Resize, Destroy, consumer
76// disconnect) stay mapped while borrowed and are unmapped when given back with
77// Queue or Release. Resize fails with ErrVideoBorrowed while a buffer is
78// borrowed; Destroy is best called when none is. DMA-BUF is not supported.
79type VideoSource = core.VideoSource

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 8

↑↓ moveenter openesc close