mirror of
https://github.com/LizardByte/Sunshine.git
synced 2025-08-10 00:52:16 +00:00
Merge branch 'nightly' into master
This commit is contained in:
@@ -75,7 +75,7 @@ auto control_shared = safe::make_shared<audio_ctx_t>(start_audio_control, stop_a
|
||||
void encodeThread(sample_queue_t samples, config_t config, void *channel_data) {
|
||||
auto packets = mail::man->queue<packet_t>(mail::audio_packets);
|
||||
|
||||
//FIXME: Pick correct opus_stream_config_t based on config.channels
|
||||
// FIXME: Pick correct opus_stream_config_t based on config.channels
|
||||
auto stream = &stream_configs[map_stream(config.channels, config.flags[config_t::HIGH_QUALITY])];
|
||||
|
||||
opus_t opus { opus_multistream_encoder_create(
|
||||
@@ -120,7 +120,7 @@ void encodeThread(sample_queue_t samples, config_t config, void *channel_data) {
|
||||
void capture(safe::mail_t mail, config_t config, void *channel_data) {
|
||||
auto shutdown_event = mail->event<bool>(mail::shutdown);
|
||||
|
||||
//FIXME: Pick correct opus_stream_config_t based on config.channels
|
||||
// FIXME: Pick correct opus_stream_config_t based on config.channels
|
||||
auto stream = &stream_configs[map_stream(config.channels, config.flags[config_t::HIGH_QUALITY])];
|
||||
|
||||
auto ref = control_shared.ref();
|
||||
@@ -135,7 +135,7 @@ void capture(safe::mail_t mail, config_t config, void *channel_data) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Order of priorty:
|
||||
// Order of priority:
|
||||
// 1. Config
|
||||
// 2. Virtual if available
|
||||
// 3. Host
|
||||
@@ -162,8 +162,14 @@ void capture(safe::mail_t mail, config_t config, void *channel_data) {
|
||||
if(!ref->sink_flag->exchange(true, std::memory_order_acquire)) {
|
||||
ref->restore_sink = !config.flags[config_t::HOST_AUDIO];
|
||||
|
||||
// If the sink is empty (Host has no sink!), definately switch to the virtual.
|
||||
if(ref->sink.host.empty()) {
|
||||
if(control->set_sink(*sink)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// If the client requests audio on the host, don't change the default sink
|
||||
if(!config.flags[config_t::HOST_AUDIO] && control->set_sink(*sink)) {
|
||||
else if(!config.flags[config_t::HOST_AUDIO] && control->set_sink(*sink)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,9 +124,9 @@ util::buffer_t<std::uint8_t> make_sps_h264(const AVCodecContext *ctx) {
|
||||
sps.seq_parameter_set_id = 0;
|
||||
sps.chroma_format_idc = 1;
|
||||
|
||||
sps.log2_max_frame_num_minus4 = 3; //4;
|
||||
sps.log2_max_frame_num_minus4 = 3; // 4;
|
||||
sps.pic_order_cnt_type = 0;
|
||||
sps.log2_max_pic_order_cnt_lsb_minus4 = 0; //4;
|
||||
sps.log2_max_pic_order_cnt_lsb_minus4 = 0; // 4;
|
||||
|
||||
sps.max_num_ref_frames = dpb_frame;
|
||||
|
||||
@@ -297,4 +297,4 @@ bool validate_sps(const AVPacket *packet, int codec_id) {
|
||||
|
||||
return ((CodedBitstreamH265Context *)ctx->priv_data)->active_sps->vui_parameters_present_flag;
|
||||
}
|
||||
} // namespace cbs
|
||||
} // namespace cbs
|
||||
|
||||
@@ -31,4 +31,4 @@ h264_t make_sps_h264(const AVCodecContext *ctx, const AVPacket *packet);
|
||||
bool validate_sps(const AVPacket *packet, int codec_id);
|
||||
} // namespace cbs
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <unordered_map>
|
||||
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include "config.h"
|
||||
#include "main.h"
|
||||
@@ -104,14 +105,14 @@ enum quality_e : int {
|
||||
enum class rc_hevc_e : int {
|
||||
constqp, /**< Constant QP mode */
|
||||
vbr_latency, /**< Latency Constrained Variable Bitrate */
|
||||
vbr_peak, /**< Peak Contrained Variable Bitrate */
|
||||
vbr_peak, /**< Peak Constrained Variable Bitrate */
|
||||
cbr, /**< Constant bitrate mode */
|
||||
};
|
||||
|
||||
enum class rc_h264_e : int {
|
||||
constqp, /**< Constant QP mode */
|
||||
cbr, /**< Constant bitrate mode */
|
||||
vbr_peak, /**< Peak Contrained Variable Bitrate */
|
||||
vbr_peak, /**< Peak Constrained Variable Bitrate */
|
||||
vbr_latency, /**< Latency Constrained Variable Bitrate */
|
||||
};
|
||||
|
||||
@@ -702,7 +703,7 @@ int apply_flags(const char *line) {
|
||||
|
||||
void apply_config(std::unordered_map<std::string, std::string> &&vars) {
|
||||
if(!fs::exists(stream.file_apps.c_str())) {
|
||||
fs::copy_file(SUNSHINE_CONFIG_DIR "/apps.json", stream.file_apps);
|
||||
fs::copy_file(SUNSHINE_ASSETS_DIR "/apps.json", stream.file_apps);
|
||||
}
|
||||
|
||||
for(auto &[name, val] : vars) {
|
||||
@@ -910,8 +911,14 @@ int parse(int argc, char *argv[]) {
|
||||
}
|
||||
}
|
||||
|
||||
// create appdata folder if it does not exist
|
||||
if(!boost::filesystem::exists(platf::appdata().string())) {
|
||||
boost::filesystem::create_directory(platf::appdata().string());
|
||||
}
|
||||
|
||||
// create config file if it does not exist
|
||||
if(!fs::exists(sunshine.config_file)) {
|
||||
fs::copy_file(SUNSHINE_CONFIG_DIR "/sunshine.conf", sunshine.config_file);
|
||||
std::ofstream { sunshine.config_file }; // create empty config file
|
||||
}
|
||||
|
||||
auto vars = parse_config(read_file(sunshine.config_file.c_str()));
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
//
|
||||
// Created by TheElixZammuto on 2021-05-09.
|
||||
// TODO: Authentication, better handling of routes common to nvhttp, cleanup
|
||||
|
||||
@@ -92,7 +91,7 @@ bool authenticate(resp_https_t response, req_https_t request) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//If credentials are shown, redirect the user to a /welcome page
|
||||
// If credentials are shown, redirect the user to a /welcome page
|
||||
if(config::sunshine.username.empty()) {
|
||||
send_redirect(response, request, "/welcome");
|
||||
return false;
|
||||
@@ -314,7 +313,7 @@ void saveApp(resp_https_t response, req_https_t request) {
|
||||
|
||||
BOOST_LOG(fatal) << config::stream.file_apps;
|
||||
try {
|
||||
//TODO: Input Validation
|
||||
// TODO: Input Validation
|
||||
pt::read_json(ss, inputTree);
|
||||
pt::read_json(config::stream.file_apps, fileTree);
|
||||
|
||||
@@ -335,7 +334,7 @@ void saveApp(resp_https_t response, req_https_t request) {
|
||||
apps_node.push_back(std::make_pair("", inputTree));
|
||||
}
|
||||
else {
|
||||
//Unfortuantely Boost PT does not allow to directly edit the array, copy should do the trick
|
||||
// Unfortunately Boost PT does not allow to directly edit the array, copy should do the trick
|
||||
pt::ptree newApps;
|
||||
int i = 0;
|
||||
for(const auto &kv : apps_node) {
|
||||
@@ -388,7 +387,7 @@ void deleteApp(resp_https_t response, req_https_t request) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
//Unfortuantely Boost PT does not allow to directly edit the array, copy should do the trick
|
||||
// Unfortunately Boost PT does not allow to directly edit the array, copy should do the trick
|
||||
pt::ptree newApps;
|
||||
int i = 0;
|
||||
for(const auto &kv : apps_node) {
|
||||
@@ -452,7 +451,7 @@ void saveConfig(resp_https_t response, req_https_t request) {
|
||||
});
|
||||
pt::ptree inputTree;
|
||||
try {
|
||||
//TODO: Input Validation
|
||||
// TODO: Input Validation
|
||||
pt::read_json(ss, inputTree);
|
||||
for(const auto &kv : inputTree) {
|
||||
std::string value = inputTree.get<std::string>(kv.first);
|
||||
@@ -488,7 +487,7 @@ void savePassword(resp_https_t response, req_https_t request) {
|
||||
});
|
||||
|
||||
try {
|
||||
//TODO: Input Validation
|
||||
// TODO: Input Validation
|
||||
pt::read_json(ss, inputTree);
|
||||
auto username = inputTree.count("currentUsername") > 0 ? inputTree.get<std::string>("currentUsername") : "";
|
||||
auto newUsername = inputTree.get<std::string>("newUsername");
|
||||
@@ -544,7 +543,7 @@ void savePin(resp_https_t response, req_https_t request) {
|
||||
});
|
||||
|
||||
try {
|
||||
//TODO: Input Validation
|
||||
// TODO: Input Validation
|
||||
pt::read_json(ss, inputTree);
|
||||
std::string pin = inputTree.get<std::string>("pin");
|
||||
outputTree.put("status", nvhttp::pin(pin));
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//
|
||||
// Created by loki on 6/3/19.
|
||||
//
|
||||
|
||||
#ifndef SUNSHINE_CONFIGHTTP_H
|
||||
#define SUNSHINE_CONFIGHTTP_H
|
||||
@@ -18,4 +16,4 @@ constexpr auto PORT_HTTPS = 1;
|
||||
void start();
|
||||
} // namespace confighttp
|
||||
|
||||
#endif //SUNSHINE_CONFIGHTTP_H
|
||||
#endif // SUNSHINE_CONFIGHTTP_H
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
//
|
||||
// Created by loki on 5/31/19.
|
||||
//
|
||||
|
||||
#include "crypto.h"
|
||||
#include <openssl/pem.h>
|
||||
|
||||
namespace crypto {
|
||||
using big_num_t = util::safe_ptr<BIGNUM, BN_free>;
|
||||
//using rsa_t = util::safe_ptr<RSA, RSA_free>;
|
||||
// using rsa_t = util::safe_ptr<RSA, RSA_free>;
|
||||
using asn1_string_t = util::safe_ptr<ASN1_STRING, ASN1_STRING_free>;
|
||||
|
||||
cert_chain_t::cert_chain_t() : _certs {}, _cert_ctx { X509_STORE_CTX_new() } {}
|
||||
@@ -22,7 +20,7 @@ static int openssl_verify_cb(int ok, X509_STORE_CTX *ctx) {
|
||||
int err_code = X509_STORE_CTX_get_error(ctx);
|
||||
|
||||
switch(err_code) {
|
||||
//FIXME: Checking for X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY is a temporary workaround to get mmonlight-embedded to work on the raspberry pi
|
||||
// FIXME: Checking for X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY is a temporary workaround to get mmonlight-embedded to work on the raspberry pi
|
||||
case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY:
|
||||
return 1;
|
||||
|
||||
@@ -274,7 +272,7 @@ int cbc_t::encrypt(const std::string_view &plaintext, std::uint8_t *cipher, aes_
|
||||
|
||||
int len;
|
||||
|
||||
int size = plaintext.size(); //round_to_pkcs7_padded(plaintext.size());
|
||||
int size = plaintext.size(); // round_to_pkcs7_padded(plaintext.size());
|
||||
|
||||
// Encrypt into the caller's buffer
|
||||
if(EVP_EncryptUpdate(encrypt_ctx.get(), cipher, &size, (const std::uint8_t *)plaintext.data(), plaintext.size()) != 1) {
|
||||
@@ -492,4 +490,4 @@ std::string rand_alphabet(std::size_t bytes, const std::string_view &alphabet) {
|
||||
return value;
|
||||
}
|
||||
|
||||
} // namespace crypto
|
||||
} // namespace crypto
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//
|
||||
// Created by loki on 6/1/19.
|
||||
//
|
||||
|
||||
#ifndef SUNSHINE_CRYPTO_H
|
||||
#define SUNSHINE_CRYPTO_H
|
||||
|
||||
@@ -44,7 +44,7 @@ int init() {
|
||||
|
||||
if(clean_slate) {
|
||||
unique_id = util::uuid_t::generate().string();
|
||||
auto dir = std::filesystem::temp_directory_path() / "Sushine"sv;
|
||||
auto dir = std::filesystem::temp_directory_path() / "Sunshine"sv;
|
||||
config::nvhttp.cert = (dir / ("cert-"s + unique_id)).string();
|
||||
config::nvhttp.pkey = (dir / ("pkey-"s + unique_id)).string();
|
||||
}
|
||||
@@ -180,4 +180,4 @@ int create_creds(const std::string &pkey, const std::string &cert) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
} // namespace http
|
||||
} // namespace http
|
||||
|
||||
@@ -16,4 +16,4 @@ extern std::string unique_id;
|
||||
extern net::net_e origin_pin_allowed;
|
||||
extern net::net_e origin_web_ui_allowed;
|
||||
|
||||
} // namespace http
|
||||
} // namespace http
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//
|
||||
// Created by loki on 6/20/19.
|
||||
//
|
||||
|
||||
// define uint32_t for <moonlight-common-c/src/Input.h>
|
||||
#include <cstdint>
|
||||
@@ -89,7 +87,7 @@ struct gamepad_t {
|
||||
|
||||
// When emulating the HOME button, we may need to artificially release the back button.
|
||||
// Afterwards, the gamepad state on sunshine won't match the state on Moonlight.
|
||||
// To prevent Sunshine from sending erronious input data to the active application,
|
||||
// To prevent Sunshine from sending erroneous input data to the active application,
|
||||
// Sunshine forces the button to be in a specific state until the gamepad state matches that of
|
||||
// Moonlight once more.
|
||||
button_state_e back_button_state;
|
||||
@@ -316,11 +314,11 @@ void passthrough(std::shared_ptr<input_t> &input, PNV_MOUSE_BUTTON_PACKET packet
|
||||
/*/
|
||||
* When Moonlight sends mouse input through absolute coordinates,
|
||||
* it's possible that BUTTON_RIGHT is pressed down immediately after releasing BUTTON_LEFT.
|
||||
* As a result, Sunshine will left click on hyperlinks in the browser before right clicking
|
||||
* As a result, Sunshine will left-click on hyperlinks in the browser before right-clicking
|
||||
*
|
||||
* This can be solved by delaying BUTTON_LEFT, however, any delay on input is undesirable during gaming
|
||||
* As a compromise, Sunshine will only put delays on BUTTON_LEFT when
|
||||
* absolute mouse coordinates have been send.
|
||||
* absolute mouse coordinates have been sent.
|
||||
*
|
||||
* Try to make sure BUTTON_RIGHT gets called before BUTTON_LEFT is released.
|
||||
*
|
||||
@@ -428,7 +426,7 @@ void passthrough(std::shared_ptr<input_t> &input, PNV_KEYBOARD_PACKET packet) {
|
||||
if(!pressed) {
|
||||
if(!release) {
|
||||
// A new key has been pressed down, we need to check for key combo's
|
||||
// If a keycombo has been pressed down, don't pass it through
|
||||
// If a key-combo has been pressed down, don't pass it through
|
||||
if(input->shortcutFlags == input_t::SHORTCUT && apply_shortcut(keyCode) > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//
|
||||
// Created by loki on 6/20/19.
|
||||
//
|
||||
|
||||
#ifndef SUNSHINE_INPUT_H
|
||||
#define SUNSHINE_INPUT_H
|
||||
@@ -32,4 +30,4 @@ struct touch_port_t : public platf::touch_port_t {
|
||||
};
|
||||
} // namespace input
|
||||
|
||||
#endif //SUNSHINE_INPUT_H
|
||||
#endif // SUNSHINE_INPUT_H
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//
|
||||
// Created by loki on 5/30/19.
|
||||
//
|
||||
|
||||
#include "process.h"
|
||||
|
||||
@@ -289,7 +287,7 @@ int main(int argc, char *argv[]) {
|
||||
upnp_unmap = upnp::start();
|
||||
});
|
||||
|
||||
//FIXME: Temporary workaround: Simple-Web_server needs to be updated or replaced
|
||||
// FIXME: Temporary workaround: Simple-Web_server needs to be updated or replaced
|
||||
if(shutdown_event->peek()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//
|
||||
// Created by loki on 12/22/19.
|
||||
//
|
||||
|
||||
#ifndef SUNSHINE_MAIN_H
|
||||
#define SUNSHINE_MAIN_H
|
||||
@@ -54,4 +52,4 @@ MAIL(rumble);
|
||||
} // namespace mail
|
||||
|
||||
|
||||
#endif //SUNSHINE_MAIN_H
|
||||
#endif // SUNSHINE_MAIN_H
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//
|
||||
// Created by loki on 12/27/19.
|
||||
//
|
||||
|
||||
#include "network.h"
|
||||
#include "utility.h"
|
||||
@@ -112,4 +110,4 @@ void free_host(ENetHost *host) {
|
||||
|
||||
enet_host_destroy(host);
|
||||
}
|
||||
} // namespace net
|
||||
} // namespace net
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//
|
||||
// Created by loki on 12/27/19.
|
||||
//
|
||||
|
||||
#ifndef SUNSHINE_NETWORK_H
|
||||
#define SUNSHINE_NETWORK_H
|
||||
@@ -32,4 +30,4 @@ net_e from_address(const std::string_view &view);
|
||||
host_t host_create(ENetAddress &addr, std::size_t peers, std::uint16_t port);
|
||||
} // namespace net
|
||||
|
||||
#endif //SUNSHINE_NETWORK_H
|
||||
#endif // SUNSHINE_NETWORK_H
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//
|
||||
// Created by loki on 6/3/19.
|
||||
//
|
||||
|
||||
#define BOOST_BIND_GLOBAL_PLACEHOLDERS
|
||||
|
||||
@@ -297,7 +295,7 @@ void clientpairingsecret(std::shared_ptr<safe::queue_t<crypto::x509_t>> &add_cer
|
||||
|
||||
// if hash not correct, probably MITM
|
||||
if(std::memcmp(hash.data(), sess.clienthash.data(), hash.size())) {
|
||||
//TODO: log
|
||||
// TODO: log
|
||||
|
||||
map_id_sess.erase(client.uniqueID);
|
||||
tree.put("root.paired", 0);
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//
|
||||
// Created by loki on 6/3/19.
|
||||
//
|
||||
|
||||
#ifndef SUNSHINE_NVHTTP_H
|
||||
#define SUNSHINE_NVHTTP_H
|
||||
@@ -17,4 +15,4 @@ bool pin(std::string pin);
|
||||
void erase_all_clients();
|
||||
} // namespace nvhttp
|
||||
|
||||
#endif //SUNSHINE_NVHTTP_H
|
||||
#endif // SUNSHINE_NVHTTP_H
|
||||
|
||||
@@ -343,12 +343,7 @@ public:
|
||||
}
|
||||
|
||||
auto sink_name = get_default_sink_name();
|
||||
if(sink_name.empty()) {
|
||||
BOOST_LOG(warning) << "Couldn't find an active sink"sv;
|
||||
}
|
||||
else {
|
||||
sink.host = sink_name;
|
||||
}
|
||||
sink.host = sink_name;
|
||||
|
||||
if(index.stereo == PA_INVALID_INDEX) {
|
||||
index.stereo = load_null(stereo, speaker::map_stereo, sizeof(speaker::map_stereo));
|
||||
@@ -380,6 +375,10 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
if(sink_name.empty()) {
|
||||
BOOST_LOG(warning) << "Couldn't find an active default sink. Continuing with virtual audio only."sv;
|
||||
}
|
||||
|
||||
if(nullcount == 3) {
|
||||
sink.null = std::make_optional(sink_t::null_t { stereo, surround51, surround71 });
|
||||
}
|
||||
@@ -388,8 +387,8 @@ public:
|
||||
}
|
||||
|
||||
std::string get_default_sink_name() {
|
||||
std::string sink_name = "@DEFAULT_SINK@"s;
|
||||
auto alarm = safe::make_alarm<int>();
|
||||
std::string sink_name;
|
||||
auto alarm = safe::make_alarm<int>();
|
||||
|
||||
cb_simple_t<pa_server_info *> server_f = [&](ctx_t::pointer ctx, const pa_server_info *server_info) {
|
||||
if(!server_info) {
|
||||
@@ -397,7 +396,9 @@ public:
|
||||
alarm->ring(-1);
|
||||
}
|
||||
|
||||
sink_name = server_info->default_sink_name;
|
||||
if(server_info->default_sink_name) {
|
||||
sink_name = server_info->default_sink_name;
|
||||
}
|
||||
alarm->ring(0);
|
||||
};
|
||||
|
||||
@@ -408,8 +409,12 @@ public:
|
||||
}
|
||||
|
||||
std::string get_monitor_name(const std::string &sink_name) {
|
||||
std::string monitor_name = "@DEFAULT_MONITOR@"s;
|
||||
auto alarm = safe::make_alarm<int>();
|
||||
std::string monitor_name;
|
||||
auto alarm = safe::make_alarm<int>();
|
||||
|
||||
if(sink_name.empty()) {
|
||||
return monitor_name;
|
||||
}
|
||||
|
||||
cb_t<pa_sink_info *> sink_f = [&](ctx_t::pointer ctx, const pa_sink_info *sink_info, int eol) {
|
||||
if(!sink_info) {
|
||||
|
||||
@@ -167,7 +167,7 @@ static std::uint32_t from_view(const std::string_view &string) {
|
||||
_CONVERT("eDP"sv, eDP);
|
||||
_CONVERT("DSI"sv, DSI);
|
||||
|
||||
BOOST_LOG(error) << "Unknown Monitor connector type ["sv << string << "]: Please report this to the Github issue tracker"sv;
|
||||
BOOST_LOG(error) << "Unknown Monitor connector type ["sv << string << "]: Please report this to the GitHub issue tracker"sv;
|
||||
return DRM_MODE_CONNECTOR_Unknown;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//
|
||||
// Created by loki on 12/14/19.
|
||||
//
|
||||
|
||||
#define BOOST_BIND_GLOBAL_PLACEHOLDERS
|
||||
|
||||
@@ -47,7 +45,7 @@ int exe(const std::string &cmd, bp::environment &env, file_t &file, std::error_c
|
||||
|
||||
int proc_t::execute(int app_id) {
|
||||
if(!running() && _app_id != -1) {
|
||||
// previous process exited on it's own, reset _process_handle
|
||||
// previous process exited on its own, reset _process_handle
|
||||
_process_handle = bp::group();
|
||||
|
||||
_app_id = -1;
|
||||
@@ -73,7 +71,7 @@ int proc_t::execute(int app_id) {
|
||||
}
|
||||
|
||||
std::error_code ec;
|
||||
//Executed when returning from function
|
||||
// Executed when returning from function
|
||||
auto fg = util::fail_guard([&]() {
|
||||
terminate();
|
||||
});
|
||||
@@ -193,9 +191,10 @@ std::vector<ctx_t> &proc_t::get_apps() {
|
||||
return _apps;
|
||||
}
|
||||
|
||||
/// Gets application image from application list.
|
||||
/// Returns default image if image configuration is not set.
|
||||
/// returns http content-type header compatible image type
|
||||
// Gets application image from application list.
|
||||
// Returns image from assets directory if found there.
|
||||
// Returns default image if image configuration is not set.
|
||||
// Returns http content-type header compatible image type.
|
||||
std::string proc_t::get_app_image(int app_id) {
|
||||
auto app_index = app_id - 1;
|
||||
if(app_index < 0 || app_index >= _apps.size()) {
|
||||
@@ -203,20 +202,41 @@ std::string proc_t::get_app_image(int app_id) {
|
||||
return SUNSHINE_ASSETS_DIR "/box.png";
|
||||
}
|
||||
|
||||
auto default_image = SUNSHINE_ASSETS_DIR "/box.png";
|
||||
auto app_image_path = _apps[app_index].image_path;
|
||||
if(app_image_path.empty()) {
|
||||
return SUNSHINE_ASSETS_DIR "/box.png";
|
||||
// image is empty, return default box image
|
||||
return default_image;
|
||||
}
|
||||
|
||||
// get the image extension and convert it to lowercase
|
||||
auto image_extension = std::filesystem::path(app_image_path).extension().string();
|
||||
boost::to_lower(image_extension);
|
||||
|
||||
std::error_code code;
|
||||
if(!std::filesystem::exists(app_image_path, code) || image_extension != ".png") {
|
||||
return SUNSHINE_ASSETS_DIR "/box.png";
|
||||
// return the default box image if extension is not "png"
|
||||
if(image_extension != ".png") {
|
||||
return default_image;
|
||||
}
|
||||
|
||||
// return only "content-type" http header compatible image type.
|
||||
// check if image is in assets directory
|
||||
auto full_image_path = std::filesystem::path(SUNSHINE_ASSETS_DIR) / app_image_path;
|
||||
if(std::filesystem::exists(full_image_path)) {
|
||||
return full_image_path.string();
|
||||
}
|
||||
else if(app_image_path == "./assets/steam.png") {
|
||||
// handle old default steam image definition
|
||||
return SUNSHINE_ASSETS_DIR "/steam.png";
|
||||
}
|
||||
|
||||
// check if specified image exists
|
||||
std::error_code code;
|
||||
if(!std::filesystem::exists(app_image_path, code)) {
|
||||
// return default box image if image does not exist
|
||||
return default_image;
|
||||
}
|
||||
|
||||
// image is a png, and not in assets directory
|
||||
// return only "content-type" http header compatible image type
|
||||
return app_image_path;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//
|
||||
// Created by loki on 12/14/19.
|
||||
//
|
||||
|
||||
#ifndef SUNSHINE_PROCESS_H
|
||||
#define SUNSHINE_PROCESS_H
|
||||
@@ -105,4 +103,4 @@ std::optional<proc::proc_t> parse(const std::string &file_name);
|
||||
|
||||
extern proc_t proc;
|
||||
} // namespace proc
|
||||
#endif //SUNSHINE_PROCESS_H
|
||||
#endif // SUNSHINE_PROCESS_H
|
||||
|
||||
16
src/rtsp.cpp
16
src/rtsp.cpp
@@ -1,6 +1,4 @@
|
||||
//
|
||||
// Created by loki on 2/2/20.
|
||||
//
|
||||
|
||||
#define BOOST_BIND_GLOBAL_PLACEHOLDERS
|
||||
|
||||
@@ -123,7 +121,7 @@ public:
|
||||
socket->read_payload();
|
||||
});
|
||||
|
||||
auto content_lenght = 0;
|
||||
auto content_length = 0;
|
||||
for(auto option = req->options; option != nullptr; option = option->next) {
|
||||
if("Content-length"sv == option->option) {
|
||||
BOOST_LOG(debug) << "Found Content-Length: "sv << option->content << " bytes"sv;
|
||||
@@ -133,14 +131,14 @@ public:
|
||||
std::string_view content { option->content };
|
||||
auto begin = std::find_if(std::begin(content), std::end(content), [](auto ch) { return (bool)std::isdigit(ch); });
|
||||
|
||||
content_lenght = util::from_chars(begin, std::end(content));
|
||||
content_length = util::from_chars(begin, std::end(content));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(end - socket->crlf >= content_lenght) {
|
||||
if(end - socket->crlf > content_lenght) {
|
||||
BOOST_LOG(warning) << "(end - socket->crlf) > content_lenght -- "sv << (std::size_t)(end - socket->crlf) << " > "sv << content_lenght;
|
||||
if(end - socket->crlf >= content_length) {
|
||||
if(end - socket->crlf > content_length) {
|
||||
BOOST_LOG(warning) << "(end - socket->crlf) > content_length -- "sv << (std::size_t)(end - socket->crlf) << " > "sv << content_length;
|
||||
}
|
||||
|
||||
fg.disable();
|
||||
@@ -271,7 +269,7 @@ public:
|
||||
if(ec) {
|
||||
BOOST_LOG(error) << "Couldn't accept incoming connections: "sv << ec.message();
|
||||
|
||||
//Stop server
|
||||
// Stop server
|
||||
clear();
|
||||
return;
|
||||
}
|
||||
@@ -380,7 +378,7 @@ void launch_session_raise(launch_session_t launch_session) {
|
||||
}
|
||||
|
||||
int session_count() {
|
||||
// Ensure session_count is up to date
|
||||
// Ensure session_count is up-to-date
|
||||
server.clear(false);
|
||||
|
||||
return server.session_count();
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//
|
||||
// Created by loki on 2/2/20.
|
||||
//
|
||||
|
||||
#ifndef SUNSHINE_RTSP_H
|
||||
#define SUNSHINE_RTSP_H
|
||||
@@ -27,4 +25,4 @@ void rtpThread();
|
||||
|
||||
} // namespace stream
|
||||
|
||||
#endif //SUNSHINE_RTSP_H
|
||||
#endif // SUNSHINE_RTSP_H
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//
|
||||
// Created by loki on 6/5/19.
|
||||
//
|
||||
|
||||
#include "process.h"
|
||||
|
||||
@@ -240,11 +238,10 @@ struct broadcast_ctx_t {
|
||||
udp::socket video_sock { io };
|
||||
udp::socket audio_sock { io };
|
||||
|
||||
// This is purely for adminitrative purposes.
|
||||
//
|
||||
// It's possible two instances of Moonlight are behind a NAT.
|
||||
// From Sunshine's point of view, the ip addresses are identical
|
||||
// We need some way to know what ports are already used for different streams
|
||||
// This is purely for administrative purposes.
|
||||
// It's possible two instances of Moonlight are behind a NAT.
|
||||
// From Sunshine's point of view, the ip addresses are identical
|
||||
// We need some way to know what ports are already used for different streams
|
||||
util::sync_t<std::vector<std::pair<std::string, std::uint16_t>>> audio_video_connections;
|
||||
|
||||
control_server_t control_server;
|
||||
@@ -767,7 +764,7 @@ void controlBroadcastThread(control_server_t *server) {
|
||||
}
|
||||
|
||||
// Let all remaining connections know the server is shutting down
|
||||
// reason: gracefull termination
|
||||
// reason: graceful termination
|
||||
std::uint32_t reason = 0x80030023;
|
||||
|
||||
control_terminate_t plaintext;
|
||||
@@ -932,7 +929,7 @@ void videoBroadcastThread(udp::socket &sock) {
|
||||
|
||||
// With a fecpercentage of 255, if payload_new is broken up into more than a 100 data_shards
|
||||
// it will generate greater than DATA_SHARDS_MAX shards.
|
||||
// Therefore, we start breaking the data up into three seperate fec blocks.
|
||||
// Therefore, we start breaking the data up into three separate fec blocks.
|
||||
auto multi_fec_threshold = 90 * blocksize;
|
||||
|
||||
// We can go up to 4 fec blocks, but 3 is plenty
|
||||
@@ -1331,7 +1328,7 @@ void join(session_t &session) {
|
||||
session.audioThread.join();
|
||||
BOOST_LOG(debug) << "Waiting for control to end..."sv;
|
||||
session.controlEnd.view();
|
||||
//Reset input on session stop to avoid stuck repeated keys
|
||||
// Reset input on session stop to avoid stuck repeated keys
|
||||
BOOST_LOG(debug) << "Resetting Input..."sv;
|
||||
input::reset(session.input);
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//
|
||||
// Created by loki on 6/5/19.
|
||||
//
|
||||
|
||||
#ifndef SUNSHINE_STREAM_H
|
||||
#define SUNSHINE_STREAM_H
|
||||
@@ -45,4 +43,4 @@ state_e state(session_t &session);
|
||||
} // namespace session
|
||||
} // namespace stream
|
||||
|
||||
#endif //SUNSHINE_STREAM_H
|
||||
#endif // SUNSHINE_STREAM_H
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//
|
||||
// Created by loki on 16-4-19.
|
||||
//
|
||||
|
||||
#ifndef SUNSHINE_SYNC_H
|
||||
#define SUNSHINE_SYNC_H
|
||||
@@ -92,4 +90,4 @@ private:
|
||||
} // namespace util
|
||||
|
||||
|
||||
#endif //T_MAN_SYNC_H
|
||||
#endif // SUNSHINE_SYNC_H
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace util {
|
||||
|
||||
class _ImplBase {
|
||||
public:
|
||||
//_unique_base_type _this_ptr;
|
||||
// _unique_base_type _this_ptr;
|
||||
|
||||
inline virtual ~_ImplBase() = default;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
namespace util {
|
||||
/*
|
||||
* Allow threads to execute unhindered
|
||||
* while keeping full controll over the threads.
|
||||
* while keeping full control over the threads.
|
||||
*/
|
||||
class ThreadPool : public TaskPool {
|
||||
public:
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//
|
||||
// Created by loki on 6/10/19.
|
||||
//
|
||||
|
||||
#ifndef SUNSHINE_THREAD_SAFE_H
|
||||
#define SUNSHINE_THREAD_SAFE_H
|
||||
@@ -37,7 +35,7 @@ public:
|
||||
_cv.notify_all();
|
||||
}
|
||||
|
||||
// pop and view shoud not be used interchangebly
|
||||
// pop and view shoud not be used interchangeably
|
||||
status_t pop() {
|
||||
std::unique_lock ul { _lock };
|
||||
|
||||
@@ -58,7 +56,7 @@ public:
|
||||
return val;
|
||||
}
|
||||
|
||||
// pop and view shoud not be used interchangebly
|
||||
// pop and view shoud not be used interchangeably
|
||||
template<class Rep, class Period>
|
||||
status_t pop(std::chrono::duration<Rep, Period> delay) {
|
||||
std::unique_lock ul { _lock };
|
||||
@@ -78,7 +76,7 @@ public:
|
||||
return val;
|
||||
}
|
||||
|
||||
// pop and view shoud not be used interchangebly
|
||||
// pop and view shoud not be used interchangeably
|
||||
const status_t &view() {
|
||||
std::unique_lock ul { _lock };
|
||||
|
||||
@@ -508,4 +506,4 @@ inline void cleanup(mail_raw_t *mail) {
|
||||
}
|
||||
} // namespace safe
|
||||
|
||||
#endif //SUNSHINE_THREAD_SAFE_H
|
||||
#endif // SUNSHINE_THREAD_SAFE_H
|
||||
|
||||
@@ -181,4 +181,4 @@ std::unique_ptr<platf::deinit_t> start() {
|
||||
|
||||
return std::make_unique<deinit_t>(std::move(urls), data, std::move(mappings));
|
||||
}
|
||||
} // namespace upnp
|
||||
} // namespace upnp
|
||||
|
||||
@@ -7,4 +7,4 @@ namespace upnp {
|
||||
[[nodiscard]] std::unique_ptr<platf::deinit_t> start();
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//
|
||||
// Created by loki on 8-2-19.
|
||||
//
|
||||
|
||||
#ifndef T_MAN_UUID_H
|
||||
#define T_MAN_UUID_H
|
||||
@@ -76,4 +74,4 @@ union uuid_t {
|
||||
}
|
||||
};
|
||||
} // namespace util
|
||||
#endif //T_MAN_UUID_H
|
||||
#endif // T_MAN_UUID_H
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//
|
||||
// Created by loki on 6/6/19.
|
||||
//
|
||||
|
||||
#include <atomic>
|
||||
#include <bitset>
|
||||
@@ -225,7 +223,7 @@ public:
|
||||
|
||||
~swdevice_t() override {}
|
||||
|
||||
// Store ownsership when frame is hw_frame
|
||||
// Store ownership when frame is hw_frame
|
||||
frame_t hw_frame;
|
||||
|
||||
frame_t sw_frame;
|
||||
@@ -239,7 +237,7 @@ public:
|
||||
enum flag_e {
|
||||
DEFAULT = 0x00,
|
||||
PARALLEL_ENCODING = 0x01,
|
||||
H264_ONLY = 0x02, // When HEVC is to heavy
|
||||
H264_ONLY = 0x02, // When HEVC is too heavy
|
||||
LIMITED_GOP_SIZE = 0x04, // Some encoders don't like it when you have an infinite GOP_SIZE. *cough* VAAPI *cough*
|
||||
SINGLE_SLICE_ONLY = 0x08, // Never use multiple slices <-- Older intel iGPU's ruin it for everyone else :P
|
||||
};
|
||||
@@ -1622,12 +1620,7 @@ retry:
|
||||
}
|
||||
|
||||
int init() {
|
||||
BOOST_LOG(info) << "//////////////////////////////////////////////////////////////////"sv;
|
||||
BOOST_LOG(info) << "// //"sv;
|
||||
BOOST_LOG(info) << "// Testing for available encoders, this may generate errors. //"sv;
|
||||
BOOST_LOG(info) << "// You can safely ignore those errors. //"sv;
|
||||
BOOST_LOG(info) << "// //"sv;
|
||||
BOOST_LOG(info) << "//////////////////////////////////////////////////////////////////"sv;
|
||||
BOOST_LOG(info) << "// Testing for available encoders, this may generate errors. You can safely ignore those errors. //"sv;
|
||||
|
||||
KITTY_WHILE_LOOP(auto pos = std::begin(encoders), pos != std::end(encoders), {
|
||||
if(
|
||||
@@ -1643,11 +1636,7 @@ int init() {
|
||||
})
|
||||
|
||||
BOOST_LOG(info);
|
||||
BOOST_LOG(info) << "//////////////////////////////////////////////////////////////"sv;
|
||||
BOOST_LOG(info) << "// //"sv;
|
||||
BOOST_LOG(info) << "// Ignore any errors mentioned above, they are not relevant //"sv;
|
||||
BOOST_LOG(info) << "// //"sv;
|
||||
BOOST_LOG(info) << "//////////////////////////////////////////////////////////////"sv;
|
||||
BOOST_LOG(info) << "// Ignore any errors mentioned above, they are not relevant. //"sv;
|
||||
BOOST_LOG(info);
|
||||
|
||||
if(encoders.empty()) {
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//
|
||||
// Created by loki on 6/9/19.
|
||||
//
|
||||
|
||||
#ifndef SUNSHINE_VIDEO_H
|
||||
#define SUNSHINE_VIDEO_H
|
||||
@@ -84,4 +82,4 @@ void capture(
|
||||
int init();
|
||||
} // namespace video
|
||||
|
||||
#endif //SUNSHINE_VIDEO_H
|
||||
#endif // SUNSHINE_VIDEO_H
|
||||
|
||||
Reference in New Issue
Block a user