12 #define __kernel_entry
17#include <unordered_map>
20#include <boost/process/v1.hpp>
32#define DEFAULT_APP_IMAGE_PATH SUNSHINE_ASSETS_DIR "/box.png"
100 boost::process::v1::environment &&env,
101 std::vector<
ctx_t> &&apps
104 _env(std::move(env)),
105 _apps(std::move(apps)) {
115 int execute(
int app_id, std::shared_ptr<rtsp_stream::launch_session_t> launch_session);
129 const std::vector<ctx_t> &
get_apps()
const;
158 std::vector<ctx_t> _apps;
160 std::chrono::steady_clock::time_point _app_launch_time;
165 boost::process::v1::child _process;
166 boost::process::v1::group _process_group;
169 std::vector<cmd_t>::const_iterator _app_prep_it;
170 std::vector<cmd_t>::const_iterator _app_prep_begin;
181 std::tuple<std::string, std::string>
calculate_app_id(
const std::string &app_name, std::string app_image_path,
int index);
196 void refresh(
const std::string &file_name);
203 std::optional<proc::proc_t>
parse(
const std::string &file_name);
209 std::unique_ptr<platf::deinit_t>
init();
217 void terminate_process_group(boost::process::v1::child &proc, boost::process::v1::group &group, std::chrono::seconds exit_timeout);
Tracks launched child processes and terminates them during shutdown.
Definition process.h:89
std::string get_app_image(int app_id)
Get app image.
Definition process.cpp:382
int running()
Definition process.cpp:285
void terminate()
Terminate the launched application process.
Definition process.cpp:321
int execute(int app_id, std::shared_ptr< rtsp_stream::launch_session_t > launch_session)
Launch the configured application process.
Definition process.cpp:151
std::string get_last_run_app_name()
Get last run app name.
Definition process.cpp:391
const std::vector< ctx_t > & get_apps() const
Return the configured applications.
Definition process.cpp:370
Unique pointer wrapper with customizable pointer and deleter types.
Definition utility.h:820
Declarations for common platform specific utilities.
int parse(int argc, char *argv[])
Parse serialized text into the corresponding runtime representation.
Definition config.cpp:1797
Declarations for the configuration of Sunshine.
std::unique_ptr< platf::deinit_t > init(const std::filesystem::path &persistence_filepath, const config::video_t &video_config)
Initialize the implementation and perform the initial state recovery (if needed).
Definition display_device.cpp:764
void refresh(const std::string &file_name)
Refresh cached platform state from the operating system.
Definition process.cpp:799
void 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.
Definition process.cpp:65
proc_t proc
Global process registry used to track and terminate child processes.
Definition process.cpp:46
bool check_valid_png(const std::filesystem::path &path)
Validates a path whether it is a valid PNG.
Definition process.cpp:499
std::tuple< std::string, std::string > 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 process.cpp:631
std::string validate_app_image_path(std::string app_image_path)
Validate app image path.
Definition process.cpp:531
Declarations for RTSP streaming.
External preparation command plus its privilege requirement.
Definition config.h:307
std::string id
Stable identifier for the configured application.
Definition process.h:79
std::string working_dir
Working dir.
Definition process.h:76
bool elevated
Whether the process should be launched elevated.
Definition process.h:80
bool wait_all
Whether Sunshine waits for all child processes.
Definition process.h:82
std::vector< cmd_t > prep_cmds
Prep cmds.
Definition process.h:58
std::chrono::seconds exit_timeout
Exit timeout.
Definition process.h:83
std::vector< std::string > detached
Definition process.h:72
std::string cmd
Command line used to launch the application.
Definition process.h:75
std::string image_path
Image path.
Definition process.h:78
std::string name
Human-readable name for this item.
Definition process.h:74
bool auto_detach
Whether the process should detach automatically.
Definition process.h:81
std::string output
Captured output from the launched process.
Definition process.h:77
Declarations for utility functions.
#define KITTY_DEFAULT_CONSTR_MOVE_THROW(x)
Declare defaulted move construction and assignment that may throw.
Definition utility.h:130