Treeland capture

protocol for capturing output contents or window contents

This protocol allows authorized application to capture output contents or window contents(useful for window streaming).


destroy()
delete this object

Unreferences the frame. This request must be called as soon as it's no longer valid.

start()
start session

Start session and keeps sending frame.

frame_done(tv_sec_hi: uint, tv_sec_lo: uint, tv_usec: uint)
Argument
Type
Description
tv_sec_hiuint
tv_sec_louint
tv_usecuint
Indicates current frame is done.

This is the ACK to the current "ready" event. The next "frame" event will be sent only when current "ready" event is acknowledged. The timestamp should be the same as the one sent in "ready" event. If the frame has the "transient" flag, all objects sent before become invalid after this event.

frame(offset_x: int, offset_y: int, width: uint, height: uint, buffer_flags: uint, flags: uint<treeland_capture_session_v1.flags>, format: uint, mod_high: uint, mod_low: uint, num_objects: uint)
Argument
Type
Description
offset_xint
crop offset x
offset_yint
crop offset y
widthuint
heightuint
buffer_flagsuint
flagsuint<treeland_capture_session_v1.flags>
formatuint
mod_highuint
mod_lowuint
num_objectsuint
supply the client with information about the frame

Main event supplying the client with information about the frame. If the capture didn't fail, this event is always emitted first before any other events. When mask is provided, x and y should be offset relative to mask surface origin. Otherwise offset_x and offset_y should always be zero.

object(index: uint, fd: fd, size: uint, offset: uint, stride: uint, plane_index: uint)
Argument
Type
Description
indexuint
fdfd
sizeuint
offsetuint
strideuint
plane_indexuint
supply the client with object fd
ready(tv_sec_hi: uint, tv_sec_lo: uint, tv_nsec: uint)
Argument
Type
Description
tv_sec_hiuint
tv_sec_louint
tv_nsecuint
indicates frame is available for reading

This event is sent as soon as the frame is presented, indicating it is available for reading. This event includes the time at which presentation happened at.

Notifies current frame is no longer valid.

If the capture failed or if the frame is no longer valid after the "frame" event has been emitted, this event will be used to inform the client to scrap the frame.

cancel_reason { temporary, permanent, resizing } 
Argument
Value
Description
temporary0
temporary error, source will produce more frames
permanent1
fatal error, source will not produce frames
resizing2
temporary error, source will produce more frames
flags { transient } 
Argument
Value
Description
transient0x1
clients should copy frame before processing


destroy()
delete this object, used or not

Destroys the context. This request can be sent at any time by the client.

copy(buffer: object<wl_buffer>)
Argument
Type
Description
bufferobject<wl_buffer>
copy capture contents

Copy capture contents to provided buffer

buffer(format: uint<wl_shm.format>, width: uint, height: uint, stride: uint)
Argument
Type
Description
formatuint<wl_shm.format>
widthuint
heightuint
strideuint
inform client to prepare buffer

Inform client to prepare buffer.

buffer_done()
all buffer formats have done

Inform client that all buffer formats supported are emitted.

Argument
Type
Description
flagsuint<treeland_capture_once_context_v1.flags>
frame flags
frame flags

Provides flags about the frame. This event is sent once before the "ready" event.

ready()
buffer is copied

Inform that buffer is ready for reading

failed()
frame copy failed

Inform that frame copy fails.

flags { y_inverted } 
Argument
Value
Description
y_inverted0x1
contents are y-inverted


destroy()
delete this object, used or not

Destroys the context. This request can be sent at any time by the client.

Argument
Type
Description
source_hintuint<treeland_capture_context_v1.source_type>
freezeuint
freeze compositing or not
with_cursoruint
whether source content contains cursor or not
maskobject<wl_surface>allow null
this mask is guaranteed to be at the top most
select source interactively

Selector is provided by compositor. Client can provide source hint to hint compositor to provide certain kinds of source.

Argument
Type
Description
framenew_id<treeland_capture_frame_v1>
capture one frame

This event can be called just once. A second call might result in a protocol error cause we just provide transient

create_session(session: new_id<treeland_capture_session_v1>)
Argument
Type
Description
sessionnew_id<treeland_capture_session_v1>
create a persistent session for capturing

Often used by a screen recorder.

Argument
Type
Description
region_xint
offset x of capture region relative to mask for capture contents
region_yint
offset y of capture region relative to mask for capture contents
region_widthuint
width of capture region
region_heightuint
height of capture region
source_typeuint<treeland_capture_context_v1.source_type>
final capture source type
notify client that source is ready

This event supplies the client some information about the capture source, including the capture region relative to mask and source type.

notify client that source selection is failed

There could a lot of reasons but the most common one is that selector is busy

source_type { output, window, region } 
Argument
Value
Description
output0x1
output source type
window0x2
window source type
region0x4
region source type
Argument
Value
Description
selector_busy1
selector is occupied by other context
user_cancel2
User cancel this context from compositor
source_destroyed3
Source has been destroyed
other4
other failure
source failure reason


destroy()
destroy the capture manager

Destroy the treeland_capture_manager_v1 object.

get_context(context: new_id<treeland_capture_context_v1>)
Argument
Type
Description
contextnew_id<treeland_capture_context_v1>
get a capture context

Compositor Support

Mutter
Mutter
47.3
KWin
KWin
6.3
Sway
Sway
1.10
COSMIC
COSMIC
0.1
Hyprland
Hyprland
0.44
niri
25.01
Weston
Weston
14
Mir
Mir
2.19
GameScope
GameScope
3.15.14
Jay
1.9.0
Labwc
Labwc
0.8.2
Wayfire
0.9.0
Treeland
Treeland
0.5.17
Louvre
Louvre
2.14.1
treeland_capture_manager_v1
x
x
x
x
x
x
x
x
x
x
x
x
1
x

SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. SPDX-License-Identifier: MIT