fix typos and comment formatting

This commit is contained in:
ReenigneArcher
2022-08-28 16:42:00 -04:00
parent f7d4f49809
commit 58ed5ba3ce
34 changed files with 73 additions and 128 deletions

View File

@@ -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) { void encodeThread(sample_queue_t samples, config_t config, void *channel_data) {
auto packets = mail::man->queue<packet_t>(mail::audio_packets); 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])]; auto stream = &stream_configs[map_stream(config.channels, config.flags[config_t::HIGH_QUALITY])];
opus_t opus { opus_multistream_encoder_create( 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) { void capture(safe::mail_t mail, config_t config, void *channel_data) {
auto shutdown_event = mail->event<bool>(mail::shutdown); 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 stream = &stream_configs[map_stream(config.channels, config.flags[config_t::HIGH_QUALITY])];
auto ref = control_shared.ref(); auto ref = control_shared.ref();
@@ -135,7 +135,7 @@ void capture(safe::mail_t mail, config_t config, void *channel_data) {
return; return;
} }
// Order of priorty: // Order of priority:
// 1. Config // 1. Config
// 2. Virtual if available // 2. Virtual if available
// 3. Host // 3. Host

View File

@@ -124,9 +124,9 @@ util::buffer_t<std::uint8_t> make_sps_h264(const AVCodecContext *ctx) {
sps.seq_parameter_set_id = 0; sps.seq_parameter_set_id = 0;
sps.chroma_format_idc = 1; 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.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; 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; return ((CodedBitstreamH265Context *)ctx->priv_data)->active_sps->vui_parameters_present_flag;
} }
} // namespace cbs } // namespace cbs

View File

@@ -31,4 +31,4 @@ h264_t make_sps_h264(const AVCodecContext *ctx, const AVPacket *packet);
bool validate_sps(const AVPacket *packet, int codec_id); bool validate_sps(const AVPacket *packet, int codec_id);
} // namespace cbs } // namespace cbs
#endif #endif

View File

@@ -105,14 +105,14 @@ enum quality_e : int {
enum class rc_hevc_e : int { enum class rc_hevc_e : int {
constqp, /**< Constant QP mode */ constqp, /**< Constant QP mode */
vbr_latency, /**< Latency Constrained Variable Bitrate */ vbr_latency, /**< Latency Constrained Variable Bitrate */
vbr_peak, /**< Peak Contrained Variable Bitrate */ vbr_peak, /**< Peak Constrained Variable Bitrate */
cbr, /**< Constant bitrate mode */ cbr, /**< Constant bitrate mode */
}; };
enum class rc_h264_e : int { enum class rc_h264_e : int {
constqp, /**< Constant QP mode */ constqp, /**< Constant QP mode */
cbr, /**< Constant bitrate mode */ cbr, /**< Constant bitrate mode */
vbr_peak, /**< Peak Contrained Variable Bitrate */ vbr_peak, /**< Peak Constrained Variable Bitrate */
vbr_latency, /**< Latency Constrained Variable Bitrate */ vbr_latency, /**< Latency Constrained Variable Bitrate */
}; };

View File

@@ -1,4 +1,3 @@
//
// Created by TheElixZammuto on 2021-05-09. // Created by TheElixZammuto on 2021-05-09.
// TODO: Authentication, better handling of routes common to nvhttp, cleanup // 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; 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()) { if(config::sunshine.username.empty()) {
send_redirect(response, request, "/welcome"); send_redirect(response, request, "/welcome");
return false; return false;
@@ -314,7 +313,7 @@ void saveApp(resp_https_t response, req_https_t request) {
BOOST_LOG(fatal) << config::stream.file_apps; BOOST_LOG(fatal) << config::stream.file_apps;
try { try {
//TODO: Input Validation // TODO: Input Validation
pt::read_json(ss, inputTree); pt::read_json(ss, inputTree);
pt::read_json(config::stream.file_apps, fileTree); 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)); apps_node.push_back(std::make_pair("", inputTree));
} }
else { 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; pt::ptree newApps;
int i = 0; int i = 0;
for(const auto &kv : apps_node) { for(const auto &kv : apps_node) {
@@ -388,7 +387,7 @@ void deleteApp(resp_https_t response, req_https_t request) {
return; return;
} }
else { 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; pt::ptree newApps;
int i = 0; int i = 0;
for(const auto &kv : apps_node) { for(const auto &kv : apps_node) {
@@ -452,7 +451,7 @@ void saveConfig(resp_https_t response, req_https_t request) {
}); });
pt::ptree inputTree; pt::ptree inputTree;
try { try {
//TODO: Input Validation // TODO: Input Validation
pt::read_json(ss, inputTree); pt::read_json(ss, inputTree);
for(const auto &kv : inputTree) { for(const auto &kv : inputTree) {
std::string value = inputTree.get<std::string>(kv.first); std::string value = inputTree.get<std::string>(kv.first);
@@ -488,7 +487,7 @@ void savePassword(resp_https_t response, req_https_t request) {
}); });
try { try {
//TODO: Input Validation // TODO: Input Validation
pt::read_json(ss, inputTree); pt::read_json(ss, inputTree);
auto username = inputTree.count("currentUsername") > 0 ? inputTree.get<std::string>("currentUsername") : ""; auto username = inputTree.count("currentUsername") > 0 ? inputTree.get<std::string>("currentUsername") : "";
auto newUsername = inputTree.get<std::string>("newUsername"); auto newUsername = inputTree.get<std::string>("newUsername");
@@ -544,7 +543,7 @@ void savePin(resp_https_t response, req_https_t request) {
}); });
try { try {
//TODO: Input Validation // TODO: Input Validation
pt::read_json(ss, inputTree); pt::read_json(ss, inputTree);
std::string pin = inputTree.get<std::string>("pin"); std::string pin = inputTree.get<std::string>("pin");
outputTree.put("status", nvhttp::pin(pin)); outputTree.put("status", nvhttp::pin(pin));

View File

@@ -1,6 +1,4 @@
//
// Created by loki on 6/3/19. // Created by loki on 6/3/19.
//
#ifndef SUNSHINE_CONFIGHTTP_H #ifndef SUNSHINE_CONFIGHTTP_H
#define SUNSHINE_CONFIGHTTP_H #define SUNSHINE_CONFIGHTTP_H
@@ -18,4 +16,4 @@ constexpr auto PORT_HTTPS = 1;
void start(); void start();
} // namespace confighttp } // namespace confighttp
#endif //SUNSHINE_CONFIGHTTP_H #endif // SUNSHINE_CONFIGHTTP_H

View File

@@ -1,13 +1,11 @@
//
// Created by loki on 5/31/19. // Created by loki on 5/31/19.
//
#include "crypto.h" #include "crypto.h"
#include <openssl/pem.h> #include <openssl/pem.h>
namespace crypto { namespace crypto {
using big_num_t = util::safe_ptr<BIGNUM, BN_free>; 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>; 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() } {} 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); int err_code = X509_STORE_CTX_get_error(ctx);
switch(err_code) { 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: case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY:
return 1; return 1;
@@ -274,7 +272,7 @@ int cbc_t::encrypt(const std::string_view &plaintext, std::uint8_t *cipher, aes_
int len; 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 // Encrypt into the caller's buffer
if(EVP_EncryptUpdate(encrypt_ctx.get(), cipher, &size, (const std::uint8_t *)plaintext.data(), plaintext.size()) != 1) { 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; return value;
} }
} // namespace crypto } // namespace crypto

View File

@@ -1,6 +1,4 @@
//
// Created by loki on 6/1/19. // Created by loki on 6/1/19.
//
#ifndef SUNSHINE_CRYPTO_H #ifndef SUNSHINE_CRYPTO_H
#define SUNSHINE_CRYPTO_H #define SUNSHINE_CRYPTO_H

View File

@@ -44,7 +44,7 @@ int init() {
if(clean_slate) { if(clean_slate) {
unique_id = util::uuid_t::generate().string(); 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.cert = (dir / ("cert-"s + unique_id)).string();
config::nvhttp.pkey = (dir / ("pkey-"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; return 0;
} }
} // namespace http } // namespace http

View File

@@ -16,4 +16,4 @@ extern std::string unique_id;
extern net::net_e origin_pin_allowed; extern net::net_e origin_pin_allowed;
extern net::net_e origin_web_ui_allowed; extern net::net_e origin_web_ui_allowed;
} // namespace http } // namespace http

View File

@@ -1,6 +1,4 @@
//
// Created by loki on 6/20/19. // Created by loki on 6/20/19.
//
// define uint32_t for <moonlight-common-c/src/Input.h> // define uint32_t for <moonlight-common-c/src/Input.h>
#include <cstdint> #include <cstdint>
@@ -89,7 +87,7 @@ struct gamepad_t {
// When emulating the HOME button, we may need to artificially release the back button. // 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. // 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 // Sunshine forces the button to be in a specific state until the gamepad state matches that of
// Moonlight once more. // Moonlight once more.
button_state_e back_button_state; 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, * When Moonlight sends mouse input through absolute coordinates,
* it's possible that BUTTON_RIGHT is pressed down immediately after releasing BUTTON_LEFT. * 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 * 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 * 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. * 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(!pressed) {
if(!release) { if(!release) {
// A new key has been pressed down, we need to check for key combo's // 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) { if(input->shortcutFlags == input_t::SHORTCUT && apply_shortcut(keyCode) > 0) {
return; return;
} }

View File

@@ -1,6 +1,4 @@
//
// Created by loki on 6/20/19. // Created by loki on 6/20/19.
//
#ifndef SUNSHINE_INPUT_H #ifndef SUNSHINE_INPUT_H
#define SUNSHINE_INPUT_H #define SUNSHINE_INPUT_H
@@ -32,4 +30,4 @@ struct touch_port_t : public platf::touch_port_t {
}; };
} // namespace input } // namespace input
#endif //SUNSHINE_INPUT_H #endif // SUNSHINE_INPUT_H

View File

@@ -1,6 +1,4 @@
//
// Created by loki on 5/30/19. // Created by loki on 5/30/19.
//
#include "process.h" #include "process.h"
@@ -289,7 +287,7 @@ int main(int argc, char *argv[]) {
upnp_unmap = upnp::start(); 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()) { if(shutdown_event->peek()) {
return 0; return 0;
} }

View File

@@ -1,6 +1,4 @@
//
// Created by loki on 12/22/19. // Created by loki on 12/22/19.
//
#ifndef SUNSHINE_MAIN_H #ifndef SUNSHINE_MAIN_H
#define SUNSHINE_MAIN_H #define SUNSHINE_MAIN_H
@@ -54,4 +52,4 @@ MAIL(rumble);
} // namespace mail } // namespace mail
#endif //SUNSHINE_MAIN_H #endif // SUNSHINE_MAIN_H

View File

@@ -1,6 +1,4 @@
//
// Created by loki on 12/27/19. // Created by loki on 12/27/19.
//
#include "network.h" #include "network.h"
#include "utility.h" #include "utility.h"
@@ -112,4 +110,4 @@ void free_host(ENetHost *host) {
enet_host_destroy(host); enet_host_destroy(host);
} }
} // namespace net } // namespace net

View File

@@ -1,6 +1,4 @@
//
// Created by loki on 12/27/19. // Created by loki on 12/27/19.
//
#ifndef SUNSHINE_NETWORK_H #ifndef SUNSHINE_NETWORK_H
#define 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); host_t host_create(ENetAddress &addr, std::size_t peers, std::uint16_t port);
} // namespace net } // namespace net
#endif //SUNSHINE_NETWORK_H #endif // SUNSHINE_NETWORK_H

View File

@@ -1,6 +1,4 @@
//
// Created by loki on 6/3/19. // Created by loki on 6/3/19.
//
#define BOOST_BIND_GLOBAL_PLACEHOLDERS #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 hash not correct, probably MITM
if(std::memcmp(hash.data(), sess.clienthash.data(), hash.size())) { if(std::memcmp(hash.data(), sess.clienthash.data(), hash.size())) {
//TODO: log // TODO: log
map_id_sess.erase(client.uniqueID); map_id_sess.erase(client.uniqueID);
tree.put("root.paired", 0); tree.put("root.paired", 0);

View File

@@ -1,6 +1,4 @@
//
// Created by loki on 6/3/19. // Created by loki on 6/3/19.
//
#ifndef SUNSHINE_NVHTTP_H #ifndef SUNSHINE_NVHTTP_H
#define SUNSHINE_NVHTTP_H #define SUNSHINE_NVHTTP_H
@@ -17,4 +15,4 @@ bool pin(std::string pin);
void erase_all_clients(); void erase_all_clients();
} // namespace nvhttp } // namespace nvhttp
#endif //SUNSHINE_NVHTTP_H #endif // SUNSHINE_NVHTTP_H

View File

@@ -167,7 +167,7 @@ static std::uint32_t from_view(const std::string_view &string) {
_CONVERT("eDP"sv, eDP); _CONVERT("eDP"sv, eDP);
_CONVERT("DSI"sv, DSI); _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; return DRM_MODE_CONNECTOR_Unknown;
} }

View File

@@ -1,6 +1,4 @@
//
// Created by loki on 12/14/19. // Created by loki on 12/14/19.
//
#define BOOST_BIND_GLOBAL_PLACEHOLDERS #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) { int proc_t::execute(int app_id) {
if(!running() && _app_id != -1) { 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(); _process_handle = bp::group();
_app_id = -1; _app_id = -1;
@@ -73,7 +71,7 @@ int proc_t::execute(int app_id) {
} }
std::error_code ec; std::error_code ec;
//Executed when returning from function // Executed when returning from function
auto fg = util::fail_guard([&]() { auto fg = util::fail_guard([&]() {
terminate(); terminate();
}); });
@@ -193,9 +191,9 @@ std::vector<ctx_t> &proc_t::get_apps() {
return _apps; return _apps;
} }
/// Gets application image from application list. // Gets application image from application list.
/// Returns default image if image configuration is not set. // Returns default image if image configuration is not set.
/// returns http content-type header compatible image type // returns http content-type header compatible image type
std::string proc_t::get_app_image(int app_id) { std::string proc_t::get_app_image(int app_id) {
auto app_index = app_id - 1; auto app_index = app_id - 1;
if(app_index < 0 || app_index >= _apps.size()) { if(app_index < 0 || app_index >= _apps.size()) {

View File

@@ -1,6 +1,4 @@
//
// Created by loki on 12/14/19. // Created by loki on 12/14/19.
//
#ifndef SUNSHINE_PROCESS_H #ifndef SUNSHINE_PROCESS_H
#define 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; extern proc_t proc;
} // namespace proc } // namespace proc
#endif //SUNSHINE_PROCESS_H #endif // SUNSHINE_PROCESS_H

View File

@@ -1,6 +1,4 @@
//
// Created by loki on 2/2/20. // Created by loki on 2/2/20.
//
#define BOOST_BIND_GLOBAL_PLACEHOLDERS #define BOOST_BIND_GLOBAL_PLACEHOLDERS
@@ -123,7 +121,7 @@ public:
socket->read_payload(); socket->read_payload();
}); });
auto content_lenght = 0; auto content_length = 0;
for(auto option = req->options; option != nullptr; option = option->next) { for(auto option = req->options; option != nullptr; option = option->next) {
if("Content-length"sv == option->option) { if("Content-length"sv == option->option) {
BOOST_LOG(debug) << "Found Content-Length: "sv << option->content << " bytes"sv; BOOST_LOG(debug) << "Found Content-Length: "sv << option->content << " bytes"sv;
@@ -133,14 +131,14 @@ public:
std::string_view content { option->content }; std::string_view content { option->content };
auto begin = std::find_if(std::begin(content), std::end(content), [](auto ch) { return (bool)std::isdigit(ch); }); 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; break;
} }
} }
if(end - socket->crlf >= content_lenght) { if(end - socket->crlf >= content_length) {
if(end - socket->crlf > content_lenght) { if(end - socket->crlf > content_length) {
BOOST_LOG(warning) << "(end - socket->crlf) > content_lenght -- "sv << (std::size_t)(end - socket->crlf) << " > "sv << content_lenght; BOOST_LOG(warning) << "(end - socket->crlf) > content_length -- "sv << (std::size_t)(end - socket->crlf) << " > "sv << content_length;
} }
fg.disable(); fg.disable();
@@ -271,7 +269,7 @@ public:
if(ec) { if(ec) {
BOOST_LOG(error) << "Couldn't accept incoming connections: "sv << ec.message(); BOOST_LOG(error) << "Couldn't accept incoming connections: "sv << ec.message();
//Stop server // Stop server
clear(); clear();
return; return;
} }
@@ -380,7 +378,7 @@ void launch_session_raise(launch_session_t launch_session) {
} }
int session_count() { int session_count() {
// Ensure session_count is up to date // Ensure session_count is up-to-date
server.clear(false); server.clear(false);
return server.session_count(); return server.session_count();

View File

@@ -1,6 +1,4 @@
//
// Created by loki on 2/2/20. // Created by loki on 2/2/20.
//
#ifndef SUNSHINE_RTSP_H #ifndef SUNSHINE_RTSP_H
#define SUNSHINE_RTSP_H #define SUNSHINE_RTSP_H
@@ -27,4 +25,4 @@ void rtpThread();
} // namespace stream } // namespace stream
#endif //SUNSHINE_RTSP_H #endif // SUNSHINE_RTSP_H

View File

@@ -1,6 +1,4 @@
//
// Created by loki on 6/5/19. // Created by loki on 6/5/19.
//
#include "process.h" #include "process.h"
@@ -240,11 +238,10 @@ struct broadcast_ctx_t {
udp::socket video_sock { io }; udp::socket video_sock { io };
udp::socket audio_sock { io }; udp::socket audio_sock { io };
// This is purely for adminitrative purposes. // This is purely for administrative purposes.
// // It's possible two instances of Moonlight are behind a NAT.
// It's possible two instances of Moonlight are behind a NAT. // From Sunshine's point of view, the ip addresses are identical
// 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
// 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; util::sync_t<std::vector<std::pair<std::string, std::uint16_t>>> audio_video_connections;
control_server_t control_server; 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 // Let all remaining connections know the server is shutting down
// reason: gracefull termination // reason: graceful termination
std::uint32_t reason = 0x80030023; std::uint32_t reason = 0x80030023;
control_terminate_t plaintext; 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 // 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. // 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; auto multi_fec_threshold = 90 * blocksize;
// We can go up to 4 fec blocks, but 3 is plenty // We can go up to 4 fec blocks, but 3 is plenty
@@ -1331,7 +1328,7 @@ void join(session_t &session) {
session.audioThread.join(); session.audioThread.join();
BOOST_LOG(debug) << "Waiting for control to end..."sv; BOOST_LOG(debug) << "Waiting for control to end..."sv;
session.controlEnd.view(); 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; BOOST_LOG(debug) << "Resetting Input..."sv;
input::reset(session.input); input::reset(session.input);

View File

@@ -1,6 +1,4 @@
//
// Created by loki on 6/5/19. // Created by loki on 6/5/19.
//
#ifndef SUNSHINE_STREAM_H #ifndef SUNSHINE_STREAM_H
#define SUNSHINE_STREAM_H #define SUNSHINE_STREAM_H
@@ -45,4 +43,4 @@ state_e state(session_t &session);
} // namespace session } // namespace session
} // namespace stream } // namespace stream
#endif //SUNSHINE_STREAM_H #endif // SUNSHINE_STREAM_H

View File

@@ -1,6 +1,4 @@
//
// Created by loki on 16-4-19. // Created by loki on 16-4-19.
//
#ifndef SUNSHINE_SYNC_H #ifndef SUNSHINE_SYNC_H
#define SUNSHINE_SYNC_H #define SUNSHINE_SYNC_H
@@ -92,4 +90,4 @@ private:
} // namespace util } // namespace util
#endif //T_MAN_SYNC_H #endif // SUNSHINE_SYNC_H

View File

@@ -17,7 +17,7 @@ namespace util {
class _ImplBase { class _ImplBase {
public: public:
//_unique_base_type _this_ptr; // _unique_base_type _this_ptr;
inline virtual ~_ImplBase() = default; inline virtual ~_ImplBase() = default;

View File

@@ -7,7 +7,7 @@
namespace util { namespace util {
/* /*
* Allow threads to execute unhindered * Allow threads to execute unhindered
* while keeping full controll over the threads. * while keeping full control over the threads.
*/ */
class ThreadPool : public TaskPool { class ThreadPool : public TaskPool {
public: public:

View File

@@ -1,6 +1,4 @@
//
// Created by loki on 6/10/19. // Created by loki on 6/10/19.
//
#ifndef SUNSHINE_THREAD_SAFE_H #ifndef SUNSHINE_THREAD_SAFE_H
#define SUNSHINE_THREAD_SAFE_H #define SUNSHINE_THREAD_SAFE_H
@@ -37,7 +35,7 @@ public:
_cv.notify_all(); _cv.notify_all();
} }
// pop and view shoud not be used interchangebly // pop and view shoud not be used interchangeably
status_t pop() { status_t pop() {
std::unique_lock ul { _lock }; std::unique_lock ul { _lock };
@@ -58,7 +56,7 @@ public:
return val; return val;
} }
// pop and view shoud not be used interchangebly // pop and view shoud not be used interchangeably
template<class Rep, class Period> template<class Rep, class Period>
status_t pop(std::chrono::duration<Rep, Period> delay) { status_t pop(std::chrono::duration<Rep, Period> delay) {
std::unique_lock ul { _lock }; std::unique_lock ul { _lock };
@@ -78,7 +76,7 @@ public:
return val; return val;
} }
// pop and view shoud not be used interchangebly // pop and view shoud not be used interchangeably
const status_t &view() { const status_t &view() {
std::unique_lock ul { _lock }; std::unique_lock ul { _lock };
@@ -508,4 +506,4 @@ inline void cleanup(mail_raw_t *mail) {
} }
} // namespace safe } // namespace safe
#endif //SUNSHINE_THREAD_SAFE_H #endif // SUNSHINE_THREAD_SAFE_H

View File

@@ -181,4 +181,4 @@ std::unique_ptr<platf::deinit_t> start() {
return std::make_unique<deinit_t>(std::move(urls), data, std::move(mappings)); return std::make_unique<deinit_t>(std::move(urls), data, std::move(mappings));
} }
} // namespace upnp } // namespace upnp

View File

@@ -7,4 +7,4 @@ namespace upnp {
[[nodiscard]] std::unique_ptr<platf::deinit_t> start(); [[nodiscard]] std::unique_ptr<platf::deinit_t> start();
} }
#endif #endif

View File

@@ -1,6 +1,4 @@
//
// Created by loki on 8-2-19. // Created by loki on 8-2-19.
//
#ifndef T_MAN_UUID_H #ifndef T_MAN_UUID_H
#define T_MAN_UUID_H #define T_MAN_UUID_H
@@ -76,4 +74,4 @@ union uuid_t {
} }
}; };
} // namespace util } // namespace util
#endif //T_MAN_UUID_H #endif // T_MAN_UUID_H

View File

@@ -1,6 +1,4 @@
//
// Created by loki on 6/6/19. // Created by loki on 6/6/19.
//
#include <atomic> #include <atomic>
#include <bitset> #include <bitset>
@@ -225,7 +223,7 @@ public:
~swdevice_t() override {} ~swdevice_t() override {}
// Store ownsership when frame is hw_frame // Store ownership when frame is hw_frame
frame_t hw_frame; frame_t hw_frame;
frame_t sw_frame; frame_t sw_frame;
@@ -239,7 +237,7 @@ public:
enum flag_e { enum flag_e {
DEFAULT = 0x00, DEFAULT = 0x00,
PARALLEL_ENCODING = 0x01, 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* 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 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() { int init() {
BOOST_LOG(info) << "//////////////////////////////////////////////////////////////////"sv; BOOST_LOG(info) << "// Testing for available encoders, this may generate errors. You can safely ignore those errors. //"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;
KITTY_WHILE_LOOP(auto pos = std::begin(encoders), pos != std::end(encoders), { KITTY_WHILE_LOOP(auto pos = std::begin(encoders), pos != std::end(encoders), {
if( if(
@@ -1643,11 +1636,7 @@ int init() {
}) })
BOOST_LOG(info); BOOST_LOG(info);
BOOST_LOG(info) << "//////////////////////////////////////////////////////////////"sv; BOOST_LOG(info) << "// Ignore any errors mentioned above, they are not relevant. //"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); BOOST_LOG(info);
if(encoders.empty()) { if(encoders.empty()) {

View File

@@ -1,6 +1,4 @@
//
// Created by loki on 6/9/19. // Created by loki on 6/9/19.
//
#ifndef SUNSHINE_VIDEO_H #ifndef SUNSHINE_VIDEO_H
#define SUNSHINE_VIDEO_H #define SUNSHINE_VIDEO_H
@@ -84,4 +82,4 @@ void capture(
int init(); int init();
} // namespace video } // namespace video
#endif //SUNSHINE_VIDEO_H #endif // SUNSHINE_VIDEO_H