Hermes 0.7.0
Linux game streaming host
Loading...
Searching...
No Matches
common.h
Go to the documentation of this file.
1
5#pragma once
6
7// standard includes
8#include <bitset>
9#include <filesystem>
10#include <functional>
11#include <mutex>
12#include <string>
13
14// lib includes
15#include <boost/core/noncopyable.hpp>
16#include <boost/asio/ip/address.hpp>
17#include <boost/process/v1/child.hpp>
18#include <boost/process/v1/group.hpp>
19#include <boost/process/v1/environment.hpp>
20
21// local includes
22#include "src/config.h"
23#include "src/logging.h"
24#include "src/thread_safe.h"
25#include "src/utility.h"
27
28extern "C" {
29#include <moonlight-common-c/src/Limelight.h>
30}
31
32using namespace std::literals;
33
34struct sockaddr;
35struct AVFrame;
36struct AVBufferRef;
37struct AVHWFramesContext;
38struct AVCodecContext;
39struct AVDictionary;
40
41namespace video {
42 struct config_t;
43} // namespace video
44
45namespace nvenc {
46 class nvenc_base;
47}
48
49namespace platf {
50 // Limited by bits in activeGamepadMask
51 constexpr auto MAX_GAMEPADS = 16;
52
54 inline std::string session_mic_source(std::string_view sink) {
55 return "source" + std::string {sink.substr(sink.find('-'))};
56 }
57
58 constexpr std::uint32_t DPAD_UP = 0x0001;
59 constexpr std::uint32_t DPAD_DOWN = 0x0002;
60 constexpr std::uint32_t DPAD_LEFT = 0x0004;
61 constexpr std::uint32_t DPAD_RIGHT = 0x0008;
62 constexpr std::uint32_t START = 0x0010;
63 constexpr std::uint32_t BACK = 0x0020;
64 constexpr std::uint32_t LEFT_STICK = 0x0040;
65 constexpr std::uint32_t RIGHT_STICK = 0x0080;
66 constexpr std::uint32_t LEFT_BUTTON = 0x0100;
67 constexpr std::uint32_t RIGHT_BUTTON = 0x0200;
68 constexpr std::uint32_t HOME = 0x0400;
69 constexpr std::uint32_t A = 0x1000;
70 constexpr std::uint32_t B = 0x2000;
71 constexpr std::uint32_t X = 0x4000;
72 constexpr std::uint32_t Y = 0x8000;
73 constexpr std::uint32_t PADDLE1 = 0x010000;
74 constexpr std::uint32_t PADDLE2 = 0x020000;
75 constexpr std::uint32_t PADDLE3 = 0x040000;
76 constexpr std::uint32_t PADDLE4 = 0x080000;
77 constexpr std::uint32_t TOUCHPAD_BUTTON = 0x100000;
78 constexpr std::uint32_t MISC_BUTTON = 0x200000;
79
81 std::string name;
82 bool is_enabled;
83 std::string reason_disabled;
84 };
85
93
95 static gamepad_feedback_msg_t make_rumble(std::uint16_t id, std::uint16_t lowfreq, std::uint16_t highfreq) {
98 msg.id = id;
99 msg.data.rumble = {lowfreq, highfreq};
100 return msg;
101 }
102
103 static gamepad_feedback_msg_t make_rumble_triggers(std::uint16_t id, std::uint16_t left, std::uint16_t right) {
106 msg.id = id;
107 msg.data.rumble_triggers = {left, right};
108 return msg;
109 }
110
111 static gamepad_feedback_msg_t make_motion_event_state(std::uint16_t id, std::uint8_t motion_type, std::uint16_t report_rate) {
114 msg.id = id;
115 msg.data.motion_event_state.motion_type = motion_type;
116 msg.data.motion_event_state.report_rate = report_rate;
117 return msg;
118 }
119
120 static gamepad_feedback_msg_t make_rgb_led(std::uint16_t id, std::uint8_t r, std::uint8_t g, std::uint8_t b) {
123 msg.id = id;
124 msg.data.rgb_led = {r, g, b};
125 return msg;
126 }
127
128 static gamepad_feedback_msg_t make_adaptive_triggers(std::uint16_t id, uint8_t event_flags, uint8_t type_left, uint8_t type_right, const std::array<uint8_t, 10> &left, const std::array<uint8_t, 10> &right) {
131 msg.id = id;
132 msg.data.adaptive_triggers = {.event_flags = event_flags, .type_left = type_left, .type_right = type_right, .left = left, .right = right};
133 return msg;
134 }
135
137 std::uint16_t id;
138
139 union {
140 struct {
141 std::uint16_t lowfreq;
142 std::uint16_t highfreq;
143 } rumble;
144
145 struct {
146 std::uint16_t left_trigger;
147 std::uint16_t right_trigger;
148 } rumble_triggers;
149
150 struct {
151 std::uint16_t report_rate;
152 std::uint8_t motion_type;
153 } motion_event_state;
154
155 struct {
156 std::uint8_t r;
157 std::uint8_t g;
158 std::uint8_t b;
159 } rgb_led;
160
161 struct {
162 uint16_t controllerNumber;
163 uint8_t event_flags;
164 uint8_t type_left;
165 uint8_t type_right;
166 std::array<uint8_t, 10> left;
167 std::array<uint8_t, 10> right;
168 } adaptive_triggers;
169 } data;
170 };
171
172 using feedback_queue_t = safe::mail_raw_t::queue_t<gamepad_feedback_msg_t>;
173
174 namespace speaker {
186
187 constexpr std::uint8_t map_stereo[] {
188 FRONT_LEFT,
189 FRONT_RIGHT
190 };
191 constexpr std::uint8_t map_surround51[] {
192 FRONT_LEFT,
193 FRONT_RIGHT,
194 FRONT_CENTER,
195 LOW_FREQUENCY,
196 BACK_LEFT,
197 BACK_RIGHT,
198 };
199 constexpr std::uint8_t map_surround71[] {
204 BACK_LEFT,
206 SIDE_LEFT,
208 };
209 } // namespace speaker
210
211 enum class mem_type_e {
213 vaapi,
214 cuda,
216 };
217
228
229 inline std::string_view from_pix_fmt(pix_fmt_e pix_fmt) {
230 using namespace std::literals;
231#define _CONVERT(x) \
232 case pix_fmt_e::x: \
233 return #x##sv
234 switch (pix_fmt) {
235 _CONVERT(yuv420p);
236 _CONVERT(yuv420p10);
237 _CONVERT(nv12);
238 _CONVERT(p010);
239 _CONVERT(ayuv);
240 _CONVERT(yuv444p16);
241 _CONVERT(y410);
242 _CONVERT(unknown);
243 }
244#undef _CONVERT
245
246 return "unknown"sv;
247 }
248
249 // Dimensions for touchscreen input
251 int offset_x, offset_y;
252 int width, height;
253 };
254
255 // These values must match Limelight-internal.h's SS_FF_* constants!
256 namespace platform_caps {
257 typedef uint32_t caps_t;
258
259 constexpr caps_t pen_touch = 0x01; // Pen and touch events
260 constexpr caps_t controller_touch = 0x02; // Controller touch events
261 }; // namespace platform_caps
262
264 std::uint32_t buttonFlags;
265 std::uint8_t lt;
266 std::uint8_t rt;
267 std::int16_t lsX;
268 std::int16_t lsY;
269 std::int16_t rsX;
270 std::int16_t rsY;
271 };
272
274 // The global index is used when looking up gamepads in the platform's
275 // gamepad array. It identifies gamepads uniquely among all clients.
276 int globalIndex;
277
278 // The client-relative index is the controller number as reported by the
279 // client. It must be used when communicating back to the client via
280 // the input feedback queue.
281 std::uint8_t clientRelativeIndex;
282 };
283
285 std::uint8_t type;
286 std::uint16_t capabilities;
287 std::uint32_t supportedButtons;
288 std::string client_id;
289 };
290
292 gamepad_id_t id;
293 std::uint8_t eventType;
294 std::uint32_t pointerId;
295 float x;
296 float y;
297 float pressure;
298 };
299
301 gamepad_id_t id;
302 std::uint8_t motionType;
303
304 // Accel: m/s^2
305 // Gyro: deg/s
306 float x;
307 float y;
308 float z;
309 };
310
312 gamepad_id_t id;
313 std::uint8_t state;
314 std::uint8_t percentage;
315 };
316
318 std::uint8_t eventType;
319 std::uint16_t rotation; // Degrees (0..360) or LI_ROT_UNKNOWN
320 std::uint32_t pointerId;
321 float x;
322 float y;
323 float pressureOrDistance; // Distance for hover and pressure for contact
324 float contactAreaMajor;
325 float contactAreaMinor;
326 };
327
328 struct pen_input_t {
329 std::uint8_t eventType;
330 std::uint8_t toolType;
331 std::uint8_t penButtons;
332 std::uint8_t tilt; // Degrees (0..90) or LI_TILT_UNKNOWN
333 std::uint16_t rotation; // Degrees (0..360) or LI_ROT_UNKNOWN
334 float x;
335 float y;
336 float pressureOrDistance; // Distance for hover and pressure for contact
337 float contactAreaMajor;
338 float contactAreaMinor;
339 };
340
341 class deinit_t {
342 public:
343 virtual ~deinit_t() = default;
344 };
345
346 struct img_t: std::enable_shared_from_this<img_t> {
347 public:
348 img_t() = default;
349
350 img_t(img_t &&) = delete;
351 img_t(const img_t &) = delete;
352 img_t &operator=(img_t &&) = delete;
353 img_t &operator=(const img_t &) = delete;
354
355 std::uint8_t *data {};
356 std::int32_t width {};
357 std::int32_t height {};
358 std::int32_t pixel_pitch {};
359 std::int32_t row_pitch {};
360
361 std::optional<std::chrono::steady_clock::time_point> frame_timestamp;
362
363 virtual ~img_t() = default;
364 };
365
366 struct sink_t {
367 // Play on host PC
368 std::string host;
369
370 // The audio backend may provide virtual sinks for stream capture.
371 struct null_t {
372 std::string stereo;
373 std::string surround51;
374 std::string surround71;
375 };
376
377 std::optional<null_t> null;
378 };
379
381 virtual ~encode_device_t() = default;
382
383 virtual int convert(platf::img_t &img) = 0;
384
386 };
387
389 void *data {};
390 AVFrame *frame {};
391
392 int convert(platf::img_t &img) override {
393 return -1;
394 }
395
396 virtual void apply_colorspace() {
397 }
398
403 virtual int set_frame(AVFrame *frame, AVBufferRef *hw_frames_ctx) {
404 BOOST_LOG(error) << "Illegal call to hwdevice_t::set_frame(). Did you forget to override it?";
405 return -1;
406 };
407
412 virtual void init_hwframes(AVHWFramesContext *frames) {};
413
418 virtual void init_codec_options(AVCodecContext *ctx, AVDictionary **options) {};
419
424 virtual int prepare_to_derive_context(int hw_device_type) {
425 return 0;
426 };
427 };
428
430 virtual bool init_encoder(const video::config_t &client_config, const video::sunshine_colorspace_t &colorspace) = 0;
431
432 nvenc::nvenc_base *nvenc = nullptr;
433 };
434
435 enum class capture_e : int {
440 error
441 };
442
443 class display_t {
444 public:
452 using push_captured_image_cb_t = std::function<bool(std::shared_ptr<img_t> &&img, bool frame_captured)>;
453
461 using pull_free_image_cb_t = std::function<bool(std::shared_ptr<img_t> &img_out)>;
462
463 display_t() noexcept:
464 offset_x {0},
465 offset_y {0} {
466 }
467
480 virtual 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) = 0;
481
482 virtual std::shared_ptr<img_t> alloc_img() = 0;
483
484 virtual int dummy_img(img_t *img) = 0;
485
486 virtual std::unique_ptr<avcodec_encode_device_t> make_avcodec_encode_device(pix_fmt_e pix_fmt) {
487 return nullptr;
488 }
489
490 virtual std::unique_ptr<nvenc_encode_device_t> make_nvenc_encode_device(pix_fmt_e pix_fmt) {
491 return nullptr;
492 }
493
500 virtual std::unique_ptr<avcodec_encode_device_t> make_pyrowave_encode_device() {
501 return nullptr;
502 }
503
504 virtual bool is_hdr() {
505 return false;
506 }
507
515 virtual bool requires_hdr_for_hdr_output() const {
516 return false;
517 }
518
519 virtual bool get_hdr_metadata(SS_HDR_METADATA &metadata) {
520 std::memset(&metadata, 0, sizeof(metadata));
521 return false;
522 }
523
530 virtual bool is_codec_supported(std::string_view name, const ::video::config_t &config) {
531 return true;
532 }
533
534 virtual ~display_t() = default;
535
536 // Offsets for when streaming a specific monitor. By default, they are 0.
537 // The offset is relative to the desktop envelope's top-left corner and the
538 // envelope is the whole desktop, both in this display's capture pixels.
539 int offset_x, offset_y;
540 int env_width, env_height;
541
542 int width, height;
543
544 protected:
545 // collect capture timing data (at loglevel debug)
546 logging::time_delta_periodic_logger sleep_overshoot_logger = {debug, "Frame capture sleep overshoot"};
547 };
548
549 class mic_t {
550 public:
551 virtual capture_e sample(std::vector<float> &frame_buffer) = 0;
552
553 virtual ~mic_t() = default;
554 };
555
558 public:
560 virtual void write(const std::int16_t *samples, int count) = 0;
561
562 virtual ~mic_writer_t() = default;
563 };
564
566 public:
567 virtual int set_sink(const std::string &sink) = 0;
568
569 virtual std::unique_ptr<mic_t> microphone(const std::uint8_t *mapping, int channels, std::uint32_t sample_rate, std::uint32_t frame_size) = 0;
570
584 virtual std::unique_ptr<mic_t> microphone_from([[maybe_unused]] const std::string &sink, const std::uint8_t *mapping, int channels, std::uint32_t sample_rate, std::uint32_t frame_size) {
585 return microphone(mapping, channels, sample_rate, frame_size);
586 }
587
593 virtual bool is_sink_available(const std::string &sink) = 0;
594
605 virtual std::vector<std::string> streams_playing_elsewhere([[maybe_unused]] const std::string &sink) {
606 return {};
607 }
608
609 virtual std::optional<sink_t> sink_info() = 0;
610
628 virtual bool create_session_sink([[maybe_unused]] const std::string &name,
629 [[maybe_unused]] const std::uint8_t *mapping,
630 [[maybe_unused]] int channels) {
631 return false;
632 }
633
638 virtual void remove_session_sink([[maybe_unused]] const std::string &name) {}
639
640 virtual ~audio_control_t() = default;
641 };
642
643 void freeInput(void *);
644
645 using input_t = util::safe_ptr<void, freeInput>;
646
647 std::filesystem::path appdata();
648
656 std::string get_mac_address(const std::string_view &address);
657
658 std::string get_local_ip_for_gateway();
659
660 std::string from_sockaddr(const sockaddr *const);
661 std::pair<std::uint16_t, std::string> from_sockaddr_ex(const sockaddr *const);
662
663 std::unique_ptr<audio_control_t> audio_control();
664
673 std::shared_ptr<display_t> display(mem_type_e hwdevice_type, const std::string &display_name, const video::config_t &config);
674
680 std::shared_ptr<display_t> encoder_probe_display(mem_type_e hwdevice_type, const video::config_t &config);
681
682 // A list of names of displays accepted as display_name with the mem_type_e
683 std::vector<std::string> display_names(mem_type_e hwdevice_type);
684
689 bool needs_encoder_reenumeration();
690
691 boost::process::v1::child run_command(bool elevated, bool interactive, const std::string &cmd, boost::filesystem::path &working_dir, const boost::process::v1::environment &env, FILE *file, std::error_code &ec, boost::process::v1::group *group);
692
699 void adjust_thread_priority(thread_priority_e priority);
700
701 // Allow OS-specific actions to be taken to prepare for streaming
702 void streaming_will_start();
703 void streaming_will_stop();
704
705 void restart();
706
713 int set_env(const std::string &name, const std::string &value);
714
720 int unset_env(const std::string &name);
721
722 struct buffer_descriptor_t {
723 const char *buffer;
724 size_t size;
725
726 // Constructors required for emplace_back() prior to C++20
727 buffer_descriptor_t(const char *buffer, size_t size):
728 buffer(buffer),
729 size(size) {
730 }
731
732 buffer_descriptor_t():
733 buffer(nullptr),
734 size(0) {
735 }
736 };
737
739 // Optional headers to be prepended to each packet
740 const char *headers;
741 size_t header_size;
742
743 // One or more data buffers to use for the payloads
744 //
745 // NB: Data buffers must be aligned to payload size!
746 std::vector<buffer_descriptor_t> &payload_buffers;
747 size_t payload_size;
748
749 // The offset (in header+payload message blocks) in the header and payload
750 // buffers to begin sending messages from
751 size_t block_offset;
752
753 // The number of header+payload message blocks to send
754 size_t block_count;
755
756 std::uintptr_t native_socket;
757 boost::asio::ip::address &target_address;
758 uint16_t target_port;
759 boost::asio::ip::address &source_address;
760
767 for (const auto &desc : payload_buffers) {
768 if (offset < desc.size) {
769 return {
770 desc.buffer + offset,
771 desc.size - offset,
772 };
773 } else {
774 offset -= desc.size;
775 }
776 }
777 return {};
778 }
779 };
780
781 bool send_batch(batched_send_info_t &send_info);
782
783 struct send_info_t {
784 const char *header;
785 size_t header_size;
786 const char *payload;
787 size_t payload_size;
788
789 std::uintptr_t native_socket;
790 boost::asio::ip::address &target_address;
791 uint16_t target_port;
792 boost::asio::ip::address &source_address;
793 };
794
795 bool send(send_info_t &send_info);
796
797 enum class qos_data_type_e : int {
798 audio,
799 video
800 };
801
810 std::unique_ptr<deinit_t> enable_socket_qos(uintptr_t native_socket, boost::asio::ip::address &address, uint16_t port, qos_data_type_e data_type, bool dscp_tagging);
811
816 void open_url(const std::string &url);
817
823 bool request_process_group_exit(std::uintptr_t native_handle);
824
830 bool process_group_running(std::uintptr_t native_handle);
831
836 input_t input(const std::string &session_tag = {});
837#ifdef HERMES_BUILD_KWIN_TRANSPORT
843 input_t input_private_kwin(const std::string &wayland_socket, const std::string &session_tag = {});
844
851 void forget_private_kwin_input(const std::string &wayland_socket);
852#endif
861 util::point_t get_mouse_loc(input_t &input);
862 void move_mouse(input_t &input, int deltaX, int deltaY);
863 void abs_mouse(input_t &input, const touch_port_t &touch_port, float x, float y);
864 void button_mouse(input_t &input, int button, bool release);
865 void scroll(input_t &input, int distance);
866 void hscroll(input_t &input, int distance);
867 void keyboard_update(input_t &input, uint16_t modcode, bool release, uint8_t flags);
868 void gamepad_update(input_t &input, int nr, const gamepad_state_t &gamepad_state);
869 void unicode(input_t &input, char *utf8, int size);
870
871 typedef deinit_t client_input_t;
872
878 std::unique_ptr<client_input_t> allocate_client_input_context(input_t &input);
879
886 void touch_update(client_input_t *input, const touch_port_t &touch_port, const touch_input_t &touch);
887
899
906 void pen_update(client_input_t *input, const touch_port_t &touch_port, const pen_input_t &pen);
907
913 void gamepad_touch(input_t &input, const gamepad_touch_t &touch);
914
920 void gamepad_motion(input_t &input, const gamepad_motion_t &motion);
921
927 void gamepad_battery(input_t &input, const gamepad_battery_t &battery);
928
937 int alloc_gamepad(input_t &input, const gamepad_id_t &id, const gamepad_arrival_t &metadata, feedback_queue_t feedback_queue);
938 void free_gamepad(input_t &input, int nr);
944 void release_gamepad(input_t &input, int nr);
949 void forget_kept_gamepads(const std::string &session_tag);
950
955 platform_caps::caps_t get_capabilities();
956
957#define SERVICE_TYPE "_nvstream._tcp"
958
959 namespace publish {
960 [[nodiscard]] std::unique_ptr<deinit_t> start();
961 }
962
963 [[nodiscard]] std::unique_ptr<deinit_t> init();
964
969 std::string get_host_name();
970
977 std::vector<supported_gamepad_t> &supported_gamepads(input_t *input);
978
979 struct high_precision_timer: private boost::noncopyable {
980 virtual ~high_precision_timer() = default;
981
986 virtual void sleep_for(const std::chrono::nanoseconds &duration) = 0;
987
992 virtual operator bool() = 0;
993 };
994
999 std::unique_ptr<high_precision_timer> create_high_precision_timer();
1000
1001 std::string
1002 get_clipboard();
1003
1004 bool
1005 set_clipboard(const std::string& content);
1006
1007 bool
1008 clipboard_available();
1009
1027
1030 bool gamescope_running {false};
1032 std::string desktop;
1033
1035 std::string describe() const {
1036 switch (kind) {
1038 return "headless";
1040 return "desktop_x11";
1042 return "desktop_wayland";
1044 return "gamescope_session";
1046 default:
1047 return "unknown";
1048 }
1049 }
1050 };
1051
1057 session_environment_t
1058 detect_session_environment();
1059
1070 bool enabled {false};
1071 bool gamescope_available {false};
1073 bool headless_capable {false};
1076
1079 std::string diagnostic;
1080 };
1081
1089
1090} // namespace platf
1091
A helper class for tracking and logging short time intervals across a period of time.
Definition logging.h:166
Abstract platform-agnostic base of standalone NVENC encoder. Derived classes perform platform-specifi...
Definition nvenc_base.h:26
virtual bool create_session_sink(const std::string &name, const std::uint8_t *mapping, int channels)
Create a sink that belongs to one isolated session alone.
Definition common.h:628
virtual std::vector< std::string > streams_playing_elsewhere(const std::string &sink)
Applications playing to a sink other than sink.
Definition common.h:605
virtual void remove_session_sink(const std::string &name)
Remove a sink created by create_session_sink(). Removing one that is already gone is not an error.
Definition common.h:638
virtual bool is_sink_available(const std::string &sink)=0
Check if the audio sink is available in the system.
virtual std::unique_ptr< mic_t > microphone_from(const std::string &sink, const std::uint8_t *mapping, int channels, std::uint32_t sample_rate, std::uint32_t frame_size)
Record a named sink's monitor, whatever the current sink is.
Definition common.h:584
virtual bool is_codec_supported(std::string_view name, const ::video::config_t &config)
Check that a given codec is supported by the display device.
Definition common.h:530
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 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)=0
Capture a frame.
virtual bool requires_hdr_for_hdr_output() const
Whether this capture backend requires an HDR encoder when the display is in HDR mode.
Definition common.h:515
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
Feeds a client's microphone into a session mic.
Definition common.h:557
virtual void write(const std::int16_t *samples, int count)=0
Never blocks: samples that do not fit are dropped.
mem_type_e
Definition common.h:211
@ system
System memory.
Definition common.h:212
@ unknown
Unknown.
Definition common.h:215
@ BACK_LEFT
Back left.
Definition common.h:180
@ LOW_FREQUENCY
Low frequency.
Definition common.h:179
@ SIDE_RIGHT
Side right.
Definition common.h:183
@ MAX_SPEAKERS
Maximum number of speakers.
Definition common.h:184
@ FRONT_LEFT
Front left.
Definition common.h:176
@ SIDE_LEFT
Side left.
Definition common.h:182
@ FRONT_CENTER
Front center.
Definition common.h:178
@ BACK_RIGHT
Back right.
Definition common.h:181
@ FRONT_RIGHT
Front right.
Definition common.h:177
std::vector< supported_gamepad_t > & supported_gamepads(input_t *input)
Gets the supported gamepads for this platform backend.
std::string session_mic_source(std::string_view sink)
The microphone source of the session that plays into sink.
Definition common.h:54
pix_fmt_e
Definition common.h:218
@ yuv420p10
YUV 4:2:0 10-bit.
Definition common.h:220
@ yuv444p16
Planar 10-bit (shifted to 16-bit) YUV 4:4:4.
Definition common.h:224
@ yuv420p
YUV 4:2:0.
Definition common.h:219
int alloc_gamepad(input_t &input, const gamepad_id_t &id, const gamepad_arrival_t &metadata, feedback_queue_t feedback_queue)
Create a new virtual gamepad.
void forget_kept_gamepads(const std::string &session_tag)
Remove the gamepads a session tag kept between streams.
session_environment_e
The kind of session/compositor environment Hermes is running in.
Definition common.h:1020
@ gamescope_session
Standalone Gamescope compositor (SteamOS Game Mode).
Definition common.h:1025
@ unknown
Could not be determined.
Definition common.h:1021
@ desktop_wayland
Wayland desktop session (KDE/GNOME/wlroots).
Definition common.h:1024
@ desktop_x11
X11 desktop session.
Definition common.h:1023
@ headless
No window system / capture source available.
Definition common.h:1022
qos_data_type_e
Definition common.h:797
std::unique_ptr< high_precision_timer > create_high_precision_timer()
Create platform-specific timer capable of high-precision sleep.
Definition misc.cpp:1811
util::point_t get_mouse_loc(input_t &input)
Get the current mouse position on screen.
std::unique_ptr< client_input_t > allocate_client_input_context(input_t &input)
Allocate a context to store per-client input data.
void pen_update(client_input_t *input, const touch_port_t &touch_port, const pen_input_t &pen)
Send a pen event to the OS.
void gamepad_motion(input_t &input, const gamepad_motion_t &motion)
Send a gamepad motion event to the OS.
gamepad_feedback_e
Definition common.h:86
@ rumble_triggers
Rumble triggers.
Definition common.h:88
@ set_adaptive_triggers
Set adaptive triggers.
Definition common.h:91
@ set_motion_event_state
Set motion event state.
Definition common.h:89
@ set_rgb_led
Set RGB LED.
Definition common.h:90
thread_priority_e
Definition common.h:693
@ low
Low priority.
Definition common.h:694
@ critical
Critical priority.
Definition common.h:697
@ high
High priority.
Definition common.h:696
@ normal
Normal priority.
Definition common.h:695
std::string get_host_name()
Returns the current computer name in UTF-8.
Definition misc.cpp:1533
void gamepad_battery(input_t &input, const gamepad_battery_t &battery)
Send a gamepad battery event to the OS.
void release_gamepad(input_t &input, int nr)
Release a gamepad because its stream ended, not because the client removed it. A detached desktop kee...
platform_caps::caps_t get_capabilities()
Get the supported platform capabilities to advertise to the client.
bool touch_binds_to_output()
Whether the session binds a touchscreen or a pen to one output.
Definition misc.cpp:198
void gamepad_touch(input_t &input, const gamepad_touch_t &touch)
Send a gamepad touch event to the OS.
input_t input(const std::string &session_tag={})
void touch_update(client_input_t *input, const touch_port_t &touch_port, const touch_input_t &touch)
Send a touch event to the OS.
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
@ interrupted
Capture was interrupted.
Definition common.h:439
appliance_readiness_t appliance_readiness()
Assess appliance-mode readiness without changing any state.
Definition misc.cpp:1972
Declarations for the configuration of Sunshine.
Declarations for logging related functions.
Standalone NVENC encoder.
Read-only assessment of whether the host could run as a dedicated streaming appliance (boot straight ...
Definition common.h:1069
bool autologin_configured
A display-manager autologin drop-in was detected.
Definition common.h:1074
bool gamescope_available
A Gamescope compositor/session is present.
Definition common.h:1071
bool headless_capable
Can present without a physical monitor (virtual display present).
Definition common.h:1073
bool enabled
config appliance_mode flag state.
Definition common.h:1070
std::string session_environment
session_environment_t::describe() value.
Definition common.h:1075
bool virtual_display_available
An EVDI or Hermes-KMS virtual display is usable.
Definition common.h:1072
virtual int prepare_to_derive_context(int hw_device_type)
Prepare to derive a context.
Definition common.h:424
virtual void init_codec_options(AVCodecContext *ctx, AVDictionary **options)
Provides a hook for allow platform-specific code to adjust codec options.
Definition common.h:418
virtual int set_frame(AVFrame *frame, AVBufferRef *hw_frames_ctx)
Set the frame to be encoded.
Definition common.h:403
virtual void init_hwframes(AVHWFramesContext *frames)
Initialize the hwframes context.
Definition common.h:412
buffer_descriptor_t buffer_for_payload_offset(ptrdiff_t offset)
Returns a payload buffer descriptor for the given payload offset.
Definition common.h:766
std::string client_id
The paired client's id; with the controller number, a stable identity.
Definition common.h:288
virtual void sleep_for(const std::chrono::nanoseconds &duration)=0
Sleep for the duration.
bool gamescope_running
A Gamescope compositor is present.
Definition common.h:1030
std::string describe() const
Stable string id for diagnostics/APIs, e.g. "gamescope_session".
Definition common.h:1035
bool can_host_virtual_display
A desktop compositor can adopt a virtual display.
Definition common.h:1031
std::string desktop
Raw XDG_CURRENT_DESKTOP, for diagnostics.
Definition common.h:1032
Declarations for thread-safe data structures.
Declarations for utility functions.
Declarations for colorspace functions.