screencast_messages.go RawHistoryFolder
1package ports
2
3import "time"
4
5// The cast messages are concrete structs, not sealed interfaces, so a send
6// on a channel never boxes them (zero allocation per frame).
7
8// CastCommandKind selects the CastCommand fields in use.
9type CastCommandKind uint8
10
11const (
12 // CastOpen starts cast ID on Output or Window.
13 CastOpen CastCommandKind = iota + 1
14 // CastFrame asks for one frame into buffer Buf.
15 CastFrame
16 // CastClose ends cast ID. Wayland sends no CastStopped for it; a frame
17 // still in flight is answered with its CastFrameDone as usual.
18 CastClose
19)
20
21// CastCommand carries screencast → wayland: open or close a cast, or request
22// one frame into a PipeWire buffer.
23type CastCommand struct {
24 Kind CastCommandKind
25 ID uint64
26 // CastOpen: the target. A window cast sets Window and leaves Output empty.
27 Output string
28 Window WindowID
29 Cursor bool
30 // CastFrame: Buf is the buffer slot. Data is the buffer's mapping,
31 // borrowed until the CastFrameDone of Buf: the sender neither reuses nor
32 // unmaps it before then.
33 Buf int
34 Data []byte
35 Stride int
36 Width, Height int
37 Format uint32 // wl_shm format
38}
39
40// CastEventKind selects the CastEvent fields in use.
41type CastEventKind uint8
42
43const (
44 // CastSize: the target is now Width x Height; the stream must renegotiate.
45 CastSize CastEventKind = iota + 1
46 // CastDamage: the target changed and a frame may be requested. Time is
47 // the flip time.
48 CastDamage
49 // CastFrameDone: the frame into Buf finished. Err is nil when Data holds
50 // a complete image; Time is the capture time.
51 CastFrameDone
52 // CastStopped: the cast ended (Reason, Err); no event follows.
53 CastStopped
54)
55
56// CastEvent carries wayland → screencast through CastSink.Push.
57type CastEvent struct {
58 Kind CastEventKind
59 ID uint64
60 Width, Height int
61 Buf int
62 Err error
63 Time time.Time
64 Reason CaptureReason
65}
66
67// CastOutput is one output of the inventory.
68type CastOutput struct {
69 Info OutputInfo
70 Modes []OutputMode
71 Current int // index into Modes, -1 when none
72 // X, Y, Width, Height are the logical placement.
73 X, Y, Width, Height int
74 Scale float64
75 Transform BufferTransform
76}
77
78// CastWindow is one window of the inventory.
79type CastWindow struct {
80 ID WindowID
81 AppID, Title string
82}
83
84// CastInventory is the set a cast target is picked from.
85type CastInventory struct {
86 Outputs []CastOutput
87 Windows []CastWindow
88 Focused string // name of the focused output
89}