Hermes 0.7.0
Linux game streaming host
Loading...
Searching...
No Matches
wlgrab.cpp
Go to the documentation of this file.
1
5// standard includes
6#include <algorithm>
7#include <cerrno>
8#include <cstdlib>
9#include <cstring>
10#include <thread>
11
12// local includes
13#include "cuda.h"
14#include "pyrowave.h"
15#include "src/logging.h"
16#include "src/platform/common.h"
17#include "src/video.h"
18#include "vaapi.h"
19#include "virtual_display.h"
20#include "wayland.h"
21
22using namespace std::literals;
23
24namespace wl {
33 static std::vector<output_rect_t> output_rects(const std::vector<std::unique_ptr<monitor_t>> &monitors) {
34 std::vector<output_rect_t> rects;
35 rects.reserve(monitors.size());
36 for (const auto &monitor : monitors) {
37 const auto &viewport = monitor->viewport;
38 const int width = monitor->logical_width > 0 ? monitor->logical_width : viewport.width;
39 const int height = monitor->logical_height > 0 ? monitor->logical_height : viewport.height;
40 rects.push_back({viewport.offset_x, viewport.offset_y, width, height});
41 }
42 return rects;
43 }
44
45 struct img_t: public platf::img_t {
46 ~img_t() override {
47 delete[] data;
48 data = nullptr;
49 }
50 };
51
52 class wlr_t: public platf::display_t {
53 public:
54 int init(platf::mem_type_e hwdevice_type, const std::string &display_name, const ::video::config_t &config) {
55 delay = std::chrono::nanoseconds {1s} / config.framerate;
56 mem_type = hwdevice_type;
57
58 if (display.init()) {
59 return -1;
60 }
61
62 interface.listen(display.registry());
63
64 display.roundtrip();
65
66 if (!interface[wl::interface_t::XDG_OUTPUT]) {
67 BOOST_LOG(error) << "Missing Wayland wire for xdg_output"sv;
68 return -1;
69 }
70
71 // Two capture protocols, and which one a session speaks is the whole
72 // difference between a stream and nothing at all. wlroots compositors
73 // speak wlr-screencopy; KWin and GNOME speak only ext-image-copy-capture,
74 // which is why a KDE or GNOME desktop was not capturable here before.
75 //
76 // Where both exist, screencopy stays the default: it is the path every
77 // working deployment is on today, and nothing is gained by moving them.
78 // ext-image-copy-capture fills the gap rather than replacing anything.
79 // HERMES_WAYLAND_CAPTURE forces one for testing the other on a session
80 // that offers both.
81 const bool have_screencopy = interface[wl::interface_t::WLR_EXPORT_DMABUF];
82 const bool have_icc = interface[wl::interface_t::IMAGE_COPY_CAPTURE] &&
85
86 const char *forced = std::getenv("HERMES_WAYLAND_CAPTURE");
87 if (forced && !std::strcmp(forced, "icc")) {
88 use_icc = have_icc;
89 if (!use_icc) {
90 BOOST_LOG(error) << "HERMES_WAYLAND_CAPTURE=icc, but this compositor does not offer "sv
91 << "ext-image-copy-capture with linux-dmabuf."sv;
92 return -1;
93 }
94 } else if (forced && !std::strcmp(forced, "screencopy")) {
95 use_icc = false;
96 if (!have_screencopy) {
97 BOOST_LOG(error) << "HERMES_WAYLAND_CAPTURE=screencopy, but this compositor does not offer "sv
98 << "wlr-screencopy."sv;
99 return -1;
100 }
101 } else {
102 use_icc = !have_screencopy && have_icc;
103 }
104
105 if (!have_screencopy && !have_icc) {
106 BOOST_LOG(error) << "This compositor offers neither wlr-screencopy nor ext-image-copy-capture; "sv
107 << "there is no way to capture it."sv;
108 return -1;
109 }
110
111 BOOST_LOG(info) << "Wayland capture protocol: "sv
112 << (use_icc ? "ext-image-copy-capture"sv : "wlr-screencopy"sv);
113
114 if (interface.monitors.empty()) {
115 BOOST_LOG(error) << "Wayland compositor did not advertise any enabled outputs."sv;
116 return -1;
117 }
118
119 // A monitor's name and description arrive on xdg_output, not on the
120 // registry, so every monitor has to be listened to before any of them can
121 // be matched by name. Doing this per selected monitor - as this used to -
122 // meant the match below always ran against empty names: the only path
123 // that reached it selected by numeric index, where the name is never
124 // read. Listening is not repeatable either, since it also adds the
125 // wl_output listener, and wayland-client aborts on a second one.
126 for (auto &candidate : interface.monitors) {
127 candidate->listen(interface.output_manager);
128 }
129 display.roundtrip();
130
131 // Capture buffers must be allocated on the GPU the compositor renders
132 // with; ask it which one that is before the first frame is requested.
133 // This performs a roundtrip, so it must not run before the listen()
134 // loop above: a roundtrip while the initial wl_output events are still
135 // unread and unlistened discards them, and the monitor size stays 0x0.
136 // An ICC session names its own device (dmabuf_device), which is the more
137 // precise answer, so only screencopy asks the default feedback.
138 if (!use_icc) {
139 dmabuf.set_render_node(wl::compositor_render_node(display, interface.dmabuf_interface));
140 }
141
142 auto monitor = interface.monitors[0].get();
143
144 if (!display_name.empty() && display_name.rfind("VIRTUAL-", 0) != 0) {
145 // Not a virtual display, parse as numeric index
146 auto streamedMonitor = util::from_view(display_name);
147
148 if (streamedMonitor >= 0 && streamedMonitor < interface.monitors.size()) {
149 monitor = interface.monitors[streamedMonitor].get();
150 }
151 } else if (display_name.rfind("VIRTUAL-", 0) == 0 || VDISPLAY::isHermesKmsDisplay(display_name)) {
152 // A Hyprland headless output is named by the compositor, not by a DRM
153 // connector, so it resolves first and by a different route - but from
154 // here on it is matched, selected and captured like any other output.
155 auto connector = VDISPLAY::getHyprlandOutputName(display_name);
156 const char *backend_label = "Hyprland headless";
157 if (connector.empty()) {
158 connector = VDISPLAY::getHermesKmsConnectorName(display_name);
159 backend_label = "Hermes-KMS";
160 }
161 if (connector.empty()) {
162 connector = VDISPLAY::getEvdiConnectorName(display_name);
163 backend_label = "EVDI";
164 }
165 const auto monitor_it = std::find_if(interface.monitors.begin(), interface.monitors.end(), [&](const auto &candidate) {
166 return candidate->name == connector || candidate->description.find(connector) != std::string::npos;
167 });
168 if (connector.empty() || monitor_it == interface.monitors.end()) {
169 BOOST_LOG(error) << "Wayland "sv << backend_label << " output " << display_name
170 << " is not enabled by the compositor; refusing to capture a physical monitor."sv;
171 return -1;
172 }
173 monitor = monitor_it->get();
174 BOOST_LOG(info) << "Selected Wayland "sv << backend_label << " output " << connector;
175 }
176
177 output = monitor->output;
178
179 offset_x = monitor->viewport.offset_x;
180 offset_y = monitor->viewport.offset_y;
181 width = monitor->viewport.width;
182 height = monitor->viewport.height;
183
184 // The compositor spreads an absolute input device across the logical
185 // bounding box of every output, origin included. The box comes from
186 // this connection's monitor list rather than from a snapshot taken when
187 // displays were enumerated, since the layout may have changed since.
188 // Both the offset within it and its size are then expressed in this
189 // output's own capture pixels, which is how platf::display_t carries
190 // them on every capture path.
191 const auto envelope = desktop_envelope(output_rects(interface.monitors));
192 const output_rect_t streamed {offset_x, offset_y, monitor->logical_width, monitor->logical_height};
193 const auto geometry = input_geometry(envelope, streamed, width, height);
194 offset_x = geometry.offset_x;
195 offset_y = geometry.offset_y;
196 env_width = geometry.env_width;
197 env_height = geometry.env_height;
198
199 BOOST_LOG(info) << "Selected monitor ["sv << monitor->description << "] for streaming"sv;
200 BOOST_LOG(debug) << "Resolution: "sv << width << 'x' << height;
201 BOOST_LOG(info) << "Desktop envelope "sv << envelope.width << 'x' << envelope.height << " at "sv << envelope.x << ',' << envelope.y
202 << " (logical), streamed output "sv << streamed.width << 'x' << streamed.height << " at "sv << streamed.x << ',' << streamed.y
203 << "; in its "sv << width << 'x' << height << " pixels: envelope "sv << env_width << 'x' << env_height
204 << ", offset "sv << offset_x << ',' << offset_y;
205
206 return 0;
207 }
208
209 int dummy_img(platf::img_t *img) override {
210 return 0;
211 }
212
213 inline platf::capture_e snapshot(const pull_free_image_cb_t &pull_free_image_cb, std::shared_ptr<platf::img_t> &img_out, std::chrono::milliseconds timeout, bool cursor) {
214 auto to = std::chrono::steady_clock::now() + timeout;
215
216 // Dispatch events until we get a new frame or the timeout expires.
217 //
218 // The two protocols are asked for a frame differently. Screencopy is asked
219 // once per frame and negotiates the buffer each time. An ICC session
220 // negotiates once and then hands out frames, so the session is opened on
221 // the first snapshot and reused; icc_capture() does nothing until the
222 // compositor has finished sending the constraints, which is why it is also
223 // called from inside the dispatch loop - that is where "done" arrives.
224 if (use_icc) {
225 if (!dmabuf.icc_active() &&
226 !dmabuf.icc_listen(
227 interface.image_copy_capture_manager,
228 interface.image_capture_source_manager,
229 interface.dmabuf_interface,
230 output,
231 cursor
232 )) {
234 }
235 // Arming can fail outright - a cursor-mode change, or a session that
236 // will not create a frame - and the loop below dispatches before it
237 // looks at the status, so an idle compositor would turn that reinit
238 // into a timeout and lose it.
239 dmabuf.icc_capture(cursor);
240 if (dmabuf.status == dmabuf_t::REINIT) {
242 }
243 } else {
244 dmabuf.listen(interface.screencopy_manager, interface.dmabuf_interface, output, cursor);
245 }
246
247 do {
248 auto remaining_time_ms = std::chrono::duration_cast<std::chrono::milliseconds>(to - std::chrono::steady_clock::now());
249 if (remaining_time_ms.count() < 0 || !display.dispatch(remaining_time_ms)) {
250 // A dead connection never delivers a frame, so it would time out here
251 // on every call forever. A protocol error is a bug on our side that a
252 // reinit would only repeat; anything else (a compositor restart) is
253 // worth reconnecting for.
254 if (auto err = display.connection_error()) {
255 return err == EPROTO ? platf::capture_e::error : platf::capture_e::reinit;
256 }
258 }
259 // Only while still waiting: icc_capture() arms a frame whenever the
260 // session is idle, so calling it after the status has already become
261 // READY throws the finished frame away and asks for another, and the
262 // loop never ends. REINIT is guarded for the same reason - the caller
263 // below decides what a failed session means, not the next iteration.
264 if (use_icc && dmabuf.status == dmabuf_t::WAITING) {
265 dmabuf.icc_capture(cursor);
266 }
267 } while (dmabuf.status == dmabuf_t::WAITING);
268
269 auto current_frame = dmabuf.current_frame;
270
271 if (
272 dmabuf.status == dmabuf_t::REINIT ||
273 current_frame->sd.width != width ||
274 current_frame->sd.height != height
275 ) {
276 // Reinit rebuilds this display and tries the same path again, which is
277 // right for a compositor that is still settling and wrong for a machine
278 // whose capture path cannot work at all. In the second case the retries
279 // never end, and because audio and input do not run through capture,
280 // what the client gets is an interactive black screen - a failure with
281 // no symptom to report. Once the failures have run long enough to rule
282 // out bad luck, end the capture with the reason instead.
284 BOOST_LOG(error) << "Wayland capture has failed on every frame and is being stopped. "sv
285 << "Streaming would have continued as a black screen. See the errors "sv
286 << "above; on a machine with more than one GPU, set adapter_name to the "sv
287 << "render node the compositor renders on."sv;
289 }
291 }
292
294 }
295
296 platf::mem_type_e mem_type;
297
298 std::chrono::nanoseconds delay;
299
300 wl::display_t display;
301 interface_t interface;
302 dmabuf_t dmabuf;
303
304 wl_output *output;
305 bool use_icc {false};
306 };
307
308 class wlr_ram_t: public wlr_t {
309 public:
310 platf::capture_e capture(const push_captured_image_cb_t &push_captured_image_cb, const pull_free_image_cb_t &pull_free_image_cb, bool *cursor) override {
311 auto next_frame = std::chrono::steady_clock::now();
312
313 sleep_overshoot_logger.reset();
314
315 while (true) {
316 auto now = std::chrono::steady_clock::now();
317
318 if (next_frame > now) {
319 std::this_thread::sleep_for(next_frame - now);
320 sleep_overshoot_logger.first_point(next_frame);
321 sleep_overshoot_logger.second_point_now_and_log();
322 }
323
324 next_frame += delay;
325 if (next_frame < now) { // some major slowdown happened; we couldn't keep up
326 next_frame = now + delay;
327 }
328
329 std::shared_ptr<platf::img_t> img_out;
330 auto status = snapshot(pull_free_image_cb, img_out, 1000ms, *cursor);
331 switch (status) {
335 return status;
337 if (!push_captured_image_cb(std::move(img_out), false)) {
339 }
340 break;
342 if (!push_captured_image_cb(std::move(img_out), true)) {
344 }
345 break;
346 default:
347 BOOST_LOG(error) << "Unrecognized capture status ["sv << (int) status << ']';
348 return status;
349 }
350 }
351
353 }
354
355 platf::capture_e snapshot(const pull_free_image_cb_t &pull_free_image_cb, std::shared_ptr<platf::img_t> &img_out, std::chrono::milliseconds timeout, bool cursor) {
356 auto status = wlr_t::snapshot(pull_free_image_cb, img_out, timeout, cursor);
357 if (status != platf::capture_e::ok) {
358 return status;
359 }
360 auto frame_timestamp = std::chrono::steady_clock::now();
361
362 auto current_frame = dmabuf.current_frame;
363
364 auto rgb_opt = egl::import_source(egl_display.get(), current_frame->sd);
365
366 if (!rgb_opt) {
368 }
369
370 if (!pull_free_image_cb(img_out)) {
371 return platf::capture_e::interrupted;
372 }
373
374 gl::ctx.BindTexture(GL_TEXTURE_2D, (*rgb_opt)->tex[0]);
375
376 // Don't remove these lines, see https://github.com/LizardByte/Sunshine/issues/453
377 int w, h;
378 gl::ctx.GetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w);
379 gl::ctx.GetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h);
380 BOOST_LOG(debug) << "width and height: w "sv << w << " h "sv << h;
381
382 gl::ctx.GetTextureSubImage((*rgb_opt)->tex[0], 0, 0, 0, 0, width, height, 1, GL_BGRA, GL_UNSIGNED_BYTE, img_out->height * img_out->row_pitch, img_out->data);
383 gl::ctx.BindTexture(GL_TEXTURE_2D, 0);
384 img_out->frame_timestamp = frame_timestamp;
385
386 return platf::capture_e::ok;
387 }
388
389 int init(platf::mem_type_e hwdevice_type, const std::string &display_name, const ::video::config_t &config) {
390 if (wlr_t::init(hwdevice_type, display_name, config)) {
391 return -1;
392 }
393
394 egl_display = egl::make_display(display.get());
395 if (!egl_display) {
396 return -1;
397 }
398
399 auto ctx_opt = egl::make_ctx(egl_display.get());
400 if (!ctx_opt) {
401 return -1;
402 }
403
404 ctx = std::move(*ctx_opt);
405
406 return 0;
407 }
408
409#ifdef HAVE_PYROWAVE
410 std::unique_ptr<platf::avcodec_encode_device_t> make_pyrowave_encode_device() override {
411 return pyrowave::make_ram_encode_device(width, height);
412 }
413#endif
414
415 std::unique_ptr<platf::avcodec_encode_device_t> make_avcodec_encode_device(platf::pix_fmt_e pix_fmt) override {
416#ifdef HERMES_BUILD_VAAPI
417 if (mem_type == platf::mem_type_e::vaapi) {
418 return va::make_avcodec_encode_device(width, height, false);
419 }
420#endif
421
422#ifdef HERMES_BUILD_CUDA
423 if (mem_type == platf::mem_type_e::cuda) {
424 return cuda::make_avcodec_encode_device(width, height, false);
425 }
426#endif
427
428 return std::make_unique<platf::avcodec_encode_device_t>();
429 }
430
431 std::shared_ptr<platf::img_t> alloc_img() override {
432 auto img = std::make_shared<img_t>();
433 img->width = width;
434 img->height = height;
435 img->pixel_pitch = 4;
436 img->row_pitch = img->pixel_pitch * width;
437 img->data = new std::uint8_t[height * img->row_pitch];
438
439 return img;
440 }
441
442 egl::display_t egl_display;
443 egl::ctx_t ctx;
444 };
445
446 class wlr_vram_t: public wlr_t {
447 public:
448 platf::capture_e capture(const push_captured_image_cb_t &push_captured_image_cb, const pull_free_image_cb_t &pull_free_image_cb, bool *cursor) override {
449 auto next_frame = std::chrono::steady_clock::now();
450
451 sleep_overshoot_logger.reset();
452
453 while (true) {
454 auto now = std::chrono::steady_clock::now();
455
456 if (next_frame > now) {
457 std::this_thread::sleep_for(next_frame - now);
458 sleep_overshoot_logger.first_point(next_frame);
459 sleep_overshoot_logger.second_point_now_and_log();
460 }
461
462 next_frame += delay;
463 if (next_frame < now) { // some major slowdown happened; we couldn't keep up
464 next_frame = now + delay;
465 }
466
467 std::shared_ptr<platf::img_t> img_out;
468 auto status = snapshot(pull_free_image_cb, img_out, 1000ms, *cursor);
469 switch (status) {
473 return status;
475 if (!push_captured_image_cb(std::move(img_out), false)) {
477 }
478 break;
480 if (!push_captured_image_cb(std::move(img_out), true)) {
482 }
483 break;
484 default:
485 BOOST_LOG(error) << "Unrecognized capture status ["sv << (int) status << ']';
486 return status;
487 }
488 }
489
491 }
492
493 platf::capture_e snapshot(const pull_free_image_cb_t &pull_free_image_cb, std::shared_ptr<platf::img_t> &img_out, std::chrono::milliseconds timeout, bool cursor) {
494 auto status = wlr_t::snapshot(pull_free_image_cb, img_out, timeout, cursor);
495 if (status != platf::capture_e::ok) {
496 return status;
497 }
498 auto frame_timestamp = std::chrono::steady_clock::now();
499
500 if (!pull_free_image_cb(img_out)) {
502 }
503 auto img = (egl::img_descriptor_t *) img_out.get();
504 img->reset();
505
506 auto current_frame = dmabuf.current_frame;
507
508 ++sequence;
509 img->sequence = sequence;
510
511 img->sd = current_frame->sd;
512 img->frame_timestamp = frame_timestamp;
513
514 // Prevent dmabuf from closing the file descriptors.
515 std::fill_n(current_frame->sd.fds, 4, -1);
516
517 return platf::capture_e::ok;
518 }
519
520 std::shared_ptr<platf::img_t> alloc_img() override {
521 auto img = std::make_shared<egl::img_descriptor_t>();
522
523 img->width = width;
524 img->height = height;
525 img->sequence = 0;
526 img->serial = std::numeric_limits<decltype(img->serial)>::max();
527 img->data = nullptr;
528
529 // File descriptors aren't open
530 std::fill_n(img->sd.fds, 4, -1);
531
532 return img;
533 }
534
535#ifdef HAVE_PYROWAVE
536 std::unique_ptr<platf::avcodec_encode_device_t> make_pyrowave_encode_device() override {
537 return pyrowave::make_gpu_encode_device(width, height, 0, 0);
538 }
539#endif
540
541 std::unique_ptr<platf::avcodec_encode_device_t> make_avcodec_encode_device(platf::pix_fmt_e pix_fmt) override {
542#ifdef HERMES_BUILD_VAAPI
543 if (mem_type == platf::mem_type_e::vaapi) {
544 return va::make_avcodec_encode_device(width, height, 0, 0, true);
545 }
546#endif
547
548#ifdef HERMES_BUILD_CUDA
549 if (mem_type == platf::mem_type_e::cuda) {
550 return cuda::make_avcodec_gl_encode_device(width, height, 0, 0);
551 }
552#endif
553
554 return std::make_unique<platf::avcodec_encode_device_t>();
555 }
556
557 int dummy_img(platf::img_t *img) override {
558 // Empty images are recognized as dummies by the zero sequence number
559 return 0;
560 }
561
562 std::uint64_t sequence {};
563 };
564
565} // namespace wl
566
567namespace platf {
568 std::shared_ptr<display_t> wl_display(mem_type_e hwdevice_type, const std::string &display_name, const video::config_t &config) {
569 if (hwdevice_type != platf::mem_type_e::system && hwdevice_type != platf::mem_type_e::vaapi && hwdevice_type != platf::mem_type_e::cuda) {
570 BOOST_LOG(error) << "Could not initialize display with the given hw device type."sv;
571 return nullptr;
572 }
573
574 if (hwdevice_type == platf::mem_type_e::vaapi || hwdevice_type == platf::mem_type_e::cuda) {
575 auto wlr = std::make_shared<wl::wlr_vram_t>();
576 if (wlr->init(hwdevice_type, display_name, config)) {
577 return nullptr;
578 }
579
580 return wlr;
581 }
582
583 auto wlr = std::make_shared<wl::wlr_ram_t>();
584 if (wlr->init(hwdevice_type, display_name, config)) {
585 return nullptr;
586 }
587
588 return wlr;
589 }
590
591 std::vector<std::string> wl_display_names() {
592 std::vector<std::string> display_names;
593
594 wl::display_t display;
595 if (display.init()) {
596 return {};
597 }
598
599 wl::interface_t interface;
600 interface.listen(display.registry());
601
602 display.roundtrip();
603
604 if (!interface[wl::interface_t::XDG_OUTPUT]) {
605 BOOST_LOG(warning) << "Missing Wayland wire for xdg_output"sv;
606 return {};
607 }
608
609 if (!interface[wl::interface_t::WLR_EXPORT_DMABUF]) {
610 BOOST_LOG(warning) << "Missing Wayland wire for wlr-export-dmabuf"sv;
611 return {};
612 }
613
614 for (auto &monitor : interface.monitors) {
615 monitor->listen(interface.output_manager);
616 }
617
618 display.roundtrip();
619
620 BOOST_LOG(info) << "-------- Start of Wayland monitor list --------"sv;
621
622 for (int x = 0; x < interface.monitors.size(); ++x) {
623 auto monitor = interface.monitors[x].get();
624
625 BOOST_LOG(info) << "Monitor " << x << " is "sv << monitor->name << ": "sv << monitor->description;
626
627 display_names.emplace_back(std::to_string(x));
628 }
629
630 const auto envelope = wl::desktop_envelope(wl::output_rects(interface.monitors));
631 BOOST_LOG(debug) << "Desktop envelope: "sv << envelope.width << 'x' << envelope.height << " at "sv << envelope.x << ',' << envelope.y << " (logical)"sv;
632
633 BOOST_LOG(info) << "--------- End of Wayland monitor list ---------"sv;
634
635 return display_names;
636 }
637
638} // namespace platf
std::function< bool(std::shared_ptr< img_t > &&img, bool frame_captured)> push_captured_image_cb_t
Callback for when a new image is ready. When display has a new image ready or a timeout occurs,...
Definition common.h:452
std::function< bool(std::shared_ptr< img_t > &img_out)> pull_free_image_cb_t
Get free image from pool. Calls must be synchronized. Blocks until there is free image in the pool or...
Definition common.h:461
virtual std::unique_ptr< avcodec_encode_device_t > make_pyrowave_encode_device()
Make a device that converts captured frames into PyroWave's GPU planes.
Definition common.h:500
@ WAITING
Waiting for a frame.
Definition wayland.h:52
@ REINIT
Reinitialize the frame.
Definition wayland.h:54
@ IMAGE_COPY_CAPTURE
ext-image-copy-capture manager
Definition wayland.h:225
@ IMAGE_CAPTURE_SOURCE
ext-image-capture-source manager, names an output as a source
Definition wayland.h:226
@ WLR_EXPORT_DMABUF
screencopy manager
Definition wayland.h:223
@ LINUX_DMABUF
linux-dmabuf protocol
Definition wayland.h:224
@ XDG_OUTPUT
xdg-output
Definition wayland.h:222
platf::capture_e capture(const push_captured_image_cb_t &push_captured_image_cb, const pull_free_image_cb_t &pull_free_image_cb, bool *cursor) override
Capture a frame.
Definition wlgrab.cpp:310
platf::capture_e capture(const push_captured_image_cb_t &push_captured_image_cb, const pull_free_image_cb_t &pull_free_image_cb, bool *cursor) override
Capture a frame.
Definition wlgrab.cpp:448
Declarations for common platform specific utilities.
mem_type_e
Definition common.h:211
std::shared_ptr< display_t > display(mem_type_e hwdevice_type, const std::string &display_name, const video::config_t &config)
Get the display_t instance for the given hwdevice_type. If display_name is empty, use the first monit...
Definition misc.cpp:1658
capture_e
Definition common.h:435
@ ok
Success.
Definition common.h:436
@ timeout
Timeout.
Definition common.h:438
@ reinit
Need to reinitialize.
Definition common.h:437
@ error
Error.
Definition common.h:440
@ interrupted
Capture was interrupted.
Definition common.h:439
std::unique_ptr< platf::avcodec_encode_device_t > make_avcodec_gl_encode_device(int width, int height, int offset_x, int offset_y)
Create a GL->CUDA encoding device for consuming captured dmabufs.
Definition cuda.cpp:612
Definitions for CUDA implementation.
Declarations for logging related functions.
Definition wayland.cpp:53
bool dmabuf_capture_exhausted()
Whether the dmabuf capture path has failed too often to be retried.
Definition wayland.cpp:708
output_rect_t desktop_envelope(const std::vector< output_rect_t > &outputs)
The desktop envelope: the bounding box of every output in logical coordinates, origin included....
Definition wayland.cpp:67
input_geometry_t input_geometry(const output_rect_t &envelope, const output_rect_t &output, int mode_width, int mode_height)
Express an output's offset within the envelope, and the envelope, in that output's own capture pixels...
Definition wayland.cpp:87
std::string compositor_render_node(display_t &display, zwp_linux_dmabuf_v1 *dmabuf_interface)
Ask the compositor which GPU it renders on.
Definition wayland.cpp:820
GPU conversion for the experimental PyroWave codec.
Declarations for VA-API hardware accelerated capture.
Declarations for video.
std::string getEvdiConnectorName(const std::string &displayName)
std::string getHermesKmsConnectorName(const std::string &displayName)
bool isHermesKmsDisplay(const std::string &displayName)
std::string getHyprlandOutputName(const std::string &displayName)
The Hyprland output name backing a virtual display, or empty.
Virtual display declarations for Linux.
Declarations for Wayland capture.