docs: improvements to source code documentation (#1236)

This commit is contained in:
ReenigneArcher
2023-05-07 15:01:44 -04:00
committed by GitHub
parent 97f18d6353
commit 979f7f4e60
71 changed files with 1284 additions and 1430 deletions

View File

@@ -52,7 +52,7 @@ NamespaceIndentation: All
ObjCSpaceAfterProperty: true ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true ObjCSpaceBeforeProtocolList: true
PointerAlignment: Right PointerAlignment: Right
ReflowComments: false ReflowComments: true
SpaceAfterCStyleCast: true SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true SpaceAfterTemplateKeyword: true

View File

@@ -8,16 +8,16 @@ version: 2
# Set the version of Python # Set the version of Python
build: build:
os: ubuntu-20.04 os: ubuntu-22.04
tools: tools:
python: "3.10" python: "3.11"
apt_packages: apt_packages:
- graphviz - graphviz
## Include the submodules, required for cmake # submodules required for include statements
# submodules: submodules:
# include: all include: all
# recursive: true recursive: true
# Build documentation in the docs/ directory with Sphinx # Build documentation in the docs/ directory with Sphinx
sphinx: sphinx:

View File

@@ -878,6 +878,7 @@ WARN_IF_UNDOC_ENUM_VAL = NO
# The default value is: NO. # The default value is: NO.
WARN_AS_ERROR = NO WARN_AS_ERROR = NO
# todo - ideally this will eventually become FAIL_ON_WARNINGS
# The WARN_FORMAT tag determines the format of the warning messages that doxygen # The WARN_FORMAT tag determines the format of the warning messages that doxygen
# can produce. The string should contain the $file, $line, and $text tags, which # can produce. The string should contain the $file, $line, and $text tags, which
@@ -2354,7 +2355,7 @@ SEARCH_INCLUDES = YES
# RECURSIVE has no effect here. # RECURSIVE has no effect here.
# This tag requires that the tag SEARCH_INCLUDES is set to YES. # This tag requires that the tag SEARCH_INCLUDES is set to YES.
INCLUDE_PATH = INCLUDE_PATH = ../third-party/ffmpeg-linux-x86_64/include/
# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
# patterns (like *.h and *.hpp) to filter out the header-files in the # patterns (like *.h and *.hpp) to filter out the header-files in the

View File

@@ -95,8 +95,16 @@ breathe_projects = dict(
) )
todo_include_todos = True todo_include_todos = True
subprocess.run('doxygen', shell=True, cwd=source_dir)
# disable epub mimetype warnings # disable epub mimetype warnings
# https://github.com/readthedocs/readthedocs.org/blob/eadf6ac6dc6abc760a91e1cb147cc3c5f37d1ea8/docs/conf.py#L235-L236 # https://github.com/readthedocs/readthedocs.org/blob/eadf6ac6dc6abc760a91e1cb147cc3c5f37d1ea8/docs/conf.py#L235-L236
suppress_warnings = ["epub.unknown_project_files"] suppress_warnings = ["epub.unknown_project_files"]
# get doxygen version
doxy_proc = subprocess.run('doxygen --version', shell=True, cwd=source_dir, capture_output=True)
doxy_version = doxy_proc.stdout.decode('utf-8').strip()
print('doxygen version: ' + doxy_version)
# run doxygen
doxy_proc = subprocess.run('doxygen Doxyfile', shell=True, cwd=source_dir)
if doxy_proc.returncode != 0:
raise RuntimeError('doxygen failed with return code ' + str(doxy_proc.returncode))

View File

@@ -1,5 +1,4 @@
#ifndef SUNSHINE_AUDIO_H #pragma once
#define SUNSHINE_AUDIO_H
#include "thread_safe.h" #include "thread_safe.h"
#include "utility.h" #include "utility.h"
@@ -44,5 +43,3 @@ namespace audio {
void void
capture(safe::mail_t mail, config_t config, void *channel_data); capture(safe::mail_t mail, config_t config, void *channel_data);
} // namespace audio } // namespace audio
#endif

View File

@@ -87,9 +87,9 @@ namespace cbs {
make_sps_h264(const AVCodecContext *ctx) { make_sps_h264(const AVCodecContext *ctx) {
H264RawSPS sps {}; H264RawSPS sps {};
/* b_per_p == ctx->max_b_frames for h264 */ // b_per_p == ctx->max_b_frames for h264
/* desired_b_depth == avoption("b_depth") == 1 */ // desired_b_depth == avoption("b_depth") == 1
/* max_b_depth == std::min(av_log2(ctx->b_per_p) + 1, desired_b_depth) ==> 1 */ // max_b_depth == std::min(av_log2(ctx->b_per_p) + 1, desired_b_depth) ==> 1
auto max_b_depth = 1; auto max_b_depth = 1;
auto dpb_frame = ctx->gop_size == 1 ? 0 : 1 + max_b_depth; auto dpb_frame = ctx->gop_size == 1 ? 0 : 1 + max_b_depth;
auto mb_width = (FFALIGN(ctx->width, 16) / 16) * 16; auto mb_width = (FFALIGN(ctx->width, 16) / 16) * 16;

View File

@@ -1,5 +1,4 @@
#ifndef SUNSHINE_CBS_H #pragma once
#define SUNSHINE_CBS_H
#include "utility.h" #include "utility.h"
@@ -28,10 +27,8 @@ namespace cbs {
make_sps_h264(const AVCodecContext *ctx, const AVPacket *packet); make_sps_h264(const AVCodecContext *ctx, const AVPacket *packet);
/** /**
* Check if SPS->VUI is present * Check if SPS->VUI is present
*/ */
bool bool
validate_sps(const AVPacket *packet, int codec_id); validate_sps(const AVPacket *packet, int codec_id);
} // namespace cbs } // namespace cbs
#endif

View File

@@ -1,5 +1,4 @@
#ifndef SUNSHINE_CONFIG_H #pragma once
#define SUNSHINE_CONFIG_H
#include <bitset> #include <bitset>
#include <chrono> #include <chrono>
@@ -162,4 +161,3 @@ namespace config {
std::unordered_map<std::string, std::string> std::unordered_map<std::string, std::string>
parse_config(const std::string_view &file_content); parse_config(const std::string_view &file_content);
} // namespace config } // namespace config
#endif

View File

@@ -1,4 +1,3 @@
// 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
#define BOOST_BIND_GLOBAL_PLACEHOLDERS #define BOOST_BIND_GLOBAL_PLACEHOLDERS

View File

@@ -1,7 +1,4 @@
// Created by loki on 6/3/19. #pragma once
#ifndef SUNSHINE_CONFIGHTTP_H
#define SUNSHINE_CONFIGHTTP_H
#include <functional> #include <functional>
#include <string> #include <string>
@@ -34,5 +31,3 @@ const std::map<std::string, std::string> mime_types = {
{ "woff2", "font/woff2" }, { "woff2", "font/woff2" },
{ "xml", "text/xml" }, { "xml", "text/xml" },
}; };
#endif // SUNSHINE_CONFIGHTTP_H

View File

@@ -1,5 +1,3 @@
// Created by loki on 5/31/19.
#include "crypto.h" #include "crypto.h"
#include <openssl/pem.h> #include <openssl/pem.h>
@@ -35,13 +33,13 @@ namespace crypto {
} }
} }
/* /**
* When certificates from two or more instances of Moonlight have been added to x509_store_t, * When certificates from two or more instances of Moonlight have been added to x509_store_t,
* only one of them will be verified by X509_verify_cert, resulting in only a single instance of * only one of them will be verified by X509_verify_cert, resulting in only a single instance of
* Moonlight to be able to use Sunshine * Moonlight to be able to use Sunshine
* *
* To circumvent this, x509_store_t instance will be created for each instance of the certificates. * To circumvent this, x509_store_t instance will be created for each instance of the certificates.
*/ */
const char * const char *
cert_chain_t::verify(x509_t::element_type *cert) { cert_chain_t::verify(x509_t::element_type *cert) {
int err_code = 0; int err_code = 0;

View File

@@ -1,7 +1,4 @@
// Created by loki on 6/1/19. #pragma once
#ifndef SUNSHINE_CRYPTO_H
#define SUNSHINE_CRYPTO_H
#include <array> #include <array>
#include <openssl/evp.h> #include <openssl/evp.h>
@@ -123,11 +120,11 @@ namespace crypto {
gcm_t(const crypto::aes_t &key, bool padding = true); gcm_t(const crypto::aes_t &key, bool padding = true);
/** /**
* length of cipher must be at least: round_to_pkcs7_padded(plaintext.size()) + crypto::cipher::tag_size * length of cipher must be at least: round_to_pkcs7_padded(plaintext.size()) + crypto::cipher::tag_size
* *
* return -1 on error * return -1 on error
* return bytes written on success * return bytes written on success
*/ */
int int
encrypt(const std::string_view &plaintext, std::uint8_t *tagged_cipher, aes_t *iv); encrypt(const std::string_view &plaintext, std::uint8_t *tagged_cipher, aes_t *iv);
@@ -145,15 +142,13 @@ namespace crypto {
cbc_t(const crypto::aes_t &key, bool padding = true); cbc_t(const crypto::aes_t &key, bool padding = true);
/** /**
* length of cipher must be at least: round_to_pkcs7_padded(plaintext.size()) * length of cipher must be at least: round_to_pkcs7_padded(plaintext.size())
* *
* return -1 on error * return -1 on error
* return bytes written on success * return bytes written on success
*/ */
int int
encrypt(const std::string_view &plaintext, std::uint8_t *cipher, aes_t *iv); encrypt(const std::string_view &plaintext, std::uint8_t *cipher, aes_t *iv);
}; };
} // namespace cipher } // namespace cipher
} // namespace crypto } // namespace crypto
#endif //SUNSHINE_CRYPTO_H

View File

@@ -1,3 +1,5 @@
#pragma once
#include "network.h" #include "network.h"
#include "thread_safe.h" #include "thread_safe.h"

View File

@@ -1,5 +1,3 @@
// 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>
extern "C" { extern "C" {
@@ -147,12 +145,12 @@ namespace input {
}; };
/** /**
* Apply shortcut based on VKEY * Apply shortcut based on VKEY
* On success * On success
* return > 0 * return > 0
* On nothing * On nothing
* return 0 * return 0
*/ */
inline int inline int
apply_shortcut(short keyCode) { apply_shortcut(short keyCode) {
constexpr auto VK_F1 = 0x70; constexpr auto VK_F1 = 0x70;
@@ -366,21 +364,20 @@ namespace input {
mouse_press[button] = !release; mouse_press[button] = !release;
} }
/////////////////////////////////// /**
/*/ * 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 sent.
* 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. *
* * input->mouse_left_button_timeout can only be nullptr
* input->mouse_left_button_timeout can only be nullptr * when the last mouse coordinates were absolute
* when the last mouse coordinates were absolute */
/*/
if (button == BUTTON_LEFT && release && !input->mouse_left_button_timeout) { if (button == BUTTON_LEFT && release && !input->mouse_left_button_timeout) {
auto f = [=]() { auto f = [=]() {
auto left_released = mouse_press[BUTTON_LEFT]; auto left_released = mouse_press[BUTTON_LEFT];
@@ -408,7 +405,6 @@ namespace input {
return; return;
} }
///////////////////////////////////
platf::button_mouse(platf_input, button, release); platf::button_mouse(platf_input, button, release);
} }
@@ -424,8 +420,8 @@ namespace input {
} }
/** /**
* Update flags for keyboard shortcut combo's * Update flags for keyboard shortcut combo's
*/ */
inline void inline void
update_shortcutFlags(int *flags, short keyCode, bool release) { update_shortcutFlags(int *flags, short keyCode, bool release) {
switch (keyCode) { switch (keyCode) {

View File

@@ -1,7 +1,4 @@
// Created by loki on 6/20/19. #pragma once
#ifndef SUNSHINE_INPUT_H
#define SUNSHINE_INPUT_H
#include <functional> #include <functional>
@@ -33,5 +30,3 @@ namespace input {
float scalar_inv; float scalar_inv;
}; };
} // namespace input } // namespace input
#endif // SUNSHINE_INPUT_H

View File

@@ -3,8 +3,7 @@
*/ */
// macros // macros
#ifndef SUNSHINE_MAIN_H #pragma once
#define SUNSHINE_MAIN_H
// standard includes // standard includes
#include <filesystem> #include <filesystem>
@@ -87,5 +86,3 @@ namespace service_ctrl {
wait_for_ui_ready(); wait_for_ui_ready();
} // namespace service_ctrl } // namespace service_ctrl
#endif #endif
#endif // SUNSHINE_MAIN_H

View File

@@ -1,12 +1,11 @@
#ifndef DOSSIER_MOVE_BY_COPY_H #pragma once
#define DOSSIER_MOVE_BY_COPY_H
#include <utility> #include <utility>
namespace move_by_copy_util { namespace move_by_copy_util {
/* /**
* When a copy is made, it moves the object * When a copy is made, it moves the object
* This allows you to move an object when a move can't be done. * This allows you to move an object when a move can't be done.
*/ */
template <class T> template <class T>
class MoveByCopy { class MoveByCopy {
public: public:
@@ -53,4 +52,3 @@ namespace move_by_copy_util {
return MoveByCopy<T>(std::move(const_cast<T &>(movable))); return MoveByCopy<T>(std::move(const_cast<T &>(movable)));
} }
} // namespace move_by_copy_util } // namespace move_by_copy_util
#endif

View File

@@ -1,5 +1,3 @@
// Created by loki on 12/27/19.
#include "network.h" #include "network.h"
#include "utility.h" #include "utility.h"
#include <algorithm> #include <algorithm>

View File

@@ -1,7 +1,4 @@
// Created by loki on 12/27/19. #pragma once
#ifndef SUNSHINE_NETWORK_H
#define SUNSHINE_NETWORK_H
#include <tuple> #include <tuple>
@@ -34,5 +31,3 @@ namespace net {
host_t host_t
host_create(ENetAddress &addr, std::size_t peers, std::uint16_t port); host_create(ENetAddress &addr, std::size_t peers, std::uint16_t port);
} // namespace net } // namespace net
#endif // SUNSHINE_NETWORK_H

View File

@@ -1,6 +1,6 @@
/** /**
* @file nvhttp.h * @file nvhttp.h
*/ */
// macros // macros
#define BOOST_BIND_GLOBAL_PLACEHOLDERS #define BOOST_BIND_GLOBAL_PLACEHOLDERS
@@ -522,15 +522,15 @@ namespace nvhttp {
} }
/** /**
* @brief Compare the user supplied pin to the Moonlight pin. * @brief Compare the user supplied pin to the Moonlight pin.
* @param pin The user supplied pin. * @param pin The user supplied pin.
* @return `true` if the pin is correct, `false` otherwise. * @return `true` if the pin is correct, `false` otherwise.
* *
* EXAMPLES: * EXAMPLES:
* ```cpp * ```cpp
* bool pin_status = nvhttp::pin("1234"); * bool pin_status = nvhttp::pin("1234");
* ``` * ```
*/ */
bool bool
pin(std::string pin) { pin(std::string pin) {
pt::ptree tree; pt::ptree tree;
@@ -889,13 +889,13 @@ namespace nvhttp {
} }
/** /**
* @brief Start the nvhttp server. * @brief Start the nvhttp server.
* *
* EXAMPLES: * EXAMPLES:
* ```cpp * ```cpp
* nvhttp::start(); * nvhttp::start();
* ``` * ```
*/ */
void void
start() { start() {
auto shutdown_event = mail::man->event<bool>(mail::shutdown); auto shutdown_event = mail::man->event<bool>(mail::shutdown);
@@ -1035,13 +1035,13 @@ namespace nvhttp {
} }
/** /**
* @brief Remove all paired clients. * @brief Remove all paired clients.
* *
* EXAMPLES: * EXAMPLES:
* ```cpp * ```cpp
* nvhttp::erase_all_clients(); * nvhttp::erase_all_clients();
* ``` * ```
*/ */
void void
erase_all_clients() { erase_all_clients() {
map_id_client.clear(); map_id_client.clear();

View File

@@ -1,10 +1,9 @@
/** /**
* @file nvhttp.h * @file nvhttp.h
*/ */
// macros // macros
#ifndef SUNSHINE_NVHTTP_H #pragma once
#define SUNSHINE_NVHTTP_H
// standard includes // standard includes
#include <string> #include <string>
@@ -18,24 +17,24 @@
namespace nvhttp { namespace nvhttp {
/** /**
* @brief The protocol version. * @brief The protocol version.
*/ */
constexpr auto VERSION = "7.1.431.-1"; constexpr auto VERSION = "7.1.431.-1";
// The negative 4th version number tells Moonlight that this is Sunshine // The negative 4th version number tells Moonlight that this is Sunshine
/** /**
* @brief The GFE version we are replicating. * @brief The GFE version we are replicating.
*/ */
constexpr auto GFE_VERSION = "3.23.0.74"; constexpr auto GFE_VERSION = "3.23.0.74";
/** /**
* @brief The HTTP port, as a difference from the config port. * @brief The HTTP port, as a difference from the config port.
*/ */
constexpr auto PORT_HTTP = 0; constexpr auto PORT_HTTP = 0;
/** /**
* @brief The HTTPS port, as a difference from the config port. * @brief The HTTPS port, as a difference from the config port.
*/ */
constexpr auto PORT_HTTPS = -5; constexpr auto PORT_HTTPS = -5;
// functions // functions
@@ -46,5 +45,3 @@ namespace nvhttp {
void void
erase_all_clients(); erase_all_clients();
} // namespace nvhttp } // namespace nvhttp
#endif // SUNSHINE_NVHTTP_H

View File

@@ -1,9 +1,4 @@
// #pragma once
// Created by loki on 6/21/19.
//
#ifndef SUNSHINE_COMMON_H
#define SUNSHINE_COMMON_H
#include <bitset> #include <bitset>
#include <filesystem> #include <filesystem>
@@ -215,8 +210,8 @@ namespace platf {
} }
/** /**
* implementations must take ownership of 'frame' * implementations must take ownership of 'frame'
*/ */
virtual int virtual int
set_frame(AVFrame *frame, AVBufferRef *hw_frames_ctx) { set_frame(AVFrame *frame, AVBufferRef *hw_frames_ctx) {
BOOST_LOG(error) << "Illegal call to hwdevice_t::set_frame(). Did you forget to override it?"; BOOST_LOG(error) << "Illegal call to hwdevice_t::set_frame(). Did you forget to override it?";
@@ -227,14 +222,14 @@ namespace platf {
set_colorspace(std::uint32_t colorspace, std::uint32_t color_range) {}; set_colorspace(std::uint32_t colorspace, std::uint32_t color_range) {};
/** /**
* Implementations may set parameters during initialization of the hwframes context * Implementations may set parameters during initialization of the hwframes context
*/ */
virtual void virtual void
init_hwframes(AVHWFramesContext *frames) {}; init_hwframes(AVHWFramesContext *frames) {};
/** /**
* Implementations may make modifications required before context derivation * Implementations may make modifications required before context derivation
*/ */
virtual int virtual int
prepare_to_derive_context(int hw_device_type) { prepare_to_derive_context(int hw_device_type) {
return 0; return 0;
@@ -254,44 +249,44 @@ namespace platf {
class display_t { class display_t {
public: public:
/** /**
* When display has a new image ready or a timeout occurs, this callback will be called with the image. * When display has a new image ready or a timeout occurs, this callback will be called with the image.
* If a frame was captured, frame_captured will be true. If a timeout occurred, it will be false. * If a frame was captured, frame_captured will be true. If a timeout occurred, it will be false.
* *
* On Break Request --> * On Break Request -->
* Returns false * Returns false
* *
* On Success --> * On Success -->
* Returns true * Returns true
*/ */
using push_captured_image_cb_t = std::function<bool(std::shared_ptr<img_t> &&img, bool frame_captured)>; using push_captured_image_cb_t = std::function<bool(std::shared_ptr<img_t> &&img, bool frame_captured)>;
/** /**
* Use to get free image from the pool. Calls must be synchronized. * Use to get free image from the pool. Calls must be synchronized.
* Blocks until there is free image in the pool or capture is interrupted. * Blocks until there is free image in the pool or capture is interrupted.
* *
* Returns: * Returns:
* 'true' on success, img_out contains free image * 'true' on success, img_out contains free image
* 'false' when capture has been interrupted, img_out contains nullptr * 'false' when capture has been interrupted, img_out contains nullptr
*/ */
using pull_free_image_cb_t = std::function<bool(std::shared_ptr<img_t> &img_out)>; using pull_free_image_cb_t = std::function<bool(std::shared_ptr<img_t> &img_out)>;
display_t() noexcept: display_t() noexcept:
offset_x { 0 }, offset_y { 0 } {} offset_x { 0 }, offset_y { 0 } {}
/** /**
* push_captured_image_cb --> The callback that is called with captured image, * push_captured_image_cb --> The callback that is called with captured image,
* must be called from the same thread as capture() * must be called from the same thread as capture()
* pull_free_image_cb --> Capture backends call this callback to get empty image * pull_free_image_cb --> Capture backends call this callback to get empty image
* from the pool. If backend uses multiple threads, calls to this * from the pool. If backend uses multiple threads, calls to this
* callback must be synchronized. Calls to this callback and * callback must be synchronized. Calls to this callback and
* push_captured_image_cb must be synchronized as well. * push_captured_image_cb must be synchronized as well.
* bool *cursor --> A pointer to the flag that indicates wether the cursor should be captured as well * bool *cursor --> A pointer to the flag that indicates wether the cursor should be captured as well
* *
* Returns either: * Returns either:
* capture_e::ok when stopping * capture_e::ok when stopping
* capture_e::error on error * capture_e::error on error
* capture_e::reinit when need of reinitialization * capture_e::reinit when need of reinitialization
*/ */
virtual capture_e virtual capture_e
capture(const push_captured_image_cb_t &push_captured_image_cb, const pull_free_image_cb_t &pull_free_image_cb, bool *cursor) = 0; capture(const push_captured_image_cb_t &push_captured_image_cb, const pull_free_image_cb_t &pull_free_image_cb, bool *cursor) = 0;
@@ -368,14 +363,14 @@ namespace platf {
audio_control(); audio_control();
/** /**
* display_name --> The name of the monitor that SHOULD be displayed * display_name --> The name of the monitor that SHOULD be displayed
* If display_name is empty --> Use the first monitor that's compatible you can find * If display_name is empty --> Use the first monitor that's compatible you can find
* If you require to use this parameter in a seperate thread --> make a copy of it. * If you require to use this parameter in a seperate thread --> make a copy of it.
* *
* config --> Stream configuration * config --> Stream configuration
* *
* Returns display_t based on hwdevice_type * Returns display_t based on hwdevice_type
*/ */
std::shared_ptr<display_t> std::shared_ptr<display_t>
display(mem_type_e hwdevice_type, const std::string &display_name, const video::config_t &config); display(mem_type_e hwdevice_type, const std::string &display_name, const video::config_t &config);
@@ -468,5 +463,3 @@ namespace platf {
std::vector<std::string_view> & std::vector<std::string_view> &
supported_gamepads(); supported_gamepads();
} // namespace platf } // namespace platf
#endif //SUNSHINE_COMMON_H

View File

@@ -1,6 +1,3 @@
//
// Created by loki on 5/16/21.
//
#include <bitset> #include <bitset>
#include <sstream> #include <sstream>

View File

@@ -30,7 +30,7 @@ using namespace std::literals;
using namespace std::literals; using namespace std::literals;
//////////////////// Special desclarations // Special declarations
/** /**
* NVCC tends to have problems with standard headers. * NVCC tends to have problems with standard headers.
* Don't include common.h, instead use bare minimum * Don't include common.h, instead use bare minimum
@@ -78,7 +78,7 @@ static_assert(sizeof(video::color_t) == sizeof(video::color_extern_t), "color ma
extern color_t colors[6]; extern color_t colors[6];
} // namespace video } // namespace video
//////////////////// End special declarations // End special declarations
namespace cuda { namespace cuda {
auto constexpr INVALID_TEXTURE = std::numeric_limits<cudaTextureObject_t>::max(); auto constexpr INVALID_TEXTURE = std::numeric_limits<cudaTextureObject_t>::max();

View File

@@ -1,5 +1,6 @@
#if !defined(SUNSHINE_PLATFORM_CUDA_H) && defined(SUNSHINE_BUILD_CUDA) #pragma once
#define SUNSHINE_PLATFORM_CUDA_H
#if defined(SUNSHINE_BUILD_CUDA)
#include <cstdint> #include <cstdint>
#include <memory> #include <memory>
@@ -89,11 +90,11 @@ namespace cuda {
sws_t(int in_width, int in_height, int out_width, int out_height, int pitch, int threadsPerBlock, ptr_t &&color_matrix); sws_t(int in_width, int in_height, int out_width, int out_height, int pitch, int threadsPerBlock, ptr_t &&color_matrix);
/** /**
* in_width, in_height -- The width and height of the captured image in pixels * in_width, in_height -- The width and height of the captured image in pixels
* out_width, out_height -- the width and height of the NV12 image in pixels * out_width, out_height -- the width and height of the NV12 image in pixels
* *
* pitch -- The size of a single row of pixels in bytes * pitch -- The size of a single row of pixels in bytes
*/ */
static std::optional<sws_t> static std::optional<sws_t>
make(int in_width, int in_height, int out_width, int out_height, int pitch); make(int in_width, int in_height, int out_width, int out_height, int pitch);

View File

@@ -1,5 +1,4 @@
#ifndef SUNSHINE_PLATFORM_LINUX_OPENGL_H #pragma once
#define SUNSHINE_PLATFORM_LINUX_OPENGL_H
#include <optional> #include <optional>
#include <string_view> #include <string_view>
@@ -94,8 +93,8 @@ namespace gl {
} }
/** /**
* Copies a part of the framebuffer to texture * Copies a part of the framebuffer to texture
*/ */
void void
copy(int id, int texture, int offset_x, int offset_y, int width, int height); copy(int id, int texture, int offset_x, int offset_y, int width, int height);
}; };
@@ -352,5 +351,3 @@ namespace egl {
bool bool
fail(); fail();
} // namespace egl } // namespace egl
#endif

View File

@@ -143,9 +143,9 @@ namespace platf {
constexpr auto UNKNOWN = 0; constexpr auto UNKNOWN = 0;
/** /**
* @brief Initializes the keycode constants for translating * @brief Initializes the keycode constants for translating
* moonlight keycodes to linux/X11 keycodes * moonlight keycodes to linux/X11 keycodes.
*/ */
static constexpr std::array<keycode_t, 0xE3> static constexpr std::array<keycode_t, 0xE3>
init_keycodes() { init_keycodes() {
std::array<keycode_t, 0xE3> keycodes {}; std::array<keycode_t, 0xE3> keycodes {};
@@ -1047,16 +1047,16 @@ namespace platf {
} }
/** /**
* @brief XTest absolute mouse move. * @brief XTest absolute mouse move.
* @param input The input_t instance to use. * @param input The input_t instance to use.
* @param x Absolute x position. * @param x Absolute x position.
* @param y Absolute y position. * @param y Absolute y position.
* *
* EXAMPLES: * EXAMPLES:
* ```cpp * ```cpp
* x_abs_mouse(input, 0, 0); * x_abs_mouse(input, 0, 0);
* ``` * ```
*/ */
static void static void
x_abs_mouse(input_t &input, float x, float y) { x_abs_mouse(input_t &input, float x, float y) {
#ifdef SUNSHINE_BUILD_X11 #ifdef SUNSHINE_BUILD_X11
@@ -1070,17 +1070,17 @@ namespace platf {
} }
/** /**
* @brief Absolute mouse move. * @brief Absolute mouse move.
* @param input The input_t instance to use. * @param input The input_t instance to use.
* @param touch_port The touch_port instance to use. * @param touch_port The touch_port instance to use.
* @param x Absolute x position. * @param x Absolute x position.
* @param y Absolute y position. * @param y Absolute y position.
* *
* EXAMPLES: * EXAMPLES:
* ```cpp * ```cpp
* abs_mouse(input, touch_port, 0, 0); * abs_mouse(input, touch_port, 0, 0);
* ``` * ```
*/ */
void void
abs_mouse(input_t &input, const touch_port_t &touch_port, float x, float y) { abs_mouse(input_t &input, const touch_port_t &touch_port, float x, float y) {
auto touchscreen = ((input_raw_t *) input.get())->touch_input.get(); auto touchscreen = ((input_raw_t *) input.get())->touch_input.get();
@@ -1101,16 +1101,16 @@ namespace platf {
} }
/** /**
* @brief XTest relative mouse move. * @brief XTest relative mouse move.
* @param input The input_t instance to use. * @param input The input_t instance to use.
* @param deltaX Relative x position. * @param deltaX Relative x position.
* @param deltaY Relative y position. * @param deltaY Relative y position.
* *
* EXAMPLES: * EXAMPLES:
* ```cpp * ```cpp
* x_move_mouse(input, 10, 10); // Move mouse 10 pixels down and right * x_move_mouse(input, 10, 10); // Move mouse 10 pixels down and right
* ``` * ```
*/ */
static void static void
x_move_mouse(input_t &input, int deltaX, int deltaY) { x_move_mouse(input_t &input, int deltaX, int deltaY) {
#ifdef SUNSHINE_BUILD_X11 #ifdef SUNSHINE_BUILD_X11
@@ -1124,16 +1124,16 @@ namespace platf {
} }
/** /**
* @brief Relative mouse move. * @brief Relative mouse move.
* @param input The input_t instance to use. * @param input The input_t instance to use.
* @param deltaX Relative x position. * @param deltaX Relative x position.
* @param deltaY Relative y position. * @param deltaY Relative y position.
* *
* EXAMPLES: * EXAMPLES:
* ```cpp * ```cpp
* move_mouse(input, 10, 10); // Move mouse 10 pixels down and right * move_mouse(input, 10, 10); // Move mouse 10 pixels down and right
* ``` * ```
*/ */
void void
move_mouse(input_t &input, int deltaX, int deltaY) { move_mouse(input_t &input, int deltaX, int deltaY) {
auto mouse = ((input_raw_t *) input.get())->mouse_input.get(); auto mouse = ((input_raw_t *) input.get())->mouse_input.get();
@@ -1154,16 +1154,16 @@ namespace platf {
} }
/** /**
* @brief XTest mouse button press/release. * @brief XTest mouse button press/release.
* @param input The input_t instance to use. * @param input The input_t instance to use.
* @param button Which mouse button to emulate. * @param button Which mouse button to emulate.
* @param release Whether the event was a press (false) or a release (true) * @param release Whether the event was a press (false) or a release (true)
* *
* EXAMPLES: * EXAMPLES:
* ```cpp * ```cpp
* x_button_mouse(input, 1, false); // Press left mouse button * x_button_mouse(input, 1, false); // Press left mouse button
* ``` * ```
*/ */
static void static void
x_button_mouse(input_t &input, int button, bool release) { x_button_mouse(input_t &input, int button, bool release) {
#ifdef SUNSHINE_BUILD_X11 #ifdef SUNSHINE_BUILD_X11
@@ -1197,16 +1197,16 @@ namespace platf {
} }
/** /**
* @brief Mouse button press/release. * @brief Mouse button press/release.
* @param input The input_t instance to use. * @param input The input_t instance to use.
* @param button Which mouse button to emulate. * @param button Which mouse button to emulate.
* @param release Whether the event was a press (false) or a release (true) * @param release Whether the event was a press (false) or a release (true)
* *
* EXAMPLES: * EXAMPLES:
* ```cpp * ```cpp
* button_mouse(input, 1, false); // Press left mouse button * button_mouse(input, 1, false); // Press left mouse button
* ``` * ```
*/ */
void void
button_mouse(input_t &input, int button, bool release) { button_mouse(input_t &input, int button, bool release) {
auto mouse = ((input_raw_t *) input.get())->mouse_input.get(); auto mouse = ((input_raw_t *) input.get())->mouse_input.get();
@@ -1245,17 +1245,17 @@ namespace platf {
} }
/** /**
* @brief XTest mouse scroll. * @brief XTest mouse scroll.
* @param input The input_t instance to use. * @param input The input_t instance to use.
* @param distance How far to scroll * @param distance How far to scroll.
* @param button_pos Which mouse button to emulate for positive scroll. * @param button_pos Which mouse button to emulate for positive scroll.
* @param button_neg Which mouse button to emulate for negative scroll. * @param button_neg Which mouse button to emulate for negative scroll.
* *
* EXAMPLES: * EXAMPLES:
* ```cpp * ```cpp
* x_scroll(input, 10, 4, 5); * x_scroll(input, 10, 4, 5);
* ``` * ```
*/ */
static void static void
x_scroll(input_t &input, int distance, int button_pos, int button_neg) { x_scroll(input_t &input, int distance, int button_pos, int button_neg) {
#ifdef SUNSHINE_BUILD_X11 #ifdef SUNSHINE_BUILD_X11
@@ -1274,15 +1274,15 @@ namespace platf {
} }
/** /**
* @brief Vertical mouse scroll. * @brief Vertical mouse scroll.
* @param input The input_t instance to use. * @param input The input_t instance to use.
* @param high_res_distance How far to scroll * @param high_res_distance How far to scroll.
* *
* EXAMPLES: * EXAMPLES:
* ```cpp * ```cpp
* scroll(input, 1200); * scroll(input, 1200);
* ``` * ```
*/ */
void void
scroll(input_t &input, int high_res_distance) { scroll(input_t &input, int high_res_distance) {
int distance = high_res_distance / 120; int distance = high_res_distance / 120;
@@ -1299,15 +1299,15 @@ namespace platf {
} }
/** /**
* @brief Horizontal mouse scroll. * @brief Horizontal mouse scroll.
* @param input The input_t instance to use. * @param input The input_t instance to use.
* @param high_res_distance How far to scroll * @param high_res_distance How far to scroll.
* *
* EXAMPLES: * EXAMPLES:
* ```cpp * ```cpp
* hscroll(input, 1200); * hscroll(input, 1200);
* ``` * ```
*/ */
void void
hscroll(input_t &input, int high_res_distance) { hscroll(input_t &input, int high_res_distance) {
int distance = high_res_distance / 120; int distance = high_res_distance / 120;
@@ -1333,17 +1333,17 @@ namespace platf {
} }
/** /**
* @brief XTest keyboard emulation. * @brief XTest keyboard emulation.
* @param input The input_t instance to use. * @param input The input_t instance to use.
* @param modcode The moonlight key code. * @param modcode The moonlight key code.
* @param release Whether the event was a press (false) or a release (true) * @param release Whether the event was a press (false) or a release (true)
* @param flags SS_KBE_FLAG_* values * @param flags SS_KBE_FLAG_* values
* *
* EXAMPLES: * EXAMPLES:
* ```cpp * ```cpp
* x_keyboard(input, 0x5A, false, 0); // Press Z * x_keyboard(input, 0x5A, false, 0); // Press Z
* ``` * ```
*/ */
static void static void
x_keyboard(input_t &input, uint16_t modcode, bool release, uint8_t flags) { x_keyboard(input_t &input, uint16_t modcode, bool release, uint8_t flags) {
#ifdef SUNSHINE_BUILD_X11 #ifdef SUNSHINE_BUILD_X11
@@ -1368,17 +1368,17 @@ namespace platf {
} }
/** /**
* @brief Keyboard emulation. * @brief Keyboard emulation.
* @param input The input_t instance to use. * @param input The input_t instance to use.
* @param modcode The moonlight key code. * @param modcode The moonlight key code.
* @param release Whether the event was a press (false) or a release (true) * @param release Whether the event was a press (false) or a release (true)
* @param flags SS_KBE_FLAG_* values * @param flags SS_KBE_FLAG_* values
* *
* EXAMPLES: * EXAMPLES:
* ```cpp * ```cpp
* keyboard(input, 0x5A, false, 0); // Press Z * keyboard(input, 0x5A, false, 0); // Press Z
* ``` * ```
*/ */
void void
keyboard(input_t &input, uint16_t modcode, bool release, uint8_t flags) { keyboard(input_t &input, uint16_t modcode, bool release, uint8_t flags) {
auto keyboard = ((input_raw_t *) input.get())->keyboard_input.get(); auto keyboard = ((input_raw_t *) input.get())->keyboard_input.get();
@@ -1407,12 +1407,12 @@ namespace platf {
} }
/** /**
* Takes an UTF-32 encoded string and returns a hex string representation of the bytes (uppercase) * Takes an UTF-32 encoded string and returns a hex string representation of the bytes (uppercase)
* *
* ex: ['👱'] = "1F471" // see UTF encoding at https://www.compart.com/en/unicode/U+1F471 * ex: ['👱'] = "1F471" // see UTF encoding at https://www.compart.com/en/unicode/U+1F471
* *
* adapted from: https://stackoverflow.com/a/7639754 * adapted from: https://stackoverflow.com/a/7639754
*/ */
std::string std::string
to_hex(const std::basic_string<char32_t> &str) { to_hex(const std::basic_string<char32_t> &str) {
std::stringstream ss; std::stringstream ss;
@@ -1427,16 +1427,16 @@ namespace platf {
} }
/** /**
* Here we receive a single UTF-8 encoded char at a time, * Here we receive a single UTF-8 encoded char at a time,
* the trick is to convert it to UTF-32 then send CTRL+SHIFT+U+<HEXCODE> in order to produce any * the trick is to convert it to UTF-32 then send CTRL+SHIFT+U+{HEXCODE} in order to produce any
* unicode character, see: https://en.wikipedia.org/wiki/Unicode_input * unicode character, see: https://en.wikipedia.org/wiki/Unicode_input
* *
* ex: * ex:
* - when receiving UTF-8 [0xF0 0x9F 0x91 0xB1] (which is '👱') * - when receiving UTF-8 [0xF0 0x9F 0x91 0xB1] (which is '👱')
* - we'll convert it to UTF-32 [0x1F471] * - we'll convert it to UTF-32 [0x1F471]
* - then type: CTRL+SHIFT+U+1F471 * - then type: CTRL+SHIFT+U+1F471
* see the conversion at: https://www.compart.com/en/unicode/U+1F471 * see the conversion at: https://www.compart.com/en/unicode/U+1F471
*/ */
void void
unicode(input_t &input, char *utf8, int size) { unicode(input_t &input, char *utf8, int size) {
auto kb = ((input_raw_t *) input.get())->keyboard_input.get(); auto kb = ((input_raw_t *) input.get())->keyboard_input.get();
@@ -1549,13 +1549,13 @@ namespace platf {
} }
/** /**
* @brief Initalize a new keyboard and return it. * @brief Initialize a new keyboard and return it.
* *
* EXAMPLES: * EXAMPLES:
* ```cpp * ```cpp
* auto my_keyboard = keyboard(); * auto my_keyboard = keyboard();
* ``` * ```
*/ */
evdev_t evdev_t
keyboard() { keyboard() {
evdev_t dev { libevdev_new() }; evdev_t dev { libevdev_new() };
@@ -1578,13 +1578,13 @@ namespace platf {
} }
/** /**
* @brief Initalize a new uinput virtual mouse and return it. * @brief Initialize a new `uinput` virtual mouse and return it.
* *
* EXAMPLES: * EXAMPLES:
* ```cpp * ```cpp
* auto my_mouse = mouse(); * auto my_mouse = mouse();
* ``` * ```
*/ */
evdev_t evdev_t
mouse() { mouse() {
evdev_t dev { libevdev_new() }; evdev_t dev { libevdev_new() };
@@ -1629,13 +1629,13 @@ namespace platf {
} }
/** /**
* @brief Initalize a new uinput virtual touchscreen and return it. * @brief Initialize a new `uinput` virtual touchscreen and return it.
* *
* EXAMPLES: * EXAMPLES:
* ```cpp * ```cpp
* auto my_touchscreen = touchscreen(); * auto my_touchscreen = touchscreen();
* ``` * ```
*/ */
evdev_t evdev_t
touchscreen() { touchscreen() {
evdev_t dev { libevdev_new() }; evdev_t dev { libevdev_new() };
@@ -1679,13 +1679,13 @@ namespace platf {
} }
/** /**
* @brief Initalize a new uinput virtual X360 gamepad and return it. * @brief Initialize a new `uinput` virtual X360 gamepad and return it.
* *
* EXAMPLES: * EXAMPLES:
* ```cpp * ```cpp
* auto my_x360 = x360(); * auto my_x360 = x360();
* ``` * ```
*/ */
evdev_t evdev_t
x360() { x360() {
evdev_t dev { libevdev_new() }; evdev_t dev { libevdev_new() };
@@ -1756,13 +1756,13 @@ namespace platf {
} }
/** /**
* @brief Initalize the input system and return it. * @brief Initialize the input system and return it.
* *
* EXAMPLES: * EXAMPLES:
* ```cpp * ```cpp
* auto my_input = input(); * auto my_input = input();
* ``` * ```
*/ */
input_t input_t
input() { input() {
input_t result { new input_raw_t() }; input_t result { new input_raw_t() };

View File

@@ -552,7 +552,7 @@ namespace platf {
return -1; return -1;
} }
//TODO: surf_sd = fb->to_sd(); // TODO: surf_sd = fb->to_sd();
auto crct = card.crtc(plane->crtc_id); auto crct = card.crtc(plane->crtc_id);
kms::print(plane.get(), fb.get(), crct.get()); kms::print(plane.get(), fb.get(), crct.get());
@@ -999,15 +999,15 @@ namespace platf {
} }
/** /**
* On Wayland, it's not possible to determine the position of the monitor on the desktop with KMS. * On Wayland, it's not possible to determine the position of the monitor on the desktop with KMS.
* Wayland does allow applications to query attached monitors on the desktop, * Wayland does allow applications to query attached monitors on the desktop,
* however, the naming scheme is not standardized across implementations. * however, the naming scheme is not standardized across implementations.
* *
* As a result, correlating the KMS output to the wayland outputs is guess work at best. * As a result, correlating the KMS output to the wayland outputs is guess work at best.
* But, it's necessary for absolute mouse coordinates to work. * But, it's necessary for absolute mouse coordinates to work.
* *
* This is an ugly hack :( * This is an ugly hack :(
*/ */
void void
correlate_to_wayland(std::vector<kms::card_descriptor_t> &cds) { correlate_to_wayland(std::vector<kms::card_descriptor_t> &cds) {
auto monitors = wl::monitors(); auto monitors = wl::monitors();

View File

@@ -1,5 +1,4 @@
#ifndef SUNSHINE_PLATFORM_MISC_H #pragma once
#define SUNSHINE_PLATFORM_MISC_H
#include <unistd.h> #include <unistd.h>
#include <vector> #include <vector>
@@ -29,5 +28,3 @@ namespace dyn {
handle(const std::vector<const char *> &libs); handle(const std::vector<const char *> &libs);
} // namespace dyn } // namespace dyn
#endif

View File

@@ -12,7 +12,9 @@ using namespace std::literals;
namespace avahi { namespace avahi {
/** Error codes used by avahi */ /**
* @brief Error codes used by avahi
*/
enum err_e { enum err_e {
OK = 0, /**< OK */ OK = 0, /**< OK */
ERR_FAILURE = -1, /**< Generic error code */ ERR_FAILURE = -1, /**< Generic error code */
@@ -113,7 +115,9 @@ namespace avahi {
CLIENT_NO_FAIL = 2 /**< Don't fail if the daemon is not available when avahi_client_new() is called, instead enter CLIENT_CONNECTING state and wait for the daemon to appear */ CLIENT_NO_FAIL = 2 /**< Don't fail if the daemon is not available when avahi_client_new() is called, instead enter CLIENT_CONNECTING state and wait for the daemon to appear */
}; };
/** Some flags for publishing functions */ /**
* @brief Some flags for publishing functions
*/
enum PublishFlags { enum PublishFlags {
PUBLISH_UNIQUE = 1, /**< For raw records: The RRset is intended to be unique */ PUBLISH_UNIQUE = 1, /**< For raw records: The RRset is intended to be unique */
PUBLISH_NO_PROBE = 2, /**< For raw records: Though the RRset is intended to be unique no probes shall be sent */ PUBLISH_NO_PROBE = 2, /**< For raw records: Though the RRset is intended to be unique no probes shall be sent */
@@ -434,4 +438,4 @@ namespace platf::publish {
return std::make_unique<deinit_t>(std::thread { avahi::simple_poll_loop, poll.get() }); return std::make_unique<deinit_t>(std::thread { avahi::simple_poll_loop, poll.get() });
} }
} // namespace platf::publish } // namespace platf::publish

View File

@@ -7,8 +7,7 @@ extern "C" {
#include <libavcodec/avcodec.h> #include <libavcodec/avcodec.h>
#include <va/va.h> #include <va/va.h>
#if !VA_CHECK_VERSION(1, 9, 0) #if !VA_CHECK_VERSION(1, 9, 0)
/* vaSyncBuffer stub allows Sunshine built against libva <2.9.0 // vaSyncBuffer stub allows Sunshine built against libva <2.9.0 to link against ffmpeg on libva 2.9.0 or later
to link against ffmpeg on libva 2.9.0 or later */
VAStatus VAStatus
vaSyncBuffer( vaSyncBuffer(
VADisplay dpy, VADisplay dpy,
@@ -56,10 +55,7 @@ namespace va {
// Needs to be closed manually // Needs to be closed manually
int fd; int fd;
/* // Total size of this object (may include regions which are not part of the surface)
* Total size of this object (may include regions which are
* not part of the surface).
*/
uint32_t size; uint32_t size;
// Format modifier applied to this object, not sure what that means // Format modifier applied to this object, not sure what that means
uint64_t drm_format_modifier; uint64_t drm_format_modifier;
@@ -85,7 +81,9 @@ namespace va {
} layers[4]; } layers[4];
}; };
/** Currently defined profiles */ /**
* @brief Currently defined profiles
*/
enum class profile_e { enum class profile_e {
// Profile ID used for video processing. // Profile ID used for video processing.
ProfileNone = -1, ProfileNone = -1,
@@ -135,9 +133,9 @@ namespace va {
IDCT = 3, IDCT = 3,
MoComp = 4, MoComp = 4,
Deblocking = 5, Deblocking = 5,
EncSlice = 6, /* slice level encode */ EncSlice = 6, /** slice level encode */
EncPicture = 7, /* pictuer encode, JPEG, etc */ EncPicture = 7, /** picture encode, JPEG, etc */
/* /**
* For an implementation that supports a low power/high performance variant * For an implementation that supports a low power/high performance variant
* for slice level encode, it can choose to expose the * for slice level encode, it can choose to expose the
* VAEntrypointEncSliceLP entrypoint. Certain encoding tools may not be * VAEntrypointEncSliceLP entrypoint. Certain encoding tools may not be
@@ -148,7 +146,7 @@ namespace va {
EncSliceLP = 8, EncSliceLP = 8,
VideoProc = 10, /**< Video pre/post-processing. */ VideoProc = 10, /**< Video pre/post-processing. */
/** /**
* \brief FEI * @brief FEI
* *
* The purpose of FEI (Flexible Encoding Infrastructure) is to allow applications to * The purpose of FEI (Flexible Encoding Infrastructure) is to allow applications to
* have more controls and trade off quality for speed with their own IPs. * have more controls and trade off quality for speed with their own IPs.
@@ -162,10 +160,10 @@ namespace va {
* and VAEncFEIDistortionBufferType) for FEI entry function. * and VAEncFEIDistortionBufferType) for FEI entry function.
* If separate PAK is set, two extra input buffers * If separate PAK is set, two extra input buffers
* (VAEncFEIMVBufferType, VAEncFEIMBModeBufferType) are needed for PAK input. * (VAEncFEIMVBufferType, VAEncFEIMBModeBufferType) are needed for PAK input.
**/ */
FEI = 11, FEI = 11,
/** /**
* \brief Stats * @brief Stats
* *
* A pre-processing function for getting some statistics and motion vectors is added, * A pre-processing function for getting some statistics and motion vectors is added,
* and some extra controls for Encode pipeline are provided. The application can * and some extra controls for Encode pipeline are provided. The application can
@@ -179,19 +177,19 @@ namespace va {
* (VAStatsStatisticsParameterBufferType) and one or two output buffers * (VAStatsStatisticsParameterBufferType) and one or two output buffers
* (VAStatsStatisticsBufferType, VAStatsStatisticsBottomFieldBufferType (for interlace only) * (VAStatsStatisticsBufferType, VAStatsStatisticsBottomFieldBufferType (for interlace only)
* and VAStatsMVBufferType) are needed for this entry point. * and VAStatsMVBufferType) are needed for this entry point.
**/ */
Stats = 12, Stats = 12,
/** /**
* \brief ProtectedTEEComm * @brief ProtectedTEEComm
* *
* A function for communicating with TEE (Trusted Execution Environment). * A function for communicating with TEE (Trusted Execution Environment).
**/ */
ProtectedTEEComm = 13, ProtectedTEEComm = 13,
/** /**
* \brief ProtectedContent * @brief ProtectedContent
* *
* A function for protected content to decrypt encrypted content. * A function for protected content to decrypt encrypted content.
**/ */
ProtectedContent = 14, ProtectedContent = 14,
}; };
@@ -475,11 +473,11 @@ namespace va {
}; };
/** /**
* This is a private structure of FFmpeg, I need this to manually create * This is a private structure of FFmpeg, I need this to manually create
* a VAAPI hardware context * a VAAPI hardware context
* *
* xdisplay will not be used internally by FFmpeg * xdisplay will not be used internally by FFmpeg
*/ */
typedef struct VAAPIDevicePriv { typedef struct VAAPIDevicePriv {
union { union {
void *xdisplay; void *xdisplay;
@@ -489,22 +487,22 @@ namespace va {
} VAAPIDevicePriv; } VAAPIDevicePriv;
/** /**
* VAAPI connection details. * VAAPI connection details.
* *
* Allocated as AVHWDeviceContext.hwctx * Allocated as AVHWDeviceContext.hwctx
*/ */
typedef struct AVVAAPIDeviceContext { typedef struct AVVAAPIDeviceContext {
/** /**
* The VADisplay handle, to be filled by the user. * The VADisplay handle, to be filled by the user.
*/ */
va::VADisplay display; va::VADisplay display;
/** /**
* Driver quirks to apply - this is filled by av_hwdevice_ctx_init(), * Driver quirks to apply - this is filled by av_hwdevice_ctx_init(),
* with reference to a table of known drivers, unless the * with reference to a table of known drivers, unless the
* AV_VAAPI_DRIVER_QUIRK_USER_SET bit is already present. The user * AV_VAAPI_DRIVER_QUIRK_USER_SET bit is already present. The user
* may need to refer to this field when performing any later * may need to refer to this field when performing any later
* operations using VAAPI with the same VADisplay. * operations using VAAPI with the same VADisplay.
*/ */
unsigned int driver_quirks; unsigned int driver_quirks;
} AVVAAPIDeviceContext; } AVVAAPIDeviceContext;

View File

@@ -1,5 +1,4 @@
#ifndef SUNSHINE_VAAPI_H #pragma once
#define SUNSHINE_VAAPI_H
#include "misc.h" #include "misc.h"
#include "src/platform/common.h" #include "src/platform/common.h"
@@ -9,12 +8,12 @@ namespace egl {
} }
namespace va { namespace va {
/** /**
* Width --> Width of the image * Width --> Width of the image
* Height --> Height of the image * Height --> Height of the image
* offset_x --> Horizontal offset of the image in the texture * offset_x --> Horizontal offset of the image in the texture
* offset_y --> Vertical offset of the image in the texture * offset_y --> Vertical offset of the image in the texture
* file_t card --> The file descriptor of the render device used for encoding * file_t card --> The file descriptor of the render device used for encoding
*/ */
std::shared_ptr<platf::hwdevice_t> std::shared_ptr<platf::hwdevice_t>
make_hwdevice(int width, int height, bool vram); make_hwdevice(int width, int height, bool vram);
std::shared_ptr<platf::hwdevice_t> std::shared_ptr<platf::hwdevice_t>
@@ -29,4 +28,3 @@ namespace va {
int int
init(); init();
} // namespace va } // namespace va
#endif

View File

@@ -1,5 +1,4 @@
#ifndef SUNSHINE_WAYLAND_H #pragma once
#define SUNSHINE_WAYLAND_H
#include <bitset> #include <bitset>
@@ -180,9 +179,9 @@ namespace wl {
class display_t { class display_t {
public: public:
/** /**
* Initialize display with display_name * Initialize display with display_name
* If display_name == nullptr -> display_name = std::getenv("WAYLAND_DISPLAY") * If display_name == nullptr -> display_name = std::getenv("WAYLAND_DISPLAY")
*/ */
int int
init(const char *display_name = nullptr); init(const char *display_name = nullptr);
@@ -246,5 +245,3 @@ namespace wl {
init() { return -1; } init() { return -1; }
} // namespace wl } // namespace wl
#endif #endif
#endif

View File

@@ -1,7 +1,3 @@
//
// Created by loki on 6/21/19.
//
#include "src/platform/common.h" #include "src/platform/common.h"
#include <fstream> #include <fstream>
@@ -389,10 +385,10 @@ namespace platf {
mem_type_e mem_type; mem_type_e mem_type;
/* /**
* Last X (NOT the streamed monitor!) size. * Last X (NOT the streamed monitor!) size.
* This way we can trigger reinitialization if the dimensions changed while streaming * This way we can trigger reinitialization if the dimensions changed while streaming
*/ */
// int env_width, env_height; // int env_width, env_height;
x11_attr_t(mem_type_e mem_type): x11_attr_t(mem_type_e mem_type):
@@ -468,11 +464,11 @@ namespace platf {
} }
/** /**
* Called when the display attributes should change. * Called when the display attributes should change.
*/ */
void void
refresh() { refresh() {
x11::GetWindowAttributes(xdisplay.get(), xwindow, &xattr); //Update xattr's x11::GetWindowAttributes(xdisplay.get(), xwindow, &xattr); // Update xattr's
} }
capture_e capture_e
@@ -521,7 +517,7 @@ namespace platf {
snapshot(const pull_free_image_cb_t &pull_free_image_cb, std::shared_ptr<platf::img_t> &img_out, std::chrono::milliseconds timeout, bool cursor) { snapshot(const pull_free_image_cb_t &pull_free_image_cb, std::shared_ptr<platf::img_t> &img_out, std::chrono::milliseconds timeout, bool cursor) {
refresh(); refresh();
//The whole X server changed, so we must reinit everything // The whole X server changed, so we must reinit everything
if (xattr.width != env_width || xattr.height != env_height) { if (xattr.width != env_width || xattr.height != env_height) {
BOOST_LOG(warning) << "X dimensions changed in non-SHM mode, request reinit"sv; BOOST_LOG(warning) << "X dimensions changed in non-SHM mode, request reinit"sv;
return capture_e::reinit; return capture_e::reinit;
@@ -657,7 +653,7 @@ namespace platf {
capture_e capture_e
snapshot(const pull_free_image_cb_t &pull_free_image_cb, std::shared_ptr<platf::img_t> &img_out, std::chrono::milliseconds timeout, bool cursor) { snapshot(const pull_free_image_cb_t &pull_free_image_cb, std::shared_ptr<platf::img_t> &img_out, std::chrono::milliseconds timeout, bool cursor) {
//The whole X server changed, so we must reinit everything // The whole X server changed, so we must reinit everything
if (xattr.width != env_width || xattr.height != env_height) { if (xattr.width != env_width || xattr.height != env_height) {
BOOST_LOG(warning) << "X dimensions changed in SHM mode, request reinit"sv; BOOST_LOG(warning) << "X dimensions changed in SHM mode, request reinit"sv;
return capture_e::reinit; return capture_e::reinit;

View File

@@ -1,5 +1,4 @@
#ifndef SUNSHINE_X11_GRAB #pragma once
#define SUNSHINE_X11_GRAB
#include <optional> #include <optional>
@@ -34,11 +33,11 @@ namespace platf::x11 {
capture(egl::cursor_t &img); capture(egl::cursor_t &img);
/** /**
* Capture and blend the cursor into the image * Capture and blend the cursor into the image
* *
* img <-- destination image * img <-- destination image
* offsetX, offsetY <--- Top left corner of the virtual screen * offsetX, offsetY <--- Top left corner of the virtual screen
*/ */
void void
blend(img_t &img, int offsetX, int offsetY); blend(img_t &img, int offsetX, int offsetY);
@@ -66,5 +65,3 @@ namespace platf::x11 {
make_display() { return nullptr; } make_display() { return nullptr; }
#endif #endif
} // namespace platf::x11 } // namespace platf::x11
#endif

View File

@@ -1,5 +1,4 @@
#ifndef SUNSHINE_PLATFORM_AV_AUDIO_H #pragma once
#define SUNSHINE_PLATFORM_AV_AUDIO_H
#import <AVFoundation/AVFoundation.h> #import <AVFoundation/AVFoundation.h>
@@ -22,5 +21,3 @@
- (int)setupMicrophone:(AVCaptureDevice *)device sampleRate:(UInt32)sampleRate frameSize:(UInt32)frameSize channels:(UInt8)channels; - (int)setupMicrophone:(AVCaptureDevice *)device sampleRate:(UInt32)sampleRate frameSize:(UInt32)frameSize channels:(UInt8)channels;
@end @end
#endif //SUNSHINE_PLATFORM_AV_AUDIO_H

View File

@@ -126,7 +126,7 @@
CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer(sampleBuffer, NULL, &audioBufferList, sizeof(audioBufferList), NULL, NULL, 0, &blockBuffer); CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer(sampleBuffer, NULL, &audioBufferList, sizeof(audioBufferList), NULL, NULL, 0, &blockBuffer);
//NSAssert(audioBufferList.mNumberBuffers == 1, @"Expected interlveaved PCM format but buffer contained %u streams", audioBufferList.mNumberBuffers); // NSAssert(audioBufferList.mNumberBuffers == 1, @"Expected interlveaved PCM format but buffer contained %u streams", audioBufferList.mNumberBuffers);
// this is safe, because an interleaved PCM stream has exactly one buffer // this is safe, because an interleaved PCM stream has exactly one buffer
// and we don't want to do sanity checks in a performance critical exec path // and we don't want to do sanity checks in a performance critical exec path

View File

@@ -1,5 +1,4 @@
#ifndef av_img_t_h #pragma once
#define av_img_t_h
#include "src/platform/common.h" #include "src/platform/common.h"
@@ -14,5 +13,3 @@ namespace platf {
~av_img_t(); ~av_img_t();
}; };
} // namespace platf } // namespace platf
#endif /* av_img_t_h */

View File

@@ -1,5 +1,4 @@
#ifndef SUNSHINE_PLATFORM_AV_VIDEO_H #pragma once
#define SUNSHINE_PLATFORM_AV_VIDEO_H
#import <AVFoundation/AVFoundation.h> #import <AVFoundation/AVFoundation.h>
@@ -38,5 +37,3 @@ typedef bool (^FrameCallbackBlock)(CMSampleBufferRef);
- (dispatch_semaphore_t)capture:(FrameCallbackBlock)frameCallback; - (dispatch_semaphore_t)capture:(FrameCallbackBlock)frameCallback;
@end @end
#endif //SUNSHINE_PLATFORM_AV_VIDEO_H

View File

@@ -150,12 +150,12 @@ namespace platf {
} }
/** /**
* A bridge from the pure C++ code of the hwdevice_t class to the pure Objective C code. * A bridge from the pure C++ code of the hwdevice_t class to the pure Objective C code.
* *
* display --> an opaque pointer to an object of this class * display --> an opaque pointer to an object of this class
* width --> the intended capture width * width --> the intended capture width
* height --> the intended capture height * height --> the intended capture height
*/ */
static void static void
setResolution(void *display, int width, int height) { setResolution(void *display, int width, int height) {
[static_cast<AVVideo *>(display) setFrameWidth:width frameHeight:height]; [static_cast<AVVideo *>(display) setFrameWidth:width frameHeight:height];

View File

@@ -1,5 +1,4 @@
#ifndef SUNSHINE_PLATFORM_MISC_H #pragma once
#define SUNSHINE_PLATFORM_MISC_H
#include <vector> #include <vector>
@@ -14,5 +13,3 @@ namespace dyn {
handle(const std::vector<const char *> &libs); handle(const std::vector<const char *> &libs);
} // namespace dyn } // namespace dyn
#endif

View File

@@ -1,5 +1,4 @@
#ifndef vtdevice_h #pragma once
#define vtdevice_h
#include "src/platform/common.h" #include "src/platform/common.h"
@@ -29,5 +28,3 @@ namespace platf {
}; };
} // namespace platf } // namespace platf
#endif /* vtdevice_h */

View File

@@ -12,7 +12,9 @@ using namespace std::literals;
namespace avahi { namespace avahi {
/** Error codes used by avahi */ /**
* @brief Error codes used by avahi
*/
enum err_e { enum err_e {
OK = 0, /**< OK */ OK = 0, /**< OK */
ERR_FAILURE = -1, /**< Generic error code */ ERR_FAILURE = -1, /**< Generic error code */
@@ -113,7 +115,9 @@ namespace avahi {
CLIENT_NO_FAIL = 2 /**< Don't fail if the daemon is not available when avahi_client_new() is called, instead enter CLIENT_CONNECTING state and wait for the daemon to appear */ CLIENT_NO_FAIL = 2 /**< Don't fail if the daemon is not available when avahi_client_new() is called, instead enter CLIENT_CONNECTING state and wait for the daemon to appear */
}; };
/** Some flags for publishing functions */ /**
* @brief Some flags for publishing functions
*/
enum PublishFlags { enum PublishFlags {
PUBLISH_UNIQUE = 1, /**< For raw records: The RRset is intended to be unique */ PUBLISH_UNIQUE = 1, /**< For raw records: The RRset is intended to be unique */
PUBLISH_NO_PROBE = 2, /**< For raw records: Though the RRset is intended to be unique no probes shall be sent */ PUBLISH_NO_PROBE = 2, /**< For raw records: Though the RRset is intended to be unique no probes shall be sent */
@@ -434,4 +438,4 @@ namespace platf::publish {
return std::make_unique<deinit_t>(std::thread { avahi::simple_poll_loop, poll.get() }); return std::make_unique<deinit_t>(std::thread { avahi::simple_poll_loop, poll.get() });
} }
}; // namespace platf::publish } // namespace platf::publish

View File

@@ -1,7 +1,3 @@
//
// Created by loki on 1/12/20.
//
#include <audioclient.h> #include <audioclient.h>
#include <mmdeviceapi.h> #include <mmdeviceapi.h>
#include <roapi.h> #include <roapi.h>
@@ -589,13 +585,13 @@ namespace platf::audio {
} }
/** /**
* If the requested sink is a virtual sink, meaning no speakers attached to * If the requested sink is a virtual sink, meaning no speakers attached to
* the host, then we can seamlessly set the format to stereo and surround sound. * the host, then we can seamlessly set the format to stereo and surround sound.
* *
* Any virtual sink detected will be prefixed by: * Any virtual sink detected will be prefixed by:
* virtual-(format name) * virtual-(format name)
* If it doesn't contain that prefix, then the format will not be changed * If it doesn't contain that prefix, then the format will not be changed
*/ */
std::optional<std::wstring> std::optional<std::wstring>
set_format(const std::string &sink) { set_format(const std::string &sink) {
std::string_view sv { sink.c_str(), sink.size() }; std::string_view sv { sink.c_str(), sink.size() };

View File

@@ -1,9 +1,4 @@
// #pragma once
// Created by loki on 4/23/20.
//
#ifndef SUNSHINE_DISPLAY_H
#define SUNSHINE_DISPLAY_H
#include <d3d11.h> #include <d3d11.h>
#include <d3d11_4.h> #include <d3d11_4.h>
@@ -237,5 +232,3 @@ namespace platf::dxgi {
std::atomic<uint32_t> next_image_id; std::atomic<uint32_t> next_image_id;
}; };
} // namespace platf::dxgi } // namespace platf::dxgi
#endif

View File

@@ -1,7 +1,3 @@
//
// Created by loki on 1/12/20.
//
#include <cmath> #include <cmath>
#include <codecvt> #include <codecvt>
#include <initguid.h> #include <initguid.h>
@@ -537,7 +533,7 @@ namespace platf::dxgi {
} }
} }
//FIXME: Duplicate output on RX580 in combination with DOOM (2016) --> BSOD // FIXME: Duplicate output on RX580 in combination with DOOM (2016) --> BSOD
{ {
// IDXGIOutput5 is optional, but can provide improved performance and wide color support // IDXGIOutput5 is optional, but can provide improved performance and wide color support
dxgi::output5_t output5 {}; dxgi::output5_t output5 {};

View File

@@ -83,7 +83,7 @@ namespace platf::dxgi {
auto colors_out = (std::uint8_t *) &cursor_pixel; auto colors_out = (std::uint8_t *) &cursor_pixel;
auto colors_in = (std::uint8_t *) img_pixel_p; auto colors_in = (std::uint8_t *) img_pixel_p;
//TODO: When use of IDXGIOutput5 is implemented, support different color formats // TODO: When use of IDXGIOutput5 is implemented, support different color formats
auto alpha = colors_out[3]; auto alpha = colors_out[3];
if (alpha == 255) { if (alpha == 255) {
*img_pixel_p = cursor_pixel; *img_pixel_p = cursor_pixel;
@@ -97,7 +97,7 @@ namespace platf::dxgi {
void void
apply_color_masked(int *img_pixel_p, int cursor_pixel) { apply_color_masked(int *img_pixel_p, int cursor_pixel) {
//TODO: When use of IDXGIOutput5 is implemented, support different color formats // TODO: When use of IDXGIOutput5 is implemented, support different color formats
auto alpha = ((std::uint8_t *) &cursor_pixel)[3]; auto alpha = ((std::uint8_t *) &cursor_pixel)[3];
if (alpha == 0xFF) { if (alpha == 0xFF) {
*img_pixel_p ^= cursor_pixel; *img_pixel_p ^= cursor_pixel;
@@ -270,7 +270,7 @@ namespace platf::dxgi {
return capture_e::reinit; return capture_e::reinit;
} }
//Copy from GPU to CPU // Copy from GPU to CPU
device_ctx->CopyResource(texture.get(), src.get()); device_ctx->CopyResource(texture.get(), src.get());
} }
} }

View File

@@ -533,7 +533,7 @@ namespace platf::dxgi {
frame_texture->AddRef(); frame_texture->AddRef();
hwframe_texture.reset(frame_texture); hwframe_texture.reset(frame_texture);
float info_in[16 / sizeof(float)] { 1.0f / (float) out_width_f }; //aligned to 16-byte float info_in[16 / sizeof(float)] { 1.0f / (float) out_width_f }; // aligned to 16-byte
info_scene = make_buffer(device.get(), info_in); info_scene = make_buffer(device.get(), info_in);
if (!info_scene) { if (!info_scene) {

View File

@@ -229,10 +229,10 @@ namespace platf {
} }
/** /**
* @brief A function to obtain the current sessions user's primary token with elevated privileges * @brief A function to obtain the current sessions user's primary token with elevated privileges
* *
* @return The users token, if user has admin capability it will be elevated. If not, it will return back a limited token. On error, nullptrs * @return The users token, if user has admin capability it will be elevated. If not, it will return back a limited token. On error, nullptrs
*/ */
HANDLE HANDLE
retrieve_users_token(bool elevated) { retrieve_users_token(bool elevated) {
DWORD consoleSessionId; DWORD consoleSessionId;
@@ -430,15 +430,15 @@ namespace platf {
} }
/** /**
* @brief Creates a bp::child object from the results of launching a process * @brief Creates a bp::child object from the results of launching a process
* *
* @param process_launched A boolean indicating whether the launch was successful or not * @param process_launched A boolean indicating whether the launch was successful or not
* @param cmd The command that was used to launch the process * @param cmd The command that was used to launch the process
* @param ec A reference to an std::error_code object that will store any error that occurred during the launch * @param ec A reference to an std::error_code object that will store any error that occurred during the launch
* @param process_info A reference to a PROCESS_INFORMATION structure that contains information about the new process * @param process_info A reference to a PROCESS_INFORMATION structure that contains information about the new process
* @param group A pointer to a bp::group object that will add the new process to its group, if not null * @param group A pointer to a bp::group object that will add the new process to its group, if not null
* @return A bp::child object representing the new process, or an empty bp::child object if the launch failed or an error occurred * @return A bp::child object representing the new process, or an empty bp::child object if the launch failed or an error occurred
*/ */
bp::child bp::child
create_boost_child_from_results(bool process_launched, const std::string &cmd, std::error_code &ec, PROCESS_INFORMATION &process_info, bp::group *group) { create_boost_child_from_results(bool process_launched, const std::string &cmd, std::error_code &ec, PROCESS_INFORMATION &process_info, bp::group *group) {
// Use RAII to ensure the process is closed when we're done with it, even if there was an error. // Use RAII to ensure the process is closed when we're done with it, even if there was an error.
@@ -477,12 +477,12 @@ namespace platf {
} }
/** /**
* @brief Impersonate the current user, invoke the callback function, then returns back to system context. * @brief Impersonate the current user, invoke the callback function, then returns back to system context.
* *
* @param user_token A handle to the user's token that was obtained from the shell * @param user_token A handle to the user's token that was obtained from the shell
* @param callback A function that will be executed while impersonating the user * @param callback A function that will be executed while impersonating the user
* @return An std::error_code object that will store any error that occurred during the impersonation * @return An std::error_code object that will store any error that occurred during the impersonation
*/ */
std::error_code std::error_code
impersonate_current_user(HANDLE user_token, std::function<void()> callback) { impersonate_current_user(HANDLE user_token, std::function<void()> callback) {
std::error_code ec; std::error_code ec;
@@ -515,12 +515,12 @@ namespace platf {
} }
/** /**
* @brief A function to create a STARTUPINFOEXW structure for launching a process * @brief A function to create a STARTUPINFOEXW structure for launching a process
* *
* @param file A pointer to a FILE object that will be used as the standard output and error for the new process, or null if not needed * @param file A pointer to a FILE object that will be used as the standard output and error for the new process, or null if not needed
* @param ec A reference to an std::error_code object that will store any error that occurred during the creation of the structure * @param ec A reference to an std::error_code object that will store any error that occurred during the creation of the structure
* @return A STARTUPINFOEXW structure that contains information about how to launch the new process * @return A STARTUPINFOEXW structure that contains information about how to launch the new process
*/ */
STARTUPINFOEXW STARTUPINFOEXW
create_startup_info(FILE *file, std::error_code &ec) { create_startup_info(FILE *file, std::error_code &ec) {
// Initialize a zeroed-out STARTUPINFOEXW structure and set its size // Initialize a zeroed-out STARTUPINFOEXW structure and set its size
@@ -563,23 +563,23 @@ namespace platf {
} }
/** /**
* @brief Runs a command on the users profile * @brief Runs a command on the users profile
* *
* This function launches a child process as the user, using the current user's environment * This function launches a child process as the user, using the current user's environment
* and a specific working directory. If the launch is successful, a `bp::child` object representing the new * and a specific working directory. If the launch is successful, a `bp::child` object representing the new
* process is returned. Otherwise, an error code is returned. * process is returned. Otherwise, an error code is returned.
* *
* @param elevated Specify to elevate the process or not * @param elevated Specify to elevate the process or not
* @param interactive Specifies whether this will run in a window or hidden * @param interactive Specifies whether this will run in a window or hidden
* @param cmd The command to run * @param cmd The command to run
* @param working_dir The working directory for the new process * @param working_dir The working directory for the new process
* @param env The environment variables to use for the new process * @param env The environment variables to use for the new process
* @param file A file object to redirect the child process's output to (may be nullptr) * @param file A file object to redirect the child process's output to (may be nullptr)
* @param ec An error code, set to indicate any errors that occur during the launch process * @param ec An error code, set to indicate any errors that occur during the launch process
* @param group A pointer to a `bp::group` object to which the new process should belong (may be nullptr) * @param group A pointer to a `bp::group` object to which the new process should belong (may be nullptr)
* *
* @return A `bp::child` object representing the new process, or an empty `bp::child` object if the launch fails * @return A `bp::child` object representing the new process, or an empty `bp::child` object if the launch fails
*/ */
bp::child bp::child
run_command(bool elevated, bool interactive, const std::string &cmd, boost::filesystem::path &working_dir, bp::environment &env, FILE *file, std::error_code &ec, bp::group *group) { run_command(bool elevated, bool interactive, const std::string &cmd, boost::filesystem::path &working_dir, bp::environment &env, FILE *file, std::error_code &ec, bp::group *group) {
BOOL ret; BOOL ret;
@@ -1091,4 +1091,4 @@ namespace platf {
} }
return {}; return {};
} }
} // namespace platf } // namespace platf

View File

@@ -1,5 +1,4 @@
#ifndef SUNSHINE_WINDOWS_MISC_H #pragma once
#define SUNSHINE_WINDOWS_MISC_H
#include <chrono> #include <chrono>
#include <string_view> #include <string_view>
@@ -18,5 +17,3 @@ namespace platf {
std::chrono::nanoseconds std::chrono::nanoseconds
qpc_time_difference(int64_t performance_counter1, int64_t performance_counter2); qpc_time_difference(int64_t performance_counter1, int64_t performance_counter2);
} // namespace platf } // namespace platf
#endif

View File

@@ -1,5 +1,3 @@
// Created by loki on 12/14/19.
#define BOOST_BIND_GLOBAL_PLACEHOLDERS #define BOOST_BIND_GLOBAL_PLACEHOLDERS
#include "process.h" #include "process.h"

View File

@@ -1,7 +1,4 @@
// Created by loki on 12/14/19. #pragma once
#ifndef SUNSHINE_PROCESS_H
#define SUNSHINE_PROCESS_H
#ifndef __kernel_entry #ifndef __kernel_entry
#define __kernel_entry #define __kernel_entry
@@ -19,27 +16,27 @@ namespace proc {
using file_t = util::safe_ptr_v2<FILE, int, fclose>; using file_t = util::safe_ptr_v2<FILE, int, fclose>;
typedef config::prep_cmd_t cmd_t; typedef config::prep_cmd_t cmd_t;
/* /**
* pre_cmds -- guaranteed to be executed unless any of the commands fail. * pre_cmds -- guaranteed to be executed unless any of the commands fail.
* detached -- commands detached from Sunshine * detached -- commands detached from Sunshine
* cmd -- Runs indefinitely until: * cmd -- Runs indefinitely until:
* No session is running and a different set of commands it to be executed * No session is running and a different set of commands it to be executed
* Command exits * Command exits
* working_dir -- the process working directory. This is required for some games to run properly. * working_dir -- the process working directory. This is required for some games to run properly.
* cmd_output -- * cmd_output --
* empty -- The output of the commands are appended to the output of sunshine * empty -- The output of the commands are appended to the output of sunshine
* "null" -- The output of the commands are discarded * "null" -- The output of the commands are discarded
* filename -- The output of the commands are appended to filename * filename -- The output of the commands are appended to filename
*/ */
struct ctx_t { struct ctx_t {
std::vector<cmd_t> prep_cmds; std::vector<cmd_t> prep_cmds;
/** /**
* Some applications, such as Steam, * Some applications, such as Steam,
* either exit quickly, or keep running indefinitely. * either exit quickly, or keep running indefinitely.
* Steam.exe is one such application. * Steam.exe is one such application.
* That is why some applications need be run and forgotten about * That is why some applications need be run and forgotten about
*/ */
std::vector<std::string> detached; std::vector<std::string> detached;
std::string name; std::string name;
@@ -66,8 +63,8 @@ namespace proc {
execute(int app_id); execute(int app_id);
/** /**
* @return _app_id if a process is running, otherwise returns 0 * @return _app_id if a process is running, otherwise returns 0
*/ */
int int
running(); running();
@@ -102,9 +99,9 @@ namespace proc {
}; };
/** /**
* Calculate a stable id based on name and image data * Calculate a stable id based on name and image data
* @return tuple of id calculated without index (for use if no collision) and one with * @return tuple of id calculated without index (for use if no collision) and one with
*/ */
std::tuple<std::string, std::string> std::tuple<std::string, std::string>
calculate_app_id(const std::string &app_name, std::string app_image_path, int index); calculate_app_id(const std::string &app_name, std::string app_image_path, int index);
@@ -117,4 +114,3 @@ namespace proc {
extern proc_t proc; extern proc_t proc;
} // namespace proc } // namespace proc
#endif // SUNSHINE_PROCESS_H

View File

@@ -1,5 +1,4 @@
#ifndef KITTY_UTIL_ITERATOR_H #pragma once
#define KITTY_UTIL_ITERATOR_H
#include <iterator> #include <iterator>
@@ -180,5 +179,3 @@ namespace round_robin_util {
return round_robin_t<V, It>(begin, end); return round_robin_t<V, It>(begin, end);
} }
} // namespace round_robin_util } // namespace round_robin_util
#endif

View File

@@ -1,5 +1,3 @@
// Created by loki on 2/2/20.
#define BOOST_BIND_GLOBAL_PLACEHOLDERS #define BOOST_BIND_GLOBAL_PLACEHOLDERS
extern "C" { extern "C" {
@@ -501,10 +499,10 @@ namespace rtsp_stream {
auto mapping_p = stream_config.mapping; auto mapping_p = stream_config.mapping;
/** /**
* GFE advertises incorrect mapping for normal quality configurations, * GFE advertises incorrect mapping for normal quality configurations,
* as a result, Moonlight rotates all channels from index '3' to the right * as a result, Moonlight rotates all channels from index '3' to the right
* To work around this, rotate channels to the left from index '3' * To work around this, rotate channels to the left from index '3'
*/ */
if (x == audio::SURROUND51 || x == audio::SURROUND71) { if (x == audio::SURROUND51 || x == audio::SURROUND71) {
std::copy_n(mapping_p, stream_config.channelCount, mapping); std::copy_n(mapping_p, stream_config.channelCount, mapping);
std::rotate(mapping + 3, mapping + 4, mapping + audio::MAX_STREAM_CONFIG); std::rotate(mapping + 3, mapping + 4, mapping + audio::MAX_STREAM_CONFIG);

View File

@@ -1,7 +1,4 @@
// Created by loki on 2/2/20. #pragma once
#ifndef SUNSHINE_RTSP_H
#define SUNSHINE_RTSP_H
#include <atomic> #include <atomic>
@@ -27,5 +24,3 @@ namespace rtsp_stream {
rtpThread(); rtpThread();
} // namespace rtsp_stream } // namespace rtsp_stream
#endif // SUNSHINE_RTSP_H

View File

@@ -1,5 +1,3 @@
// Created by loki on 6/5/19.
#include "process.h" #include "process.h"
#include <future> #include <future>
@@ -359,11 +357,11 @@ namespace stream {
}; };
/** /**
* First part of cipher must be struct of type control_encrypted_t * First part of cipher must be struct of type control_encrypted_t
* *
* returns empty string_view on failure * returns empty string_view on failure
* returns string_view pointing to payload data * returns string_view pointing to payload data
*/ */
template <std::size_t max_payload_size> template <std::size_t max_payload_size>
static inline std::string_view static inline std::string_view
encode_control(session_t *session, const std::string_view &plaintext, std::array<std::uint8_t, max_payload_size> &tagged_cipher) { encode_control(session_t *session, const std::string_view &plaintext, std::array<std::uint8_t, max_payload_size> &tagged_cipher) {

View File

@@ -1,7 +1,4 @@
// Created by loki on 6/5/19. #pragma once
#ifndef SUNSHINE_STREAM_H
#define SUNSHINE_STREAM_H
#include <boost/asio.hpp> #include <boost/asio.hpp>
@@ -49,5 +46,3 @@ namespace stream {
state(session_t &session); state(session_t &session);
} // namespace session } // namespace session
} // namespace stream } // namespace stream
#endif // SUNSHINE_STREAM_H

View File

@@ -1,7 +1,4 @@
// Created by loki on 16-4-19. #pragma once
#ifndef SUNSHINE_SYNC_H
#define SUNSHINE_SYNC_H
#include <array> #include <array>
#include <mutex> #include <mutex>
@@ -98,5 +95,3 @@ namespace sync_util {
}; };
} // namespace sync_util } // namespace sync_util
#endif // SUNSHINE_SYNC_H

View File

@@ -37,9 +37,9 @@ using namespace std::literals;
namespace system_tray { namespace system_tray {
/** /**
* @brief Callback for opening the UI from the system tray. * @brief Callback for opening the UI from the system tray.
* @param item The tray menu item. * @param item The tray menu item.
*/ */
void void
tray_open_ui_cb(struct tray_menu *item) { tray_open_ui_cb(struct tray_menu *item) {
BOOST_LOG(info) << "Opening UI from system tray"sv; BOOST_LOG(info) << "Opening UI from system tray"sv;
@@ -47,45 +47,45 @@ namespace system_tray {
} }
/** /**
* @brief Callback for opening GitHub Sponsors from the system tray. * @brief Callback for opening GitHub Sponsors from the system tray.
* @param item The tray menu item. * @param item The tray menu item.
*/ */
void void
tray_donate_github_cb(struct tray_menu *item) { tray_donate_github_cb(struct tray_menu *item) {
platf::open_url("https://github.com/sponsors/LizardByte"); platf::open_url("https://github.com/sponsors/LizardByte");
} }
/** /**
* @brief Callback for opening MEE6 donation from the system tray. * @brief Callback for opening MEE6 donation from the system tray.
* @param item The tray menu item. * @param item The tray menu item.
*/ */
void void
tray_donate_mee6_cb(struct tray_menu *item) { tray_donate_mee6_cb(struct tray_menu *item) {
platf::open_url("https://mee6.xyz/m/804382334370578482"); platf::open_url("https://mee6.xyz/m/804382334370578482");
} }
/** /**
* @brief Callback for opening Patreon from the system tray. * @brief Callback for opening Patreon from the system tray.
* @param item The tray menu item. * @param item The tray menu item.
*/ */
void void
tray_donate_patreon_cb(struct tray_menu *item) { tray_donate_patreon_cb(struct tray_menu *item) {
platf::open_url("https://www.patreon.com/LizardByte"); platf::open_url("https://www.patreon.com/LizardByte");
} }
/** /**
* @brief Callback for opening PayPal donation from the system tray. * @brief Callback for opening PayPal donation from the system tray.
* @param item The tray menu item. * @param item The tray menu item.
*/ */
void void
tray_donate_paypal_cb(struct tray_menu *item) { tray_donate_paypal_cb(struct tray_menu *item) {
platf::open_url("https://www.paypal.com/paypalme/ReenigneArcher"); platf::open_url("https://www.paypal.com/paypalme/ReenigneArcher");
} }
/** /**
* @brief Callback for restarting Sunshine from the system tray. * @brief Callback for restarting Sunshine from the system tray.
* @param item The tray menu item. * @param item The tray menu item.
*/ */
void void
tray_restart_cb(struct tray_menu *item) { tray_restart_cb(struct tray_menu *item) {
BOOST_LOG(info) << "Restarting from system tray"sv; BOOST_LOG(info) << "Restarting from system tray"sv;
@@ -94,9 +94,9 @@ namespace system_tray {
} }
/** /**
* @brief Callback for exiting Sunshine from the system tray. * @brief Callback for exiting Sunshine from the system tray.
* @param item The tray menu item. * @param item The tray menu item.
*/ */
void void
tray_quit_cb(struct tray_menu *item) { tray_quit_cb(struct tray_menu *item) {
BOOST_LOG(info) << "Quiting from system tray"sv; BOOST_LOG(info) << "Quiting from system tray"sv;
@@ -138,10 +138,10 @@ namespace system_tray {
}; };
/** /**
* @brief Create the system tray. * @brief Create the system tray.
* @details This function has an endless loop, so it should be run in a separate thread. * @details This function has an endless loop, so it should be run in a separate thread.
* @return 1 if the system tray failed to create, otherwise 0 once the tray has been terminated. * @return 1 if the system tray failed to create, otherwise 0 once the tray has been terminated.
*/ */
int int
system_tray() { system_tray() {
#ifdef _WIN32 #ifdef _WIN32
@@ -229,9 +229,9 @@ namespace system_tray {
} }
/** /**
* @brief Run the system tray with platform specific options. * @brief Run the system tray with platform specific options.
* @note macOS requires that UI elements be created on the main thread, so the system tray is not implemented for macOS. * @note macOS requires that UI elements be created on the main thread, so the system tray is not implemented for macOS.
*/ */
void void
run_tray() { run_tray() {
// create the system tray // create the system tray
@@ -252,9 +252,9 @@ namespace system_tray {
} }
/** /**
* @brief Exit the system tray. * @brief Exit the system tray.
* @return 0 after exiting the system tray. * @return 0 after exiting the system tray.
*/ */
int int
end_tray() { end_tray() {
tray_exit(); tray_exit();

View File

@@ -2,8 +2,7 @@
* @file system_tray.h * @file system_tray.h
*/ */
#ifndef SUNSHINE_SYSTEM_TRAY_H #pragma once
#define SUNSHINE_SYSTEM_TRAY_H
// system_tray namespace // system_tray namespace
namespace system_tray { namespace system_tray {
@@ -31,4 +30,3 @@ namespace system_tray {
end_tray(); end_tray();
} // namespace system_tray } // namespace system_tray
#endif // SUNSHINE_SYSTEM_TRAY_H

View File

@@ -1,5 +1,4 @@
#ifndef KITTY_TASK_POOL_H #pragma once
#define KITTY_TASK_POOL_H
#include <chrono> #include <chrono>
#include <deque> #include <deque>
@@ -111,8 +110,8 @@ namespace task_pool_util {
} }
/** /**
* @return an id to potentially delay the task * @return an id to potentially delay the task.
*/ */
template <class Function, class X, class Y, class... Args> template <class Function, class X, class Y, class... Args>
auto auto
pushDelayed(Function &&newTask, std::chrono::duration<X, Y> duration, Args &&...args) { pushDelayed(Function &&newTask, std::chrono::duration<X, Y> duration, Args &&...args) {
@@ -146,8 +145,9 @@ namespace task_pool_util {
} }
/** /**
* @param duration The delay before executing the task * @param task_id The id of the task to delay.
*/ * @param duration The delay before executing the task.
*/
template <class X, class Y> template <class X, class Y>
void void
delay(task_id_t task_id, std::chrono::duration<X, Y> duration) { delay(task_id_t task_id, std::chrono::duration<X, Y> duration) {
@@ -257,4 +257,3 @@ namespace task_pool_util {
} }
}; };
} // namespace task_pool_util } // namespace task_pool_util
#endif

View File

@@ -1,14 +1,12 @@
#ifndef KITTY_THREAD_POOL_H #pragma once
#define KITTY_THREAD_POOL_H
#include "task_pool.h" #include "task_pool.h"
#include <thread> #include <thread>
namespace thread_pool_util { namespace thread_pool_util {
/* /**
* Allow threads to execute unhindered * Allow threads to execute unhindered while keeping full control over the threads.
* while keeping full control over the threads. */
*/
class ThreadPool: public task_pool_util::TaskPool { class ThreadPool: public task_pool_util::TaskPool {
public: public:
typedef TaskPool::__task __task; typedef TaskPool::__task __task;
@@ -127,4 +125,3 @@ namespace thread_pool_util {
} }
}; };
} // namespace thread_pool_util } // namespace thread_pool_util
#endif

View File

@@ -1,7 +1,4 @@
// Created by loki on 6/10/19. #pragma once
#ifndef SUNSHINE_THREAD_SAFE_H
#define SUNSHINE_THREAD_SAFE_H
#include <array> #include <array>
#include <atomic> #include <atomic>
@@ -574,5 +571,3 @@ namespace safe {
mail->cleanup(); mail->cleanup();
} }
} // namespace safe } // namespace safe
#endif // SUNSHINE_THREAD_SAFE_H

View File

@@ -1,5 +1,4 @@
#ifndef SUNSHINE_UPNP_H #pragma once
#define SUNSHINE_UPNP_H
#include "platform/common.h" #include "platform/common.h"
@@ -7,5 +6,3 @@ namespace upnp {
[[nodiscard]] std::unique_ptr<platf::deinit_t> [[nodiscard]] std::unique_ptr<platf::deinit_t>
start(); start();
} }
#endif

View File

@@ -1,5 +1,4 @@
#ifndef UTILITY_H #pragma once
#define UTILITY_H
#include <algorithm> #include <algorithm>
#include <condition_variable> #include <condition_variable>
@@ -1030,4 +1029,3 @@ namespace util {
big(T x) { return endian_helper<T>::big(x); } big(T x) { return endian_helper<T>::big(x); }
} // namespace endian } // namespace endian
} // namespace util } // namespace util
#endif

View File

@@ -1,7 +1,4 @@
// Created by loki on 8-2-19. #pragma once
#ifndef T_MAN_UUID_H
#define T_MAN_UUID_H
#include <random> #include <random>
@@ -80,4 +77,3 @@ namespace uuid_util {
} }
}; };
} // namespace uuid_util } // namespace uuid_util
#endif // T_MAN_UUID_H

View File

@@ -1,10 +1,7 @@
#ifndef INCLUDE_GUARD #pragma once
#define INCLUDE_GUARD
#define PROJECT_NAME "@PROJECT_NAME@" #define PROJECT_NAME "@PROJECT_NAME@"
#define PROJECT_VER "@PROJECT_VERSION@" #define PROJECT_VER "@PROJECT_VERSION@"
#define PROJECT_VER_MAJOR "@PROJECT_VERSION_MAJOR@" #define PROJECT_VER_MAJOR "@PROJECT_VERSION_MAJOR@"
#define PROJECT_VER_MINOR "@PROJECT_VERSION_MINOR@" #define PROJECT_VER_MINOR "@PROJECT_VERSION_MINOR@"
#define PROJECT_VER_PATCH "@PROJECT_VERSION_PATCH@" #define PROJECT_VER_PATCH "@PROJECT_VERSION_PATCH@"
#endif // INCLUDE_GUARD

View File

@@ -1,5 +1,3 @@
// Created by loki on 6/6/19.
#include <atomic> #include <atomic>
#include <bitset> #include <bitset>
#include <list> #include <list>
@@ -163,8 +161,8 @@ namespace video {
} }
/** /**
* When preserving aspect ratio, ensure that padding is black * When preserving aspect ratio, ensure that padding is black
*/ */
int int
prefill() { prefill() {
auto frame = sw_frame ? sw_frame.get() : this->frame; auto frame = sw_frame ? sw_frame.get() : this->frame;
@@ -1001,7 +999,7 @@ namespace video {
auto &sps = session.sps; auto &sps = session.sps;
auto &vps = session.vps; auto &vps = session.vps;
/* send the frame to the encoder */ // send the frame to the encoder
auto ret = avcodec_send_frame(ctx.get(), frame); auto ret = avcodec_send_frame(ctx.get(), frame);
if (ret < 0) { if (ret < 0) {
char err_str[AV_ERROR_MAX_STRING_SIZE] { 0 }; char err_str[AV_ERROR_MAX_STRING_SIZE] { 0 };
@@ -1962,13 +1960,13 @@ namespace video {
return true; return true;
} }
/* /**
This is called once at startup and each time a stream is launched to * This is called once at startup and each time a stream is launched to
ensure the best encoder is selected. Encoder availablility can change * ensure the best encoder is selected. Encoder availablility can change
at runtime due to all sorts of things from driver updates to eGPUs. * at runtime due to all sorts of things from driver updates to eGPUs.
*
This is only safe to call when there is no client actively streaming. * This is only safe to call when there is no client actively streaming.
*/ */
int int
probe_encoders() { probe_encoders() {
auto encoder_list = encoders; auto encoder_list = encoders;

View File

@@ -1,7 +1,4 @@
// Created by loki on 6/9/19. #pragma once
#ifndef SUNSHINE_VIDEO_H
#define SUNSHINE_VIDEO_H
#include "input.h" #include "input.h"
#include "platform/common.h" #include "platform/common.h"
@@ -103,5 +100,3 @@ namespace video {
int int
probe_encoders(); probe_encoders();
} // namespace video } // namespace video
#endif // SUNSHINE_VIDEO_H

View File

@@ -101,7 +101,7 @@
*/ */
#if defined(KHRONOS_STATIC) #if defined(KHRONOS_STATIC)
/* If the preprocessor constant KHRONOS_STATIC is defined, make the /* If the preprocessor constant KHRONOS_STATIC is defined, make the
* header compatible with static linking. */ * header compatible with static linking. */
#define KHRONOS_APICALL #define KHRONOS_APICALL
#elif defined(_WIN32) #elif defined(_WIN32)
#define KHRONOS_APICALL __declspec(dllimport) #define KHRONOS_APICALL __declspec(dllimport)
@@ -143,8 +143,8 @@
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
/* /*
* Using <stdint.h> * Using <stdint.h>
*/ */
#include <stdint.h> #include <stdint.h>
typedef int32_t khronos_int32_t; typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t; typedef uint32_t khronos_uint32_t;
@@ -156,8 +156,8 @@ typedef uint64_t khronos_uint64_t;
#elif defined(__VMS) || defined(__sgi) #elif defined(__VMS) || defined(__sgi)
/* /*
* Using <inttypes.h> * Using <inttypes.h>
*/ */
#include <inttypes.h> #include <inttypes.h>
typedef int32_t khronos_int32_t; typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t; typedef uint32_t khronos_uint32_t;
@@ -208,8 +208,8 @@ typedef unsigned int khronos_uint32_t;
#else #else
/* /*
* Generic fallback * Generic fallback
*/ */
#include <stdint.h> #include <stdint.h>
typedef int32_t khronos_int32_t; typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t; typedef uint32_t khronos_uint32_t;

File diff suppressed because it is too large Load Diff