From 6d91e680c57661245d93a99b42dc9d7c14a0dce6 Mon Sep 17 00:00:00 2001 From: ns6089 <61738816+ns6089@users.noreply.github.com> Date: Thu, 8 Aug 2024 17:52:08 +0300 Subject: [PATCH 1/5] feat(logging): include milliseconds timestamps (#2963) --- src/logging.cpp | 15 ++++++++++----- src_assets/common/assets/web/index.html | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/logging.cpp b/src/logging.cpp index 5cc226ea..a78b5b5d 100644 --- a/src/logging.cpp +++ b/src/logging.cpp @@ -4,10 +4,12 @@ */ // standard includes #include +#include #include // lib includes #include +#include #include #include #include @@ -67,7 +69,6 @@ namespace logging { sink->set_formatter([](const bl::record_view &view, bl::formatting_ostream &os) { constexpr const char *message = "Message"; constexpr const char *severity = "Severity"; - constexpr int DATE_BUFFER_SIZE = 21 + 2 + 1; // Full string plus ": \0" auto log_level = view.attribute_values()[severity].extract().get(); @@ -93,11 +94,15 @@ namespace logging { break; }; - char _date[DATE_BUFFER_SIZE]; - std::time_t t = std::time(nullptr); - strftime(_date, DATE_BUFFER_SIZE, "[%Y:%m:%d:%H:%M:%S]: ", std::localtime(&t)); + auto now = std::chrono::system_clock::now(); + auto ms = std::chrono::duration_cast( + now - std::chrono::time_point_cast(now)); - os << _date << log_type << view.attribute_values()[message].extract(); + auto t = std::chrono::system_clock::to_time_t(now); + auto lt = *std::localtime(&t); + + os << "["sv << std::put_time(<, "%Y-%m-%d %H:%M:%S.") << boost::format("%03u") % ms.count() << "]: "sv + << log_type << view.attribute_values()[message].extract(); }); // Flush after each log record to ensure log file contents on disk isn't stale. diff --git a/src_assets/common/assets/web/index.html b/src_assets/common/assets/web/index.html index d279f16d..9eccf9e1 100644 --- a/src_assets/common/assets/web/index.html +++ b/src_assets/common/assets/web/index.html @@ -142,7 +142,7 @@ /** Parse the text errors, calculating the text, the timestamp and the level */ fancyLogs() { if (!this.logs) return []; - let regex = /(\[\d{4}:\d{2}:\d{2}:\d{2}:\d{2}:\d{2}\]):\s/g; + let regex = /(\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3}]):\s/g; let rawLogLines = (this.logs.split(regex)).splice(1); let logLines = [] for (let i = 0; i < rawLogLines.length; i += 2) { From 19250f13d6dae893218515474dc0c8a7fa1da12c Mon Sep 17 00:00:00 2001 From: ns6089 <61738816+ns6089@users.noreply.github.com> Date: Thu, 8 Aug 2024 20:39:30 +0300 Subject: [PATCH 2/5] tests(windows): prefer static libraries (#2939) --- tests/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d49272f6..73979d37 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -70,4 +70,10 @@ target_compile_definitions(${PROJECT_NAME} PUBLIC ${SUNSHINE_DEFINITIONS} ${TEST target_compile_options(${PROJECT_NAME} PRIVATE $<$:${SUNSHINE_COMPILE_OPTIONS}>;$<$:${SUNSHINE_COMPILE_OPTIONS_CUDA};-std=c++17>) # cmake-lint: disable=C0301 target_link_options(${PROJECT_NAME} PRIVATE) +if (WIN32) + # prefer static libraries since we're linking statically + # this fixes gtest_main and libcurl linking errors, when using non MSYS2 version of CMake + set_target_properties(${PROJECT_NAME} PROPERTIES LINK_SEARCH_START_STATIC 1) +endif () + add_test(NAME ${PROJECT_NAME} COMMAND sunshine_test) From b6b8e681cbf226c48b6d415d24ba3891a2b59542 Mon Sep 17 00:00:00 2001 From: ns6089 <61738816+ns6089@users.noreply.github.com> Date: Thu, 8 Aug 2024 23:09:51 +0300 Subject: [PATCH 3/5] fix: print encoder name to info log during creation (#2965) --- src/video.cpp | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/src/video.cpp b/src/video.cpp index 7758d68a..908b7fa9 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -1725,28 +1725,6 @@ namespace video { std::unique_ptr make_encode_session(platf::display_t *disp, const encoder_t &encoder, const config_t &config, int width, int height, std::unique_ptr encode_device) { - if (encode_device) { - switch (encode_device->colorspace.colorspace) { - case colorspace_e::bt2020: - BOOST_LOG(info) << "HDR color coding [Rec. 2020 + SMPTE 2084 PQ]"sv; - break; - - case colorspace_e::rec601: - BOOST_LOG(info) << "SDR color coding [Rec. 601]"sv; - break; - - case colorspace_e::rec709: - BOOST_LOG(info) << "SDR color coding [Rec. 709]"sv; - break; - - case colorspace_e::bt2020sdr: - BOOST_LOG(info) << "SDR color coding [Rec. 2020]"sv; - break; - } - BOOST_LOG(info) << "Color depth: " << encode_device->colorspace.bit_depth << "-bit"; - BOOST_LOG(info) << "Color range: ["sv << (encode_device->colorspace.full_range ? "JPEG"sv : "MPEG"sv) << ']'; - } - if (dynamic_cast(encode_device.get())) { auto avcodec_encode_device = boost::dynamic_pointer_cast(std::move(encode_device)); return make_avcodec_encode_session(disp, encoder, config, width, height, std::move(avcodec_encode_device)); @@ -1880,6 +1858,25 @@ namespace video { auto colorspace = colorspace_from_client_config(config, disp.is_hdr()); auto pix_fmt = (colorspace.bit_depth == 10) ? encoder.platform_formats->pix_fmt_10bit : encoder.platform_formats->pix_fmt_8bit; + { + auto encoder_name = config.videoFormat == 0 ? encoder.h264.name : + config.videoFormat == 1 ? encoder.hevc.name : + config.videoFormat == 2 ? encoder.av1.name : + "unknown"; + + BOOST_LOG(info) << "Creating encoder " << logging::bracket(encoder_name); + + auto color_coding = colorspace.colorspace == colorspace_e::bt2020 ? "HDR (Rec. 2020 + SMPTE 2084 PQ)" : + colorspace.colorspace == colorspace_e::rec601 ? "SDR (Rec. 601)" : + colorspace.colorspace == colorspace_e::rec709 ? "SDR (Rec. 709)" : + colorspace.colorspace == colorspace_e::bt2020sdr ? "SDR (Rec. 2020)" : + "unknown"; + + BOOST_LOG(info) << "Color coding: " << color_coding; + BOOST_LOG(info) << "Color depth: " << colorspace.bit_depth << "-bit"; + BOOST_LOG(info) << "Color range: " << (colorspace.full_range ? "JPEG" : "MPEG"); + } + if (dynamic_cast(encoder.platform_formats.get())) { result = disp.make_avcodec_encode_device(pix_fmt); } From 0b8468ca3e785b903a8d0b65653dc3061a4cfa98 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Thu, 8 Aug 2024 21:17:15 -0400 Subject: [PATCH 4/5] feat(macos): add beta homebrew formula (#2990) --- .github/workflows/CI.yml | 33 +++++++++++++++++++++++++++++++++ docs/getting_started.md | 2 ++ packaging/sunshine.rb | 1 + 3 files changed, 36 insertions(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 4476655b..20f5b25c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -590,6 +590,39 @@ jobs: tag: ${{ needs.setup_release.outputs.release_tag }} token: ${{ secrets.GH_BOT_TOKEN }} + - name: Patch homebrew formula + # create beta version of the formula + # don't run this on macOS, as the sed command fails + if: >- + matrix.release + run: | + # variables + formula_file="homebrew/sunshine-beta.rb" + + # rename the file + mv homebrew/sunshine.rb $formula_file + + # update the formula + sed -i 's/class Sunshine < Formula/class SunshineBeta < Formula/' $formula_file + sed -i 's/# conflicts_with/conflicts_with/' $formula_file + + # print new file + echo "New formula:" + cat $formula_file + + - name: Upload Homebrew Beta Formula + if: >- + matrix.release && + needs.setup_release.outputs.publish_release == 'true' + uses: LizardByte/homebrew-release-action@v2024.612.21058 + with: + formula_file: ${{ github.workspace }}/homebrew/sunshine-beta.rb + git_email: ${{ secrets.GH_BOT_EMAIL }} + git_username: ${{ secrets.GH_BOT_NAME }} + publish: true + token: ${{ secrets.GH_BOT_TOKEN }} + validate: false + build_mac_port: needs: [setup_release] strategy: diff --git a/docs/getting_started.md b/docs/getting_started.md index 086ce6cd..c738992b 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -262,6 +262,8 @@ brew install sunshine brew uninstall sunshine ``` +@tip{For beta you can replace `sunshine` with `sunshine-beta` in the above commands.} + #### Portfile This package requires that you have [MacPorts](https://www.macports.org/install.php) installed. diff --git a/packaging/sunshine.rb b/packaging/sunshine.rb index 65290dc2..cf6886b4 100644 --- a/packaging/sunshine.rb +++ b/packaging/sunshine.rb @@ -1,6 +1,7 @@ require "language/node" class @PROJECT_NAME@ < Formula + # conflicts_with "sunshine", because: "sunshine and sunshine-beta cannot be installed at the same time" desc "@PROJECT_DESCRIPTION@" homepage "@PROJECT_HOMEPAGE_URL@" url "@GITHUB_CLONE_URL@", From 0e153cf292f2e9bad895950d2004ca6121dae6fa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 9 Aug 2024 03:57:30 +0000 Subject: [PATCH 5/5] build(deps): bump LizardByte/homebrew-release-action from 2024.612.21058 to 2024.809.31635 (#2992) build(deps): bump LizardByte/homebrew-release-action Bumps [LizardByte/homebrew-release-action](https://github.com/lizardbyte/homebrew-release-action) from 2024.612.21058 to 2024.809.31635. - [Release notes](https://github.com/lizardbyte/homebrew-release-action/releases) - [Commits](https://github.com/lizardbyte/homebrew-release-action/compare/v2024.612.21058...v2024.809.31635) --- updated-dependencies: - dependency-name: LizardByte/homebrew-release-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/CI.yml | 4 ++-- .github/workflows/update-homebrew-release.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 20f5b25c..1ed66a7b 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -565,7 +565,7 @@ jobs: - name: Validate Homebrew Formula if: | matrix.release != true - uses: LizardByte/homebrew-release-action@v2024.612.21058 + uses: LizardByte/homebrew-release-action@v2024.809.31635 with: formula_file: ${{ github.workspace }}/homebrew/sunshine.rb git_email: ${{ secrets.GH_BOT_EMAIL }} @@ -614,7 +614,7 @@ jobs: if: >- matrix.release && needs.setup_release.outputs.publish_release == 'true' - uses: LizardByte/homebrew-release-action@v2024.612.21058 + uses: LizardByte/homebrew-release-action@v2024.809.31635 with: formula_file: ${{ github.workspace }}/homebrew/sunshine-beta.rb git_email: ${{ secrets.GH_BOT_EMAIL }} diff --git a/.github/workflows/update-homebrew-release.yml b/.github/workflows/update-homebrew-release.yml index 1ab0e16a..dc6ef218 100644 --- a/.github/workflows/update-homebrew-release.yml +++ b/.github/workflows/update-homebrew-release.yml @@ -61,7 +61,7 @@ jobs: if: >- steps.check.outputs.hasTopic == 'true' && fromJson(steps.download.outputs.downloaded_files)[0] - uses: LizardByte/homebrew-release-action@v2024.612.21058 + uses: LizardByte/homebrew-release-action@v2024.809.31635 with: formula_file: ${{ fromJson(steps.download.outputs.downloaded_files)[0] }} git_email: ${{ secrets.GH_BOT_EMAIL }}