Definitions for wlgrab capture. More...
#include <thread>#include "cuda.h"#include "src/logging.h"#include "src/platform/common.h"#include "src/video.h"#include "vaapi.h"#include "vulkan_encode.h"#include "wayland.h"Classes | |
| struct | wl::img_t |
| Captured frame buffer shared between capture and encode stages. More... | |
| class | wl::wlr_ram_t |
| Wayland screencopy backend that copies frames into system memory. More... | |
| class | wl::wlr_t |
| Wayland screencopy capture backend shared by RAM and VRAM paths. More... | |
| class | wl::wlr_vram_t |
| Wayland screencopy backend that exports frames as GPU resources. 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::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. | |
| std::shared_ptr< display_t > | platf::wl_display (mem_type_e hwdevice_type, const std::string &display_name, const video::config_t &config) |
| Create a Wayland display capture backend. | |
| std::vector< std::string > | platf::wl_display_names () |
| Enumerate displays available through the Wayland capture backend. | |
Definitions for wlgrab capture.
| 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::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. |
| std::shared_ptr< display_t > platf::wl_display | ( | mem_type_e | hwdevice_type, |
| const std::string & | display_name, | ||
| const video::config_t & | config ) |
Create a Wayland display capture backend.
Create a Wayland capture backend for the requested memory type.
| hwdevice_type | Hardware device type requested for capture or encode. |
| display_name | Display name. |
| config | Configuration values to apply. |
| std::vector< std::string > platf::wl_display_names | ( | ) |
Enumerate displays available through the Wayland capture backend.
Enumerate capture display names reported by the Wayland compositor.