|
Hermes 0.7.0
Linux game streaming host
|
Declarations for common platform specific utilities. More...
#include <bitset>#include <filesystem>#include <functional>#include <mutex>#include <string>#include <boost/core/noncopyable.hpp>#include <boost/asio/ip/address.hpp>#include <boost/process/v1/child.hpp>#include <boost/process/v1/group.hpp>#include <boost/process/v1/environment.hpp>#include "src/config.h"#include "src/logging.h"#include "src/thread_safe.h"#include "src/utility.h"#include "src/video_colorspace.h"#include <moonlight-common-c/src/Limelight.h>Go to the source code of this file.
Namespaces | |
| namespace | nvenc |
| Standalone NVENC encoder. | |
Macros | |
| #define | _CONVERT(x) |
| #define | SERVICE_TYPE "_nvstream._tcp" |
Typedefs | |
| using | platf::feedback_queue_t = safe::mail_raw_t::queue_t<gamepad_feedback_msg_t> |
| typedef uint32_t | platf::platform_caps::caps_t |
| using | platf::input_t = util::safe_ptr<void, freeInput> |
| typedef deinit_t | platf::client_input_t |
Functions | |
| std::string | platf::session_mic_source (std::string_view sink) |
| The microphone source of the session that plays into sink. | |
| std::string_view | platf::from_pix_fmt (pix_fmt_e pix_fmt) |
| void | platf::freeInput (void *) |
| std::filesystem::path | platf::appdata () |
| Performs migration if necessary, then returns the appdata directory. | |
| std::string | platf::get_mac_address (const std::string_view &address) |
The MAC address of the interface that holds address. | |
| std::string | platf::get_local_ip_for_gateway () |
| std::string | platf::from_sockaddr (const sockaddr *const) |
| std::pair< std::uint16_t, std::string > | platf::from_sockaddr_ex (const sockaddr *const) |
| std::unique_ptr< audio_control_t > | platf::audio_control () |
| std::shared_ptr< display_t > | platf::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 monitor that's compatible you can find If you require to use this parameter in a separate thread, make a copy of it. | |
| std::shared_ptr< display_t > | platf::encoder_probe_display (mem_type_e hwdevice_type, const video::config_t &config) |
| A display with no screen behind it, for validating encoders. | |
| std::vector< std::string > | platf::display_names (mem_type_e hwdevice_type) |
| bool | platf::needs_encoder_reenumeration () |
| Check if GPUs/drivers have changed since the last call to this function. | |
| boost::process::v1::child | platf::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) |
| void | platf::adjust_thread_priority (thread_priority_e priority) |
| void | platf::streaming_will_start () |
| void | platf::streaming_will_stop () |
| void | platf::restart () |
| int | platf::set_env (const std::string &name, const std::string &value) |
| Set an environment variable. | |
| int | platf::unset_env (const std::string &name) |
| Unset an environment variable. | |
| bool | platf::send_batch (batched_send_info_t &send_info) |
| bool | platf::send (send_info_t &send_info) |
| std::unique_ptr< deinit_t > | platf::enable_socket_qos (uintptr_t native_socket, boost::asio::ip::address &address, uint16_t port, qos_data_type_e data_type, bool dscp_tagging) |
| Enable QoS on the given socket for traffic to the specified destination. | |
| void | platf::open_url (const std::string &url) |
| Open a url in the default web browser. | |
| bool | platf::request_process_group_exit (std::uintptr_t native_handle) |
| Attempt to gracefully terminate a process group. | |
| bool | platf::process_group_running (std::uintptr_t native_handle) |
| Check if a process group still has running children. | |
| input_t | platf::input (const std::string &session_tag={}) |
| util::point_t | platf::get_mouse_loc (input_t &input) |
| Get the current mouse position on screen. | |
| void | platf::move_mouse (input_t &input, int deltaX, int deltaY) |
| void | platf::abs_mouse (input_t &input, const touch_port_t &touch_port, float x, float y) |
| void | platf::button_mouse (input_t &input, int button, bool release) |
| void | platf::scroll (input_t &input, int distance) |
| void | platf::hscroll (input_t &input, int distance) |
| void | platf::keyboard_update (input_t &input, uint16_t modcode, bool release, uint8_t flags) |
| void | platf::gamepad_update (input_t &input, int nr, const gamepad_state_t &gamepad_state) |
| void | platf::unicode (input_t &input, char *utf8, int size) |
| std::unique_ptr< client_input_t > | platf::allocate_client_input_context (input_t &input) |
| Allocate a context to store per-client input data. | |
| void | platf::touch_update (client_input_t *input, const touch_port_t &touch_port, const touch_input_t &touch) |
| Send a touch event to the OS. | |
| bool | platf::touch_binds_to_output () |
| Whether the session binds a touchscreen or a pen to one output. | |
| void | platf::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 | platf::gamepad_touch (input_t &input, const gamepad_touch_t &touch) |
| Send a gamepad touch event to the OS. | |
| void | platf::gamepad_motion (input_t &input, const gamepad_motion_t &motion) |
| Send a gamepad motion event to the OS. | |
| void | platf::gamepad_battery (input_t &input, const gamepad_battery_t &battery) |
| Send a gamepad battery event to the OS. | |
| int | platf::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 | platf::free_gamepad (input_t &input, int nr) |
| void | platf::release_gamepad (input_t &input, int nr) |
| Release a gamepad because its stream ended, not because the client removed it. A detached desktop keeps it for the next stream to the same desktop, so the desktop's programs never see the controller leave. | |
| void | platf::forget_kept_gamepads (const std::string &session_tag) |
| Remove the gamepads a session tag kept between streams. | |
| platform_caps::caps_t | platf::get_capabilities () |
| Get the supported platform capabilities to advertise to the client. | |
| std::unique_ptr< deinit_t > | platf::publish::start () |
| std::unique_ptr< deinit_t > | platf::init () |
| std::string | platf::get_host_name () |
| Returns the current computer name in UTF-8. | |
| std::vector< supported_gamepad_t > & | platf::supported_gamepads (input_t *input) |
| Gets the supported gamepads for this platform backend. | |
| std::unique_ptr< high_precision_timer > | platf::create_high_precision_timer () |
| Create platform-specific timer capable of high-precision sleep. | |
| std::string | platf::get_clipboard () |
| bool | platf::set_clipboard (const std::string &content) |
| bool | platf::clipboard_available () |
| session_environment_t | platf::detect_session_environment () |
| Detect the current session/compositor environment. | |
| appliance_readiness_t | platf::appliance_readiness () |
| Assess appliance-mode readiness without changing any state. | |
Variables | |
| constexpr auto | platf::MAX_GAMEPADS = 16 |
| constexpr std::uint32_t | platf::DPAD_UP = 0x0001 |
| constexpr std::uint32_t | platf::DPAD_DOWN = 0x0002 |
| constexpr std::uint32_t | platf::DPAD_LEFT = 0x0004 |
| constexpr std::uint32_t | platf::DPAD_RIGHT = 0x0008 |
| constexpr std::uint32_t | platf::START = 0x0010 |
| constexpr std::uint32_t | platf::BACK = 0x0020 |
| constexpr std::uint32_t | platf::LEFT_STICK = 0x0040 |
| constexpr std::uint32_t | platf::RIGHT_STICK = 0x0080 |
| constexpr std::uint32_t | platf::LEFT_BUTTON = 0x0100 |
| constexpr std::uint32_t | platf::RIGHT_BUTTON = 0x0200 |
| constexpr std::uint32_t | platf::HOME = 0x0400 |
| constexpr std::uint32_t | platf::A = 0x1000 |
| constexpr std::uint32_t | platf::B = 0x2000 |
| constexpr std::uint32_t | platf::X = 0x4000 |
| constexpr std::uint32_t | platf::Y = 0x8000 |
| constexpr std::uint32_t | platf::PADDLE1 = 0x010000 |
| constexpr std::uint32_t | platf::PADDLE2 = 0x020000 |
| constexpr std::uint32_t | platf::PADDLE3 = 0x040000 |
| constexpr std::uint32_t | platf::PADDLE4 = 0x080000 |
| constexpr std::uint32_t | platf::TOUCHPAD_BUTTON = 0x100000 |
| constexpr std::uint32_t | platf::MISC_BUTTON = 0x200000 |
| constexpr std::uint8_t | platf::speaker::map_stereo [] |
| constexpr std::uint8_t | platf::speaker::map_surround51 [] |
| constexpr std::uint8_t | platf::speaker::map_surround71 [] |
| constexpr caps_t | platf::platform_caps::pen_touch = 0x01 |
| constexpr caps_t | platf::platform_caps::controller_touch = 0x02 |
Declarations for common platform specific utilities.
Definition in file common.h.
| #define _CONVERT | ( | x | ) |
| using platf::feedback_queue_t = safe::mail_raw_t::queue_t<gamepad_feedback_msg_t> |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
The kind of session/compositor environment Hermes is running in.
This drives how Hermes handles virtual displays and Gamescope:
|
strong |
| void platf::abs_mouse | ( | input_t & | input, |
| const touch_port_t & | touch_port, | ||
| float | x, | ||
| float | y ) |
Definition at line 118 of file virtualhid.cpp.
| void platf::adjust_thread_priority | ( | thread_priority_e | priority | ) |
| int platf::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.
| input | The global input context. |
| id | The gamepad ID. |
| metadata | Controller metadata from client (empty if none provided). |
| feedback_queue | The queue for posting messages back to the client. |
Definition at line 183 of file virtualhid.cpp.
| std::unique_ptr< client_input_t > platf::allocate_client_input_context | ( | input_t & | input | ) |
Allocate a context to store per-client input data.
| input | The global input context. |
Definition at line 103 of file virtualhid.cpp.
| fs::path platf::appdata | ( | ) |
| appliance_readiness_t platf::appliance_readiness | ( | ) |
| std::unique_ptr< audio_control_t > platf::audio_control | ( | ) |
| void platf::button_mouse | ( | input_t & | input, |
| int | button, | ||
| bool | release ) |
Definition at line 125 of file virtualhid.cpp.
| std::unique_ptr< high_precision_timer > platf::create_high_precision_timer | ( | ) |
| session_environment_t platf::detect_session_environment | ( | ) |
| std::shared_ptr< display_t > platf::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 monitor that's compatible you can find If you require to use this parameter in a separate thread, make a copy of it.
| display_name | The name of the monitor that SHOULD be displayed |
| config | Stream configuration |
| std::vector< std::string > platf::display_names | ( | mem_type_e | hwdevice_type | ) |
| std::unique_ptr< deinit_t > platf::enable_socket_qos | ( | uintptr_t | native_socket, |
| boost::asio::ip::address & | address, | ||
| uint16_t | port, | ||
| qos_data_type_e | data_type, | ||
| bool | dscp_tagging ) |
Enable QoS on the given socket for traffic to the specified destination.
Enables QoS on the given socket for traffic to the specified destination.
| native_socket | The native socket handle. |
| address | The destination address for traffic sent on this socket. |
| port | The destination port for traffic sent on this socket. |
| data_type | The type of traffic sent on this socket. |
| dscp_tagging | Specifies whether to enable DSCP tagging on outgoing traffic. |
| std::shared_ptr< display_t > platf::encoder_probe_display | ( | mem_type_e | hwdevice_type, |
| const video::config_t & | config ) |
A display with no screen behind it, for validating encoders.
It captures nothing; validation encodes only the synthetic frames it fills in, so no monitor or virtual output is needed or touched.
Definition at line 92 of file encoder_probe_display.cpp.
| void platf::forget_kept_gamepads | ( | const std::string & | session_tag | ) |
Remove the gamepads a session tag kept between streams.
| session_tag | The tag of a session that has stopped. |
Definition at line 201 of file virtualhid.cpp.
| void platf::free_gamepad | ( | input_t & | input, |
| int | nr ) |
Definition at line 193 of file virtualhid.cpp.
| void platf::freeInput | ( | void * | pointer | ) |
Definition at line 107 of file virtualhid.cpp.
|
inline |
| std::string platf::from_sockaddr | ( | const sockaddr * const | ip_addr | ) |
| std::pair< std::uint16_t, std::string > platf::from_sockaddr_ex | ( | const sockaddr * const | ip_addr | ) |
| void platf::gamepad_battery | ( | input_t & | input, |
| const gamepad_battery_t & | battery ) |
Send a gamepad battery event to the OS.
| input | The global input context. |
| battery | The battery event. |
Definition at line 217 of file virtualhid.cpp.
| void platf::gamepad_motion | ( | input_t & | input, |
| const gamepad_motion_t & | motion ) |
Send a gamepad motion event to the OS.
| input | The global input context. |
| motion | The motion event. |
Definition at line 213 of file virtualhid.cpp.
| void platf::gamepad_touch | ( | input_t & | input, |
| const gamepad_touch_t & | touch ) |
Send a gamepad touch event to the OS.
| input | The global input context. |
| touch | The touch event. |
Definition at line 209 of file virtualhid.cpp.
| void platf::gamepad_update | ( | input_t & | input, |
| int | nr, | ||
| const gamepad_state_t & | gamepad_state ) |
Definition at line 205 of file virtualhid.cpp.
| platform_caps::caps_t platf::get_capabilities | ( | ) |
Get the supported platform capabilities to advertise to the client.
Definition at line 221 of file virtualhid.cpp.
| std::string platf::get_host_name | ( | ) |
| std::string platf::get_mac_address | ( | const std::string_view & | address | ) |
The MAC address of the interface that holds address.
Addresses are compared as addresses, not text, so a link-local address printed with its scope (fe80::1eth0) finds its interface.
| address | The host address a client reached. |
| util::point_t platf::get_mouse_loc | ( | input_t & | input | ) |
Get the current mouse position on screen.
| input | The input_t instance to use. |
Examples
Definition at line 226 of file virtualhid.cpp.
| void platf::hscroll | ( | input_t & | input, |
| int | distance ) |
Definition at line 139 of file virtualhid.cpp.
| input_t platf::input | ( | const std::string & | session_tag = {} | ) |
Create a platform input device set. session_tag is stamped into Linux uinput phys/uniq metadata so a compositor seat can select only its client.
Definition at line 99 of file virtualhid.cpp.
| void platf::move_mouse | ( | input_t & | input, |
| int | deltaX, | ||
| int | deltaY ) |
Definition at line 111 of file virtualhid.cpp.
| bool platf::needs_encoder_reenumeration | ( | ) |
| void platf::open_url | ( | const std::string & | url | ) |
| void platf::pen_update | ( | client_input_t * | input, |
| const touch_port_t & | touch_port, | ||
| const pen_input_t & | pen ) |
Send a pen event to the OS.
| input | The client-specific input context. |
| touch_port | The current viewport for translating to screen coordinates. |
| pen | The pen event. |
Definition at line 173 of file virtualhid.cpp.
| bool platf::process_group_running | ( | std::uintptr_t | native_handle | ) |
| void platf::release_gamepad | ( | input_t & | input, |
| int | nr ) |
Release a gamepad because its stream ended, not because the client removed it. A detached desktop keeps it for the next stream to the same desktop, so the desktop's programs never see the controller leave.
Definition at line 197 of file virtualhid.cpp.
| bool platf::request_process_group_exit | ( | std::uintptr_t | native_handle | ) |
| void platf::scroll | ( | input_t & | input, |
| int | distance ) |
Definition at line 132 of file virtualhid.cpp.
| bool platf::send | ( | send_info_t & | send_info | ) |
| bool platf::send_batch | ( | batched_send_info_t & | send_info | ) |
|
inline |
| int platf::set_env | ( | const std::string & | name, |
| const std::string & | value ) |
|
nodiscard |
Definition at line 421 of file publish.cpp.
| std::vector< supported_gamepad_t > & platf::supported_gamepads | ( | input_t * | input | ) |
Gets the supported gamepads for this platform backend.
This may be called prior to platf::input()!
| input | Pointer to the platform's input_t or nullptr. |
Definition at line 230 of file virtualhid.cpp.
| bool platf::touch_binds_to_output | ( | ) |
Whether the session binds a touchscreen or a pen to one output.
Such a device reports where on its own surface it was touched, so the compositor has to decide which output that surface stands for. KWin and Mutter bind it to a single output, and the coordinates Hermes sends are then relative to the streamed output alone. Everywhere else the device spans the whole desktop and the streamed output's offset within it is part of the coordinate.
| void platf::touch_update | ( | client_input_t * | input, |
| const touch_port_t & | touch_port, | ||
| const touch_input_t & | touch ) |
Send a touch event to the OS.
| input | The client-specific input context. |
| touch_port | The current viewport for translating to screen coordinates. |
| touch | The touch event. |
Definition at line 160 of file virtualhid.cpp.
| void platf::unicode | ( | input_t & | input, |
| char * | utf8, | ||
| int | size ) |
Definition at line 153 of file virtualhid.cpp.
| int platf::unset_env | ( | const std::string & | name | ) |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |