Compare commits

..

1 Commits

Author SHA1 Message Date
ReenigneArcher 88fbd5a398 build(docker): use cross compilation 2025-02-03 19:51:02 -05:00
22 changed files with 136 additions and 132 deletions
+1 -5
View File
@@ -554,16 +554,12 @@ jobs:
rm '/usr/local/bin/2to3-3.12'
rm '/usr/local/bin/idle3'
rm '/usr/local/bin/idle3.12'
rm '/usr/local/bin/idle3.13'
rm '/usr/local/bin/pydoc3'
rm '/usr/local/bin/pydoc3.12'
rm '/usr/local/bin/pydoc3.13'
rm '/usr/local/bin/python3'
rm '/usr/local/bin/python3.12'
rm '/usr/local/bin/python3.13'
rm '/usr/local/bin/python3-config'
rm '/usr/local/bin/python3.12'
rm '/usr/local/bin/python3.12-config'
rm '/usr/local/bin/python3.13-config'
brew install python
- name: Setup python
+31 -3
View File
@@ -1,16 +1,19 @@
# syntax=docker/dockerfile:1
# artifacts: true
# platforms: linux/amd64,linux/arm64/v8
# platforms_pr: linux/amd64
# platforms_pr: linux/amd64,linux/arm64/v8
# no-cache-filters: sunshine-base,artifacts,sunshine
ARG BASE=debian
ARG TAG=bookworm
FROM ${BASE}:${TAG} AS sunshine-base
ENV DEBIAN_FRONTEND=noninteractive
FROM sunshine-base AS sunshine-build
ARG BASE
ARG TAG
FROM --platform=$BUILDPLATFORM ${BASE}:${TAG} AS sunshine-build
ENV DEBIAN_FRONTEND=noninteractive
ARG TARGETPLATFORM
ARG BRANCH
ARG BUILD_VERSION
ARG COMMIT
@@ -30,8 +33,33 @@ COPY --link .. .
RUN <<_BUILD
#!/bin/bash
set -e
if [[ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]]; then
cross_compile="--cross-compile"
else
cross_compile=""
fi
case "${TARGETPLATFORM}" in
linux/amd64)
cc_target_tuple="x86_64-linux-gnu"
cc_target_arch="amd64"
;;
linux/arm64)
cc_target_tuple="aarch64-linux-gnu"
cc_target_arch="arm64"
;;
*)
echo "unsupported platform: ${TARGETPLATFORM}";
exit 1
;;
esac
chmod +x ./scripts/linux_build.sh
./scripts/linux_build.sh \
${cross_compile} \
--cc-target-tuple="${cc_target_tuple}" \
--cc-target-arch="${cc_target_arch}" \
--publisher-name='LizardByte' \
--publisher-website='https://app.lizardbyte.dev' \
--publisher-issue-url='https://app.lizardbyte.dev/support' \
+1 -26
View File
@@ -974,9 +974,7 @@ editing the `conf` file in a text editor. Use the examples as reference.
</tr>
<tr>
<td>Default</td>
<td colspan="2">@code{}
disabled
@endcode</td>
<td colspan="2">@code{}verify_only@endcode</td>
</tr>
<tr>
<td>Example</td>
@@ -1316,29 +1314,6 @@ editing the `conf` file in a text editor. Use the examples as reference.
</tr>
</table>
### max_bitrate
<table>
<tr>
<td>Description</td>
<td colspan="2">
The maximum bitrate (in Kbps) that Sunshine will encode the stream at. If set to 0, it will always use the bitrate requested by Moonlight.
</td>
</tr>
<tr>
<td>Default</td>
<td colspan="2">@code{}
0
@endcode</td>
</tr>
<tr>
<td>Example</td>
<td colspan="2">@code{}
max_bitrate = 5000
@endcode</td>
</tr>
</table>
### min_fps_factor
<table>
+2 -2
View File
@@ -10,12 +10,12 @@
"dependencies": {
"@lizardbyte/shared-web": "2024.921.191855",
"vue": "3.5.13",
"vue-i18n": "11.1.1"
"vue-i18n": "11.0.1"
},
"devDependencies": {
"@vitejs/plugin-vue": "4.6.2",
"serve": "14.2.3",
"vite": "4.5.9",
"vite": "4.5.2",
"vite-plugin-ejs": "1.6.4"
}
}
+82 -35
View File
@@ -3,6 +3,10 @@ set -e
# Default value for arguments
appimage_build=0
cc_install_root="/mnt/cross"
cc_target_tuple="$(uname -m)-linux-gnu"
cc_target_arch="$(dpkg --print-architecture || rpm --eval '%{_host}')"
cross_compile=0
num_processors=$(nproc)
publisher_name="Third Party Publisher"
publisher_website=""
@@ -28,6 +32,10 @@ Options:
-h, --help Display this help message.
-s, --sudo-off Disable sudo command.
--appimage-build Compile for AppImage, this will not create the AppImage, just the executable.
--cc-install-root The root directory to install the cross compiler. Default is /mnt/cross. (Fedora only)
--cc-target-tuple The target tuple for the cross compiler.
--cc-target-arch The target architecture for the cross compiler.
--cross-compile Enable cross compilation.
--num-processors The number of processors to use for compilation. Default is the value of 'nproc'.
--publisher-name The name of the publisher (not developer) of the application.
--publisher-website The URL of the publisher's website.
@@ -55,6 +63,16 @@ while getopts ":hs-:" opt; do
appimage_build=1
skip_libva=1
;;
cc-install-root=*)
cc_install_root="${OPTARG#*=}"
;;
cc-target-tuple=*)
cc_target_tuple="${OPTARG#*=}"
;;
cc-target-arch=*)
cc_target_arch="${OPTARG#*=}"
;;
cross-compile) cross_compile=1 ;;
num-processors=*)
num_processors="${OPTARG#*=}"
;;
@@ -97,28 +115,28 @@ function add_debain_based_deps() {
"cmake"
"doxygen"
"flex" # required if we need to compile doxygen
"gcc-${gcc_version}"
"g++-${gcc_version}"
"gcc-${gcc_version}:${cc_target_arch}"
"g++-${gcc_version}:${cc_target_arch}"
"git"
"graphviz"
"libcap-dev" # KMS
"libcurl4-openssl-dev"
"libdrm-dev" # KMS
"libevdev-dev"
"libminiupnpc-dev"
"libnotify-dev"
"libnuma-dev"
"libopus-dev"
"libpulse-dev"
"libssl-dev"
"libwayland-dev" # Wayland
"libx11-dev" # X11
"libxcb-shm0-dev" # X11
"libxcb-xfixes0-dev" # X11
"libxcb1-dev" # X11
"libxfixes-dev" # X11
"libxrandr-dev" # X11
"libxtst-dev" # X11
"libcap-dev:${cc_target_arch}" # KMS
"libcurl4-openssl-dev:${cc_target_arch}"
"libdrm-dev:${cc_target_arch}" # KMS
"libevdev-dev:${cc_target_arch}"
"libminiupnpc-dev:${cc_target_arch}"
"libnotify-dev:${cc_target_arch}"
"libnuma-dev:${cc_target_arch}"
"libopus-dev:${cc_target_arch}"
"libpulse-dev:${cc_target_arch}"
"libssl-dev:${cc_target_arch}"
"libwayland-dev:${cc_target_arch}" # Wayland
"libx11-dev:${cc_target_arch}" # X11
"libxcb-shm0-dev:${cc_target_arch}" # X11
"libxcb-xfixes0-dev:${cc_target_arch}" # X11
"libxcb1-dev:${cc_target_arch}" # X11
"libxfixes-dev:${cc_target_arch}" # X11
"libxrandr-dev:${cc_target_arch}" # X11
"libxtst-dev:${cc_target_arch}" # X11
"ninja-build"
"npm" # web-ui
"udev"
@@ -128,7 +146,13 @@ function add_debain_based_deps() {
if [ "$skip_libva" == 0 ]; then
dependencies+=(
"libva-dev" # VA-API
"libva-dev:${cc_target_arch}" # VA-API
)
fi
if [ "$cross_compile" == 1 ]; then
dependencies+=(
"crossbuild-essential-${cc_target_arch}"
)
fi
}
@@ -136,7 +160,7 @@ function add_debain_based_deps() {
function add_debain_deps() {
add_debain_based_deps
dependencies+=(
"libayatana-appindicator3-dev"
"libayatana-appindicator3-dev:${cc_target_arch}"
)
}
@@ -148,7 +172,7 @@ function add_ubuntu_deps() {
add_debain_based_deps
dependencies+=(
"libappindicator3-dev"
"libappindicator3-dev:${cc_target_arch}"
)
}
@@ -156,10 +180,19 @@ function add_fedora_deps() {
dependencies+=(
"cmake"
"doxygen"
"gcc"
"g++"
"git"
"graphviz"
"ninja-build"
"npm"
"rpm-build" # if you want to build an RPM binary package
"wget" # necessary for cuda install with `run` file
"which" # necessary for cuda install with `run` file
"xorg-x11-server-Xvfb" # necessary for headless unit testing
)
arch_dependencies=(
"gcc"
"g++"
"libappindicator-gtk3-devel"
"libcap-devel"
"libcurl-devel"
@@ -176,20 +209,14 @@ function add_fedora_deps() {
"libXtst-devel" # X11
"mesa-libGL-devel"
"miniupnpc-devel"
"ninja-build"
"npm"
"numactl-devel"
"openssl-devel"
"opus-devel"
"pulseaudio-libs-devel"
"rpm-build" # if you want to build an RPM binary package
"wget" # necessary for cuda install with `run` file
"which" # necessary for cuda install with `run` file
"xorg-x11-server-Xvfb" # necessary for headless unit testing
)
if [ "$skip_libva" == 0 ]; then
dependencies+=(
arch_dependencies+=(
"libva-devel" # VA-API
)
fi
@@ -204,15 +231,15 @@ function install_cuda() {
local cuda_prefix="https://developer.download.nvidia.com/compute/cuda/"
local cuda_suffix=""
if [ "$architecture" == "aarch64" ]; then
if [ "$cc_target_arch" == "aarch64" ]; then
local cuda_suffix="_sbsa"
fi
if [ "$architecture" == "aarch64" ]; then
if [ "$cc_target_arch" == "aarch64" ]; then
# we need to patch the math-vector.h file for aarch64 fedora
# back up /usr/include/bits/math-vector.h
math_vector_file=""
if [ "$distro" == "ubuntu" ] || [ "$version" == "24.04" ]; then
if [ "$distro" == "ubuntu" ] && [ "$version" == "24.04" ]; then
math_vector_file="/usr/include/aarch64-linux-gnu/bits/math-vector.h"
elif [ "$distro" == "fedora" ]; then
math_vector_file="/usr/include/bits/math-vector.h"
@@ -283,6 +310,11 @@ function run_install() {
"-DSUNSHINE_ENABLE_DRM=ON"
)
if [ "$cross_compile" == 1 ]; then
cmake_args+=("-DCMAKE_C_COMPILER=${cc_target_tuple}-gcc")
cmake_args+=("-DCMAKE_CXX_COMPILER=${cc_target_tuple}-g++")
fi
if [ "$appimage_build" == 1 ]; then
cmake_args+=("-DSUNSHINE_BUILD_APPIMAGE=ON")
fi
@@ -313,6 +345,11 @@ function run_install() {
# Install the dependencies
$package_install_command "${dependencies[@]}"
# Fedora has a special command for installing architecture specific packages
if [ "$distro" == "fedora" ]; then
$package_install_command_arch "${arch_dependencies[@]}"
fi
# reload the environment
# shellcheck source=/dev/null
source ~/.bashrc
@@ -448,6 +485,11 @@ elif grep -q "PLATFORM_ID=\"platform:f39\"" /etc/os-release; then
version="39"
package_update_command="${sudo_cmd} dnf update -y"
package_install_command="${sudo_cmd} dnf install -y"
if [ "$cross_compile" == 0 ]; then
package_install_command_arch="${sudo_cmd} dnf -y --releasever=39 --forcearch=${cc_target_arch} install"
else
package_install_command_arch="${sudo_cmd} dnf -y --installroot=${cc_install_root} --releasever=39 --forcearch=${cc_target_arch} install"
fi
cuda_version="12.4.0"
cuda_build="550.54.14"
gcc_version="13"
@@ -457,6 +499,11 @@ elif grep -q "PLATFORM_ID=\"platform:f40\"" /etc/os-release; then
version="40"
package_update_command="${sudo_cmd} dnf update -y"
package_install_command="${sudo_cmd} dnf install -y"
if [ "$cross_compile" == 0 ]; then
package_install_command_arch="${sudo_cmd} dnf -y --releasever=39 --forcearch=${cc_target_arch} install"
else
package_install_command_arch="${sudo_cmd} dnf -y --installroot=${cc_install_root} --releasever=39 --forcearch=${cc_target_arch} install"
fi
cuda_version=
cuda_build=
gcc_version="13"
+1 -1
View File
@@ -1,2 +1,2 @@
Babel==2.17.0
Babel==2.16.0
clang-format
+2 -4
View File
@@ -497,7 +497,7 @@ namespace config {
{}, // output_name
{
video_t::dd_t::config_option_e::disabled, // configuration_option
video_t::dd_t::config_option_e::verify_only, // configuration_option
video_t::dd_t::resolution_option_e::automatic, // resolution_option
{}, // manual_resolution
video_t::dd_t::refresh_rate_option_e::automatic, // refresh_rate_option
@@ -509,8 +509,7 @@ namespace config {
{} // wa
}, // display_device
1, // min_fps_factor
0 // max_bitrate
1 // min_fps_factor
};
audio_t audio {
@@ -1139,7 +1138,6 @@ namespace config {
bool_f(vars, "dd_wa_hdr_toggle", video.dd.wa.hdr_toggle);
int_between_f(vars, "min_fps_factor", video.min_fps_factor, {1, 3});
int_f(vars, "max_bitrate", video.max_bitrate);
path_f(vars, "pkey", nvhttp.pkey);
path_f(vars, "cert", nvhttp.cert);
-1
View File
@@ -138,7 +138,6 @@ namespace config {
} dd;
int min_fps_factor; // Minimum fps target, determines minimum frame time
int max_bitrate; // Maximum bitrate, sets ceiling in kbps for bitrate requested from client
};
struct audio_t {
+1 -1
View File
@@ -528,7 +528,7 @@ namespace nvenc {
NV_ENC_LOCK_BITSTREAM lock_bitstream = {min_struct_version(NV_ENC_LOCK_BITSTREAM_VER, 1, 2)};
lock_bitstream.outputBitstream = output_bitstream;
lock_bitstream.doNotWait = async_event_handle ? 1 : 0;
lock_bitstream.doNotWait = 0;
if (async_event_handle && !wait_for_async_event(100)) {
BOOST_LOG(error) << "NvEnc: frame " << frame_index << " encode wait timeout";
-12
View File
@@ -10,19 +10,11 @@
namespace nvenc {
nvenc_d3d11::nvenc_d3d11(NV_ENC_DEVICE_TYPE device_type):
nvenc_base(device_type) {
async_event_handle = CreateEvent(NULL, FALSE, FALSE, NULL);
}
nvenc_d3d11::~nvenc_d3d11() {
if (dll) {
FreeLibrary(dll);
dll = NULL;
}
if (async_event_handle) {
CloseHandle(async_event_handle);
}
}
bool nvenc_d3d11::init_library() {
@@ -61,9 +53,5 @@ namespace nvenc {
return false;
}
bool nvenc_d3d11::wait_for_async_event(uint32_t timeout_ms) {
return WaitForSingleObject(async_event_handle, timeout_ms) == WAIT_OBJECT_0;
}
} // namespace nvenc
#endif
+4 -2
View File
@@ -25,7 +25,10 @@ namespace nvenc {
*/
class nvenc_d3d11: public nvenc_base {
public:
explicit nvenc_d3d11(NV_ENC_DEVICE_TYPE device_type);
explicit nvenc_d3d11(NV_ENC_DEVICE_TYPE device_type):
nvenc_base(device_type) {
}
~nvenc_d3d11();
/**
@@ -36,7 +39,6 @@ namespace nvenc {
protected:
bool init_library() override;
bool wait_for_async_event(uint32_t timeout_ms) override;
private:
HMODULE dll = NULL;
+2 -21
View File
@@ -299,7 +299,6 @@ namespace video {
REF_FRAMES_INVALIDATION = 1 << 8, ///< Support reference frames invalidation
ALWAYS_REPROBE = 1 << 9, ///< This is an encoder of last resort and we want to aggressively probe for a better one
YUV444_SUPPORT = 1 << 10, ///< Encoder may support 4:4:4 chroma sampling depending on hardware
ASYNC_TEARDOWN = 1 << 11, ///< Encoder supports async teardown on a different thread
};
class avcodec_encode_session_t: public encode_session_t {
@@ -504,7 +503,7 @@ namespace video {
{}, // Fallback options
"h264_nvenc"s,
},
PARALLEL_ENCODING | REF_FRAMES_INVALIDATION | YUV444_SUPPORT | ASYNC_TEARDOWN // flags
PARALLEL_ENCODING | REF_FRAMES_INVALIDATION | YUV444_SUPPORT // flags
};
#elif !defined(__APPLE__)
encoder_t nvenc {
@@ -1687,8 +1686,7 @@ namespace video {
}
}
auto bitrate = ((config::video.max_bitrate > 0) ? std::min(config.bitrate, config::video.max_bitrate) : config.bitrate) * 1000;
BOOST_LOG(info) << "Streaming bitrate is " << bitrate;
auto bitrate = config.bitrate * 1000;
ctx->rc_max_rate = bitrate;
ctx->bit_rate = bitrate;
@@ -1858,23 +1856,6 @@ namespace video {
return;
}
// As a workaround for NVENC hangs and to generally speed up encoder reinit,
// we will complete the encoder teardown in a separate thread if supported.
// This will move expensive processing off the encoder thread to allow us
// to restart encoding as soon as possible. For cases where the NVENC driver
// hang occurs, this thread may probably never exit, but it will allow
// streaming to continue without requiring a full restart of Sunshine.
auto fail_guard = util::fail_guard([&encoder, &session] {
if (encoder.flags & ASYNC_TEARDOWN) {
std::thread encoder_teardown_thread {[session = std::move(session)]() mutable {
BOOST_LOG(info) << "Starting async encoder teardown";
session.reset();
BOOST_LOG(info) << "Async encoder teardown complete";
}};
encoder_teardown_thread.detach();
}
});
// set minimum frame time, avoiding violation of client-requested target framerate
auto minimum_frame_time = std::chrono::milliseconds(1000 / std::min(config.framerate, (config::video.min_fps_factor * 10)));
BOOST_LOG(debug) << "Minimum frame time set to "sv << minimum_frame_time.count() << "ms, based on min fps factor of "sv << config::video.min_fps_factor << "."sv;
+1 -2
View File
@@ -168,7 +168,7 @@
"install_steam_audio_drivers": "enabled",
"adapter_name": "",
"output_name": "",
"dd_configuration_option": "disabled",
"dd_configuration_option": "verify_only",
"dd_resolution_option": "auto",
"dd_manual_resolution": "",
"dd_refresh_rate_option": "auto",
@@ -179,7 +179,6 @@
"dd_mode_remapping": {"mixed": [], "resolution_only": [], "refresh_rate_only": []},
"dd_wa_hdr_toggle": "disabled",
"min_fps_factor": 1,
"max_bitrate": 0,
},
},
{
@@ -68,7 +68,7 @@ function addRemappingEntry() {
{{ $t('config.dd_config_label') }}
</label>
<select id="dd_configuration_option" class="form-select" v-model="config.dd_configuration_option">
<option value="disabled">{{ $t('_common.disabled_def') }}</option>
<option value="disabled">{{ $t('_common.disabled') }}</option>
<option value="verify_only">{{ $t('config.dd_config_verify_only') }}</option>
<option value="ensure_active">{{ $t('config.dd_config_ensure_active') }}</option>
<option value="ensure_primary">{{ $t('config.dd_config_ensure_primary') }}</option>
@@ -17,13 +17,6 @@ const config = ref(props.config)
<input type="number" min="1" max="3" class="form-control" id="min_fps_factor" placeholder="1" v-model="config.min_fps_factor" />
<div class="form-text">{{ $t('config.min_fps_factor_desc') }}</div>
</div>
<!--max_bitrate-->
<div class="mb-3">
<label for="max_bitrate" class="form-label">{{ $t("config.max_bitrate") }}</label>
<input type="number" class="form-control" id="max_bitrate" placeholder="0" v-model="config.max_bitrate" />
<div class="form-text">{{ $t("config.max_bitrate_desc") }}</div>
</div>
</template>
<style scoped>
@@ -160,7 +160,7 @@
"dd_config_revert_delay_desc": "Additional delay in milliseconds to wait before reverting configuration when the app has been closed or the last session terminated. Main purpose is to provide a smoother transition when quickly switching between apps.",
"dd_config_revert_on_disconnect": "Config revert on disconnect",
"dd_config_revert_on_disconnect_desc": "Revert configuration upon disconnect of all clients instead of app close or last session termination.",
"dd_config_verify_only": "Verify that the display is enabled",
"dd_config_verify_only": "Verify that the display is enabled (default)",
"dd_hdr_option": "HDR",
"dd_hdr_option_auto": "Switch on/off the HDR mode as requested by the client (default)",
"dd_hdr_option_disabled": "Do not change HDR settings",
@@ -252,8 +252,6 @@
"log_level_desc": "The minimum log level printed to standard out",
"log_path": "Logfile Path",
"log_path_desc": "The file where the current logs of Sunshine are stored.",
"max_bitrate": "Maximum Bitrate",
"max_bitrate_desc": "The maximum bitrate (in Kbps) that Sunshine will encode the stream at. If set to 0, it will always use the bitrate requested by Moonlight.",
"min_fps_factor": "Minimum FPS Factor",
"min_fps_factor_desc": "Sunshine will use this factor to calculate the minimum time between frames. Increasing this value slightly may help when streaming mostly static content. Higher values will consume more bandwidth.",
"min_threads": "Minimum CPU Thread Count",