|
Hermes 0.7.0
Linux game streaming host
|
Definitions for the startup and shutdown of the apps started by a streaming Session. More...
#include <algorithm>#include <array>#include <atomic>#include <csignal>#include <cstdio>#include <cctype>#include <cstdlib>#include <chrono>#include <cstring>#include <filesystem>#include <fstream>#include <map>#include <mutex>#include <optional>#include <sstream>#include <string>#include <string_view>#include <thread>#include <unordered_map>#include <utility>#include <vector>#include <fcntl.h>#include <poll.h>#include <signal.h>#include <spawn.h>#include <sys/wait.h>#include <unistd.h>#include <xf86drm.h>#include "platform/linux/bounded_command.h"#include "platform/linux/desktop_steam.h"#include "platform/linux/gamescope_session.h"#include "platform/linux/window_placement.h"#include "platform/linux/wayland.h"#include <boost/algorithm/string.hpp>#include <boost/crc.hpp>#include <boost/filesystem.hpp>#include <boost/program_options/parsers.hpp>#include <boost/process/v1/search_path.hpp>#include <boost/property_tree/json_parser.hpp>#include <boost/property_tree/ptree.hpp>#include <openssl/evp.h>#include <openssl/sha.h>#include "config.h"#include "crypto.h"#include "display_device.h"#include "file_handler.h"#include "logging.h"#include "platform/common.h"#include "process.h"#include "frame_limit_env.h"#include "httpcommon.h"#include "system_tray.h"#include "utility.h"#include "audio.h"#include "video.h"#include "uuid.h"#include "platform/linux/session_audio.h"#include "platform/linux/session_broker.h"#include "platform/linux/process_group.h"#include "platform/linux/detached_scope.h"#include "platform/linux/session_devices.h"#include "platform/linux/session_bus.h"#include "platform/linux/virtual_display.h"#include <sys/stat.h>Go to the source code of this file.
Classes | |
| class | proc::deinit_t |
Macros | |
| #define | BOOST_BIND_GLOBAL_PLACEHOLDERS |
| #define | BOOST_PROCESS_VERSION 1 |
| #define | DEFAULT_APP_IMAGE_PATH HERMES_ASSETS_DIR "/box.png" |
Functions | |
| virtual_display_decision_t | proc::decide_virtual_display (const ctx_t &app, const rtsp_stream::launch_session_t &launch_session, bool headless_mode) |
| std::string_view | proc::describe (virtual_display_source_e source) |
| bool | proc::launch_requests_virtual_display (const ctx_t &app, const rtsp_stream::launch_session_t &launch_session, bool headless_mode) |
| scale_factor_decision_t | proc::decide_scale_factor (const ctx_t &app, const rtsp_stream::launch_session_t &launch_session, int host_default) |
| std::string_view | proc::describe (scale_factor_source_e source) |
| session_route_e | proc::resolve_session_route (const ctx_t &app, bool isolated_sessions_enabled, bool virtual_display_requested, std::string_view global_method) |
| void | proc::onVDisplayWatchdogFailed () |
| void | proc::initVDisplayDriver () |
| Initialize the virtual display driver. This should be called early in startup to enable virtual display support. | |
| std::unique_ptr< platf::deinit_t > | proc::init () |
| Initialize proc functions. | |
| void | proc::terminate_process_group (boost::process::v1::child &proc, boost::process::v1::group &group, std::chrono::seconds exit_timeout) |
| Terminates all child processes in a process group. | |
| boost::filesystem::path | proc::find_working_directory (const std::string &cmd, const boost::process::v1::environment &env) |
| std::string_view::iterator | proc::find_match (std::string_view::iterator begin, std::string_view::iterator end) |
| std::string | proc::parse_env_val (boost::process::v1::native_environment &env, const std::string_view &val_raw) |
| std::string | proc::validate_app_image_path (std::string app_image_path) |
| std::optional< std::string > | proc::calculate_sha256 (const std::string &filename) |
| uint32_t | proc::calculate_crc32 (const std::string &input) |
| std::tuple< std::string, std::string > | proc::calculate_app_id (const std::string &app_name, std::string app_image_path, int index) |
| Calculate a stable id based on name and image data. | |
| void | proc::migrate_apps (nlohmann::json *fileTree_p, nlohmann::json *inputTree_p) |
| Migrate the applications stored in the file tree by merging in a new app. | |
| void | proc::migration_v2 (nlohmann::json &fileTree) |
| void | proc::migration_v3 (nlohmann::json &fileTree) |
| void | proc::migration_v5 (nlohmann::json &fileTree) |
| void | proc::migration_v6 (nlohmann::json &fileTree) |
| void | proc::migration_v7 (nlohmann::json &fileTree) |
| void | proc::migrate (nlohmann::json &fileTree, const std::string &fileName, bool persist=true) |
| std::optional< proc::proc_t > | proc::parse (const std::string &file_name, bool fallback_on_failure=true) |
| Load the applications from apps.json. | |
| void | proc::refresh (const std::string &file_name, bool needs_terminate) |
Variables | |
| proc_t | proc::proc |
| int | proc::input_only_app_id = -1 |
| std::string | proc::input_only_app_id_str |
| int | proc::terminate_app_id = -1 |
| std::string | proc::terminate_app_id_str |
| VDISPLAY::DRIVER_STATUS | proc::vDisplayDriverStatus = VDISPLAY::DRIVER_STATUS::UNKNOWN |
Definitions for the startup and shutdown of the apps started by a streaming Session.
Definition in file process.cpp.
| #define BOOST_BIND_GLOBAL_PLACEHOLDERS |
Definition at line 5 of file process.cpp.
| #define BOOST_PROCESS_VERSION 1 |
Definition at line 8 of file process.cpp.
| #define DEFAULT_APP_IMAGE_PATH HERMES_ASSETS_DIR "/box.png" |
Definition at line 88 of file process.cpp.
| std::tuple< std::string, std::string > proc::calculate_app_id | ( | const std::string & | app_name, |
| std::string | app_image_path, | ||
| int | index ) |
Calculate a stable id based on name and image data.
Definition at line 4470 of file process.cpp.
| uint32_t proc::calculate_crc32 | ( | const std::string & | input | ) |
Definition at line 4464 of file process.cpp.
| std::optional< std::string > proc::calculate_sha256 | ( | const std::string & | filename | ) |
Definition at line 4429 of file process.cpp.
| scale_factor_decision_t proc::decide_scale_factor | ( | const ctx_t & | app, |
| const rtsp_stream::launch_session_t & | launch_session, | ||
| int | host_default ) |
Decide a launch's resolution scale: an app that forces its scale wins, then the client's, then the app's own when it is not 100, then the host default.
Definition at line 148 of file process.cpp.
| virtual_display_decision_t proc::decide_virtual_display | ( | const ctx_t & | app, |
| const rtsp_stream::launch_session_t & | launch_session, | ||
| bool | headless_mode ) |
Decide whether a launch uses a virtual display.
Headless mode always does. An app that forces its setting wins next, on or off. Otherwise a client that stated a choice gets it. Without one, the launch uses a virtual display if the client asked for one or the app's setting is on, as before.
Definition at line 109 of file process.cpp.
| std::string_view proc::describe | ( | scale_factor_source_e | source | ) |
Definition at line 165 of file process.cpp.
| std::string_view proc::describe | ( | virtual_display_source_e | source | ) |
A phrase for the log: "forced by the app", "the client's choice", ...
Definition at line 126 of file process.cpp.
| std::string_view::iterator proc::find_match | ( | std::string_view::iterator | begin, |
| std::string_view::iterator | end ) |
Definition at line 4329 of file process.cpp.
| boost::filesystem::path proc::find_working_directory | ( | const std::string & | cmd, |
| const boost::process::v1::environment & | env ) |
Definition at line 1685 of file process.cpp.
| std::unique_ptr< platf::deinit_t > proc::init | ( | ) |
Initialize proc functions.
Definition at line 1601 of file process.cpp.
| void proc::initVDisplayDriver | ( | ) |
Initialize the virtual display driver. This should be called early in startup to enable virtual display support.
Definition at line 1580 of file process.cpp.
| bool proc::launch_requests_virtual_display | ( | const ctx_t & | app, |
| const rtsp_stream::launch_session_t & | launch_session, | ||
| bool | headless_mode ) |
Return whether policy explicitly requests a virtual display for this launch.
This is intentionally narrower than the legacy execute() fallback that may create a display merely because no active display is available. Losing a monitor must not by itself change session ownership.
Definition at line 140 of file process.cpp.
| void proc::migrate | ( | nlohmann::json & | fileTree, |
| const std::string & | fileName, | ||
| bool | persist = true ) |
Definition at line 4832 of file process.cpp.
| void proc::migrate_apps | ( | nlohmann::json * | fileTree_p, |
| nlohmann::json * | inputTree_p ) |
Migrate the applications stored in the file tree by merging in a new app.
This function updates the application entries in fileTree_p using the data in inputTree_p. If an app in the file tree does not have a UUID, one is generated and inserted. If an app with the same UUID as the new app is found, it is replaced. Additionally, empty keys (such as "prep-cmd" or "detached") and keys no longer needed ("launching", "index") are removed from the input.
Legacy versions of Sunshine/Apollo stored boolean and integer values as strings. The following keys are converted:
A migration version is stored in the file tree (under "version") so that future changes can be applied.
| fileTree_p | Pointer to the JSON object representing the file tree. |
| inputTree_p | Pointer to the JSON object representing the new app. |
Definition at line 4521 of file process.cpp.
| void proc::migration_v2 | ( | nlohmann::json & | fileTree | ) |
Definition at line 4575 of file process.cpp.
| void proc::migration_v3 | ( | nlohmann::json & | fileTree | ) |
v3: gamescope launcher entries now carry an explicit virtual-display-layout. Entries created before the field existed ran with the v0.5.0 "extend" placement, which left a nested Gamescope on the physical monitor and an empty virtual display in the stream. Pin existing launcher entries to "mirror" (the pre-0.5.0 clone behaviour) unless the user already set a layout themselves.
Definition at line 4684 of file process.cpp.
| void proc::migration_v5 | ( | nlohmann::json & | fileTree | ) |
v5: the Detached Desktop and Detached Steam entries, added once to an existing list as they are to a new one: each after the host entry it is the detached counterpart of, or at the end. An entry the user deleted stays deleted, since this runs once.
Definition at line 4723 of file process.cpp.
| void proc::migration_v6 | ( | nlohmann::json & | fileTree | ) |
v6: covers that tell Hermes' default apps apart. Desktop and Low Res Desktop, or Steam Big Picture and the Gamescope Steam Session, looked the same in a client's app list. Only an entry still exactly as Hermes shipped it - its name and the cover it came with - gets the new cover.
Definition at line 4768 of file process.cpp.
| void proc::migration_v7 | ( | nlohmann::json & | fileTree | ) |
v7: session-type became isolation-method, named after what each value runs; "shared" never was a way to isolate, so it became the host-session flag. Hermes' own entries lose "Detached" from their names unless the user renamed them.
Rename session-type to isolation-method in a parsed apps.json.
Definition at line 4796 of file process.cpp.
| void proc::onVDisplayWatchdogFailed | ( | ) |
Definition at line 1575 of file process.cpp.
| std::optional< proc::proc_t > proc::parse | ( | const std::string & | file_name, |
| bool | fallback_on_failure = true ) |
Load the applications from apps.json.
| file_name | The apps file. |
| fallback_on_failure | When the file can't be loaded, return the fallback Desktop and built-in entries (startup) instead of nothing (a reload, which keeps the current list). |
Definition at line 4864 of file process.cpp.
| std::string proc::parse_env_val | ( | boost::process::v1::native_environment & | env, |
| const std::string_view & | val_raw ) |
Definition at line 4350 of file process.cpp.
| void proc::refresh | ( | const std::string & | file_name, |
| bool | needs_terminate ) |
Definition at line 5251 of file process.cpp.
| session_route_e proc::resolve_session_route | ( | const ctx_t & | app, |
| bool | isolated_sessions_enabled, | ||
| bool | virtual_display_requested, | ||
| std::string_view | global_method = "gamescope" ) |
Resolve a launch to the host session or an independent private session.
An app's own isolation method always applies. An app on the default follows global_method when a virtual display is requested, unless its layout places that display on the host desktop. host-session apps always stay on the host.
Definition at line 179 of file process.cpp.
| void proc::terminate_process_group | ( | boost::process::v1::child & | proc, |
| boost::process::v1::group & | group, | ||
| std::chrono::seconds | exit_timeout ) |
Terminates all child processes in a process group.
| proc | The child process itself. |
| group | The group of all children in the process tree. |
| exit_timeout | The timeout to wait for the process group to gracefully exit. |
Definition at line 1611 of file process.cpp.
| std::string proc::validate_app_image_path | ( | std::string | app_image_path | ) |
Definition at line 4393 of file process.cpp.
| int proc::input_only_app_id = -1 |
Definition at line 96 of file process.cpp.
| std::string proc::input_only_app_id_str |
Definition at line 97 of file process.cpp.
| proc_t proc::proc |
Definition at line 94 of file process.cpp.
| int proc::terminate_app_id = -1 |
Definition at line 98 of file process.cpp.
| std::string proc::terminate_app_id_str |
Definition at line 99 of file process.cpp.
| VDISPLAY::DRIVER_STATUS proc::vDisplayDriverStatus = VDISPLAY::DRIVER_STATUS::UNKNOWN |
Definition at line 101 of file process.cpp.