Declarations for Wayland capture. More...
#include <array>#include <bitset>#include <chrono>#include <cstdint>#include <map>#include <optional>#include <string>#include <vector>#include <linux-dmabuf-unstable-v1.h>#include <wlr-screencopy-unstable-v1.h>#include <xdg-output-unstable-v1.h>#include "graphics.h"Go to the source code of this file.
Classes | |
| class | wl::display_t |
| Wayland display connection used to dispatch capture events. More... | |
| class | wl::dmabuf_t |
| Listener state for Wayland screencopy frames backed by DMA-BUFs. More... | |
| class | wl::frame_t |
| Captured Wayland frame metadata and DMA-BUF surface state. More... | |
| struct | wl::gbm_bo_accessors_t |
| GBM buffer accessors used to export DMA-BUF plane metadata. More... | |
| struct | wl::gbm_device_accessors_t |
| Functions used to open a render node and create/destroy a GBM device on it. More... | |
| class | wl::gbm_device_t |
| Owner of a GBM device together with the render-node descriptor it was created from. More... | |
| class | wl::interface_t |
| Wayland registry state for screencopy, DMA-BUF, and output globals. More... | |
| class | wl::monitor_t |
| Wayland output metadata used to match a configured display name. More... | |
Typedefs | |
| using | wl::display_internal_t = util::safe_ptr<wl_display, wl_display_disconnect> |
| Owning pointer for a Wayland display connection. | |
Enumerations | |
| enum class | wl::screencopy_request_e { keep , copy , copy_with_damage } |
| What a capture does about its screencopy request before waiting for a frame. More... | |
Functions | |
| std::chrono::steady_clock::time_point | wl::damage_frame_time (std::optional< std::chrono::steady_clock::time_point > compositor_time, std::chrono::steady_clock::time_point now, std::chrono::nanoseconds delay) |
| Pick the time a captured frame is charged to the damage-driven budget at. | |
| std::optional< std::uint32_t > | wl::export_gbm_bo_planes (gbm_bo *bo, frame_t &frame, const gbm_bo_accessors_t &accessors) |
| Export every GBM buffer plane into a captured frame descriptor. | |
| int | wl::init () |
| Initialize Wayland registry interfaces required for capture. | |
| std::map< std::uint32_t, std::vector< std::uint64_t > > | wl::intersect_modifiers (const std::map< std::uint32_t, std::vector< std::uint64_t > > &compositor_modifiers, const std::map< std::uint32_t, std::vector< std::uint64_t > > &encoder_modifiers) |
| Intersect compositor and encoder modifiers to find common formats. | |
| std::vector< std::unique_ptr< monitor_t > > | wl::monitors (const char *display_name) |
| Refresh the monitor list reported by the display server. | |
| std::chrono::steady_clock::time_point | wl::next_damage_request (std::chrono::steady_clock::time_point next_request, std::chrono::steady_clock::time_point frame_time, std::chrono::nanoseconds delay) |
| Move the earliest time of the next damage-driven request on by one captured frame. | |
| screencopy_request_e | wl::next_screencopy_request (bool pending, bool requested_cursor, bool cursor, bool event_driven, bool have_frame) |
| Decide which screencopy request a capture waits on next. | |
| bool | wl::should_wait_for_damage_request (std::chrono::steady_clock::time_point next_request, std::chrono::steady_clock::time_point now, std::chrono::nanoseconds delay) |
| Determine whether a damage-driven request should wait for its budget. | |
| bool | wl::use_damage_capture (std::uint32_t screencopy_version, double stream_fps, std::int32_t refresh_mhz) |
| Determine whether wlroots capture should ask for frames with copy_with_damage. | |
| bool | wl::use_vram_capture (platf::mem_type_e hwdevice_type) |
| Determine whether wlroots capture should keep frames in VRAM for the requested memory type. | |
Declarations for Wayland capture.
|
strong |
| std::chrono::steady_clock::time_point wl::damage_frame_time | ( | std::optional< std::chrono::steady_clock::time_point > | compositor_time, |
| std::chrono::steady_clock::time_point | now, | ||
| std::chrono::nanoseconds | delay ) |
Pick the time a captured frame is charged to the damage-driven budget at.
The compositor's own timestamp is the better one, it does not carry the delay of getting the frame to Sunshine. The screencopy protocol does not say which clock it is on, though. A time ahead of now, or more than one interval behind it, is not from the clock the budget runs on and would leave the budget permanently due or permanently out of reach, so the frame is charged at now instead.
| compositor_time | Time the compositor gave for the frame, if any. |
| now | Time the frame was received, on Sunshine's clock. |
| delay | Frame interval of the stream. |
| std::optional< std::uint32_t > wl::export_gbm_bo_planes | ( | gbm_bo * | bo, |
| frame_t & | frame, | ||
| const gbm_bo_accessors_t & | accessors ) |
Export every GBM buffer plane into a captured frame descriptor.
| bo | GBM buffer whose DMA-BUF planes will be exported. |
| frame | Frame that takes ownership of the exported file descriptors. |
| accessors | GBM accessors used to query the buffer. |
| int wl::init | ( | ) |
Initialize Wayland registry interfaces required for capture.
| std::map< std::uint32_t, std::vector< std::uint64_t > > wl::intersect_modifiers | ( | const std::map< std::uint32_t, std::vector< std::uint64_t > > & | compositor_modifiers, |
| const std::map< std::uint32_t, std::vector< std::uint64_t > > & | encoder_modifiers ) |
Intersect compositor and encoder modifiers to find common formats.
| compositor_modifiers | Modifiers supported by the compositor for each format. |
| encoder_modifiers | Modifiers supported by the encoder for each format. |
| std::vector< std::unique_ptr< monitor_t > > wl::monitors | ( | const char * | display_name = nullptr | ) |
Refresh the monitor list reported by the display server.
| display_name | Display name. |
| std::chrono::steady_clock::time_point wl::next_damage_request | ( | std::chrono::steady_clock::time_point | next_request, |
| std::chrono::steady_clock::time_point | frame_time, | ||
| std::chrono::nanoseconds | delay ) |
Move the earliest time of the next damage-driven request on by one captured frame.
Every captured frame costs one frame interval of budget, which holds an output that changes faster than the stream to the stream's rate. A frame that arrives after the budget ran out resets it to a quarter interval before the frame's own time, so a source running at the stream's rate is asked for with room to spare.
| next_request | Earliest request time before this frame. |
| frame_time | Time the compositor presented the captured frame. |
| delay | Frame interval of the stream. |
| screencopy_request_e wl::next_screencopy_request | ( | bool | pending, |
| bool | requested_cursor, | ||
| bool | cursor, | ||
| bool | event_driven, | ||
| bool | have_frame ) |
Decide which screencopy request a capture waits on next.
A request that outlived a timeout is kept: with copy_with_damage a still picture never answers, and asking again on every timeout would pile requests up in the compositor. It is replaced when the cursor setting changed since it was made. The setting is fixed when a request is created and changing it does not damage the output, so on a still picture the old request would go on answering with the cursor as it was. The replacement is a plain copy, which brings the picture up to date at once.
The same holds when no request is out. The last frame was captured with the setting of the last request, so if the setting changed since then, the picture the stream is showing is out of date and the next request is a plain copy as well. This covers a change between two requests, and a request that could not be withdrawn and was answered with the old setting.
| pending | Whether a request is still waiting for the compositor. |
| requested_cursor | Cursor setting the last request was made with, pending or answered. |
| cursor | Cursor setting wanted now. |
| event_driven | Whether frames are requested with copy_with_damage. |
| have_frame | Whether this capture has delivered a frame yet. |
| bool wl::should_wait_for_damage_request | ( | std::chrono::steady_clock::time_point | next_request, |
| std::chrono::steady_clock::time_point | now, | ||
| std::chrono::nanoseconds | delay ) |
Determine whether a damage-driven request should wait for its budget.
| next_request | Earliest time the next frame may be asked for. |
| now | Current time. |
| delay | Frame interval of the stream. |
| bool wl::use_damage_capture | ( | std::uint32_t | screencopy_version, |
| double | stream_fps, | ||
| std::int32_t | refresh_mhz ) |
Determine whether wlroots capture should ask for frames with copy_with_damage.
With copy_with_damage the compositor answers when the output has a new picture, so capture follows the compositor's frames instead of sampling them on a clock of Sunshine's own. That needs version 2 of the screencopy protocol and an output that refreshes at least half again as fast as the stream. On an output running at the stream's own rate, the commits a paced copy forces are part of what keeps the output's clients on time.
| screencopy_version | Version of the screencopy global the compositor offered. |
| stream_fps | Frame rate requested for the stream. |
| refresh_mhz | Refresh rate of the captured output in mHz, 0 when the compositor did not say. |
| bool wl::use_vram_capture | ( | platf::mem_type_e | hwdevice_type | ) |
Determine whether wlroots capture should keep frames in VRAM for the requested memory type.
| hwdevice_type | Hardware device type requested for capture or encode. |