diff --git a/.dockerignore b/.dockerignore index 641742725e4..e4efe5a80af 100644 --- a/.dockerignore +++ b/.dockerignore @@ -9,7 +9,6 @@ # ignore repo directories and files docker/ -gh-pages-template/ scripts/ tools/ crowdin.yml diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index ba0fca9d3c3..84af91b370d 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -25,7 +25,7 @@ body: - type: dropdown attributes: label: Is your issue present in the latest beta/pre-release? - description: Please test the latest [pre-release](https://github.com/LizardByte/Sunshine/releases). + description: Please test the latest [pre-release](https://github.com/SunshineStream/Sunshine/releases). options: - "I didn't read the issue template" - "I'm too lazy to test" diff --git a/.github/org-sync-state.json b/.github/org-sync-state.json index 2c1aa8ceecd..e7fbf2392af 100644 --- a/.github/org-sync-state.json +++ b/.github/org-sync-state.json @@ -34,42 +34,42 @@ }, ".github/workflows/_release-notifier.yml": { "mode": "sync", - "sha": "7a30fa1a356c9113993059734de5905b1907e328", + "sha": "9667efbb1857e2d4ad1a044beeb7cd8ac40e551c", "permissions": "100644" }, ".github/workflows/_top-issues.yml": { "mode": "sync", - "sha": "3072822c6a6832079de60fe8940953e008da165f", + "sha": "83a8bf0617b59cdb96245bac71232aabbb620d14", "permissions": "100644" }, ".github/workflows/_update-changelog.yml": { "mode": "sync", - "sha": "314caf7ef30b645909d3567d1f6a7fd33c268cd0", + "sha": "e7b9dc6a758937c95f58fdd1b93cae619f0f5cbc", "permissions": "100644" }, ".github/workflows/_update-docs.yml": { "mode": "sync", - "sha": "22c2a5175dcb70b44a80d0df25795e9a119dafe9", + "sha": "dd890841d5b656dc46beb5277250dde9be788c05", "permissions": "100644" }, ".github/workflows/_update-flathub-repo.yml": { "mode": "sync", - "sha": "4b75a2482160981e7370dfe6ed80ff0ef6bc1058", + "sha": "3fd24093a0feda111443f3be25ae40ec0d0057d9", "permissions": "100644" }, ".github/workflows/_update-homebrew-repo.yml": { "mode": "sync", - "sha": "cdd96ddb50eb55191a19977cef22d770785c5eec", + "sha": "5c796be7311de074c8310030c3b06a08f2958304", "permissions": "100644" }, ".github/workflows/_update-pacman-repo.yml": { "mode": "sync", - "sha": "89a67aaedf9eeb3d14731eb62ebc27c4ff7c9981", + "sha": "16561abbb1108a2ecd326509bdb01f26129bad4b", "permissions": "100644" }, ".github/workflows/_update-winget-repo.yml": { "mode": "sync", - "sha": "9bb4d8e97f4171025489854485f7ab6dfe6e64aa", + "sha": "5aecabfa2e590e99e2d9b8f58cecc1c902ebb87f", "permissions": "100644" }, "renovate.json": { diff --git a/.github/workflows/_release-notifier.yml b/.github/workflows/_release-notifier.yml index 7a30fa1a356..9667efbb185 100644 --- a/.github/workflows/_release-notifier.yml +++ b/.github/workflows/_release-notifier.yml @@ -17,7 +17,6 @@ jobs: update-blog: name: Update blog uses: LizardByte/.github/.github/workflows/__call-release-notifier.yml@master - if: github.repository_owner == 'LizardByte' permissions: contents: read with: diff --git a/.github/workflows/_top-issues.yml b/.github/workflows/_top-issues.yml index 3072822c6a6..83a8bf0617b 100644 --- a/.github/workflows/_top-issues.yml +++ b/.github/workflows/_top-issues.yml @@ -21,7 +21,6 @@ jobs: top-issues: name: Top issues uses: LizardByte/.github/.github/workflows/__call-top-issues.yml@master - if: github.repository_owner == 'LizardByte' permissions: contents: read issues: write diff --git a/.github/workflows/_update-changelog.yml b/.github/workflows/_update-changelog.yml index 314caf7ef30..e7b9dc6a758 100644 --- a/.github/workflows/_update-changelog.yml +++ b/.github/workflows/_update-changelog.yml @@ -23,7 +23,6 @@ jobs: name: Update Changelog uses: LizardByte/.github/.github/workflows/__call-update-changelog.yml@master if: >- - github.repository_owner == 'LizardByte' && (github.event_name == 'workflow_dispatch' || (!github.event.release.prerelease && !github.event.release.draft)) permissions: diff --git a/.github/workflows/_update-docs.yml b/.github/workflows/_update-docs.yml index 22c2a5175dc..dd890841d5b 100644 --- a/.github/workflows/_update-docs.yml +++ b/.github/workflows/_update-docs.yml @@ -27,7 +27,6 @@ jobs: update-docs: name: Update docs uses: LizardByte/.github/.github/workflows/__call-update-docs.yml@master - if: github.repository_owner == 'LizardByte' permissions: {} with: readthedocs_slug: ${{ vars.READTHEDOCS_SLUG }} diff --git a/.github/workflows/_update-flathub-repo.yml b/.github/workflows/_update-flathub-repo.yml index 4b75a248216..3fd24093a0f 100644 --- a/.github/workflows/_update-flathub-repo.yml +++ b/.github/workflows/_update-flathub-repo.yml @@ -23,7 +23,6 @@ jobs: update-flathub-repo: name: Update Flathub Repo uses: LizardByte/.github/.github/workflows/__call-update-flathub-repo.yml@master - if: github.repository_owner == 'LizardByte' permissions: contents: read with: diff --git a/.github/workflows/_update-homebrew-repo.yml b/.github/workflows/_update-homebrew-repo.yml index cdd96ddb50e..5c796be7311 100644 --- a/.github/workflows/_update-homebrew-repo.yml +++ b/.github/workflows/_update-homebrew-repo.yml @@ -23,7 +23,6 @@ jobs: update-homebrew-repo: name: Update Homebrew repo uses: LizardByte/.github/.github/workflows/__call-update-homebrew-repo.yml@master - if: github.repository_owner == 'LizardByte' permissions: contents: read with: diff --git a/.github/workflows/_update-pacman-repo.yml b/.github/workflows/_update-pacman-repo.yml index 89a67aaedf9..16561abbb11 100644 --- a/.github/workflows/_update-pacman-repo.yml +++ b/.github/workflows/_update-pacman-repo.yml @@ -23,7 +23,6 @@ jobs: update-pacman-repo: name: Update pacman repo uses: LizardByte/.github/.github/workflows/__call-update-pacman-repo.yml@master - if: github.repository_owner == 'LizardByte' permissions: contents: read with: diff --git a/.github/workflows/_update-winget-repo.yml b/.github/workflows/_update-winget-repo.yml index 9bb4d8e97f4..5aecabfa2e5 100644 --- a/.github/workflows/_update-winget-repo.yml +++ b/.github/workflows/_update-winget-repo.yml @@ -23,7 +23,6 @@ jobs: update-winget-repo: name: Update Winget repo uses: LizardByte/.github/.github/workflows/__call-update-winget-repo.yml@master - if: github.repository_owner == 'LizardByte' permissions: contents: read secrets: diff --git a/.github/workflows/ci-cloudsmith.yml b/.github/workflows/ci-cloudsmith.yml index f36ced9aeee..f619e0a6d3d 100644 --- a/.github/workflows/ci-cloudsmith.yml +++ b/.github/workflows/ci-cloudsmith.yml @@ -38,7 +38,7 @@ jobs: --pattern '*.rpm' - name: Upload packages to Cloudsmith - uses: LizardByte/actions/actions/cloudsmith_upload@0528b495e6af82b4d698ec6c907a9b1842622068 # v2026.1029.234422 + uses: LizardByte/actions/actions/cloudsmith_upload@81873587bacc6842098865a35bbb32f2f21cee3b # v2026.1123.33249 with: api_key: ${{ secrets.CLOUDSMITH_API_KEY }} owner: lizardbyte diff --git a/.github/workflows/ci-copr.yml b/.github/workflows/ci-copr.yml index 9c9cb0681da..714f5869a1f 100644 --- a/.github/workflows/ci-copr.yml +++ b/.github/workflows/ci-copr.yml @@ -17,13 +17,18 @@ on: required: false jobs: + organization: + uses: LizardByte/.github/.github/workflows/__call-organization.yml@master + call-copr-ci: + needs: organization + if: needs.organization.outputs.allowed == 'true' permissions: contents: read uses: LizardByte/copr-ci/.github/workflows/copr-ci.yml@master with: copr_pr_webhook_token: "05fc9b07-a19b-4f83-89b2-ae1e7e0b5282" - github_org_owner: LizardByte + github_org_owner: ${{ github.repository_owner }} copr_ownername: lizardbyte auto_update_package: true job_timeout: 90 @@ -36,9 +41,10 @@ jobs: name: Release if: github.event_name == 'release' && - startsWith(github.repository, 'LizardByte/') && + needs.organization.outputs.allowed == 'true' && github.event.release.prerelease == true needs: + - organization - call-copr-ci permissions: contents: write @@ -55,7 +61,7 @@ jobs: run: ls -l artifacts - name: Update GitHub Release - uses: LizardByte/actions/actions/release_create@0528b495e6af82b4d698ec6c907a9b1842622068 # v2026.1029.234422 + uses: LizardByte/actions/actions/release_create@81873587bacc6842098865a35bbb32f2f21cee3b # v2026.1123.33249 with: allowUpdates: true body: ${{ github.event.release.body }} diff --git a/.github/workflows/ci-flatpak.yml b/.github/workflows/ci-flatpak.yml index 695b5bad01f..dcbf1e80ec7 100644 --- a/.github/workflows/ci-flatpak.yml +++ b/.github/workflows/ci-flatpak.yml @@ -35,7 +35,7 @@ jobs: steps: - name: More space if: matrix.arch == 'x86_64' - uses: LizardByte/actions/actions/more_space@0528b495e6af82b4d698ec6c907a9b1842622068 # v2026.1029.234422 + uses: LizardByte/actions/actions/more_space@81873587bacc6842098865a35bbb32f2f21cee3b # v2026.1123.33249 with: analyze-space-savings: true clean-all: true @@ -52,7 +52,7 @@ jobs: python-version: ${{ env.PYTHON_VERSION }} - name: Setup uv - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3 + uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0 with: enable-cache: true @@ -288,8 +288,8 @@ jobs: cp "./package-lock.json" "./flathub/" cp "./packaging/linux/flatpak/README.md" "./flathub/" cp "./packaging/linux/flatpak/flathub.json" "./flathub/" + # Includes the Git source lists referenced by the Sunshine module. cp -r "./packaging/linux/flatpak/modules/." "./flathub/modules/" - # submodules will need to be handled in the workflow that creates the PR # create the archive tar -czf ./artifacts/flathub.tar.gz -C ./flathub . diff --git a/.github/workflows/ci-freebsd.yml b/.github/workflows/ci-freebsd.yml index d2c72e5f879..720867ba0fe 100644 --- a/.github/workflows/ci-freebsd.yml +++ b/.github/workflows/ci-freebsd.yml @@ -48,7 +48,7 @@ jobs: echo "PROCESSOR_COUNT: $PROCESSOR_COUNT" - name: Setup FreeBSD - uses: vmactions/freebsd-vm@c46abacb49f09938ca4e1702d15d836285d694cc # v1.5.9 + uses: vmactions/freebsd-vm@811efaaac0668df8bfb8308c3ec997b5ab50037b # v1.6.0 with: arch: ${{ matrix.arch }} cpu: ${{ steps.processor_count.outputs.PROCESSOR_COUNT }} @@ -110,7 +110,7 @@ jobs: --python "/usr/local/bin/python${PYTHON_VERSION}" \ --no-python-downloads \ --no-install-project - # uv.lock pins external artifacts; the reviewed vendored glad2 build hook is required. + # uv.lock pins the source artifact for MarkupSafe, which has no FreeBSD wheel. uv sync "$@" # NOSONAR(githubactions:S8541, githubactions:S8544) set -- \ --project third-party/lizardbyte-common \ @@ -157,7 +157,7 @@ jobs: -DSUNSHINE_ENABLE_PORTAL=ON \ -DSUNSHINE_ENABLE_WAYLAND=ON \ -DSUNSHINE_ENABLE_X11=ON \ - -DSUNSHINE_PUBLISHER_NAME="${GITHUB_REPOSITORY_OWNER}" \ + -DSUNSHINE_PUBLISHER_NAME="LizardByte" \ -DSUNSHINE_PUBLISHER_WEBSITE="https://app.lizardbyte.dev" \ -DSUNSHINE_PUBLISHER_ISSUE_URL="https://app.lizardbyte.dev/support" @@ -217,7 +217,8 @@ jobs: cd "${GITHUB_WORKSPACE}/build/tests" export DISPLAY=:1 - Xvfb ${DISPLAY} -screen 0 1024x768x24 & + # Do not reset the server when enumeration closes the last X11 connection. + Xvfb ${DISPLAY} -screen 0 1024x768x24 -noreset & XVFB_PID=$! trap 'kill "${XVFB_PID}" 2>/dev/null || true; wait "${XVFB_PID}" 2>/dev/null || true' EXIT diff --git a/.github/workflows/ci-homebrew.yml b/.github/workflows/ci-homebrew.yml index e6166d207ba..7f983a887b6 100644 --- a/.github/workflows/ci-homebrew.yml +++ b/.github/workflows/ci-homebrew.yml @@ -50,7 +50,7 @@ jobs: steps: - name: More space if: runner.os == 'Linux' && matrix.release != true - uses: LizardByte/actions/actions/more_space@0528b495e6af82b4d698ec6c907a9b1842622068 # v2026.1029.234422 + uses: LizardByte/actions/actions/more_space@81873587bacc6842098865a35bbb32f2f21cee3b # v2026.1123.33249 with: analyze-space-savings: true clean-all: true diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index e5b082ac988..b23f386c758 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -39,7 +39,7 @@ jobs: runner: ubuntu-22.04 steps: - name: More space - uses: LizardByte/actions/actions/more_space@0528b495e6af82b4d698ec6c907a9b1842622068 # v2026.1029.234422 + uses: LizardByte/actions/actions/more_space@81873587bacc6842098865a35bbb32f2f21cee3b # v2026.1123.33249 with: analyze-space-savings: true clean-all: true @@ -77,7 +77,7 @@ jobs: chmod +x ./scripts/linux_build.sh echo "::add-matcher::.github/matchers/gcc.json" ./scripts/linux_build.sh \ - --publisher-name="${GITHUB_REPOSITORY_OWNER}" \ + --publisher-name="LizardByte" \ --publisher-website="https://app.lizardbyte.dev" \ --publisher-issue-url="https://app.lizardbyte.dev/support" \ --skip-cleanup \ @@ -178,10 +178,10 @@ jobs: sudo rm -rf /var/lib/apt/lists/* - name: Setup virtual desktop - uses: LizardByte/actions/actions/virtual_desktop@0528b495e6af82b4d698ec6c907a9b1842622068 # v2026.1029.234422 + uses: LizardByte/actions/actions/virtual_desktop@81873587bacc6842098865a35bbb32f2f21cee3b # v2026.1123.33249 - name: Setup uv - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3 + uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0 with: enable-cache: true diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index 9e2b18e485d..e3b19915bf8 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -102,7 +102,7 @@ jobs: python-version: ${{ env.PYTHON_VERSION }} - name: Setup uv - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3 + uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0 with: enable-cache: true @@ -138,7 +138,7 @@ jobs: -DOpus_ROOT_DIR="$(brew --prefix opus 2>/dev/null)" \ -DQt6_DIR="$(brew --prefix qtbase 2>/dev/null)/lib/cmake/Qt6" \ -DQt6Svg_DIR="$(brew --prefix qtsvg 2>/dev/null)/lib/cmake/Qt6Svg" \ - -DSUNSHINE_PUBLISHER_NAME="${GITHUB_REPOSITORY_OWNER}" \ + -DSUNSHINE_PUBLISHER_NAME="LizardByte" \ -DSUNSHINE_PUBLISHER_WEBSITE="https://app.lizardbyte.dev" \ -DSUNSHINE_PUBLISHER_ISSUE_URL="https://app.lizardbyte.dev/support" \ -DAPPLE_CODESIGN_IDENTITY="${APPLE_CODESIGN_IDENTITY}" diff --git a/.github/workflows/ci-release.yml b/.github/workflows/ci-release.yml index 08a9433e0c4..098940ed1bb 100644 --- a/.github/workflows/ci-release.yml +++ b/.github/workflows/ci-release.yml @@ -13,16 +13,22 @@ concurrency: cancel-in-progress: true jobs: + organization: + uses: LizardByte/.github/.github/workflows/__call-organization.yml@master + npm: + needs: organization name: NPM if: >- github.event.action == 'released' && - github.repository_owner == 'LizardByte' + needs.organization.outputs.allowed == 'true' permissions: contents: read id-token: write # required for provenance and OIDC packages: write uses: LizardByte/.github/.github/workflows/__call-update-npm.yml@master + secrets: + GH_TOKEN: ${{ secrets.GH_BOT_TOKEN }} with: release_version: ${{ github.event.release.tag_name }} @@ -39,8 +45,10 @@ jobs: cloudsmith: name: Cloudsmith - if: startsWith(github.repository, 'LizardByte/') - needs: copr + if: needs.organization.outputs.allowed == 'true' + needs: + - organization + - copr permissions: contents: read uses: ./.github/workflows/ci-cloudsmith.yml diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml index badf24af48d..f9903a3a7ce 100644 --- a/.github/workflows/ci-windows.yml +++ b/.github/workflows/ci-windows.yml @@ -75,7 +75,7 @@ jobs: - name: Setup Dependencies Windows # if a dependency needs to be pinned, see https://github.com/LizardByte/build-deps/pull/186 - uses: msys2/setup-msys2@ec48f7c5447b3140e2b088413ae3a55687bccb6e # v2.33.0 + uses: msys2/setup-msys2@3c51bf698df1e37b2261f53cb67797b97761185c # v2.34.0 with: msystem: ${{ matrix.msystem }} update: true @@ -152,7 +152,7 @@ jobs: - name: Setup dotnet # needed for wix uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0 with: - dotnet-version: '10.x' + dotnet-version: '11.x' - name: Setup NodeJS uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 @@ -180,7 +180,7 @@ jobs: python-version: ${{ env.PYTHON_VERSION }} - name: Setup uv - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3 + uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0 with: enable-cache: true @@ -220,7 +220,7 @@ jobs: -DBUILD_WERROR=ON \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DSUNSHINE_ASSETS_DIR=assets \ - -DSUNSHINE_PUBLISHER_NAME="${GITHUB_REPOSITORY_OWNER}" \ + -DSUNSHINE_PUBLISHER_NAME="LizardByte" \ -DSUNSHINE_PUBLISHER_WEBSITE="https://app.lizardbyte.dev" \ -DSUNSHINE_PUBLISHER_ISSUE_URL="https://app.lizardbyte.dev/support" echo "::add-matcher::.github/matchers/gcc.json" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a7ee2622ae4..70ce5aa20d1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,6 +14,9 @@ concurrency: cancel-in-progress: true jobs: + organization: + uses: LizardByte/.github/.github/workflows/__call-organization.yml@master + github-env: name: GitHub Env Debug permissions: @@ -21,9 +24,12 @@ jobs: uses: LizardByte/.github/.github/workflows/__call-github-env.yml@master release-setup: + needs: organization name: Release Setup outputs: - publish_release: ${{ steps.release-setup.outputs.publish_release }} + publish_release: >- + ${{ needs.organization.outputs.allowed == 'true' && + steps.release-setup.outputs.publish_release == 'true' }} release_body: ${{ steps.release-setup.outputs.release_body }} release_commit: ${{ steps.release-setup.outputs.release_commit }} release_generate_release_notes: ${{ steps.release-setup.outputs.release_generate_release_notes }} @@ -38,7 +44,7 @@ jobs: - name: Release Setup id: release-setup - uses: LizardByte/actions/actions/release_setup@0528b495e6af82b4d698ec6c907a9b1842622068 # v2026.1029.234422 + uses: LizardByte/actions/actions/release_setup@81873587bacc6842098865a35bbb32f2f21cee3b # v2026.1123.33249 with: github_token: ${{ secrets.GITHUB_TOKEN }} @@ -202,8 +208,9 @@ jobs: if: >- always() && !cancelled() && - startsWith(github.repository, 'LizardByte/') + needs.organization.outputs.allowed == 'true' needs: + - organization - build-freebsd - build-linux - build-archlinux @@ -292,8 +299,9 @@ jobs: name: Release if: needs.release-setup.outputs.publish_release == 'true' && - startsWith(github.repository, 'LizardByte/') + needs.organization.outputs.allowed == 'true' needs: + - organization - release-setup - build-archlinux - build-alpine @@ -319,7 +327,7 @@ jobs: run: ls -l artifacts - name: Create/Update GitHub Release - uses: LizardByte/actions/actions/release_create@0528b495e6af82b4d698ec6c907a9b1842622068 # v2026.1029.234422 + uses: LizardByte/actions/actions/release_create@81873587bacc6842098865a35bbb32f2f21cee3b # v2026.1123.33249 with: allowUpdates: false body: ${{ needs.release-setup.outputs.release_body }} @@ -334,8 +342,9 @@ jobs: name: Release Homebrew Beta if: needs.release-setup.outputs.publish_release == 'true' && - startsWith(github.repository, 'LizardByte/') + needs.organization.outputs.allowed == 'true' needs: + - organization - release-setup - build-homebrew - release diff --git a/.github/workflows/publish-artifacts.yml b/.github/workflows/publish-artifacts.yml index 3e1f2f1da25..006a67160dd 100644 --- a/.github/workflows/publish-artifacts.yml +++ b/.github/workflows/publish-artifacts.yml @@ -20,6 +20,6 @@ jobs: runs-on: ubuntu-latest steps: - name: Publish PR artifacts - uses: LizardByte/actions/actions/artifact_comment@0528b495e6af82b4d698ec6c907a9b1842622068 # v2026.1029.234422 + uses: LizardByte/actions/actions/artifact_comment@81873587bacc6842098865a35bbb32f2f21cee3b # v2026.1123.33249 with: artifact_patterns: build-* diff --git a/.github/workflows/update-pages.yml b/.github/workflows/update-pages.yml deleted file mode 100644 index 58282454700..00000000000 --- a/.github/workflows/update-pages.yml +++ /dev/null @@ -1,46 +0,0 @@ ---- -name: Build GH-Pages -permissions: {} - -on: - pull_request: - push: - branches: - - master - workflow_dispatch: - -concurrency: - group: "${{ github.workflow }}-${{ github.ref }}" - cancel-in-progress: true - -jobs: - prep: - runs-on: ubuntu-latest - permissions: - contents: read - steps: - - name: Checkout - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - - name: Upload artifact - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 - with: - name: prep - path: gh-pages-template/ - if-no-files-found: error - include-hidden-files: true - retention-days: 1 - - call-jekyll-build: - needs: prep - permissions: - contents: read - uses: LizardByte/LizardByte.github.io/.github/workflows/jekyll-build.yml@master - secrets: - GH_BOT_EMAIL: ${{ secrets.GH_BOT_EMAIL }} - GH_BOT_TOKEN: ${{ secrets.GH_BOT_TOKEN }} - with: - clean_gh_pages: true - gh_bot_name: ${{ vars.GH_BOT_NAME }} - site_artifact: 'prep' - target_branch: 'gh-pages' diff --git a/.gitmodules b/.gitmodules index 41352019857..d1789f0e7b1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,62 +2,11 @@ path = packaging/linux/flatpak/deps/flatpak-builder-tools url = https://github.com/flatpak/flatpak-builder-tools.git branch = master -[submodule "third-party/build-deps"] - path = third-party/build-deps - url = https://github.com/LizardByte/build-deps.git - branch = master [submodule "third-party/dockle"] path = third-party/dockle url = https://github.com/LizardByte/dockle.git branch = master -[submodule "third-party/glad"] - path = third-party/glad - url = https://github.com/Dav1dde/glad.git -[submodule "third-party/libdisplaydevice"] - path = third-party/libdisplaydevice - url = https://github.com/LizardByte/libdisplaydevice.git - branch = master -[submodule "third-party/libvirtualhid"] - path = third-party/libvirtualhid - url = https://github.com/LizardByte/libvirtualhid.git - branch = master [submodule "third-party/lizardbyte-common"] path = third-party/lizardbyte-common url = https://github.com/LizardByte/lizardbyte-common.git branch = master -[submodule "third-party/moonlight-common-c"] - path = third-party/moonlight-common-c - url = https://github.com/moonlight-stream/moonlight-common-c.git - branch = master -[submodule "third-party/nvapi"] - path = third-party/nvapi - url = https://github.com/NVIDIA/nvapi.git - branch = main -[submodule "third-party/plasma-wayland-protocols"] - path = third-party/plasma-wayland-protocols - url = https://github.com/KDE/plasma-wayland-protocols.git - branch = master -[submodule "third-party/Simple-Web-Server"] - path = third-party/Simple-Web-Server - url = https://github.com/LizardByte-infrastructure/Simple-Web-Server.git - branch = master -[submodule "third-party/TPCircularBuffer"] - path = third-party/TPCircularBuffer - url = https://github.com/michaeltyson/TPCircularBuffer.git - branch = master -[submodule "third-party/tray"] - path = third-party/tray - url = https://github.com/LizardByte/tray.git - branch = master -[submodule "third-party/ViGEmClient"] - path = third-party/ViGEmClient - url = https://github.com/LizardByte/Virtual-Gamepad-Emulation-Client.git - branch = master -[submodule "third-party/wayland-protocols"] - path = third-party/wayland-protocols - url = https://github.com/LizardByte-infrastructure/wayland-protocols.git - branch = main -[submodule "third-party/wlr-protocols"] - path = third-party/wlr-protocols - url = https://github.com/LizardByte-infrastructure/wlr-protocols.git - branch = master diff --git a/AGENTS.md b/AGENTS.md index 8b47e7b63f2..650c456fcba 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -65,7 +65,7 @@ test names and code structure to show the grouping instead. ## Issues and pull requests When asked to create an issue or pull request, use the templates provided by the LizardByte/.github repo or -LizardByte/Sunshine repo, with the Sunshine templates taking precedence if both exist. At the end of the issue +SunshineStream/Sunshine repo, with the Sunshine templates taking precedence if both exist. At the end of the issue or pull request body, add an attribution naming the AI agent, model, and thinking level used to generate it. Repeat that attribution in a separate comment on the created issue or pull request. For example: diff --git a/CMakeLists.txt b/CMakeLists.txt index 61c8a635b74..54d6dd2ba7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,12 +2,12 @@ cmake_minimum_required(VERSION 3.24) # `CMAKE_CUDA_ARCHITECTURES` requires 3.18 # `set_source_files_properties` requires 3.18 # `cmake_path(CONVERT ... TO_NATIVE_PATH_LIST ...)` requires 3.20 -# `third-party/libvirtualhid` requires 3.24 +# libvirtualhid requires 3.24 # todo - set this conditionally project(Sunshine VERSION 0.0.0 DESCRIPTION "Self-hosted game stream host for Moonlight" - HOMEPAGE_URL "https://app.lizardbyte.dev/Sunshine") + HOMEPAGE_URL "https://sunshine.lizardbyte.dev") # Minimum separately installed Virtual HID Broker version supported by this build. set(LIBVIRTUALHID_MINIMUM_VERSION "2026.914.1218.10") @@ -77,11 +77,6 @@ if(${END_BUILD}) return() endif() -# Build-deps owns the dependency versions shared with its FFmpeg builds. -# Include its lock only for full builds so manifest-only configurations do not -# require the build-deps submodule. -include(${CMAKE_CURRENT_SOURCE_DIR}/third-party/build-deps/package-lock.cmake) - # project constants include(${CMAKE_MODULE_PATH}/prep/constants.cmake) diff --git a/DOCKER_README.md b/DOCKER_README.md index a7d8610e690..bb1dbc33e3f 100644 --- a/DOCKER_README.md +++ b/DOCKER_README.md @@ -33,7 +33,7 @@ You must combine the `SUNSHINE_VERSION` and `SUNSHINE_OS` to determine the tag t `-`. For example, `latest-ubuntu-24.04`. See all our available tags on [docker hub](https://hub.docker.com/r/lizardbyte/sunshine/tags) or -[ghcr](https://github.com/LizardByte/Sunshine/pkgs/container/sunshine/versions) for more info. +[ghcr](https://github.com/orgs/LizardByte/packages/container/package/sunshine) for more info. ## Where used This is a list of docker projects using Sunshine. Something missing? Let us know about it! diff --git a/README.md b/README.md index 57dae3d1aed..c03fc387230 100644 --- a/README.md +++ b/README.md @@ -16,38 +16,38 @@ - Star History Rank - GitHub Trending Repository of the Day

- GitHub stars - GitHub Releases + GitHub stars + GitHub Releases Docker - GHCR + GHCR Flathub installs Flathub Version Winget Version - GitHub Workflow Status (CI) - GitHub Workflow Status (localize) - Codecov - SonarCloud + GitHub Workflow Status (CI) + GitHub Workflow Status (localize) + Codecov + SonarCloud ## ℹ️ About @@ -58,6 +58,8 @@ encoding. Software encoding is also available. You can connect to Sunshine from devices. A web UI is provided to allow configuration, and client pairing, from your favorite web browser. Pair from the local server or any mobile device. +Visit the [Sunshine website](https://sunshine.lizardbyte.dev/) for downloads and an overview. + LizardByte has the full documentation hosted on [Read the Docs](https://docs.lizardbyte.dev/projects/sunshine) * [Stable Docs](https://docs.lizardbyte.dev/projects/sunshine/latest/) diff --git a/cmake/compile_definitions/common.cmake b/cmake/compile_definitions/common.cmake index dce2982e17f..3379e2b2e57 100644 --- a/cmake/compile_definitions/common.cmake +++ b/cmake/compile_definitions/common.cmake @@ -68,8 +68,12 @@ elseif(UNIX) endif() # libvirtualhid -add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/libvirtualhid") +CPMGetPackage(libvirtualhid) list(APPEND SUNSHINE_EXTERNAL_LIBRARIES libvirtualhid::libvirtualhid) +if(WIN32) + # session_input.cpp uses libvirtualhid's Windows key layout tables (header-only, not exported) + include_directories(SYSTEM "${libvirtualhid_SOURCE_DIR}/src") +endif() list(APPEND PLATFORM_TARGET_FILES "${CMAKE_SOURCE_DIR}/src/platform/virtualhid_input.h" "${CMAKE_SOURCE_DIR}/src/platform/virtualhid_input.cpp") @@ -131,13 +135,13 @@ endif() list(APPEND PLATFORM_TARGET_FILES ${NVENC_SOURCES}) set(SUNSHINE_TARGET_FILES - "${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/src/Input.h" - "${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/src/Rtsp.h" - "${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/src/RtspParser.c" - "${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/src/Video.h" - "${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/nanors/deps/obl/oblas_common.c" - "${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/nanors/deps/obl/oblas_lite.c" - "${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/nanors/rs.c" + "${moonlight-common-c_SOURCE_DIR}/src/Input.h" + "${moonlight-common-c_SOURCE_DIR}/src/Rtsp.h" + "${moonlight-common-c_SOURCE_DIR}/src/RtspParser.c" + "${moonlight-common-c_SOURCE_DIR}/src/Video.h" + "${moonlight-common-c_SOURCE_DIR}/nanors/deps/obl/oblas_common.c" + "${moonlight-common-c_SOURCE_DIR}/nanors/deps/obl/oblas_lite.c" + "${moonlight-common-c_SOURCE_DIR}/nanors/rs.c" "${CMAKE_SOURCE_DIR}/src/upnp.cpp" "${CMAKE_SOURCE_DIR}/src/upnp.h" "${CMAKE_SOURCE_DIR}/src/cbs.cpp" @@ -165,6 +169,7 @@ set(SUNSHINE_TARGET_FILES "${CMAKE_SOURCE_DIR}/src/httpcommon.h" "${CMAKE_SOURCE_DIR}/src/confighttp.cpp" "${CMAKE_SOURCE_DIR}/src/confighttp.h" + "${CMAKE_SOURCE_DIR}/src/compat/moonlight.h" "${CMAKE_SOURCE_DIR}/src/rtsp.cpp" "${CMAKE_SOURCE_DIR}/src/rtsp.h" "${CMAKE_SOURCE_DIR}/src/stream.cpp" @@ -222,9 +227,10 @@ include_directories( BEFORE SYSTEM "${CMAKE_SOURCE_DIR}/third-party" - "${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/enet/include" - "${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/nanors" - "${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/nanors/deps/obl" + "${moonlight-common-c_SOURCE_DIR}/enet/include" + "${moonlight-common-c_SOURCE_DIR}/nanors" + "${moonlight-common-c_SOURCE_DIR}/nanors/deps/obl" + "${SUNSHINE_DEPENDENCY_INCLUDE_DIR}" ${OPENSSL_INCLUDE_DIR} ${Opus_INCLUDE_DIR} ${FFMPEG_INCLUDE_DIRS} diff --git a/cmake/compile_definitions/linux.cmake b/cmake/compile_definitions/linux.cmake index b47c48ac54e..1188d4027ad 100644 --- a/cmake/compile_definitions/linux.cmake +++ b/cmake/compile_definitions/linux.cmake @@ -136,16 +136,29 @@ endif() # vulkan video encoding (via FFmpeg) if(${SUNSHINE_ENABLE_VULKAN}) - if(NOT SUNSHINE_SYSTEM_VULKAN_HEADERS) - # use Vulkan headers from build-deps submodule (system headers may be too old, e.g. Ubuntu 22.04) - set(VULKAN_HEADERS_DIR "${CMAKE_SOURCE_DIR}/third-party/build-deps/third-party/FFmpeg/Vulkan-Headers/include") - else() + if(SUNSHINE_SYSTEM_VULKAN_HEADERS) find_package(VulkanHeaders REQUIRED) get_target_property(VULKAN_HEADERS_DIR Vulkan::Headers INTERFACE_INCLUDE_DIRECTORIES) + elseif(EXISTS "${FFMPEG_PREPARED_BINARIES}/include/vulkan/vulkan.h") + set(VULKAN_HEADERS_DIR "${FFMPEG_INCLUDE_DIRS}") + else() + include("${CMAKE_MODULE_PATH}/dependencies/build_deps.cmake") + if(DEFINED CPM_DECLARATION_vulkan_headers) + # Keep the package declaration owned by build-deps. + set(SUNSHINE_CPM_PACKAGE_LOCK_ENABLED "${CPM_PACKAGE_LOCK_ENABLED}") + set(CPM_PACKAGE_LOCK_ENABLED OFF) + CPMAddPackage(NAME vulkan_headers DOWNLOAD_ONLY YES) + set(CPM_PACKAGE_LOCK_ENABLED "${SUNSHINE_CPM_PACKAGE_LOCK_ENABLED}") + unset(SUNSHINE_CPM_PACKAGE_LOCK_ENABLED) + set(VULKAN_HEADERS_DIR "${vulkan_headers_SOURCE_DIR}/include") + else() + # Older build-deps releases pin Vulkan Headers as a Git submodule. + set(VULKAN_HEADERS_DIR "${build_deps_SOURCE_DIR}/third-party/FFmpeg/Vulkan-Headers/include") + endif() endif() if(NOT EXISTS "${VULKAN_HEADERS_DIR}/vulkan/vulkan.h") - message(FATAL_ERROR "Vulkan headers not found in build-deps submodule") + message(FATAL_ERROR "Vulkan headers not found in ${VULKAN_HEADERS_DIR}") endif() find_library(VULKAN_LIBRARY NAMES vulkan vulkan-1) @@ -217,7 +230,8 @@ if(WAYLAND_FOUND) add_compile_definitions(SUNSHINE_BUILD_WAYLAND) if(NOT SUNSHINE_SYSTEM_WAYLAND_PROTOCOLS) - set(WAYLAND_PROTOCOLS_DIR "${CMAKE_SOURCE_DIR}/third-party/wayland-protocols") + CPMAddPackage(NAME wayland_protocols DOWNLOAD_ONLY YES) + set(WAYLAND_PROTOCOLS_DIR "${wayland_protocols_SOURCE_DIR}") else() pkg_get_variable(WAYLAND_PROTOCOLS_DIR wayland-protocols pkgdatadir) pkg_check_modules(WAYLAND_PROTOCOLS wayland-protocols REQUIRED) @@ -225,7 +239,8 @@ if(WAYLAND_FOUND) GEN_WAYLAND("${WAYLAND_PROTOCOLS_DIR}" "unstable/xdg-output" xdg-output-unstable-v1) GEN_WAYLAND("${WAYLAND_PROTOCOLS_DIR}" "unstable/linux-dmabuf" linux-dmabuf-unstable-v1) - GEN_WAYLAND("${CMAKE_SOURCE_DIR}/third-party/wlr-protocols" "unstable" wlr-screencopy-unstable-v1) + CPMAddPackage(NAME wlr_protocols DOWNLOAD_ONLY YES) + GEN_WAYLAND("${wlr_protocols_SOURCE_DIR}" "unstable" wlr-screencopy-unstable-v1) include_directories( SYSTEM @@ -288,8 +303,9 @@ set(KWIN_FOUND OFF) if(PIPEWIRE_FOUND AND WAYLAND_FOUND AND ${SUNSHINE_ENABLE_KWIN}) set(KWIN_FOUND ON) add_compile_definitions(SUNSHINE_BUILD_KWIN) - GEN_WAYLAND("${CMAKE_SOURCE_DIR}/third-party/plasma-wayland-protocols/src/protocols" "" kde-output-order-v1) - GEN_WAYLAND("${CMAKE_SOURCE_DIR}/third-party/plasma-wayland-protocols/src/protocols" "" zkde-screencast-unstable-v1) + CPMAddPackage(NAME plasma_wayland_protocols DOWNLOAD_ONLY YES) + GEN_WAYLAND("${plasma_wayland_protocols_SOURCE_DIR}/src/protocols" "" kde-output-order-v1) + GEN_WAYLAND("${plasma_wayland_protocols_SOURCE_DIR}/src/protocols" "" zkde-screencast-unstable-v1) list(APPEND PLATFORM_TARGET_FILES "${CMAKE_SOURCE_DIR}/src/platform/linux/kwingrab.cpp") elseif(${SUNSHINE_ENABLE_KWIN} AND NOT WAYLAND_FOUND) diff --git a/cmake/compile_definitions/macos.cmake b/cmake/compile_definitions/macos.cmake index bb478dcfe8c..a41d7846255 100644 --- a/cmake/compile_definitions/macos.cmake +++ b/cmake/compile_definitions/macos.cmake @@ -37,6 +37,7 @@ list(APPEND SUNSHINE_EXTERNAL_LIBRARIES ${FOUNDATION_LIBRARY} ${IOKIT_LIBRARY} ${USER_NOTIFICATIONS_LIBRARY} + ${SCREEN_CAPTURE_KIT_LIBRARY} ${VIDEO_TOOLBOX_LIBRARY}) set(APPLE_PLIST_TEMPLATE "${SUNSHINE_SOURCE_ASSETS_DIR}/macos/build/Info.plist.in") @@ -51,14 +52,20 @@ set(PLATFORM_TARGET_FILES "${CMAKE_SOURCE_DIR}/src/platform/macos/av_video.h" "${CMAKE_SOURCE_DIR}/src/platform/macos/av_video.m" "${CMAKE_SOURCE_DIR}/src/platform/macos/display.mm" + "${CMAKE_SOURCE_DIR}/src/platform/macos/display_helpers.h" + "${CMAKE_SOURCE_DIR}/src/platform/macos/display_helpers.mm" "${CMAKE_SOURCE_DIR}/src/platform/macos/input.cpp" "${CMAKE_SOURCE_DIR}/src/platform/macos/microphone.mm" "${CMAKE_SOURCE_DIR}/src/platform/macos/misc.mm" "${CMAKE_SOURCE_DIR}/src/platform/macos/misc.h" - "${CMAKE_SOURCE_DIR}/src/platform/macos/nv12_zero_device.cpp" - "${CMAKE_SOURCE_DIR}/src/platform/macos/nv12_zero_device.h" "${CMAKE_SOURCE_DIR}/src/platform/macos/publish.cpp" - "${CMAKE_SOURCE_DIR}/third-party/TPCircularBuffer/TPCircularBuffer.c" - "${CMAKE_SOURCE_DIR}/third-party/TPCircularBuffer/TPCircularBuffer.h" + "${CMAKE_SOURCE_DIR}/src/platform/macos/sc_capture.h" + "${CMAKE_SOURCE_DIR}/src/platform/macos/sc_capture.mm" + "${CMAKE_SOURCE_DIR}/src/platform/macos/sc_capture_loop.cpp" + "${CMAKE_SOURCE_DIR}/src/platform/macos/sc_capture_loop.h" + "${CMAKE_SOURCE_DIR}/src/platform/macos/vt_encoder.h" + "${CMAKE_SOURCE_DIR}/src/platform/macos/vt_encoder.mm" + "${tpcircularbuffer_SOURCE_DIR}/TPCircularBuffer.c" + "${tpcircularbuffer_SOURCE_DIR}/TPCircularBuffer.h" ${APPLE_ENTITLEMENTS_FILE} ${APPLE_PLIST_FILE}) diff --git a/cmake/compile_definitions/windows.cmake b/cmake/compile_definitions/windows.cmake index b0c5680a55f..299fd2145e1 100644 --- a/cmake/compile_definitions/windows.cmake +++ b/cmake/compile_definitions/windows.cmake @@ -38,14 +38,16 @@ add_definitions(-DMINIUPNP_STATICLIB) add_subdirectory(tools) # todo - this is temporary, only tools for Windows are needed, for now # nvidia -include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/third-party/nvapi") +CPMAddPackage(NAME nvapi DOWNLOAD_ONLY YES) +include_directories(SYSTEM "${nvapi_SOURCE_DIR}") file(GLOB NVPREFS_FILES CONFIGURE_DEPENDS - "${CMAKE_SOURCE_DIR}/third-party/nvapi/*.h" + "${nvapi_SOURCE_DIR}/*.h" "${CMAKE_SOURCE_DIR}/src/platform/windows/nvprefs/*.cpp" "${CMAKE_SOURCE_DIR}/src/platform/windows/nvprefs/*.h") # vigem -include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/third-party/ViGEmClient/include") +CPMAddPackage(NAME vigemclient DOWNLOAD_ONLY YES) +include_directories(SYSTEM "${vigemclient_SOURCE_DIR}/include") # sunshine icon if(NOT DEFINED SUNSHINE_ICON_PATH) @@ -84,11 +86,11 @@ set(PLATFORM_TARGET_FILES "${CMAKE_SOURCE_DIR}/src/platform/windows/audio.cpp" "${CMAKE_SOURCE_DIR}/src/platform/windows/utf_utils.cpp" "${CMAKE_SOURCE_DIR}/src/platform/windows/utf_utils.h" - "${CMAKE_SOURCE_DIR}/third-party/ViGEmClient/src/ViGEmClient.cpp" - "${CMAKE_SOURCE_DIR}/third-party/ViGEmClient/include/ViGEm/Client.h" - "${CMAKE_SOURCE_DIR}/third-party/ViGEmClient/include/ViGEm/Common.h" - "${CMAKE_SOURCE_DIR}/third-party/ViGEmClient/include/ViGEm/Util.h" - "${CMAKE_SOURCE_DIR}/third-party/ViGEmClient/include/ViGEm/km/BusShared.h" + "${vigemclient_SOURCE_DIR}/src/ViGEmClient.cpp" + "${vigemclient_SOURCE_DIR}/include/ViGEm/Client.h" + "${vigemclient_SOURCE_DIR}/include/ViGEm/Common.h" + "${vigemclient_SOURCE_DIR}/include/ViGEm/Util.h" + "${vigemclient_SOURCE_DIR}/include/ViGEm/km/BusShared.h" ${NVPREFS_FILES}) set(OPENSSL_LIBRARIES diff --git a/cmake/dependencies/build_deps.cmake b/cmake/dependencies/build_deps.cmake new file mode 100644 index 00000000000..85e98eee540 --- /dev/null +++ b/cmake/dependencies/build_deps.cmake @@ -0,0 +1,4 @@ +include_guard(GLOBAL) + +CPMAddPackage(NAME build_deps DOWNLOAD_ONLY YES) +include("${build_deps_SOURCE_DIR}/package-lock.cmake") diff --git a/cmake/dependencies/common.cmake b/cmake/dependencies/common.cmake index 5deb442a4cd..c4eb67ed833 100644 --- a/cmake/dependencies/common.cmake +++ b/cmake/dependencies/common.cmake @@ -8,13 +8,30 @@ find_package(OpenSSL REQUIRED) # boost, this should be before Simple-Web-Server as it also depends on boost include(dependencies/Boost_Sunshine) -# submodules # moonlight common library +# Sunshine builds only the ENet target and compiles selected Moonlight sources directly. +CPMAddPackage(NAME moonlight-common-c DOWNLOAD_ONLY YES) set(ENET_NO_INSTALL ON CACHE BOOL "Don't install any libraries built for enet") -add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/enet") +add_subdirectory("${moonlight-common-c_SOURCE_DIR}/enet" "${moonlight-common-c_BINARY_DIR}/enet") # web server -add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/Simple-Web-Server") +CPMGetPackage(simple_web_server) + +set(SUNSHINE_DEPENDENCY_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/dependency-include") + +# Forward each header in ARGN from source_dir into include_prefix to preserve qualified includes. +function(sunshine_forward_dependency_headers source_dir include_prefix) + foreach(header IN LISTS ARGN) + file(GENERATE + OUTPUT "${SUNSHINE_DEPENDENCY_INCLUDE_DIR}/${include_prefix}/${header}" + CONTENT "#include \"${source_dir}/${header}\"\n") + endforeach() +endfunction() + +sunshine_forward_dependency_headers("${moonlight-common-c_SOURCE_DIR}/src" "moonlight-common-c/src" + Input.h Limelight.h Limelight-internal.h Rtsp.h VideoFormats.h) +sunshine_forward_dependency_headers("${simple_web_server_SOURCE_DIR}" "Simple-Web-Server" + client_http.hpp client_https.hpp crypto.hpp server_http.hpp server_https.hpp) # lizardbyte common helpers set(LIZARDBYTE_COMMON_BUILD_TEST_SUPPORT ${BUILD_TESTS} @@ -22,7 +39,7 @@ set(LIZARDBYTE_COMMON_BUILD_TEST_SUPPORT ${BUILD_TESTS} add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/lizardbyte-common") # libdisplaydevice -add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/libdisplaydevice") +CPMGetPackage(libdisplaydevice) if(SUNSHINE_ENABLE_TRAY) if(SUNSHINE_USE_STATIC_QT) @@ -54,7 +71,7 @@ if(SUNSHINE_ENABLE_TRAY) set(CMAKE_MODULE_PATH "${_sunshine_module_path}") endif() - add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/tray") + CPMGetPackage(tray) # TRAY_QT_VERSION is scoped to the tray subdirectory, so inspect the target's actual dependencies. get_target_property(_sunshine_tray_link_libraries tray LINK_LIBRARIES) @@ -86,7 +103,6 @@ if(SUNSHINE_ENABLE_TRAY) endif() # common dependencies -include("${CMAKE_MODULE_PATH}/dependencies/nv_codec_headers.cmake") include("${CMAKE_MODULE_PATH}/dependencies/nlohmann_json.cmake") include("${CMAKE_MODULE_PATH}/dependencies/libdatachannel.cmake") find_package(PkgConfig REQUIRED) @@ -99,6 +115,7 @@ include_directories(SYSTEM ${MINIUPNP_INCLUDE_DIRS}) # ffmpeg pre-compiled binaries include("${CMAKE_MODULE_PATH}/dependencies/ffmpeg.cmake") +include("${CMAKE_MODULE_PATH}/dependencies/nv_codec_headers.cmake") # Opus if(TARGET PkgConfig::SUNSHINE_BUNDLED_OPUS) diff --git a/cmake/dependencies/ffmpeg.cmake b/cmake/dependencies/ffmpeg.cmake index 7347b1e3dca..16cadf00d76 100644 --- a/cmake/dependencies/ffmpeg.cmake +++ b/cmake/dependencies/ffmpeg.cmake @@ -18,50 +18,11 @@ if(NOT DEFINED FFMPEG_PREPARED_BINARIES) # Determine download location set(FFMPEG_DOWNLOAD_DIR "${CMAKE_BINARY_DIR}/_deps") - # Fetch tags for the build-deps submodule so tag lookups work in CI shallow clones - execute_process( - COMMAND git -C "${CMAKE_SOURCE_DIR}/third-party/build-deps" fetch --tags --depth=1 - OUTPUT_QUIET - ERROR_QUIET - ) - - # Get the current commit/tag from the build-deps submodule - execute_process( - COMMAND git -C "${CMAKE_SOURCE_DIR}/third-party/build-deps" describe --tags --exact-match - OUTPUT_VARIABLE FFMPEG_RELEASE_TAG - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_QUIET - ) - - # If no exact tag match, try to get the commit hash and look for a tag - if(NOT FFMPEG_RELEASE_TAG) - execute_process( - COMMAND git -C "${CMAKE_SOURCE_DIR}/third-party/build-deps" rev-parse HEAD - OUTPUT_VARIABLE BUILD_DEPS_COMMIT - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_QUIET - ) - - # Try to find a tag that points to this commit - execute_process( - COMMAND git -C "${CMAKE_SOURCE_DIR}/third-party/build-deps" tag --points-at ${BUILD_DEPS_COMMIT} - OUTPUT_VARIABLE FFMPEG_RELEASE_TAG - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_QUIET - ) - endif() - - # Set GitHub release URL + # Use the release pinned alongside the build-deps-owned codec headers. set(FFMPEG_GITHUB_REPO "LizardByte/build-deps") - if(FFMPEG_RELEASE_TAG) - set(FFMPEG_RELEASE_URL "https://github.com/${FFMPEG_GITHUB_REPO}/releases/download/${FFMPEG_RELEASE_TAG}") - set(FFMPEG_VERSION_DIR "${FFMPEG_DOWNLOAD_DIR}/ffmpeg-${FFMPEG_RELEASE_TAG}") - message(STATUS "Using FFmpeg from build-deps tag: ${FFMPEG_RELEASE_TAG}") - else() - set(FFMPEG_RELEASE_URL "https://github.com/${FFMPEG_GITHUB_REPO}/releases/latest/download") - set(FFMPEG_VERSION_DIR "${FFMPEG_DOWNLOAD_DIR}/ffmpeg-latest") - message(STATUS "Using FFmpeg from latest build-deps release") - endif() + set(FFMPEG_RELEASE_URL "https://github.com/${FFMPEG_GITHUB_REPO}/releases/download/${BUILD_DEPS_TAG}") + set(FFMPEG_VERSION_DIR "${FFMPEG_DOWNLOAD_DIR}/ffmpeg-${BUILD_DEPS_TAG}") + message(STATUS "Using FFmpeg from build-deps tag: ${BUILD_DEPS_TAG}") # Set extraction directory and prepared binaries path set(FFMPEG_EXTRACT_DIR "${FFMPEG_VERSION_DIR}") @@ -294,9 +255,6 @@ if(UNIX AND NOT APPLE) file(COPY "${FFMPEG_PREPARED_BINARIES}/include/" DESTINATION "${FFMPEG_INCLUDE_DIRS}" PATTERN "va" EXCLUDE) endif() set(_sunshine_bundled_include "${FFMPEG_PREPARED_BINARIES}/include") - if(NV_CODEC_HEADERS_13_1_INCLUDE_DIR STREQUAL _sunshine_bundled_include) - set(NV_CODEC_HEADERS_13_1_INCLUDE_DIR "${FFMPEG_INCLUDE_DIRS}") - endif() foreach(dependency FFMPEG OPUS) if(TARGET PkgConfig::SUNSHINE_BUNDLED_${dependency}) get_target_property(_sunshine_include_dirs diff --git a/cmake/dependencies/glad.cmake b/cmake/dependencies/glad.cmake index 21a769ffb6d..90d1754768b 100644 --- a/cmake/dependencies/glad.cmake +++ b/cmake/dependencies/glad.cmake @@ -1,6 +1,6 @@ # # Generates the glad OpenGL/EGL loader library using the glad2 generator. -# Sources are generated at build time via the glad submodule's CMake integration. +# Sources are generated at build time via the CPM-fetched glad CMake integration. # include_guard(GLOBAL) @@ -100,7 +100,11 @@ set(PYTHON_EXECUTABLE "${Python_EXECUTABLE}" CACHE FILEPATH "Python interpreter if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.27") set(CMAKE_POLICY_VERSION_MINIMUM 3.5) endif() -add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/glad/cmake" glad2-cmake) +CPMAddPackage(NAME glad DOWNLOAD_ONLY YES) +# Refresh the upstream cache entries when the checkout path changes. +set(GLAD_CMAKE_DIR "${glad_SOURCE_DIR}/cmake" CACHE STRING "Directory containing glad's CMake files" FORCE) +set(GLAD_SOURCES_DIR "${glad_SOURCE_DIR}" CACHE STRING "Directory containing glad's Python sources" FORCE) +add_subdirectory("${GLAD_CMAKE_DIR}" glad2-cmake) unset(CMAKE_POLICY_VERSION_MINIMUM) if(NOT GLAD_SKIP_PIP_INSTALL) @@ -143,7 +147,7 @@ if(NOT GLAD_SKIP_PIP_INSTALL) execute_process( COMMAND "${UV_EXECUTABLE}" pip install --python "${_glad_python_executable}" - --requirement "${CMAKE_SOURCE_DIR}/third-party/glad/requirements.txt" + --requirement "${glad_SOURCE_DIR}/requirements.txt" --quiet COMMAND_ERROR_IS_FATAL ANY ) diff --git a/cmake/dependencies/macos.cmake b/cmake/dependencies/macos.cmake index 3dc396fe27c..4ca9ab60614 100644 --- a/cmake/dependencies/macos.cmake +++ b/cmake/dependencies/macos.cmake @@ -11,8 +11,12 @@ FIND_LIBRARY(CORE_VIDEO_LIBRARY CoreVideo) FIND_LIBRARY(FOUNDATION_LIBRARY Foundation) FIND_LIBRARY(IOKIT_LIBRARY IOKit) FIND_LIBRARY(USER_NOTIFICATIONS_LIBRARY UserNotifications) +FIND_LIBRARY(SCREEN_CAPTURE_KIT_LIBRARY ScreenCaptureKit) FIND_LIBRARY(VIDEO_TOOLBOX_LIBRARY VideoToolbox) if(SUNSHINE_ENABLE_TRAY) FIND_LIBRARY(COCOA Cocoa REQUIRED) endif() + +CPMAddPackage(NAME tpcircularbuffer DOWNLOAD_ONLY YES) +include_directories(SYSTEM "${tpcircularbuffer_SOURCE_DIR}") diff --git a/cmake/dependencies/nv_codec_headers.cmake b/cmake/dependencies/nv_codec_headers.cmake index a30c86eff58..625536526f8 100644 --- a/cmake/dependencies/nv_codec_headers.cmake +++ b/cmake/dependencies/nv_codec_headers.cmake @@ -1,22 +1,24 @@ +set(SUNSHINE_PREPARED_NV_CODEC_HEADERS "${FFMPEG_PREPARED_BINARIES}/include/ffnvcodec/nvEncodeAPI.h") + +if(WIN32 OR (NOT APPLE AND NOT EXISTS "${SUNSHINE_PREPARED_NV_CODEC_HEADERS}")) + include("${CMAKE_MODULE_PATH}/dependencies/build_deps.cmake") +endif() + # Keep build-deps-owned declarations out of Sunshine's generated package lock. set(SUNSHINE_CPM_PACKAGE_LOCK_ENABLED "${CPM_PACKAGE_LOCK_ENABLED}") set(CPM_PACKAGE_LOCK_ENABLED OFF) if(NOT APPLE) - set(SUNSHINE_PREPARED_NV_CODEC_HEADERS - "${FFMPEG_PREPARED_BINARIES}/include/ffnvcodec/nvEncodeAPI.h") - - if(DEFINED FFMPEG_PREPARED_BINARIES AND EXISTS "${SUNSHINE_PREPARED_NV_CODEC_HEADERS}") + if(EXISTS "${SUNSHINE_PREPARED_NV_CODEC_HEADERS}") # Prepared FFmpeg bundles include the NV codec headers used to build them. - set(NV_CODEC_HEADERS_13_1_INCLUDE_DIR "${FFMPEG_PREPARED_BINARIES}/include") + set(NV_CODEC_HEADERS_13_1_INCLUDE_DIR "${FFMPEG_INCLUDE_DIRS}") message(STATUS "Using NV codec headers from prepared FFmpeg binaries") else() CPMGetPackage(nv_codec_headers_13_1) set(NV_CODEC_HEADERS_13_1_INCLUDE_DIR "${nv_codec_headers_13_1_SOURCE_DIR}/include") endif() - - unset(SUNSHINE_PREPARED_NV_CODEC_HEADERS) endif() +unset(SUNSHINE_PREPARED_NV_CODEC_HEADERS) if(WIN32) CPMGetPackage(nv_codec_headers_13) diff --git a/cmake/prep/options.cmake b/cmake/prep/options.cmake index f6d4e5b4c66..fe5de0cc88e 100644 --- a/cmake/prep/options.cmake +++ b/cmake/prep/options.cmake @@ -23,8 +23,8 @@ if(WIN32) "Require static Qt libraries and their static third-party dependencies." ON) endif() -option(SUNSHINE_SYSTEM_VULKAN_HEADERS "Use system installation of vulkan-headers rather than the submodule." OFF) -option(SUNSHINE_SYSTEM_WAYLAND_PROTOCOLS "Use system installation of wayland-protocols rather than the submodule." OFF) +option(SUNSHINE_SYSTEM_VULKAN_HEADERS "Use system Vulkan headers instead of the build-deps pin." OFF) +option(SUNSHINE_SYSTEM_WAYLAND_PROTOCOLS "Use system Wayland protocols instead of the CPM package." OFF) option(BOOST_USE_STATIC "Use static boost libraries." ON) diff --git a/cmake/targets/common.cmake b/cmake/targets/common.cmake index 0bdbea5a22e..7d47ebdbff9 100644 --- a/cmake/targets/common.cmake +++ b/cmake/targets/common.cmake @@ -92,7 +92,12 @@ add_custom_target(web-ui ALL WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" COMMENT "Installing NPM Dependencies and Building the Web UI" COMMAND "${CMAKE_COMMAND}" -E env "${NPM_PATH}" ${NPM_COMMAND} "${NPM}" ci ${NPM_INSTALL_FLAGS} - COMMAND "${CMAKE_COMMAND}" -E env "${NPM_PATH}" "SUNSHINE_BUILD_HOMEBREW=${NPM_BUILD_HOMEBREW}" "SUNSHINE_SOURCE_ASSETS_DIR=${NPM_SOURCE_ASSETS_DIR}" "SUNSHINE_ASSETS_DIR=${NPM_ASSETS_DIR}" ${NPM_COMMAND} "${NPM}" run build # cmake-lint: disable=C0301 + COMMAND "${CMAKE_COMMAND}" -E env "${NPM_PATH}" + "SUNSHINE_BUILD_HOMEBREW=${NPM_BUILD_HOMEBREW}" + "SUNSHINE_SOURCE_ASSETS_DIR=${NPM_SOURCE_ASSETS_DIR}" + "SUNSHINE_ASSETS_DIR=${NPM_ASSETS_DIR}" + "SUNSHINE_LIBVIRTUALHID_ICON=${libvirtualhid_SOURCE_DIR}/libvirtualhid.svg" + ${NPM_COMMAND} "${NPM}" run build VERBATIM) # docs @@ -119,7 +124,7 @@ set_source_files_properties("${CMAKE_SOURCE_DIR}/src/upnp.cpp" DIRECTORY "${CMAKE_SOURCE_DIR}" "${TEST_DIR}" PROPERTIES COMPILE_FLAGS -Wno-pedantic) -# third-party/ViGEmClient +# ViGEmClient set(VIGEM_COMPILE_FLAGS "") string(APPEND VIGEM_COMPILE_FLAGS "-Wno-unknown-pragmas ") string(APPEND VIGEM_COMPILE_FLAGS "-Wno-misleading-indentation ") @@ -127,7 +132,7 @@ string(APPEND VIGEM_COMPILE_FLAGS "-Wno-class-memaccess ") string(APPEND VIGEM_COMPILE_FLAGS "-Wno-unused-function ") string(APPEND VIGEM_COMPILE_FLAGS "-Wno-unused-variable ") string(APPEND VIGEM_COMPILE_FLAGS "-Wno-missing-field-initializers ") -set_source_files_properties("${CMAKE_SOURCE_DIR}/third-party/ViGEmClient/src/ViGEmClient.cpp" +set_source_files_properties("${vigemclient_SOURCE_DIR}/src/ViGEmClient.cpp" DIRECTORY "${CMAKE_SOURCE_DIR}" "${TEST_DIR}" PROPERTIES COMPILE_DEFINITIONS "UNICODE=1;ERROR_INVALID_DEVICE_OBJECT_PARAMETER=650" diff --git a/dockle.toml b/dockle.toml index 8ce58774256..fc081f9624c 100644 --- a/dockle.toml +++ b/dockle.toml @@ -2,7 +2,7 @@ name = "Sunshine" version = "0.0.0" description = "Self-hosted game stream host for Moonlight." -repository = "https://github.com/LizardByte/Sunshine" +repository = "https://github.com/SunshineStream/Sunshine" logo = "sunshine.svg" favicon = "sunshine.ico" diff --git a/docs/building.md b/docs/building.md index 6799b12c9eb..66cd6d37361 100644 --- a/docs/building.md +++ b/docs/building.md @@ -14,6 +14,9 @@ It is recommended to use one of the following compilers: ### Dependencies +CMake fetches pinned source dependencies through CPM on the first configure. Initialize the remaining Git submodules +with `git submodule update --init --recursive` before configuring. + Boost `1.89.0` or newer can be supplied as a system package. When a compatible system package is unavailable, CMake downloads the project-locked Boost release through CPM. Static Boost libraries are preferred on every platform by default; pass `-DBOOST_USE_STATIC=OFF` to use shared system libraries instead. @@ -79,7 +82,7 @@ export CXX=clang++19 #### Linux Dependencies vary depending on the distribution. You can reference our -[linux_build.sh](https://github.com/LizardByte/Sunshine/blob/master/scripts/linux_build.sh) script for a list of +[linux_build.sh](https://github.com/SunshineStream/Sunshine/blob/master/scripts/linux_build.sh) script for a list of dependencies we use in Debian-based, Fedora-based and Arch-based distributions. Please submit a PR if you would like to extend the script to support other distributions. @@ -237,7 +240,7 @@ MSYS2 Node.js package is not supported because its shared runtime cannot load th Ensure [git](https://git-scm.com) is installed on your system, then clone the repository using the following command: ```bash -git clone https://github.com/lizardbyte/sunshine.git --recurse-submodules +git clone https://github.com/SunshineStream/Sunshine.git --recurse-submodules cd sunshine mkdir build ``` @@ -251,7 +254,7 @@ ninja -C build > [!TIP] > Available build options can be found in -> [options.cmake](https://github.com/LizardByte/Sunshine/blob/master/cmake/prep/options.cmake). +> [options.cmake](https://github.com/SunshineStream/Sunshine/blob/master/cmake/prep/options.cmake). ### Package diff --git a/docs/changelog.md b/docs/changelog.md index 9a5069a50b6..6766e63da95 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -4,6 +4,6 @@ + src="https://raw.githubusercontent.com/SunshineStream/Sunshine/changelog/CHANGELOG.md"> @endhtmlonly diff --git a/docs/configuration.md b/docs/configuration.md index 5cc26d51bd9..60eed01d473 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -810,12 +810,13 @@ consent prompt for directory ACLs, so the Web UI shows setup steps for correctin **FreeBSD/Linux + pipewire:**
@code{} - pactl info | grep Source - # in some causes you'd need to use the `Sink` device, if `Source` doesn't work, so try: - pactl info | grep Sink + pactl list short sinks @endcode

+ Copy the sink name (second column) into `audio_sink`. +
+
**macOS:**
Sunshine can only access microphones on macOS due to system limitations. @@ -1031,7 +1032,7 @@ consent prompt for directory ACLs, so the Web UI shows setup steps for correctin Description - Select the display number you want to stream. + Select the display you want to stream. @tip{To find the appropriate values follow these instructions.

@@ -1047,7 +1048,10 @@ consent prompt for directory ACLs, so the Web UI shows setup steps for correctin Info: Detected display: DVI-D-1 (id: 4) connected: false @endcode It is recommended to use the stable display connector name (text right before the parenthesis, e.g. DP-0) for this value. - For wlgrab/x11grab and kmsgrab the numeric id value can also be used. + With KMS (kmsgrab) or wlroots (wlgrab), use the exact connector name from the capture backend's monitor list + in the Sunshine log. If a numeric setting does not match an enumerated output, Sunshine selects the first + detected display instead. Replace the number with the connector name of the intended display. + With X11 (x11grab), the numeric id can also be used.

**macOS:** @@ -1123,7 +1127,7 @@ consent prompt for directory ACLs, so the Web UI shows setup steps for correctin Example (FreeBSD/Linux) @code{} - output_name = 0 + output_name = DP-1 @endcode @@ -1518,6 +1522,31 @@ consent prompt for directory ACLs, so the Web UI shows setup steps for correctin +### max_stream_resolution + + + + + + + + + + + + + + +
Description + The maximum resolution (formatted as WIDTHxHEIGHT) that Sunshine will stream at. Larger client requests + are downscaled, preserving aspect ratio. Lowering this reduces encoding latency on hosts where the + encoder cannot keep up with the requested resolution. If empty, the resolution requested by Moonlight + is used. +
Default@code{} + @endcode
Example@code{} + max_stream_resolution = 2560x1440 + @endcode
+ ### minimum_fps_target @@ -1914,6 +1943,32 @@ consent prompt for directory ACLs, so the Web UI shows setup steps for correctin
+### dscp_tagging + + + + + + + + + + + + + + +
Description + Mark audio and video packets with DSCP priority tags when requested by the client. + @tip{Disabling this may help if audio crackles or stutters on Wi-Fi while the network otherwise appears + healthy. Some routers handle tagged traffic poorly.} + @note{On Windows, disabling this also removes local traffic prioritization.} +
Default@code{} + enabled + @endcode
Example@code{} + dscp_tagging = disabled + @endcode
+ ### stream_protocol @@ -2354,6 +2409,88 @@ consent prompt for directory ACLs, so the Web UI shows setup steps for correctin
+### mpeg2_mode + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Description + Allows any client implementing the Sunshine codec extension to request MPEG-2/H.262 video streams. + Support is unadvertised by default and must be enabled here. Sunshine probes MPEG-2 independently of + H.264, preferring the selected backend before trying other available backends. Enabling H.263+ does not + displace a working hardware MPEG-2 encoder. Streams using different encoder backends use separate + capture workers. + @warning{MPEG-2 may be more CPU-intensive to encode than modern hardware-accelerated codecs when hardware + encoding is unavailable.} +
Default@code{} + 0 + @endcode
Example@code{} + mpeg2_mode = 2 + @endcode
Choices0preserve modern codec automatic selection and keep MPEG-2 unadvertised
1do not advertise support for MPEG-2
2advertise support for MPEG-2/H.262 video after a successful encoder probe
+ +### h263p_mode + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Description + Allows any client implementing the Sunshine codec extension to request H.263+ video streams. + Support is unadvertised by default and must be enabled here. Sunshine selects and probes its H.263+ + backend independently of MPEG-2 and modern codecs; H.264 support is not a prerequisite. + The stream width and height must both be multiples of four after applying any resolution cap. + @warning{H.263+ uses software encoding in Sunshine and may reduce host performance.} +
Default@code{} + 0 + @endcode
Example@code{} + h263p_mode = 2 + @endcode
Choices0preserve modern codec automatic selection and keep H.263+ unadvertised
1do not advertise support for H.263+
2advertise support for H.263+ video after a successful encoder probe
+ ### capture @@ -2482,7 +2619,7 @@ consent prompt for directory ACLs, so the Web UI shows setup steps for correctin @endcode - + @@ -2503,6 +2640,11 @@ consent prompt for directory ACLs, so the Web UI shows setup steps for correctin + + + + @@ -3218,7 +3360,7 @@ consent prompt for directory ACLs, so the Web UI shows setup steps for correctin @@ -3237,56 +3379,15 @@ consent prompt for directory ACLs, so the Web UI shows setup steps for correctin - + - + - - -
ChoicesChoices nvenc For NVIDIA graphics cards
Use Vulkan encoder (AMD, Intel, NVIDIA). @note{Applies to Linux only.}
videotoolboxUse VideoToolbox. + @note{Applies to macOS only.}
software Encoding occurs on the CPU
Description - The entropy encoding to use. + The entropy encoding to use for H.264. @note{This option only applies when using macOS.}
Choices autolet ffmpeg decidelet VideoToolbox decide
cabaccontext adaptive binary arithmetic coding - faster decodecontext adaptive binary arithmetic coding - higher quality
cavlccontext adaptive variable-length coding - higher quality
- -### vt_software - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
Description - Force Video Toolbox to use software encoding. - @note{This option only applies when using macOS.} -
Default@code{} - auto - @endcode
Example@code{} - vt_software = auto - @endcode
Choicesautolet ffmpeg decide
disableddisable software encoding
allowedallow software encoding
forcedforce software encodingcontext adaptive variable-length coding - faster decode
diff --git a/docs/getting_started.md b/docs/getting_started.md index 194856a96fb..d4d6e46db94 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -3,7 +3,7 @@ The recommended method for running Sunshine is to use the [binaries](#binaries) included in the [latest release][latest-release], unless otherwise specified. -[Pre-releases](https://github.com/LizardByte/Sunshine/releases) are also available. These should be considered beta, +[Pre-releases](https://github.com/SunshineStream/Sunshine/releases) are also available. These should be considered beta, and release artifacts may be missing when merging changes on a faster cadence. ## Binaries @@ -35,8 +35,8 @@ See [Docker](../DOCKER_README.md) for more information. | Architecture | Package | |---------------|----------------------------------------------------------------------------------------------------------------------------------------| - | amd64/x86_64 | [Sunshine-FreeBSD-14.4-amd64.pkg](https://github.com/LizardByte/Sunshine/releases/latest/download/Sunshine-FreeBSD-14.3-amd64.pkg) | - | arm64/aarch64 | [Sunshine-FreeBSD-14.4-aarch64.pkg](https://github.com/LizardByte/Sunshine/releases/latest/download/Sunshine-FreeBSD-14.3-aarch64.pkg) | + | amd64/x86_64 | [Sunshine-FreeBSD-14.4-amd64.pkg](https://github.com/SunshineStream/Sunshine/releases/latest/download/Sunshine-FreeBSD-14.3-amd64.pkg) | + | arm64/aarch64 | [Sunshine-FreeBSD-14.4-aarch64.pkg](https://github.com/SunshineStream/Sunshine/releases/latest/download/Sunshine-FreeBSD-14.3-aarch64.pkg) | 2. Open terminal and run the following command. ```sh @@ -68,37 +68,14 @@ CUDA is used for NVFBC capture and direct GPU-memory NVENC encoding. > Arch Linux package from LizardByte's [pacman-repo](https://github.com/LizardByte/pacman-repo) is already built with > CUDA support, so its users do not need to install the CUDA Toolkit. -> [!NOTE] -> See [CUDA GPUS](https://developer.nvidia.com/cuda-gpus) to cross-reference Compute Capability to your GPU. -> The table below applies to packages provided by LizardByte. - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CUDA Compatibility
CUDA VersionMin DriverCUDA Compute CapabilitiesPackage
13.1.1590.48.0150;52;60;61;62;70;72;75;80;86;87;89;90;100;101;103;120;121Sunshine_{version}_{arch}.AppImage
sunshine_{version}-1+{distro}{distro-version}_{arch}.deb
sunshine_{arch}.flatpak
Sunshine-{version}-1.{distro+version}.{arch}.rpm
sunshine.pkg.tar.zst
+For official Linux packages built with CUDA 13, the CUDA paths require a GPU with compute capability 7.5 (Turing) +or newer. [CUDA Toolkit 13 removed offline compilation support for Maxwell, Pascal, and Volta](https://docs.nvidia.com/cuda/cuda-features-archive/index.html). +These GPUs can still have an NVENC hardware encoder, but that does not make the CUDA kernels in these packages +compatible with them. Installing a different CUDA Toolkit alongside a prebuilt package does not change those kernels. + +Use [NVIDIA's GPU list](https://developer.nvidia.com/cuda-gpus) to check your GPU's compute capability. +Toolkit versions can vary by package. Use an NVIDIA driver compatible with the package's toolkit and your GPU; +see [NVIDIA's CUDA compatibility guide](https://docs.nvidia.com/deploy/cuda-compatibility/). #### Alpine Linux @@ -137,7 +114,7 @@ apk del sunshine into your home directory. ```bash cd ~ - wget https://github.com/LizardByte/Sunshine/releases/latest/download/Sunshine_{version}_{arch}.AppImage + wget https://github.com/SunshineStream/Sunshine/releases/latest/download/Sunshine_{version}_{arch}.AppImage ``` 2. Open terminal and run the following command. ```bash @@ -174,7 +151,7 @@ pacman -S sunshine ##### Install PKGBUILD Archive Open terminal and run the following command. ```bash -wget https://github.com/LizardByte/Sunshine/releases/latest/download/sunshine.pkg.tar.gz +wget https://github.com/SunshineStream/Sunshine/releases/latest/download/sunshine.pkg.tar.gz tar -xvf sunshine.pkg.tar.gz cd sunshine @@ -429,8 +406,8 @@ Prebuilt DMG packages require macOS 15.0 (Sequoia) or newer. | Architecture | Package | |-----------------------|------------------------------------------------------------------------------------------------------------------------| - | arm64 (Apple Silicon) | [Sunshine-macOS-arm64.dmg](https://github.com/LizardByte/Sunshine/releases/latest/download/Sunshine-macOS-arm64.dmg) | - | x86_64 (Intel) | [Sunshine-macOS-x86_64.dmg](https://github.com/LizardByte/Sunshine/releases/latest/download/Sunshine-macOS-x86_64.dmg) | + | arm64 (Apple Silicon) | [Sunshine-macOS-arm64.dmg](https://github.com/SunshineStream/Sunshine/releases/latest/download/Sunshine-macOS-arm64.dmg) | + | x86_64 (Intel) | [Sunshine-macOS-x86_64.dmg](https://github.com/SunshineStream/Sunshine/releases/latest/download/Sunshine-macOS-x86_64.dmg) | 2. Open the downloaded `.dmg` file. 3. Drag `Sunshine.app` into the `Applications` folder. @@ -475,8 +452,8 @@ brew uninstall sunshine | Architecture | Installer | |-----------------------|----------------------------------------------------------------------------------------------------------------------------------------------| - | AMD64/x64 (Intel/AMD) | [Sunshine-Windows-AMD64-installer.msi](https://github.com/LizardByte/Sunshine/releases/latest/download/Sunshine-Windows-AMD64-installer.msi) | - | ARM64 | [Sunshine-Windows-ARM64-installer.msi](https://github.com/LizardByte/Sunshine/releases/latest/download/Sunshine-Windows-ARM64-installer.msi) | + | AMD64/x64 (Intel/AMD) | [Sunshine-Windows-AMD64-installer.msi](https://github.com/SunshineStream/Sunshine/releases/latest/download/Sunshine-Windows-AMD64-installer.msi) | + | ARM64 | [Sunshine-Windows-ARM64-installer.msi](https://github.com/SunshineStream/Sunshine/releases/latest/download/Sunshine-Windows-ARM64-installer.msi) | > [!TIP] > Installer logs can be found in the following directory: @@ -499,8 +476,8 @@ overflow menu. Different versions of Windows may provide slightly different step | Architecture | Installer | |-----------------------|------------------------------------------------------------------------------------------------------------------------------------| - | AMD64/x64 (Intel/AMD) | [Sunshine-Windows-AMD64-lite.zip](https://github.com/LizardByte/Sunshine/releases/latest/download/Sunshine-Windows-AMD64-lite.zip) | - | ARM64 | [Sunshine-Windows-ARM64-lite.zip](https://github.com/LizardByte/Sunshine/releases/latest/download/Sunshine-Windows-ARM64lite.zip) | + | AMD64/x64 (Intel/AMD) | [Sunshine-Windows-AMD64-lite.zip](https://github.com/SunshineStream/Sunshine/releases/latest/download/Sunshine-Windows-AMD64-lite.zip) | + | ARM64 | [Sunshine-Windows-ARM64-lite.zip](https://github.com/SunshineStream/Sunshine/releases/latest/download/Sunshine-Windows-ARM64lite.zip) | 2. Open command prompt as administrator 3. Firewall rules @@ -821,4 +798,4 @@ Guides are available [here](guides.md). Tutorials and Guides are community generated. Want to contribute? Reach out to us on our discord server.} -[latest-release]: https://github.com/LizardByte/Sunshine/releases/latest +[latest-release]: https://github.com/SunshineStream/Sunshine/releases/latest diff --git a/docs/legal.md b/docs/legal.md index deb0b111c2d..2c3edf1bb0c 100644 --- a/docs/legal.md +++ b/docs/legal.md @@ -5,7 +5,7 @@ > any legal questions or concerns about using Sunshine, we recommend consulting with a lawyer. Sunshine is licensed under the GPL-3.0 license, which allows for free use and modification of the software. -The full text of the license can be reviewed [here](https://github.com/LizardByte/Sunshine/blob/master/LICENSE). +The full text of the license can be reviewed [here](https://github.com/SunshineStream/Sunshine/blob/master/LICENSE). ## Commercial Use Sunshine can be used in commercial applications without any limitations. This means that businesses and organizations diff --git a/docs/maintainers/release.md b/docs/maintainers/release.md index 25048feec9c..fed568c7887 100644 --- a/docs/maintainers/release.md +++ b/docs/maintainers/release.md @@ -5,18 +5,18 @@ to be created before making a stable release. Below are the instructions for con ## npm publishing -Stable releases publish the prebuilt Web UI as `@lizardbyte/sunshine` to npm and GitHub Packages. npm trusts the -`LizardByte/Sunshine` repository's `ci-release.yml` workflow through the `npmjs` GitHub environment, with direct -publishing enabled. The shared release workflow derives the package version from the release tag and does not require -an npm access token. +Stable releases publish the prebuilt Web UI as `@lizardbyte/sunshine` to npm and GitHub Packages. Configure npm's +trusted publisher for the `SunshineStream/Sunshine` repository, the `ci-release.yml` workflow, and the `npmjs` GitHub +environment, with direct publishing enabled. The shared release workflow derives the package version from the +release tag and does not require an npm access token. 1. Wait for the pre-release to be created. 2. Once the pre-release is created, the copr build will begin in the [beta copr repo](https://copr.fedorainfracloud.org/coprs/lizardbyte/beta/). Wait for this build to succeed before continuing. You can view the status - [here](https://github.com/LizardByte/Sunshine/actions/workflows/ci-copr.yml?query=event%3Arelease) + [here](https://github.com/SunshineStream/Sunshine/actions/workflows/ci-copr.yml?query=event%3Arelease) 3. Once the workflow mentioned in step 2 completes, it will update the GitHub release with the RPM files from the copr - build. It also calls the separate [Cloudsmith workflow](https://github.com/LizardByte/Sunshine/actions/workflows/ci-cloudsmith.yml), + build. It also calls the separate [Cloudsmith workflow](https://github.com/SunshineStream/Sunshine/actions/workflows/ci-cloudsmith.yml), which publishes currently supported DEB and RPM packages to the [beta Cloudsmith repo](https://cloudsmith.io/~lizardbyte/repos/beta/). 4. At this point, the GitHub release can be edited. @@ -40,7 +40,7 @@ an npm access token. - Facebook - X - - Update changelog in [changelog](https://github.com/LizardByte/Sunshine/tree/changelog) branch + - Update changelog in [changelog](https://github.com/SunshineStream/Sunshine/tree/changelog) branch - Update docs on [Read The Docs](https://app.readthedocs.org/projects/sunshinestream/) - Update official [Flathub repo](https://github.com/flathub/dev.lizardbyte.app.Sunshine/pulls) via a PR (we have merge control) diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 3c3d604ff01..945ba343a59 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -31,6 +31,11 @@ For absolute-positioning problems, set **Configuration > Advanced > Log Level** Sunshine forwards libvirtualhid diagnostics with a `[libvirtualhid]` prefix, including the streamed display viewport and full desktop bounds used for mouse coordinate mapping. +For native touch or pen input on KDE Wayland, Sunshine maps its virtual devices to the streamed display. +Use Plasma 6.5.1 or later, which fixes changing a device's assigned output. Display layouts with monitors +left of or above the desktop origin are supported. Other Wayland compositors retain their device mapping +settings; assign Sunshine's virtual touchscreen and pen tablet through the compositor's input configuration. + ### Web UI Access Can't access the web UI? @@ -238,11 +243,17 @@ If needed, you can override it manually in your systemd service file or shell en When the seat is not `seat0`, Sunshine appends the seat name to its virtual device names, for example: -- Keyboard passthrough (seat1) -- Sunshine (libvirtualhid) PS5 Controller (seat1) +- libvirtualhid Keyboard (seat1) +- libvirtualhid Mouse (seat1) +- libvirtualhid Mouse (seat1) (Absolute) +- Sunshine (libvirtualhid) X-Box 360 Controller (seat1) Sunshine creates two mouse devices: a relative one and an absolute one. +> [!NOTE] +> PlayStation gamepads always use Sony's native product name (`Wireless Controller`) so that Steam recognizes them, +> so they do not carry a seat suffix. + To assign Sunshine's virtual devices to the correct seat, create this udev rules file (/etc/udev/rules.d/72-sunshine-virtual-seat.rules): ```udev diff --git a/gh-pages-template/.readthedocs.yaml b/gh-pages-template/.readthedocs.yaml deleted file mode 100644 index d37df415dbb..00000000000 --- a/gh-pages-template/.readthedocs.yaml +++ /dev/null @@ -1,25 +0,0 @@ ---- -# Read the Docs configuration file -# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details - -version: 2 - -build: - os: ubuntu-26.04 - tools: - ruby: "3.3" - apt_packages: - - 7zip - - jq - jobs: - install: - - | - mkdir -p "./tmp" - branch="master" - base_url="https://raw.githubusercontent.com/LizardByte/LizardByte.github.io" - url="${base_url}/refs/heads/${branch}/scripts/readthedocs_build.sh" - curl -sSL -o "./tmp/readthedocs_build.sh" "${url}" - chmod +x "./tmp/readthedocs_build.sh" - build: - html: - - "./tmp/readthedocs_build.sh" diff --git a/gh-pages-template/_config.yml b/gh-pages-template/_config.yml deleted file mode 100644 index c6ea376f8b9..00000000000 --- a/gh-pages-template/_config.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -# See https://github.com/LizardByte/beautiful-jekyll-next/blob/master/_config.yml for documented options - -avatar: "/Sunshine/assets/img/navbar-avatar.png" diff --git a/gh-pages-template/_data/features.yml b/gh-pages-template/_data/features.yml deleted file mode 100644 index 067bdcd7a2f..00000000000 --- a/gh-pages-template/_data/features.yml +++ /dev/null @@ -1,36 +0,0 @@ ---- -- title: "Self-hosted" - icon_fa: "fas fa-server" - description: > - Run Sunshine on your own hardware. No need to pay monthly fees to a - cloud gaming provider. - -- title: "Moonlight Support" - icon_img: "https://moonlight-stream.org/images/moonlight.svg" - icon_img_alt: "Moonlight" - description: > - Connect to Sunshine from any Moonlight client. Moonlight is available - for Windows, macOS, Linux, Android, iOS, Xbox, and more. See - clients for more information. - -- title: "Hardware Encoding" - icon_fa: "fas fa-microchip" - description: > - Sunshine supports AMD, Intel, and Nvidia GPUs for hardware encoding. - Software encoding is also available. - -- title: "Low Latency" - icon_fa: "fas fa-globe" - description: > - Sunshine is designed to provide the lowest latency possible to achieve optimal gaming performance. - -- title: "Control" - icon_fa: "fas fa-gamepad" - description: > - Sunshine emulates Xbox 360|One|Series, PlayStation DualShock 4|DualSense, or Nintendo Switch Pro controllers. - Use nearly any controller on your Moonlight client! - -- title: "Configurable" - icon_fa: "fas fa-gear" - description: > - Sunshine offers many configuration options to customize your experience. diff --git a/gh-pages-template/assets/img/banners/AdobeStock_231616343.jpeg b/gh-pages-template/assets/img/banners/AdobeStock_231616343.jpeg deleted file mode 100644 index 818e82d24c2..00000000000 Binary files a/gh-pages-template/assets/img/banners/AdobeStock_231616343.jpeg and /dev/null differ diff --git a/gh-pages-template/assets/img/banners/AdobeStock_231616343_1920x1280.jpg b/gh-pages-template/assets/img/banners/AdobeStock_231616343_1920x1280.jpg deleted file mode 100644 index d235cd5fc3a..00000000000 Binary files a/gh-pages-template/assets/img/banners/AdobeStock_231616343_1920x1280.jpg and /dev/null differ diff --git a/gh-pages-template/assets/img/banners/AdobeStock_303330124.jpeg b/gh-pages-template/assets/img/banners/AdobeStock_303330124.jpeg deleted file mode 100644 index 4a5ab376e0e..00000000000 Binary files a/gh-pages-template/assets/img/banners/AdobeStock_303330124.jpeg and /dev/null differ diff --git a/gh-pages-template/assets/img/banners/AdobeStock_303330124_1920x1280.jpg b/gh-pages-template/assets/img/banners/AdobeStock_303330124_1920x1280.jpg deleted file mode 100644 index 8e047dc3d12..00000000000 Binary files a/gh-pages-template/assets/img/banners/AdobeStock_303330124_1920x1280.jpg and /dev/null differ diff --git a/gh-pages-template/assets/img/banners/AdobeStock_305732536.jpeg b/gh-pages-template/assets/img/banners/AdobeStock_305732536.jpeg deleted file mode 100644 index d79c40a2466..00000000000 Binary files a/gh-pages-template/assets/img/banners/AdobeStock_305732536.jpeg and /dev/null differ diff --git a/gh-pages-template/assets/img/banners/AdobeStock_305732536_1920x1280.jpg b/gh-pages-template/assets/img/banners/AdobeStock_305732536_1920x1280.jpg deleted file mode 100644 index bdde5c9f4f5..00000000000 Binary files a/gh-pages-template/assets/img/banners/AdobeStock_305732536_1920x1280.jpg and /dev/null differ diff --git a/gh-pages-template/assets/img/navbar-avatar.png b/gh-pages-template/assets/img/navbar-avatar.png deleted file mode 100644 index 0a44d94a4e3..00000000000 Binary files a/gh-pages-template/assets/img/navbar-avatar.png and /dev/null differ diff --git a/gh-pages-template/assets/img/screenshots/01-sunshine-welcome-page.png b/gh-pages-template/assets/img/screenshots/01-sunshine-welcome-page.png deleted file mode 100644 index 97c5a5af07e..00000000000 Binary files a/gh-pages-template/assets/img/screenshots/01-sunshine-welcome-page.png and /dev/null differ diff --git a/gh-pages-template/index.html b/gh-pages-template/index.html deleted file mode 100644 index 360ea5eddd0..00000000000 --- a/gh-pages-template/index.html +++ /dev/null @@ -1,304 +0,0 @@ ---- -title: Sunshine -subtitle: A LizardByte project -layout: page -full-width: true -after-content: -- donate.html -- support.html -cover-img: -- /Sunshine/assets/img/banners/AdobeStock_305732536_1920x1280.jpg -- /Sunshine/assets/img/banners/AdobeStock_231616343_1920x1280.jpg -- /Sunshine/assets/img/banners/AdobeStock_303330124_1920x1280.jpg ---- - - -
-
-

- Sunshine is a self-hosted game stream host for Moonlight. Offering low latency, cloud gaming - server capabilities with support for AMD, Intel, and Nvidia GPUs for hardware encoding. Software - encoding is also available. You can connect to Sunshine from any Moonlight client on a variety - of devices. A web UI is provided to allow configuration, and client pairing, from your favorite - web browser. Pair from the local server or any mobile device. -

-
-
- - -
-
-

Features

-
- {% for feature in site.data.features %} -
-
-
-
-
- {% if feature.icon_fa %} - - {% elsif feature.icon_img %} - {{ feature.icon_img_alt | default: feature.title }} - {% endif %} -
-
-
{{ feature.title }}
-

{{ feature.description }}

-
-
-
-
-
- {% endfor %} -
-
-
- - -
-
-

Clients

-
- -
-
-
- - -
-
- -
-
-
-
- -
-

Documentation

-

- Read the documentation to learn how to install, use, and configure Sunshine. -

-
-
-
- {% capture github_release_package_icons %} - Windows - macOS - FreeBSD - AppImage - Alpine Linux - Arch Linux - Debian - Fedora - openSUSE - Ubuntu - Flatpak - Homebrew - {% endcapture %} - -
-
- - -
- -
-
-
- - - diff --git a/package-lock.cmake b/package-lock.cmake index 5231caa5a9a..924fa17cd93 100644 --- a/package-lock.cmake +++ b/package-lock.cmake @@ -8,28 +8,8 @@ # Renovate-bot will update the versions and hashes in this file when a new version of a dependency is released. # The comments above each dependency are used by renovate to identify the dependencies and extract the version numbers. -# See https://github.com/LizardByte/.github/blob/master/renovate-config.json5 for the configuration of renovate. -# -# Expected dependency structure for new entries: -# - Start each block with a human-readable comment, for example `# Example dependency`. -# - Follow it with consecutive renovate metadata comments. -# - The first metadata line must start with `# renovate:` and include `datasource=` and `depName=`. -# - Optional metadata keys are `packageName=`, `versioning=`, `extractVersion=`, and `registryUrl=`. -# - Optional metadata may stay on the `# renovate:` line or continue on the next consecutive `#` lines. -# - Keep metadata keys in this order: `datasource`, `depName`, `packageName`, `versioning`, -# `extractVersion`, `registryUrl`. -# - After metadata, declare the tracked value with `set(NAME_VERSION ...)` or `set(NAME_TAG ...)`. -# - If the dependency also tracks a SHA256, keep `set(NAME_SHA256 ...)` immediately after the -# matching `NAME_VERSION` or `NAME_TAG` line with no unrelated lines between them. -# - Keep `CPMDeclarePackage(...)` below the tracked values. -# -# Example layout: -# - `# Example dependency` -# - `# renovate: datasource=github-tags depName=owner/repo` -# - `# versioning=regex:^v(?\d+)\.(?\d+)\.(?\d+)$` -# - `set(EXAMPLE_TAG v1.2.3)` -# - `set(EXAMPLE_SHA256 )` -# - `CPMDeclarePackage(...)` +# See https://github.com/LizardByte/.github/blob/master/renovate/cmake.json5 for the configuration of renovate. +# See https://github.com/LizardByte/.github/blob/master/renovate/README.md#cpm-package-lock for annotation instructions. set(PATCH_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/patches") @@ -39,10 +19,164 @@ set(PATCH_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/patches") set(BOOST_TAG boost-1.92.0) set(BOOST_SHA256 9bed76128d4e46755dbe818487788c6fceb6f72b378f4daa49b7e1e600d9088d) string(REGEX REPLACE "^boost-" "" BOOST_VERSION "${BOOST_TAG}") +set(BOOST_PATCH_ARGS) +if(NOT WIN32 AND CMAKE_VERSION VERSION_GREATER_EQUAL "4.5" AND BOOST_TAG STREQUAL "boost-1.92.0") + # Backport the Boost.Locale source grouping fix for CMake 4.5. + # https://github.com/boostorg/locale/pull/273 + set(BOOST_PATCH_ARGS PATCHES "${PATCH_DIRECTORY}/boost-locale-cmake-4.5.patch") +endif() CPMDeclarePackage(Boost NAME Boost VERSION ${BOOST_VERSION} URL https://github.com/boostorg/boost/releases/download/${BOOST_TAG}/${BOOST_TAG}-cmake.tar.xz URL_HASH SHA256=${BOOST_SHA256} + ${BOOST_PATCH_ARGS} + DOWNLOAD_ONLY YES +) + +# Build-deps supplies the FFmpeg binaries and the NV codec and Vulkan header pins. +# renovate: datasource=github-releases depName=LizardByte/build-deps +set(BUILD_DEPS_TAG v2026.1017.131201) +CPMDeclarePackage(build_deps + NAME build_deps + GIT_REPOSITORY https://github.com/LizardByte/build-deps.git + GIT_TAG ${BUILD_DEPS_TAG} + GIT_SHALLOW TRUE + # The pinned release still carries Vulkan Headers as a submodule. + GIT_CONFIG "submodule.active=third-party/FFmpeg/Vulkan-Headers" + DOWNLOAD_ONLY YES +) + +# glad +# renovate: datasource=github-tags depName=Dav1dde/glad +set(GLAD_TAG v2.0.8) +CPMDeclarePackage(glad + NAME glad + GIT_REPOSITORY https://github.com/Dav1dde/glad.git + GIT_TAG ${GLAD_TAG} + GIT_SHALLOW TRUE + DOWNLOAD_ONLY YES +) + +# libdisplaydevice +# renovate: datasource=github-tags depName=LizardByte/libdisplaydevice +set(LIBDISPLAYDEVICE_TAG v2026.1008.124543) +CPMDeclarePackage(libdisplaydevice + NAME libdisplaydevice + GIT_REPOSITORY https://github.com/LizardByte/libdisplaydevice.git + GIT_TAG ${LIBDISPLAYDEVICE_TAG} + GIT_SHALLOW TRUE + GIT_CONFIG "submodule.active=:(exclude)third-party" +) + +# libvirtualhid +# renovate: datasource=git-refs depName=LizardByte/libvirtualhid +# ref=master +set(LIBVIRTUALHID_COMMIT dd8153df338c6fb399ea4a048fa97b4c536f12a0) +CPMDeclarePackage(libvirtualhid + NAME libvirtualhid + GIT_REPOSITORY https://github.com/LizardByte/libvirtualhid.git + GIT_TAG ${LIBVIRTUALHID_COMMIT} + # Windows compiles a source file from this submodule. + GIT_SUBMODULES third-party/lizardbyte-common + GIT_SUBMODULES_RECURSE FALSE +) + +# moonlight-common-c +# renovate: datasource=git-refs depName=moonlight-stream/moonlight-common-c +# ref=master +set(MOONLIGHT_COMMON_C_COMMIT b4ee1cea3d19e13c0b37c26585e6b1ee174effcb) +CPMDeclarePackage(moonlight-common-c + NAME moonlight-common-c + GIT_REPOSITORY https://github.com/moonlight-stream/moonlight-common-c.git + GIT_TAG ${MOONLIGHT_COMMON_C_COMMIT} + GIT_SUBMODULES enet nanors + DOWNLOAD_ONLY YES +) + +# NVIDIA NVAPI +# renovate: datasource=git-refs depName=NVIDIA/nvapi +# ref=main +set(NVAPI_COMMIT 51e5aae4bc40c3ccd3fb7d4dfd94256e7bfc496e) +CPMDeclarePackage(nvapi + NAME nvapi + GIT_REPOSITORY https://github.com/NVIDIA/nvapi.git + GIT_TAG ${NVAPI_COMMIT} + DOWNLOAD_ONLY YES +) + +# Plasma Wayland protocols +# renovate: datasource=github-tags depName=KDE/plasma-wayland-protocols +set(PLASMA_WAYLAND_PROTOCOLS_TAG v1.23.0) +CPMDeclarePackage(plasma_wayland_protocols + NAME plasma_wayland_protocols + GIT_REPOSITORY https://github.com/KDE/plasma-wayland-protocols.git + GIT_TAG ${PLASMA_WAYLAND_PROTOCOLS_TAG} + GIT_SHALLOW TRUE + DOWNLOAD_ONLY YES +) + +# Simple-Web-Server +# renovate: datasource=git-refs depName=eidheim/Simple-Web-Server +# ref=master +set(SIMPLE_WEB_SERVER_COMMIT 546895a93a29062bb178367b46c7afb72da9881e) +CPMDeclarePackage(simple_web_server + NAME simple_web_server + GIT_REPOSITORY https://github.com/LizardByte-infrastructure/Simple-Web-Server.git + GIT_TAG ${SIMPLE_WEB_SERVER_COMMIT} +) + +# TPCircularBuffer +# renovate: datasource=git-refs depName=michaeltyson/TPCircularBuffer +# ref=master +set(TPCIRCULARBUFFER_COMMIT cc520397504bb72bc6df79ff03eb72988a6dc50d) +CPMDeclarePackage(tpcircularbuffer + NAME tpcircularbuffer + GIT_REPOSITORY https://github.com/michaeltyson/TPCircularBuffer.git + GIT_TAG ${TPCIRCULARBUFFER_COMMIT} + DOWNLOAD_ONLY YES +) + +# System tray +# renovate: datasource=github-tags depName=LizardByte/tray +set(TRAY_TAG v2026.1117.200659) +CPMDeclarePackage(tray + NAME tray + GIT_REPOSITORY https://github.com/LizardByte/tray.git + GIT_TAG ${TRAY_TAG} + GIT_SHALLOW TRUE + GIT_CONFIG "submodule.active=:(exclude)third-party" +) + +# ViGEmClient +# renovate: datasource=git-refs depName=LizardByte/Virtual-Gamepad-Emulation-Client +# ref=master +set(VIGEMCLIENT_COMMIT 8d71f6740ffff4671cdadbca255ce528e3cd3fef) +CPMDeclarePackage(vigemclient + NAME vigemclient + GIT_REPOSITORY https://github.com/LizardByte/Virtual-Gamepad-Emulation-Client.git + GIT_TAG ${VIGEMCLIENT_COMMIT} + DOWNLOAD_ONLY YES +) + +# Wayland protocols +# renovate: datasource=github-tags depName=wayland/wayland-protocols +set(WAYLAND_PROTOCOLS_TAG 1.50) +CPMDeclarePackage(wayland_protocols + NAME wayland_protocols + GIT_REPOSITORY https://github.com/LizardByte-infrastructure/wayland-protocols.git + GIT_TAG ${WAYLAND_PROTOCOLS_TAG} + GIT_SHALLOW TRUE + DOWNLOAD_ONLY YES +) + +# wlroots protocols +# renovate: datasource=git-refs depName=wlroots/wlr-protocols +# ref=master +set(WLR_PROTOCOLS_COMMIT 1106a4a1c57562ddd438c547da4c0d6dc150d624) +CPMDeclarePackage(wlr_protocols + NAME wlr_protocols + GIT_REPOSITORY https://github.com/LizardByte-infrastructure/wlr-protocols.git + GIT_TAG ${WLR_PROTOCOLS_COMMIT} DOWNLOAD_ONLY YES ) diff --git a/package-lock.json b/package-lock.json index 6e7025cc018..1e477fb5a31 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,25 +9,25 @@ "version": "0.0.0", "license": "GPL-3.0-only", "dependencies": { - "@intlify/message-compiler": "11.4.18", - "@lucide/vue": "1.70.0", - "bootstrap": "5.3.8", + "@intlify/message-compiler": "11.4.23", + "@lucide/vue": "1.76.0", + "bootstrap": "5.3.9", "date-fns": "4.4.0", "marked": "18.0.12", - "vue": "3.5.45", - "vue-i18n": "11.4.18", - "vue-router": "5.4.0", + "vue": "3.5.46", + "vue-i18n": "11.4.23", + "vue-router": "5.5.1", "vue3-simple-icons": "16.10.0" }, "devDependencies": { "@codecov/vite-plugin": "2.0.1", - "@vitejs/plugin-vue": "6.0.10", - "@vitest/coverage-v8": "5.0.5", - "@vue/test-utils": "2.5.1", - "jsdom": "31.0.0", - "serve": "14.2.6", - "vite": "8.3.5", - "vitest": "5.0.5" + "@vitejs/plugin-vue": "6.0.11", + "@vitest/coverage-v8": "5.1.0", + "@vue/test-utils": "2.6.0", + "jsdom": "31.0.1", + "serve": "14.2.8", + "vite": "8.3.8", + "vitest": "5.1.0" }, "funding": { "url": "https://app.lizardbyte.dev" @@ -100,9 +100,9 @@ "license": "MIT" }, "node_modules/@babel/helper-string-parser": { - "version": "7.29.11", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.11.tgz", - "integrity": "sha512-snZbO7MEDOof+hvNa97EjEY7qD7h2kwvQr5AJC3ZhQudKW5dnej6k3kP9NQV88hJwaS8vDqRLFo9rivLEhle2g==", + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.14.tgz", + "integrity": "sha512-CXvKMFvM80ihI7Vox9jb+kQjnyjESQNPM+vB7U0Zz6TWuZA+Z/FL0QPMH300h33qJtIx+REeBhXqWOPW48TcAQ==", "license": "MIT", "engines": { "node": ">=6.9.0" @@ -118,12 +118,12 @@ } }, "node_modules/@babel/parser": { - "version": "7.29.12", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.12.tgz", - "integrity": "sha512-WJ7JBp/Q4+z/ImydtI7jS6NVco5++632ExBemSX+Ysb+G1lCwQ5BVo3SY+jGGOcZXI4ZccbZSUSJLNBW6eEpJg==", + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.14.tgz", + "integrity": "sha512-VL220vXuyO2z3rNIQwY7ftj9UwpqOt+33sH+sBWkOekbsSR2g7EEMnOx24ZlCH0xOA3DM/33SifVFGbnJD8r/w==", "license": "MIT", "dependencies": { - "@babel/types": "^7.29.11" + "@babel/types": "^7.29.14" }, "bin": { "parser": "bin/babel-parser.js" @@ -133,12 +133,12 @@ } }, "node_modules/@babel/types": { - "version": "7.29.11", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.11.tgz", - "integrity": "sha512-WCsemW40Cpc6gouC1SrY6PBaZ+oLRlEVY9XBvZBI7il/HyUrb2nJ505wE1MHEFyDZNnrWDEuy4jL50WVHfTTSQ==", + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.14.tgz", + "integrity": "sha512-UjI/dKmwJwT9pOszJitq2G6EObZPnsZUfdCr92z2TlF3EZK9J3EdfOKUrCzHl6wFthbzwhzl1Soc/UIwxRiq6w==", "license": "MIT", "dependencies": { - "@babel/helper-string-parser": "^7.29.11", + "@babel/helper-string-parser": "^7.29.14", "@babel/helper-validator-identifier": "^7.29.7" }, "engines": { @@ -190,6 +190,37 @@ "vite": "4.x || 5.x || 6.x" } }, + "node_modules/@emnapi/core": { + "version": "2.0.0-beta.2", + "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-2.0.0-beta.2.tgz", + "integrity": "sha512-MzCVoWtcg4Pm2B3je5mMvYMvj3MmBKw+fU7vbsJc9/iT8ip6/eYIHo/Dsm/mr+wsHB6SEyJDuxB09Yy6r/8+4A==", + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/wasi-threads": "2.2.0", + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/runtime": { + "version": "2.0.0-beta.2", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-2.0.0-beta.2.tgz", + "integrity": "sha512-JcrSPzPvZuNZvJqPTF9Fw25LbOJ8avzFVlaf2grmH4Cku0oGP47tRgqPZadcfj3YoZMHkFVnCYFbQM8I+i5QEw==", + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/wasi-threads": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-2.2.0.tgz", + "integrity": "sha512-JP7OYH38Q7+pyTAe14raZHLQIK7BDKbdwji+Xi3pcd/6QkJYQH3SX4wu6EplGrGJWRepoNzedfm0G3B9Z4e9Rw==", + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, "node_modules/@exodus/bytes": { "version": "1.16.0", "resolved": "https://registry.npmjs.org/@exodus/bytes/-/bytes-1.16.0.tgz", @@ -209,14 +240,14 @@ } }, "node_modules/@intlify/core-base": { - "version": "11.4.18", - "resolved": "https://registry.npmjs.org/@intlify/core-base/-/core-base-11.4.18.tgz", - "integrity": "sha512-uryU7clROKIJsCLM8I8J6GA4pw9EVI5BCptnFQslpUXGPj/dCrlrixOaV/6gL1jLXZe3Hl8YY3yNi24bgfhvBw==", + "version": "11.4.23", + "resolved": "https://registry.npmjs.org/@intlify/core-base/-/core-base-11.4.23.tgz", + "integrity": "sha512-V8a3BQ7iTVPDetJ/LJfGn3lDx4Ir35OjjO4BLgVrFuL+0egWzwUyfdLIPAEYWlMGdo14eC5p6uk3tSlTYY0YmQ==", "license": "MIT", "dependencies": { - "@intlify/devtools-types": "11.4.18", - "@intlify/message-compiler": "11.4.18", - "@intlify/shared": "11.4.18" + "@intlify/devtools-types": "11.4.23", + "@intlify/message-compiler": "11.4.23", + "@intlify/shared": "11.4.23" }, "engines": { "node": ">= 22" @@ -226,13 +257,13 @@ } }, "node_modules/@intlify/devtools-types": { - "version": "11.4.18", - "resolved": "https://registry.npmjs.org/@intlify/devtools-types/-/devtools-types-11.4.18.tgz", - "integrity": "sha512-J7/PW4wSSijVzR8j578q2+/HICPbA09RhCIMZsLHEL8PlRkdXXVadhunrxLOre8cBe8dDK54922frpa0Z1UimA==", + "version": "11.4.23", + "resolved": "https://registry.npmjs.org/@intlify/devtools-types/-/devtools-types-11.4.23.tgz", + "integrity": "sha512-zuWkolaeK8ej5z7L9Ss7FLIBHgE8ZF+XcwV1o/vQ7IKagiDg/IosA7fOa2HUFVMW5yT2ugph9rshevHGzcowBQ==", "license": "MIT", "dependencies": { - "@intlify/core-base": "11.4.18", - "@intlify/shared": "11.4.18" + "@intlify/core-base": "11.4.23", + "@intlify/shared": "11.4.23" }, "engines": { "node": ">= 22" @@ -242,12 +273,12 @@ } }, "node_modules/@intlify/message-compiler": { - "version": "11.4.18", - "resolved": "https://registry.npmjs.org/@intlify/message-compiler/-/message-compiler-11.4.18.tgz", - "integrity": "sha512-9v2s0+mIuJaFOyWBfZBHrV/g9VLFH/4osx/zaQ52BgT6FQkjvTWHWyNriCMRqWs3PEuBKysmwTUwmNpg9iPjJw==", + "version": "11.4.23", + "resolved": "https://registry.npmjs.org/@intlify/message-compiler/-/message-compiler-11.4.23.tgz", + "integrity": "sha512-HgmnQV/lBBX8KgxoNwngzzq8DLw/jECJgz9eBfQGdkEYte7Bw1RSqhIskcWp0DEWrSg2wijUi6dJjpq1WUD+zg==", "license": "MIT", "dependencies": { - "@intlify/shared": "11.4.18", + "@intlify/shared": "11.4.23", "source-map-js": "^1.0.2" }, "engines": { @@ -258,9 +289,9 @@ } }, "node_modules/@intlify/shared": { - "version": "11.4.18", - "resolved": "https://registry.npmjs.org/@intlify/shared/-/shared-11.4.18.tgz", - "integrity": "sha512-8q7UR/eAFP0xOZndaClKYeh/lWkcIPOZkWsU85CMR9BYLjTeaENpAFWfFBvuUI8fFz0BDtZvR/fgbwiiQaqcDg==", + "version": "11.4.23", + "resolved": "https://registry.npmjs.org/@intlify/shared/-/shared-11.4.23.tgz", + "integrity": "sha512-1iqGalDCOlHZ8y7LOC3yisSm52K5AmkTmaNO23XGFYWU6Z1oIX8VeAGRq9rn2KrDFb8nMtQaxNyMa1n8EeDm5g==", "license": "MIT", "engines": { "node": ">= 22" @@ -290,9 +321,9 @@ } }, "node_modules/@jridgewell/resolve-uri": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", - "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.3.tgz", + "integrity": "sha512-lhTtjtoEArWBjismtfS761S9Hlyn+nIZqOZVYoZ1Xn82PMNMVnk+jj/NhC4fAXGTs7ydONcJiR5vyQBTMDu27g==", "license": "MIT", "engines": { "node": ">=6.0.0" @@ -315,14 +346,35 @@ } }, "node_modules/@lucide/vue": { - "version": "1.70.0", - "resolved": "https://registry.npmjs.org/@lucide/vue/-/vue-1.70.0.tgz", - "integrity": "sha512-kutUu3oEtfQnyaP6hh76ShG2dxa8PiL6uY3rk3DqclQe0Vd2FtPlnclezR0XMQtlFMPiEaCOXDSuhehFHW5ErQ==", + "version": "1.76.0", + "resolved": "https://registry.npmjs.org/@lucide/vue/-/vue-1.76.0.tgz", + "integrity": "sha512-jipcmtcHPhYgKwXLFjRu8ZBfq1cTb1uD5j7y5s69FMBLcCO9bg/WDwvkAlum/sqqB8xUfkM4Bd/n0bW4rzCBDw==", "license": "ISC", "peerDependencies": { "vue": ">=3.0.1" } }, + "node_modules/@napi-rs/wasm-runtime": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.2.6.tgz", + "integrity": "sha512-mRyDmEw9/fCDXCGfL1sbgIw/GUK0PVxRW4YwgPN61F3LQ+fSyoBFarJVzgGyhF6kRzEQZ0FejDqm4WLXSeqQmw==", + "license": "MIT", + "optional": true, + "dependencies": { + "@tybys/wasm-util": "^0.10.3" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=23.5.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Brooooooklyn" + }, + "peerDependencies": { + "@emnapi/core": "^1.7.1 || 2.0.0-beta.2", + "@emnapi/runtime": "^1.7.1 || 2.0.0-beta.2" + } + }, "node_modules/@octokit/auth-token": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-6.0.0.tgz", @@ -524,9 +576,9 @@ } }, "node_modules/@rolldown/binding-android-arm-eabi": { - "version": "1.2.16", - "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.16.tgz", - "integrity": "sha512-ia3DwAs0OsMGS7+IConptSiyk9pEXkOx/AbJ2n/lAGxH3QkWQus1t8d7gnAT38FCU2sQu8lUbeR6AiZFv4JxaA==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.19.tgz", + "integrity": "sha512-e+Ebe0WT+9tbXmNKPIiC8YrWAHYwug3m6i4p3rZGGulfZri1jtI4HslT+OZnFf/OIHowWF71DTlHwXBP2SiA7A==", "cpu": [ "arm" ], @@ -540,9 +592,9 @@ } }, "node_modules/@rolldown/binding-android-arm64": { - "version": "1.2.16", - "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.16.tgz", - "integrity": "sha512-kx5wBiMB6E7TEvpl2B9gjLU004BkvEm2Dr941BFjx/SontPwSzNuQUIoVKxHHoSjpFIfHMmcguyLOtyn0hObRg==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.19.tgz", + "integrity": "sha512-hOombrTJ+szt2ciEzS7oCA78lMPBgF5UMQWCJIyNfnrI7GLl8HYoFqCnpL2gcPOaXMqryGCU5ExdQKyDDcC+yA==", "cpu": [ "arm64" ], @@ -556,9 +608,9 @@ } }, "node_modules/@rolldown/binding-darwin-arm64": { - "version": "1.2.16", - "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.16.tgz", - "integrity": "sha512-qslZrXnKJU4cUpjoAmtAo/KQM9e2IRMlmpig6Zpwj+8KWxW8v+nkAf9216Bsek9lOC1jvg2yCjygCFo2f83msQ==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.19.tgz", + "integrity": "sha512-XoMA2pwCKGTQzUjPgtRwkedH4WmXhdIPKT6l6oOxd1PUbNodGI6DcBekgN7EC//+x3pfBYX/qL1gNmZAqivw5g==", "cpu": [ "arm64" ], @@ -572,9 +624,9 @@ } }, "node_modules/@rolldown/binding-darwin-x64": { - "version": "1.2.16", - "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.16.tgz", - "integrity": "sha512-FdF+y48ND13eAyM2mQn+85kvAqNlvRWROy2rhgA463X/0Gv4vGtazZtfaF1mRBLscYvtOlh4QnLjOWiFzX69OQ==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.19.tgz", + "integrity": "sha512-zo8EsSSwMZCY/e+fRnGaX02YGgvJD0yvhNi/9hpGPA2MJ9ZF8dPCw75UGfpI6OpQ/myR/dIYmogRvqiZD0TrXg==", "cpu": [ "x64" ], @@ -588,9 +640,9 @@ } }, "node_modules/@rolldown/binding-freebsd-x64": { - "version": "1.2.16", - "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.16.tgz", - "integrity": "sha512-ddjqFM5e95AgLbUPtKIS7V1KTVlA0RUgCVr5mn+/IEhsdy3pr+Vuj/HZ7nlMN2FyxIwUktOH1LEPIQXO1v9y1Q==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.19.tgz", + "integrity": "sha512-O8ISAOfI1nj7AuBPd30FSF47z7f7lzlk5poQVGgiikvQuGEBFYvW8ki+UEnT+YJPnNGjQzn304klt4O9FUE7mA==", "cpu": [ "x64" ], @@ -604,9 +656,9 @@ } }, "node_modules/@rolldown/binding-linux-arm-gnueabihf": { - "version": "1.2.16", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.16.tgz", - "integrity": "sha512-tHdKWbFkFBI687iim3LIyIvyL7j66VvQYkDPss5Stn/qyE2tWkR1YD0dXmXPFKKqT/o5ZEJVsaRsWS2meQwGOA==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.19.tgz", + "integrity": "sha512-/lYCba5NO0yq4S0jGMH8QTBtkvQxoXjoQWzF5BcWp9MjB9jxVRD1GQDNofkVjcOj30DWyhLIN/4Oe60JKzaONw==", "cpu": [ "arm" ], @@ -620,9 +672,9 @@ } }, "node_modules/@rolldown/binding-linux-arm64-gnu": { - "version": "1.2.16", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.16.tgz", - "integrity": "sha512-FJiLGAblPBMlBEdbOqw6kW6QcXDWAf/oJu7gYs9ZJZwmg+K+/zjFLxPTIY9izJUzxzc24FHvmseyA0IvJSl17w==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.19.tgz", + "integrity": "sha512-pm/apFMBnSbFb3O6nG5pHO1iqHhZrjGDFEjSm+ot9J17XXPvH9L90y5h+jgfHCE+Qdlsvy8qKEcU4VKxgjD+vA==", "cpu": [ "arm64" ], @@ -639,9 +691,9 @@ } }, "node_modules/@rolldown/binding-linux-arm64-musl": { - "version": "1.2.16", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.16.tgz", - "integrity": "sha512-hrJpblMsrQ58U9veWpbXzkhV5zStunds6HWLprqq1qauvgBr1E6P+24kLj6lSLI9vjRn/RYpjprhkHQPKGWpNg==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.19.tgz", + "integrity": "sha512-K1SmQp3FFichn8oqrNIwvFoZ5wcvjC7goBzpaMNvLf9FZc+QB/QvLmnpJZgAAGHiD980tP8FZZnXk2K94rvlxg==", "cpu": [ "arm64" ], @@ -658,9 +710,9 @@ } }, "node_modules/@rolldown/binding-linux-ppc64-gnu": { - "version": "1.2.16", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.16.tgz", - "integrity": "sha512-qJd/dC6j6CwLG9/s/RP2nb1RZ0GIgj7Ioj7x/SYa3RzjVrlzrmH0fhIOpfvqQDeIsdP0loi+kHaMhJzY1PBIaA==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.19.tgz", + "integrity": "sha512-I0xwD57jP/3A7+5UPZin2w8Y7XHEmEM5zqpYZOcQ45MlNW6tUJUziymV3yRr7rL4vwyfEcRsRksC4a7Kc08p5Q==", "cpu": [ "ppc64" ], @@ -677,9 +729,9 @@ } }, "node_modules/@rolldown/binding-linux-s390x-gnu": { - "version": "1.2.16", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.16.tgz", - "integrity": "sha512-Vx7Xg5uUJuNcujJjI70OICaH0EYj80BtOLZTSN7uOYg8QOLlyKnaG0IW7Fn/J0IpJsaKzmDKMhOQv1JBM9m9vg==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.19.tgz", + "integrity": "sha512-BrtEHT24SNXj9HiXqy+s/kXiSiQGt6EKCPUlRirAoIioVxKGnbXBUEkbZASAei7iZJB0/Ynm+0JP00Ipx7AnSw==", "cpu": [ "s390x" ], @@ -696,9 +748,9 @@ } }, "node_modules/@rolldown/binding-linux-x64-gnu": { - "version": "1.2.16", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.16.tgz", - "integrity": "sha512-TNKhgE3uJTsTzatUSSYt0Kgo+Oa2uSlSjz4r1aEIea7HX6ULBym4fAlYUhG1i6pjNf2njfCUAfKwr6C3E9Xg1w==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.19.tgz", + "integrity": "sha512-rm75/9DkHKeU2WnA8w4X94WGYgLlDCFCfkQC+4bguVJmC/jvDRv2B+2wLOYhyE0fVuv7//Ckk39OoOufyCu76Q==", "cpu": [ "x64" ], @@ -715,9 +767,9 @@ } }, "node_modules/@rolldown/binding-linux-x64-musl": { - "version": "1.2.16", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.16.tgz", - "integrity": "sha512-7chXdpjXZ8qG0+mIxECN3cT9kvhZ3/oZhMX6Pp876P7CDrIy8nJswva6Mq357JR7eYXfuskwZxMeV1SzoZdHrA==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.19.tgz", + "integrity": "sha512-irh/4+iYFM4GAzpluDErgjz89bj6NDtqqMAG/6O1LG38Ed3NpyebzCpcVNkFW8uhy+/3/BocUvnXDR33CXWe9A==", "cpu": [ "x64" ], @@ -734,9 +786,9 @@ } }, "node_modules/@rolldown/binding-openharmony-arm64": { - "version": "1.2.16", - "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.16.tgz", - "integrity": "sha512-Kwjt+7uNTJK5/MDkGWGVO2KQPnj8yAV75dMpfwyHZrJSXWHrniOB0aUEWlVYf3H1hOqFLIStLdM5QXq6bnKmOQ==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.19.tgz", + "integrity": "sha512-+KWTWNoPt+CfSq94CiceWu3yPE+QzkaG+phPyz9G60tmZLwfQkcA4AeksafzvJAw4pvg1mcd5a1TkUqVv0s4JA==", "cpu": [ "arm64" ], @@ -749,10 +801,28 @@ "node": "^20.19.0 || >=22.12.0" } }, + "node_modules/@rolldown/binding-wasm32-wasi": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-wasm32-wasi/-/binding-wasm32-wasi-1.2.19.tgz", + "integrity": "sha512-7EH+skOsl5qpWnK0vzamgJFhOv1cwxQpsxm8tI883K9fur5c27p8q87fzEO6BbBPabA2/+s/zR63/pLc137iOg==", + "cpu": [ + "wasm32" + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/core": "2.0.0-beta.2", + "@emnapi/runtime": "2.0.0-beta.2", + "@napi-rs/wasm-runtime": "1.2.6" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=23.5.0" + } + }, "node_modules/@rolldown/binding-win32-arm64-msvc": { - "version": "1.2.16", - "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.16.tgz", - "integrity": "sha512-/LH6WfjDRXXJz/p5xl4TmU+jpcnwcxbKEQBW/GZE0JHfN0lGIyTtsUEGaQ/q/GikkGJ2yLKe6pwm7AnEWO8pdw==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.19.tgz", + "integrity": "sha512-3Q1Yg1Q7tEvBWoZf5rFvG/GKZQPgwfru+p4wBajDfJFBs0SHCpL++dfTjW9gyAKd1T7ZpIYvdaUax7Pa/IhFVQ==", "cpu": [ "arm64" ], @@ -766,9 +836,9 @@ } }, "node_modules/@rolldown/binding-win32-x64-msvc": { - "version": "1.2.16", - "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.16.tgz", - "integrity": "sha512-1lv1KvX0Z871zfk7vw+dnXMMnHNyDwMzWG8Kv3HxDXMOhzCX4SHc7HK319fInP0i+0p9D8brkfzL7pJOaGl+tw==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.19.tgz", + "integrity": "sha512-y/sqRRc6d7hECzOFc5n3LSeqctmIp9mMjY1Kq4s14uLPd/LZ4z7i1zrW6fMtp2mPeuQIC4e6ULMcwQzMomqQag==", "cpu": [ "x64" ], @@ -782,11 +852,21 @@ } }, "node_modules/@rolldown/pluginutils": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.1.tgz", - "integrity": "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.1.1.tgz", + "integrity": "sha512-glFIJDvLNDtJhT9qrMFWLPbvS+skxgt4L0K8Ei2YtnhPysAJnsI7nyxSJxKj4ADeKX0OLjC4ntRkwpLOoS3rwA==", "license": "MIT" }, + "node_modules/@tybys/wasm-util": { + "version": "0.10.5", + "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.5.tgz", + "integrity": "sha512-dOGOPxlaNV+G046mZzN+9C0dAcQZeSKcXiVaM0TYy/LM4ttTmgSBDxYfovcYI8Em3+eAbiAYpvWLOv8+ZVRJKA==", + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, "node_modules/@types/chai": { "version": "5.2.3", "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz", @@ -812,9 +892,9 @@ "license": "MIT" }, "node_modules/@vitejs/plugin-vue": { - "version": "6.0.10", - "resolved": "https://registry.npmjs.org/@vitejs/plugin-vue/-/plugin-vue-6.0.10.tgz", - "integrity": "sha512-b80aUQh3n+qEzzZm5oQp3rT2QImeCx58K6eFl/RkJ3d65KW0kTuv5lNsLRVAjbW9YRUpo/wzmvzMgV34bTAItA==", + "version": "6.0.11", + "resolved": "https://registry.npmjs.org/@vitejs/plugin-vue/-/plugin-vue-6.0.11.tgz", + "integrity": "sha512-m48lskIUJGlB6qUiYhDMI8nd2ngeidz2U4nKTjqI13cFMu5rH8JeEILPkDtK9Fk/TjBA2pkj8AlbenqDaKu+ww==", "dev": true, "license": "MIT", "dependencies": { @@ -825,19 +905,19 @@ }, "peerDependencies": { "vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0", - "vue": "^3.2.25 || ^3.6.0-rc.10" + "vue": "^3.2.25 || ^3.6.0-rc.15" } }, "node_modules/@vitest/coverage-v8": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-5.0.5.tgz", - "integrity": "sha512-4KpkGdIrSqBihx/JyP/e+S+IKB98etg1XDQiLAxksLfcShnwi1VReGeOT9NI43hLHbknosKp/1CCLn9Zgcs8mg==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-5.1.0.tgz", + "integrity": "sha512-OY9aShBQG5KOIw2zCo9fDoCHI9RHliNHJ//nM7m6jGg41Hyke9JOGWmeMlK74xYErsxMoK8mIB3gAeEyFVA7LA==", "dev": true, "license": "MIT", "dependencies": { "@bcoe/v8-coverage": "^1.0.2", - "@vitest/istanbul-lib-coverage": "^1.0.2", - "@vitest/istanbul-lib-report": "^1.0.2", + "@vitest/istanbul-lib-coverage": "^2.1.0", + "@vitest/istanbul-lib-report": "^2.1.0", "ast-v8-to-istanbul": "^1.0.7", "magicast": "^0.5.5", "obug": "^3.0.0", @@ -848,8 +928,8 @@ "url": "https://opencollective.com/vitest" }, "peerDependencies": { - "@vitest/browser": "5.0.5", - "vitest": "5.0.5" + "@vitest/browser": "5.1.0", + "vitest": "5.1.0" }, "peerDependenciesMeta": { "@vitest/browser": { @@ -858,9 +938,9 @@ } }, "node_modules/@vitest/istanbul-lib-coverage": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@vitest/istanbul-lib-coverage/-/istanbul-lib-coverage-1.0.2.tgz", - "integrity": "sha512-9J/JMwOf9AoJhAywhrn7ScKTL38hsWQP/qPG60OtaAFcQ5OXPwKsxZFlbnuCKmZ61m8/lGgHYnFpdyQZUvG/iA==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@vitest/istanbul-lib-coverage/-/istanbul-lib-coverage-2.1.0.tgz", + "integrity": "sha512-WOjuS+xcjSIy7ruYBQ+9BUcV7XZQ0FyVcbWbWxW9TRx/kLGx5SQaeFRIFDJxjNplb6YsT7SpKo2zuXXUo91OIQ==", "dev": true, "license": "MIT", "engines": { @@ -868,27 +948,27 @@ } }, "node_modules/@vitest/istanbul-lib-report": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@vitest/istanbul-lib-report/-/istanbul-lib-report-1.0.2.tgz", - "integrity": "sha512-gUsfXZJbzPamoIY5TvHFiMMoXESBrUMo+xqaj+rYrWI69+EnvRlYBlP96ZnHPY4vX8kyUpgAnFUCg5wZG/HkDQ==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@vitest/istanbul-lib-report/-/istanbul-lib-report-2.1.0.tgz", + "integrity": "sha512-+ZFta25nWtGCOBG9/IET8w1RO5Oawsd6H8Uf6AJ9EA/StFuKVtKAEJEJ6uRt84OH+T4YkI0ASmIHAhRA+0KVxw==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/istanbul-lib-coverage": "1.0.2" + "@vitest/istanbul-lib-coverage": "2.1.0" }, "engines": { "node": ">=22" } }, "node_modules/@vitest/mocker": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-5.0.5.tgz", - "integrity": "sha512-xLL3lkDegJZw+MGoGaCCsFayDZthGgpAtr3Vziyfc4p7xH89K7KRPcRBBh/kEYm0Aqkt5DtTmkYpBtRV/FrHZg==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-5.1.0.tgz", + "integrity": "sha512-5umB9/jlWcqVS6fsrFmv5Gdnpu6wAUio/lEOwAmvB7v+lFo/IW2B9FhAD0p19GCULTgMzLCdUmuCDCnAzWgppQ==", "dev": true, "license": "MIT", "dependencies": { "@jridgewell/trace-mapping": "0.3.31", - "@vitest/spy": "5.0.5", + "@vitest/spy": "5.1.0", "estree-walker": "^3.0.3", "magic-string": "^1.4.3" }, @@ -919,9 +999,9 @@ } }, "node_modules/@vitest/spy": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-5.0.5.tgz", - "integrity": "sha512-lwJRExuH417257Q5wv9QYugN9IMJkoxcrKrYxGPQkBzl7wlNpTUxD/5yNX4ESKVUIShKPgkGchYPFMWOOk0wzw==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-5.1.0.tgz", + "integrity": "sha512-2DPO5OMHWKrBngC+fCmTQqemNF0gidRhp3lxbBmRhW+M1XJrfgPpqNqWVevXtn2f2ufD5ZaR1B6B641aAlcX5A==", "dev": true, "license": "MIT", "funding": { @@ -955,44 +1035,77 @@ } } }, + "node_modules/@vue-macros/common/node_modules/local-pkg": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/local-pkg/-/local-pkg-1.2.1.tgz", + "integrity": "sha512-++gUqRDEvcnN6Zhqrr+y/CkVEHhlrR96vZn3nZZPYzMcBUyBtTKzB9NadClFIsIVSsu+3i9tfk/erqy9kAmt7Q==", + "license": "MIT", + "dependencies": { + "mlly": "^1.7.4", + "pkg-types": "^2.3.0", + "quansync": "^0.2.11" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/@vue-macros/common/node_modules/quansync": { + "version": "0.2.11", + "resolved": "https://registry.npmjs.org/quansync/-/quansync-0.2.11.tgz", + "integrity": "sha512-AifT7QEbW9Nri4tAwR5M/uzpBuqfZf+zwaEM/QkzEjj7NBuFD2rBuy0K3dE+8wltbezDV7JMA0WfnCPYRSYbXA==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/antfu" + }, + { + "type": "individual", + "url": "https://github.com/sponsors/sxzz" + } + ], + "license": "MIT" + }, "node_modules/@vue/compiler-core": { - "version": "3.5.45", - "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.45.tgz", - "integrity": "sha512-XGHJrM6ufZARAc/w+tyOswStw9tdKiqCKBScI4gGaNxD+aaGu/HQWgKJ+JItjRLPqenQ7iE7G8AJC7T5ew1p+g==", + "version": "3.5.46", + "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.46.tgz", + "integrity": "sha512-yb+N8/mgBcoeqCJPVyJI/D3OphLrSMXnB3ZQUNmRLU/1fsMW4bFfdJWNi9oIj7+EA3ULKKkP7b/VCpcYQYeiuQ==", "license": "MIT", "dependencies": { "@babel/parser": "^7.29.12", - "@vue/shared": "3.5.45", + "@vue/shared": "3.5.46", "entities": "^7.0.1", "estree-walker": "^2.0.2", - "source-map-js": "^1.2.2" + "source-map-js": "^1.2.3" } }, "node_modules/@vue/compiler-dom": { - "version": "3.5.45", - "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.45.tgz", - "integrity": "sha512-LbP2d19GSOYGPmvMBBCVJVlv7TKtjM1Cfeyu3cYia720pknZP+1cLX7H5MVatvruT6MuJhiPuNbQBW/MDn/EwA==", + "version": "3.5.46", + "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.46.tgz", + "integrity": "sha512-Bj3lCSw3DQnDRDxw115XqdLDd0+18Nftlgd8OXSGG+ud74hxJIE17eYrM+VWgQrTMsvJbLh9Hzf2MkwAzru36Q==", "license": "MIT", "dependencies": { - "@vue/compiler-core": "3.5.45", - "@vue/shared": "3.5.45" + "@vue/compiler-core": "3.5.46", + "@vue/shared": "3.5.46" } }, "node_modules/@vue/compiler-sfc": { - "version": "3.5.45", - "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.45.tgz", - "integrity": "sha512-MKFjb2UX0M/l/jhfzqMLrI8VM4pfvFKG3pqFZkSZFHRLtNld/O4RtUPZFWSwhro/14qP88UQEkWzHxAZAQ0tsw==", + "version": "3.5.46", + "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.46.tgz", + "integrity": "sha512-hjUvMxGh+QIgegwksfp6BRBYleE/a8veZHvTR6sa+o+bM4HU+WnrUZlhN0X+pDcsl8Lhwmbu72xPvLMk3XUwog==", "license": "MIT", "dependencies": { "@babel/parser": "^7.29.12", - "@vue/compiler-core": "3.5.45", - "@vue/compiler-dom": "3.5.45", - "@vue/compiler-ssr": "3.5.45", - "@vue/shared": "3.5.45", + "@vue/compiler-core": "3.5.46", + "@vue/compiler-dom": "3.5.46", + "@vue/compiler-ssr": "3.5.46", + "@vue/shared": "3.5.46", "estree-walker": "^2.0.2", "magic-string": "^0.30.21", "postcss": "^8.5.32", - "source-map-js": "^1.2.2" + "source-map-js": "^1.2.3" } }, "node_modules/@vue/compiler-sfc/node_modules/magic-string": { @@ -1005,13 +1118,13 @@ } }, "node_modules/@vue/compiler-ssr": { - "version": "3.5.45", - "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.45.tgz", - "integrity": "sha512-RF5sbZOfYz5AK00tOJUn2PwFXR2fS1u2HVzI8D9VF9rGAFxuGBqg2bB1kJ3ZHMprqSltXnT9MZE1IsqjSM8oew==", + "version": "3.5.46", + "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.46.tgz", + "integrity": "sha512-qebChL3aP0m1k+TlSf+fZWvOwAf3flBCi5o+n01ykR3DX4mTIWheFltmoiQ12+z66/4cGeXqbB2P7sPWkGhQNQ==", "license": "MIT", "dependencies": { - "@vue/compiler-dom": "3.5.45", - "@vue/shared": "3.5.45" + "@vue/compiler-dom": "3.5.46", + "@vue/shared": "3.5.46" } }, "node_modules/@vue/devtools-api": { @@ -1039,57 +1152,57 @@ "license": "MIT" }, "node_modules/@vue/reactivity": { - "version": "3.5.45", - "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.45.tgz", - "integrity": "sha512-WqkyubNWpI4OYBOipSrjIssMdJO8K1i9Zts/Wm8Er10/0msOEwCyWWWvZnAI7WW3kQsTong6DJp8Cbb+vd4cPA==", + "version": "3.5.46", + "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.46.tgz", + "integrity": "sha512-+FHtYTvGxgFoX3oRs7soz6JHizGv50Q26WJN6PWtXuTLXRfkfUpDUTRuoTA/kiZVVt8NMeMpsPQLh9h++ReUjQ==", "license": "MIT", "dependencies": { - "@vue/shared": "3.5.45" + "@vue/shared": "3.5.46" } }, "node_modules/@vue/runtime-core": { - "version": "3.5.45", - "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.5.45.tgz", - "integrity": "sha512-bzIO3+FABjpj85uIKSc+Qnj36/sxDNI3tcH9i6w6xKA1k6e0ejv0G0jMCfeJBvK3yGL5XbJ3DMZj+ClqyCHFYw==", + "version": "3.5.46", + "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.5.46.tgz", + "integrity": "sha512-eJUzKAUaHAmtnys/l9qduPzUnBrYMkmsCU7TN+vbSOSpm8kcETT7nacKxIO4MBej/XiOraVzq+lSeZv7o1//jQ==", "license": "MIT", "dependencies": { - "@vue/reactivity": "3.5.45", - "@vue/shared": "3.5.45" + "@vue/reactivity": "3.5.46", + "@vue/shared": "3.5.46" } }, "node_modules/@vue/runtime-dom": { - "version": "3.5.45", - "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.5.45.tgz", - "integrity": "sha512-ZvRTFMDgfqTDYWvJfoVpQTJx1RN5M6l7Pyd6wfdY2NaXzbPQVh9ezeQYFbNPP6bIcRVn2SqSSR25N/jSW69BFw==", + "version": "3.5.46", + "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.5.46.tgz", + "integrity": "sha512-6L7lbBvXTYBFFjIt25a0pgdpmn3Ns8RqUnNVibRzF4bgyiWJvqOhKEV5MXYWKlCttZE3aGeJN8mveo+6IrIKXA==", "license": "MIT", "dependencies": { - "@vue/reactivity": "3.5.45", - "@vue/runtime-core": "3.5.45", - "@vue/shared": "3.5.45", - "csstype": "^3.2.3" + "@vue/reactivity": "3.5.46", + "@vue/runtime-core": "3.5.46", + "@vue/shared": "3.5.46", + "csstype": "^3.2.4" } }, "node_modules/@vue/server-renderer": { - "version": "3.5.45", - "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.5.45.tgz", - "integrity": "sha512-1fNXUHhhsWf4EVL4XixbGBU5mKdiIXJAB82feHRTyPPo6ZUEYWIJuEeUl3mVV6QDBp50HJOX4obLhxYXlrjrzA==", + "version": "3.5.46", + "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.5.46.tgz", + "integrity": "sha512-4mc0YWREc6OZ5pDCigvKPDzIUV+aciiH92yvyTS6xaHHxW/80rMceQQn11pYe7OEEBt2YQgYWR9zF8QF30GJUQ==", "license": "MIT", "dependencies": { - "@vue/compiler-ssr": "3.5.45", - "@vue/runtime-dom": "3.5.45", - "@vue/shared": "3.5.45" + "@vue/compiler-ssr": "3.5.46", + "@vue/runtime-dom": "3.5.46", + "@vue/shared": "3.5.46" } }, "node_modules/@vue/shared": { - "version": "3.5.45", - "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.45.tgz", - "integrity": "sha512-ue9fgHmVNPlP7iW3+cxoBX/Cnlw53dHlVSw0JKGY6z1lObg8pHoj928M2nzG4/yVsMZ3NaRZ2s2z61uC16NDwQ==", + "version": "3.5.46", + "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.46.tgz", + "integrity": "sha512-P1WePbdzHrcIciWtmY2Im9EFhdakd3rZxYqvalOa3SfoxtF35Q8Uhmj1tKn6bWP4utcOpN8ao6BoJUItq0Uf+g==", "license": "MIT" }, "node_modules/@vue/test-utils": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/@vue/test-utils/-/test-utils-2.5.1.tgz", - "integrity": "sha512-V/4a99odJ7hapr0bRt35XxljGk8hefq31gSOnlKTcEq2fUeoj2qb+FcpJYfQu4qfYhW9Ug+O2+CZ3QmZ7gXDzA==", + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/@vue/test-utils/-/test-utils-2.6.0.tgz", + "integrity": "sha512-kTB6s2p34cA/xXSpt17G0enU9A3F3pdm+o5GZgE3WGXXXpXJ5SVBsRhgCJNCc+ekGAzY0T7Hjyo5yEfwencBlg==", "dev": true, "license": "MIT", "dependencies": { @@ -1209,9 +1322,9 @@ } }, "node_modules/ansi-regex": { - "version": "6.5.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.5.0.tgz", - "integrity": "sha512-zhvbbbdt1kbw7EJ9OQoxmQcuaNR9P5kTj7e/YdmOSU10aHWbycofJxA6jKfoEy3vlLdctOF9ZHaxLtmSm998wQ==", + "version": "6.6.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.6.0.tgz", + "integrity": "sha512-XZ5apbzreCbXSKwPjJstu8R0zOi247w3XYwWxtwBXgpZrCyc1Ka7p9/xY0A9/diMewmHbEKz+FIraWaEWjlN5g==", "dev": true, "license": "MIT", "engines": { @@ -1237,27 +1350,6 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/arch": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/arch/-/arch-2.2.0.tgz", - "integrity": "sha512-Of/R0wqp83cgHozfIYLbBMnej79U/SVGOOyuB3VVFv1NRM/PSFMK12x9KVtiYzJqmnU5WR2qp0Z5rHb7sWGnFQ==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT" - }, "node_modules/arg": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/arg/-/arg-5.0.2.tgz", @@ -1292,9 +1384,9 @@ } }, "node_modules/ast-v8-to-istanbul": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/ast-v8-to-istanbul/-/ast-v8-to-istanbul-1.0.7.tgz", - "integrity": "sha512-kFL68AG6ajd8fg248zwM9GQrUWEp79gsmjum34OEXjs4yHuUMZfYKwOLW9GMmB4oNvVrj+EAGxsP7ye2UR9UlA==", + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/ast-v8-to-istanbul/-/ast-v8-to-istanbul-1.0.8.tgz", + "integrity": "sha512-lPdpagk13ANXV+HClJEpCZM7kUsl5XcvgqKzZhaj6Ve1ZFICcY2sGhAN1n1vT0tML6EclT7bfVgTxqL57Gkpow==", "dev": true, "license": "MIT", "dependencies": { @@ -1331,9 +1423,9 @@ } }, "node_modules/ast-walker-scope/node_modules/@babel/helper-string-parser": { - "version": "8.0.8", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-8.0.8.tgz", - "integrity": "sha512-fVM+gSuKbdv9cpmyRNh5EvsDHUZCdxQH3FdnFKSkNYHpbsn95bbrxm+ES3MVeQjcqwi2O5ur/DjLfmTQaO60ng==", + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-8.1.2.tgz", + "integrity": "sha512-TRz5Z0MgfIfWqwEIq/pCpUpEXQxUt2Ig2ZbxG3SdmhSbHMAFFYGOix0kI4JLV371/TA+qWnQ4xWHPWjojkyRFA==", "license": "MIT", "engines": { "node": "^22.18.0 || >=24.11.0" @@ -1349,12 +1441,12 @@ } }, "node_modules/ast-walker-scope/node_modules/@babel/parser": { - "version": "8.0.10", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-8.0.10.tgz", - "integrity": "sha512-h+ah2Kg0ne1Vii892dShj9gky9I5jPzkd8x4s/3xgN/P2bMWmHS3qq59tum3mCVjCBXI8uqfYyYtrfp1Mz6+1w==", + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-8.1.2.tgz", + "integrity": "sha512-ZDKU7vaX0VORd2BhaO+3FKr/30TKjbUy3SMZcydiPngnAb+MesgUoh5SJcE5EwEyBj14M5J6fK56GuBqvYmOpw==", "license": "MIT", "dependencies": { - "@babel/types": "^8.0.10" + "@babel/types": "^8.1.2" }, "bin": { "parser": "bin/babel-parser.js" @@ -1364,12 +1456,12 @@ } }, "node_modules/ast-walker-scope/node_modules/@babel/types": { - "version": "8.0.10", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-8.0.10.tgz", - "integrity": "sha512-KV8Y+teoRsmXeEPS4sCJY1kwV+hcPzHP1qQqgCxrjKOehLdBaxpsFBfoJ8MXWFV80y6Jw56+TM95wR0Per8dYw==", + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-8.1.2.tgz", + "integrity": "sha512-uXt6qt2f5G61jZwNIzK1RKu7l5Xjt1VXtPPOGuVveha9fxbx0QM94U1kM4pFZKTRLjWK+X8vmwjwbIemJjiQTA==", "license": "MIT", "dependencies": { - "@babel/helper-string-parser": "^8.0.8", + "@babel/helper-string-parser": "^8.1.2", "@babel/helper-validator-identifier": "^8.0.6" }, "engines": { @@ -1377,12 +1469,12 @@ } }, "node_modules/ast-walker-scope/node_modules/ast-kit": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ast-kit/-/ast-kit-3.0.0.tgz", - "integrity": "sha512-8OG92q3R35qjC/4i6BLBMg8IB+fClWu/1PEwg2Z9Rn+BuNaiEgJzpzn+pxWOdHJWDCAwu2JP0wCDTozAM4QirQ==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ast-kit/-/ast-kit-3.0.1.tgz", + "integrity": "sha512-fCGiQvmHghhf858e/SVGh2aUo/FsbtB5qB8bifo6ygHK5OMcGna56FUvS0IrYvo+unYwIi1nCklEh/KUaOKVmg==", "license": "MIT", "dependencies": { - "@babel/parser": "^8.0.0", + "@babel/parser": "^8.1.0", "estree-walker": "^3.0.3", "pathe": "^2.0.3" }, @@ -1456,9 +1548,9 @@ } }, "node_modules/bootstrap": { - "version": "5.3.8", - "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.3.8.tgz", - "integrity": "sha512-HP1SZDqaLDPwsNiqRqi5NcP0SSXciX2s9E+RyqJIIqGo+vJeN5AJVM98CXmW/Wux0nQ5L7jeWUdplCEf0Ee+tg==", + "version": "5.3.9", + "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.3.9.tgz", + "integrity": "sha512-20cU0rcfw8WdxtVbmfU+xT2EjvVTw9Ror/h1Qvd7DXCujRg8OO9mdBCsmTHdJFf3BuadmBNJtgIuUXsBqSkk/w==", "funding": [ { "type": "github", @@ -1511,9 +1603,9 @@ } }, "node_modules/brace-expansion": { - "version": "5.0.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", - "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", + "version": "5.0.13", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.13.tgz", + "integrity": "sha512-Vh3dmFbc4wZeox7M9I/0L9GfFd83Su4+yCck/OF9Gi/P/dAHn0RT7X4K9R7gMNMhDck3DvhR6QXsnQdjjgwNvQ==", "dev": true, "license": "MIT", "dependencies": { @@ -1590,15 +1682,15 @@ } }, "node_modules/chokidar": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-5.0.0.tgz", - "integrity": "sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-6.0.0.tgz", + "integrity": "sha512-Ec2Z7wpcKBiMpR7DxteoqS/sq5G5d2A4fpxzPv6+fD7xNNdrTghn7L11YwV5EN1B3i72Erc3XVT5FkWIDx90+A==", "license": "MIT", "dependencies": { - "readdirp": "^5.0.0" + "readdirp": "^5.1.1" }, "engines": { - "node": ">= 20.19.0" + "node": ">= 22.22" }, "funding": { "url": "https://paulmillr.com/funding/" @@ -1617,24 +1709,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/clipboardy": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/clipboardy/-/clipboardy-3.0.0.tgz", - "integrity": "sha512-Su+uU5sr1jkUy1sGRpLKjKrvEOVXgSgiSInwa/qeID6aJ07yh+5NWc3h2QfjHjBnfX4LhtFcuAWKUsJ3r+fjbg==", - "dev": true, - "license": "MIT", - "dependencies": { - "arch": "^2.2.0", - "execa": "^5.1.1", - "is-wsl": "^2.2.0" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -1679,15 +1753,16 @@ } }, "node_modules/compression": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/compression/-/compression-1.8.1.tgz", - "integrity": "sha512-9mAqGPHLakhCLeNyxPkK4xVo746zQ/czLH1Ky+vkitMnWfWZps8r0qXuwhwizagCRttsL4lfG4pIOvaWLpAP0w==", + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/compression/-/compression-1.8.2.tgz", + "integrity": "sha512-o8vI5RE5A6EVVOd9o41jKp41aJom+QTEO/Bx8MYNjexMo/Bv2WOjUfZr+aL0WnYSgymUy6zeguqLTsIhV0gMvQ==", "dev": true, "license": "MIT", "dependencies": { "bytes": "3.1.2", "compressible": "~2.0.18", "debug": "2.6.9", + "destroy": "1.2.0", "negotiator": "~0.6.4", "on-headers": "~1.1.0", "safe-buffer": "5.2.1", @@ -1695,6 +1770,10 @@ }, "engines": { "node": ">= 0.8.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/concat-map": { @@ -1745,25 +1824,10 @@ "url": "https://opencollective.com/express" } }, - "node_modules/cross-spawn": { - "version": "7.0.6", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", - "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", - "dev": true, - "license": "MIT", - "dependencies": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - }, - "engines": { - "node": ">= 8" - } - }, "node_modules/csstype": { - "version": "3.2.3", - "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz", - "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==", + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.4.tgz", + "integrity": "sha512-PoKaoPzQapnEoqUSnHx1u6W6ku8CVEgKsnpmmzU3m1nwkidpPBQ8V/Zq2+bWNrsOKoKLwTGdbx6xF7BXP1zLVQ==", "license": "MIT" }, "node_modules/data-urls": { @@ -1817,6 +1881,17 @@ "node": ">=4.0.0" } }, + "node_modules/destroy": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, "node_modules/detect-libc": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", @@ -1885,30 +1960,6 @@ "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", "license": "MIT" }, - "node_modules/execa": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", - "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", - "dev": true, - "license": "MIT", - "dependencies": { - "cross-spawn": "^7.0.3", - "get-stream": "^6.0.0", - "human-signals": "^2.1.0", - "is-stream": "^2.0.0", - "merge-stream": "^2.0.0", - "npm-run-path": "^4.0.1", - "onetime": "^5.1.2", - "signal-exit": "^3.0.3", - "strip-final-newline": "^2.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sindresorhus/execa?sponsor=1" - } - }, "node_modules/expect-type": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.4.0.tgz", @@ -1980,23 +2031,10 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, - "node_modules/get-stream": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", - "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/glob": { - "version": "13.0.6", - "resolved": "https://registry.npmjs.org/glob/-/glob-13.0.6.tgz", - "integrity": "sha512-Wjlyrolmm8uDpm/ogGyXZXb1Z+Ca2B8NbJwqBVg0axK9GbBeoS7yGV6vjXnYdGm6X53iehEuxxbyiKp8QmN4Vw==", + "version": "13.0.7", + "resolved": "https://registry.npmjs.org/glob/-/glob-13.0.7.tgz", + "integrity": "sha512-wfsFgXQ8A3SEI9XGf7Nl3Y9l7ffSrGh7SUCT7vU/2CzYPep9kjxAn1S40F9OPKxAMGCVl7HtNlJhrCJUeUq83g==", "dev": true, "license": "BlueOak-1.0.0", "dependencies": { @@ -2040,16 +2078,6 @@ "node": "^22.13.0 || >=24.0.0" } }, - "node_modules/human-signals": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", - "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": ">=10.17.0" - } - }, "node_modules/ini": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", @@ -2094,22 +2122,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/is-docker": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", - "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", - "dev": true, - "license": "MIT", - "bin": { - "is-docker": "cli.js" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", @@ -2140,39 +2152,6 @@ "dev": true, "license": "MIT" }, - "node_modules/is-stream": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", - "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/is-wsl": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", - "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", - "dev": true, - "license": "MIT", - "dependencies": { - "is-docker": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", - "dev": true, - "license": "ISC" - }, "node_modules/js-beautify": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/js-beautify/-/js-beautify-2.0.3.tgz", @@ -2210,9 +2189,9 @@ "license": "MIT" }, "node_modules/jsdom": { - "version": "31.0.0", - "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-31.0.0.tgz", - "integrity": "sha512-xAkhD9z1eyFC5+QUi9K24CaZJgdCQ2GOGLW1GdVDoQvkp/AxEH9TQ0pAplPOlIiV92hfcgnFOADZypbjgbBT6Q==", + "version": "31.0.1", + "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-31.0.1.tgz", + "integrity": "sha512-CbhJL8ZQg3eKswxSZth4QO9tW0jPIhmR0vtSXQSbKSfWbwIT6hoRc17wdHIVTQ43KI0mdV5iTJr3281IDgVZ5g==", "dev": true, "license": "MIT", "dependencies": { @@ -2534,17 +2513,17 @@ } }, "node_modules/local-pkg": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/local-pkg/-/local-pkg-1.2.1.tgz", - "integrity": "sha512-++gUqRDEvcnN6Zhqrr+y/CkVEHhlrR96vZn3nZZPYzMcBUyBtTKzB9NadClFIsIVSsu+3i9tfk/erqy9kAmt7Q==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/local-pkg/-/local-pkg-2.0.0.tgz", + "integrity": "sha512-xvTNwM27EpU+fkLSpo33Pq/nm8m5zNf0aU/hF4W4ZM9RHQjVZa5KTmmXIzEzVsdI09NOUqj0djHhTv96sUowSQ==", "license": "MIT", "dependencies": { - "mlly": "^1.7.4", - "pkg-types": "^2.3.0", - "quansync": "^0.2.11" + "mlly": "^1.8.2", + "pkg-types": "^2.3.1", + "quansync": "^1.0.0" }, "engines": { - "node": ">=14" + "node": ">=20.19.0" }, "funding": { "url": "https://github.com/sponsors/antfu" @@ -2617,13 +2596,6 @@ "node": ">= 20" } }, - "node_modules/merge-stream": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", - "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", - "dev": true, - "license": "MIT" - }, "node_modules/mime-db": { "version": "1.54.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", @@ -2657,16 +2629,6 @@ "node": ">= 0.6" } }, - "node_modules/mimic-fn": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", - "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/minimatch": { "version": "10.2.6", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz", @@ -2795,19 +2757,6 @@ "integrity": "sha512-wzRsrJwNlFbqIRQt8aCeL2WE8USip/uuvGSOZV1D02CxX8ABTMbw8IywKjH7yWHETMXbWJI4OBpihg9rmz2Vyg==", "license": "MIT" }, - "node_modules/npm-run-path": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", - "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", - "dev": true, - "license": "MIT", - "dependencies": { - "path-key": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/obug": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/obug/-/obug-3.0.0.tgz", @@ -2832,26 +2781,10 @@ "node": ">= 0.8" } }, - "node_modules/onetime": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", - "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", - "dev": true, - "license": "MIT", - "dependencies": { - "mimic-fn": "^2.1.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/parse5": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-8.1.0.tgz", - "integrity": "sha512-sq3qBFpee5jeocbFbO48VHlGr8sT7mbXS0vxlKN6sottBtJzrOG3998sr0llSZcQAGgfpdmEYAIZE0P9z0dE8w==", + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-8.1.1.tgz", + "integrity": "sha512-EcR/6WDcU7b2N3vQSxKALCk9lXGtUMQxXio008OEMBE0kavu/7JLfBEeFPzi43nMqVDSbEn3QCK+BMCc9zO//w==", "dev": true, "license": "MIT", "dependencies": { @@ -2862,13 +2795,13 @@ } }, "node_modules/parse5-parser-stream": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/parse5-parser-stream/-/parse5-parser-stream-8.1.0.tgz", - "integrity": "sha512-58MPfNTA+DsIzro41rU94xghnu/h2N4yEPdPdGPlZVHM/QvA5jlVGYVo7IzlHbFLHYx3cZUnr9s9HBrA0tEYyw==", + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/parse5-parser-stream/-/parse5-parser-stream-8.1.1.tgz", + "integrity": "sha512-hMcVbbUJcQmP8rURWUdYrT1flRiBiBVjq/RYGguJpDUgIXSqdYKlE0CxthmdMWoSlBAuL5bUBa73g0pttSy7Hw==", "dev": true, "license": "MIT", "dependencies": { - "parse5": "^8.0.0" + "parse5": "^8.1.1" }, "funding": { "url": "https://github.com/inikulin/parse5?sponsor=1" @@ -2894,16 +2827,6 @@ "dev": true, "license": "(WTFPL OR MIT)" }, - "node_modules/path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, "node_modules/path-scurry": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.2.tgz", @@ -2970,9 +2893,9 @@ } }, "node_modules/postcss": { - "version": "8.5.32", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.32.tgz", - "integrity": "sha512-LJlKCCAUFKOuZxipUdYw1NzIITEsPcgyOG9LkvRJvuKj/bRzbuRY0ARXvL0pWGpsZvn8jku+LMep2eU0seHp8g==", + "version": "8.5.33", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.33.tgz", + "integrity": "sha512-RVHEU9/Pp1Fnjr/MpAJsZoADukCKhfIi15OunEYiGktIkYLkPVvC1sioWolGDS7XByMTx9m/IGbro0Js13zhnQ==", "funding": [ { "type": "opencollective", @@ -3015,9 +2938,9 @@ } }, "node_modules/quansync": { - "version": "0.2.11", - "resolved": "https://registry.npmjs.org/quansync/-/quansync-0.2.11.tgz", - "integrity": "sha512-AifT7QEbW9Nri4tAwR5M/uzpBuqfZf+zwaEM/QkzEjj7NBuFD2rBuy0K3dE+8wltbezDV7JMA0WfnCPYRSYbXA==", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/quansync/-/quansync-1.0.0.tgz", + "integrity": "sha512-5xZacEEufv3HSTPQuchrvV6soaiACMFnq1H8wkVioctoH3TRha9Sz66lOxRwPK/qZj7HPiSveih9yAyh98gvqA==", "funding": [ { "type": "individual", @@ -3104,9 +3027,9 @@ } }, "node_modules/rolldown": { - "version": "1.2.16", - "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.16.tgz", - "integrity": "sha512-bWvlMpFKiTfDKfnK7FC2MPgPeWCf/Kpwsq49ApdW+FQaBZb6O6dZ4MAPbPUjp7hYQrw/RobqCzn64BRrQecGHw==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.19.tgz", + "integrity": "sha512-QIiV1J9d0pzN4jeeTH4sjPy0AZ6cAy2cG0ExeoE1+U8Rvj+hR3gYkokx0YbeUNGlZqiQJJ2utcETe0oKXwzsuA==", "devOptional": true, "license": "MIT", "dependencies": { @@ -3120,21 +3043,22 @@ "node": "^20.19.0 || >=22.12.0" }, "optionalDependencies": { - "@rolldown/binding-android-arm-eabi": "1.2.16", - "@rolldown/binding-android-arm64": "1.2.16", - "@rolldown/binding-darwin-arm64": "1.2.16", - "@rolldown/binding-darwin-x64": "1.2.16", - "@rolldown/binding-freebsd-x64": "1.2.16", - "@rolldown/binding-linux-arm-gnueabihf": "1.2.16", - "@rolldown/binding-linux-arm64-gnu": "1.2.16", - "@rolldown/binding-linux-arm64-musl": "1.2.16", - "@rolldown/binding-linux-ppc64-gnu": "1.2.16", - "@rolldown/binding-linux-s390x-gnu": "1.2.16", - "@rolldown/binding-linux-x64-gnu": "1.2.16", - "@rolldown/binding-linux-x64-musl": "1.2.16", - "@rolldown/binding-openharmony-arm64": "1.2.16", - "@rolldown/binding-win32-arm64-msvc": "1.2.16", - "@rolldown/binding-win32-x64-msvc": "1.2.16" + "@rolldown/binding-android-arm-eabi": "1.2.19", + "@rolldown/binding-android-arm64": "1.2.19", + "@rolldown/binding-darwin-arm64": "1.2.19", + "@rolldown/binding-darwin-x64": "1.2.19", + "@rolldown/binding-freebsd-x64": "1.2.19", + "@rolldown/binding-linux-arm-gnueabihf": "1.2.19", + "@rolldown/binding-linux-arm64-gnu": "1.2.19", + "@rolldown/binding-linux-arm64-musl": "1.2.19", + "@rolldown/binding-linux-ppc64-gnu": "1.2.19", + "@rolldown/binding-linux-s390x-gnu": "1.2.19", + "@rolldown/binding-linux-x64-gnu": "1.2.19", + "@rolldown/binding-linux-x64-musl": "1.2.19", + "@rolldown/binding-openharmony-arm64": "1.2.19", + "@rolldown/binding-wasm32-wasi": "1.2.19", + "@rolldown/binding-win32-arm64-msvc": "1.2.19", + "@rolldown/binding-win32-x64-msvc": "1.2.19" } }, "node_modules/safe-buffer": { @@ -3178,9 +3102,9 @@ "license": "MIT" }, "node_modules/semver": { - "version": "7.8.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", - "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "version": "7.8.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.6.tgz", + "integrity": "sha512-9lpSSU4Mly3mrtruwLs1eLK6+gzbzqeBFwRNjIjE+9LuDpWdYctrQlQ3ej1Ilgi7gknpsTRnPoLP8DpCHqHIJw==", "dev": true, "license": "ISC", "bin": { @@ -3191,9 +3115,9 @@ } }, "node_modules/serve": { - "version": "14.2.6", - "resolved": "https://registry.npmjs.org/serve/-/serve-14.2.6.tgz", - "integrity": "sha512-QEjUSA+sD4Rotm1znR8s50YqA3kYpRGPmtd5GlFxbaL9n/FdUNbqMhxClqdditSk0LlZyA/dhud6XNRTOC9x2Q==", + "version": "14.2.8", + "resolved": "https://registry.npmjs.org/serve/-/serve-14.2.8.tgz", + "integrity": "sha512-7or7YqR3zXwHhiBGj40l9yODyQY146O+hXKaEAfQYQkcvHtMDdX95K96xr50qL9EjXScyYVJb1NIgVE8F0i5cA==", "dev": true, "license": "MIT", "dependencies": { @@ -3203,10 +3127,10 @@ "boxen": "7.0.0", "chalk": "5.0.1", "chalk-template": "0.4.0", - "clipboardy": "3.0.0", - "compression": "1.8.1", + "compression": "1.8.2", "is-port-reachable": "4.0.0", "serve-handler": "6.1.7", + "tinyclip": "^0.1.12", "update-check": "1.5.4" }, "bin": { @@ -3240,9 +3164,9 @@ "license": "MIT" }, "node_modules/serve-handler/node_modules/brace-expansion": { - "version": "1.1.21", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.21.tgz", - "integrity": "sha512-9zeA+KLZNNzglF2TPKRQEDyx6Yby7daAkuy8MiPzpXPsYDWi/DRM8jmwUDxokQjYqBpv5DgPiwD4h4ZZSy1Ujw==", + "version": "1.1.22", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.22.tgz", + "integrity": "sha512-CKLDTuSsN0+r1ThM0WkzzBI7dnPI6xEGfa/JnVYIK9JNBA1N1NyPwXVHor//NKD/y3sDxp764sZdLhFK7pH8XQ==", "dev": true, "license": "MIT", "dependencies": { @@ -3286,43 +3210,13 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, - "license": "MIT", - "dependencies": { - "shebang-regex": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/signal-exit": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", - "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", - "dev": true, - "license": "ISC" - }, "node_modules/source-map-js": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz", - "integrity": "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.4.tgz", + "integrity": "sha512-J7ZjMvHd9O1fcT/5V09QWaaSl2BbWx3F6O08spde82Namf9UB0GxRVIPiNbVsdKkoizHiSpTodo3vp2bAy91MA==", "license": "BSD-3-Clause", "engines": { - "node": ">=0.10.0" + "node": ">=6.0.0" } }, "node_modules/std-env": { @@ -3366,16 +3260,6 @@ "url": "https://github.com/chalk/strip-ansi?sponsor=1" } }, - "node_modules/strip-final-newline": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", - "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/strip-json-comments": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", @@ -3409,6 +3293,16 @@ "node": ">=20.0.0" } }, + "node_modules/tinyclip": { + "version": "0.1.15", + "resolved": "https://registry.npmjs.org/tinyclip/-/tinyclip-0.1.15.tgz", + "integrity": "sha512-uo33abH+Ays0xYaDysoBt494Hb3hsEczMpcC0MwFl773pazORx4fmvKhclhR1wonUbB6vvpRsvVMwnhfqeMc+A==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^16.14.0 || >= 17.3.0" + } + }, "node_modules/tinyexec": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.3.1.tgz", @@ -3446,29 +3340,29 @@ } }, "node_modules/tldts": { - "version": "7.4.19", - "resolved": "https://registry.npmjs.org/tldts/-/tldts-7.4.19.tgz", - "integrity": "sha512-48dH6aSpQnpbzDUc4vIQZ1VjB8tkK+e8c1yx05/SZK+rkssgjEOlxDd/yU8/a4vGYQ9vRgJr9dwMq9TJ0b3X2Q==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/tldts/-/tldts-7.5.4.tgz", + "integrity": "sha512-Rn2ABgjHZrA+jzqom5zhxA0hLohzYrIgfCPyhpTUxqsUrcsBYuab49LseR9waB9Jr8/MxdodvMHA91oRiGLO3Q==", "dev": true, "license": "MIT", "dependencies": { - "tldts-core": "^7.4.19" + "tldts-core": "^7.5.4" }, "bin": { "tldts": "bin/cli.js" } }, "node_modules/tldts-core": { - "version": "7.4.20", - "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-7.4.20.tgz", - "integrity": "sha512-C630TWXZCZmLq0F2bW4QqwnaaxCQ/svpAqvJwnC4JvgEM5ohhBnGsEzTLSOXcN+xjz+kEaHS5uoWIw2klnqd0A==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-7.5.4.tgz", + "integrity": "sha512-9+4zWtKEDZ3V3FoZ1B97rv+5z5oqp7yeXGVze3CxgQ+CJro9do9DCPD00wxstYZDXDMXsurkBerFfiB6GYtPbA==", "dev": true, "license": "MIT" }, "node_modules/tough-cookie": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-6.0.2.tgz", - "integrity": "sha512-exgYmnmL/sJpR3upZfXG5PoatXQii55xAiXGXzY+sROLZ/Y+SLcp9PgJNI9Vz37HpQ74WvDcLT8eqm+kV3FzrA==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-6.1.0.tgz", + "integrity": "sha512-FTxc8u8Kl2tz0Lat1u8ksvcy8bwHRyEMawwTWybo51JqaC6O7SvfuhAKg+Ld6VqyIe2QRJBzY9HA7y2WyFRT2w==", "dev": true, "license": "BSD-3-Clause", "dependencies": { @@ -3491,6 +3385,13 @@ "node": "^22.14.0 || >=24.0.0" } }, + "node_modules/tslib": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.9.1.tgz", + "integrity": "sha512-a4Ux9VKuIMHsOS7ENbEq6hK2ZGYIT27Rtl0E4eD9KqwxhKiQeMZE/9xb3IdYwWaSOyIBQLExhQgXDTYoiCxnWA==", + "license": "0BSD", + "optional": true + }, "node_modules/tunnel": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", @@ -3589,16 +3490,16 @@ } }, "node_modules/vite": { - "version": "8.3.5", - "resolved": "https://registry.npmjs.org/vite/-/vite-8.3.5.tgz", - "integrity": "sha512-z1YpjieJ9g0ebTmQpLBv/oq9E3F9EIlOe+7LahW8SrE3LTiG3udBRUXQOlYXP9b+IC2q2phHeVxj9xGlw34OEQ==", + "version": "8.3.8", + "resolved": "https://registry.npmjs.org/vite/-/vite-8.3.8.tgz", + "integrity": "sha512-LzOn3h9rG/0vhLdXrV4yJ4QFA9eEoqCl+Yx+kGJd7aB9w6nfNgVHKSYwLPZUHrz4ZGa+t+kXjV9itvcHDLQouA==", "devOptional": true, "license": "MIT", "dependencies": { "lightningcss": "^1.33.0", "picomatch": "^4.0.7", - "postcss": "^8.5.30", - "rolldown": "~1.2.14", + "postcss": "^8.5.32", + "rolldown": "~1.2.18", "tinyglobby": "^0.2.17" }, "bin": { @@ -3667,14 +3568,14 @@ } }, "node_modules/vitest": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/vitest/-/vitest-5.0.5.tgz", - "integrity": "sha512-cPODOMF8YnkiiYtDdHo6n4wWmBrOBBbOIYH2d33M4l3CdNn72h+qMmO6uXffUN6A5AZFXNND/d+krS9mgkXRfg==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-5.1.0.tgz", + "integrity": "sha512-MzmNFnrwa8v8lF1bLxw3UJ4EREwVOVb75VqJZmUDRjJ6EluK/x9th7qTbaeDk41WxE1GxWqmTXcdsfobfH5sOA==", "dev": true, "license": "MIT", "dependencies": { "@types/chai": "^5.2.2", - "@vitest/mocker": "5.0.5", + "@vitest/mocker": "5.1.0", "chai": "^6.3.0", "es-module-lexer": "^2.3.2", "expect-type": "^1.4.0", @@ -3700,12 +3601,12 @@ "@edge-runtime/vm": "*", "@opentelemetry/api": "^1.9.0", "@types/node": "^22.0.0 || >=24.0.0", - "@vitest/browser-playwright": "5.0.5", - "@vitest/browser-preview": "5.0.5", + "@vitest/browser-playwright": "5.1.0", + "@vitest/browser-preview": "5.1.0", "@vitest/browser-webdriverio": "^5.0.0-beta.5 || >=5.0.0", - "@vitest/coverage-istanbul": "5.0.5", - "@vitest/coverage-v8": "5.0.5", - "@vitest/ui": "5.0.5", + "@vitest/coverage-istanbul": "5.1.0", + "@vitest/coverage-v8": "5.1.0", + "@vitest/ui": "5.1.0", "happy-dom": "*", "jsdom": "*", "vite": "^6.4.0 || ^7.0.0 || ^8.0.0" @@ -3750,16 +3651,16 @@ } }, "node_modules/vue": { - "version": "3.5.45", - "resolved": "https://registry.npmjs.org/vue/-/vue-3.5.45.tgz", - "integrity": "sha512-3cvsib8m9c0vB24+MDKsgcW4+Da4xaBl9Z/5Tbm2pmSIsRPxcil4cdXjXlVsmJ2g64XJo5h+IRd7rsdGT9pZaw==", + "version": "3.5.46", + "resolved": "https://registry.npmjs.org/vue/-/vue-3.5.46.tgz", + "integrity": "sha512-0kW5CgfjMPBqmH158049SaE1muufp+K/ZyrwvSEwrwYky6QB7zL2y8kXfruneKb9O12eh0xAJL6CVSpzb9o0Kg==", "license": "MIT", "dependencies": { - "@vue/compiler-dom": "3.5.45", - "@vue/compiler-sfc": "3.5.45", - "@vue/runtime-dom": "3.5.45", - "@vue/server-renderer": "3.5.45", - "@vue/shared": "3.5.45" + "@vue/compiler-dom": "3.5.46", + "@vue/compiler-sfc": "3.5.46", + "@vue/runtime-dom": "3.5.46", + "@vue/server-renderer": "3.5.46", + "@vue/shared": "3.5.46" }, "peerDependencies": { "typescript": "*" @@ -3778,14 +3679,14 @@ "license": "MIT" }, "node_modules/vue-i18n": { - "version": "11.4.18", - "resolved": "https://registry.npmjs.org/vue-i18n/-/vue-i18n-11.4.18.tgz", - "integrity": "sha512-NMPOTrqSUVPJxSuiYi0uJ2q0bZovoGuQb13hY9lR+ywb/FOtJRoXqxPRcO/64CDed4tkk9lZ6hRPG7HBP1nxvg==", + "version": "11.4.23", + "resolved": "https://registry.npmjs.org/vue-i18n/-/vue-i18n-11.4.23.tgz", + "integrity": "sha512-O+H2L/LF9xzklv2PZEqYAaG0rrbQokm6aX6/gPDxdtokBSDhKm+lvEPVbC3hXdvKpN5ICSBWigIkJ06AzCs3Lw==", "license": "MIT", "dependencies": { - "@intlify/core-base": "11.4.18", - "@intlify/devtools-types": "11.4.18", - "@intlify/shared": "11.4.18", + "@intlify/core-base": "11.4.23", + "@intlify/devtools-types": "11.4.23", + "@intlify/shared": "11.4.23", "@vue/devtools-api": "^6.5.0" }, "engines": { @@ -3799,18 +3700,18 @@ } }, "node_modules/vue-router": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-5.4.0.tgz", - "integrity": "sha512-pFvcYcxinDHjZUlf7AzFBrT8r8Xqvv4uMHoJnjc+EqPawXQvHTkF8S4tfSmQLpriVHUGfkaKlI7Et0KRjTMTdw==", + "version": "5.5.1", + "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-5.5.1.tgz", + "integrity": "sha512-lUENd/QIhKd2HWACnXID3us0GWBnuOi3BwkTUzce2+4nfM/b3seV5saNURM9+wt48/qUxviotpcm7yFxC0U4qA==", "license": "MIT", "dependencies": { - "@vue-macros/common": "^3.1.3", - "@vue/devtools-api": "^8.1.5", + "@vue-macros/common": "^3.1.4", + "@vue/devtools-api": "^8.2.1", "ast-walker-scope": "^0.10.0", - "chokidar": "^5.0.0", - "confbox": "^0.3.1", - "local-pkg": "^1.2.1", - "magic-string": "^1.4.3", + "chokidar": "^6.0.0", + "confbox": "^0.3.2", + "local-pkg": "^2.0.0", + "magic-string": "^1.4.5", "mlly": "^1.8.2", "muggle-string": "^0.4.1", "nostics": "^1.3.0", @@ -3818,7 +3719,7 @@ "picomatch": "^4.0.7", "scule": "^1.3.0", "tinyglobby": "^0.2.17", - "unplugin": "^3.4.0", + "unplugin": "^3.7.0", "unplugin-utils": "^0.3.2" }, "funding": { @@ -3977,22 +3878,6 @@ "node": "^22.14.0 || >=24.0.0" } }, - "node_modules/which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "license": "ISC", - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "node-which": "bin/node-which" - }, - "engines": { - "node": ">= 8" - } - }, "node_modules/why-is-node-running": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-3.2.1.tgz", diff --git a/package.json b/package.json index a7265bdc9d1..d3d7a4423f2 100644 --- a/package.json +++ b/package.json @@ -4,13 +4,13 @@ "description": "Prebuilt web UI assets for the Sunshine game-stream host", "license": "GPL-3.0-only", "funding": "https://app.lizardbyte.dev", - "homepage": "https://app.lizardbyte.dev/Sunshine", + "homepage": "https://sunshine.lizardbyte.dev", "repository": { "type": "git", - "url": "git+https://github.com/LizardByte/Sunshine.git" + "url": "git+https://github.com/SunshineStream/Sunshine.git" }, "bugs": { - "url": "https://github.com/LizardByte/Sunshine/issues" + "url": "https://github.com/SunshineStream/Sunshine/issues" }, "files": [ "build/assets/web/" @@ -24,25 +24,25 @@ }, "type": "module", "dependencies": { - "@intlify/message-compiler": "11.4.18", - "@lucide/vue": "1.70.0", - "bootstrap": "5.3.8", + "@intlify/message-compiler": "11.4.23", + "@lucide/vue": "1.76.0", + "bootstrap": "5.3.9", "date-fns": "4.4.0", "marked": "18.0.12", - "vue": "3.5.45", - "vue-i18n": "11.4.18", - "vue-router": "5.4.0", + "vue": "3.5.46", + "vue-i18n": "11.4.23", + "vue-router": "5.5.1", "vue3-simple-icons": "16.10.0" }, "devDependencies": { "@codecov/vite-plugin": "2.0.1", - "@vitejs/plugin-vue": "6.0.10", - "@vitest/coverage-v8": "5.0.5", - "@vue/test-utils": "2.5.1", - "jsdom": "31.0.0", - "serve": "14.2.6", - "vite": "8.3.5", - "vitest": "5.0.5" + "@vitejs/plugin-vue": "6.0.11", + "@vitest/coverage-v8": "5.1.0", + "@vue/test-utils": "2.6.0", + "jsdom": "31.0.1", + "serve": "14.2.8", + "vite": "8.3.8", + "vitest": "5.1.0" }, "overrides": { "@codecov/vite-plugin": { diff --git a/packaging/linux/Alpine/APKBUILD b/packaging/linux/Alpine/APKBUILD index 2b302987ef0..5384fc2195b 100644 --- a/packaging/linux/Alpine/APKBUILD +++ b/packaging/linux/Alpine/APKBUILD @@ -1,4 +1,4 @@ -# Edit on GitHub: https://github.com/LizardByte/Sunshine/blob/master/packaging/linux/Alpine/APKBUILD +# Edit on GitHub: https://github.com/SunshineStream/Sunshine/blob/master/packaging/linux/Alpine/APKBUILD # Reference: https://wiki.alpinelinux.org/wiki/APKBUILD_Reference : "${_run_unit_tests:=false}" # Run the test suite and generate coverage; useful in CI. diff --git a/packaging/linux/Arch/PKGBUILD b/packaging/linux/Arch/PKGBUILD index 019b5249f91..4eaee277302 100644 --- a/packaging/linux/Arch/PKGBUILD +++ b/packaging/linux/Arch/PKGBUILD @@ -1,4 +1,4 @@ -# Edit on github: https://github.com/LizardByte/Sunshine/blob/master/packaging/linux/Arch/PKGBUILD +# Edit on github: https://github.com/SunshineStream/Sunshine/blob/master/packaging/linux/Arch/PKGBUILD # Reference: https://wiki.archlinux.org/title/PKGBUILD ## options diff --git a/packaging/linux/copr/Sunshine.spec b/packaging/linux/copr/Sunshine.spec index 73def6b84ce..f96710c4ac8 100644 --- a/packaging/linux/copr/Sunshine.spec +++ b/packaging/linux/copr/Sunshine.spec @@ -20,7 +20,7 @@ Version: %{build_version} Release: 1%{?dist} Summary: Self-hosted game stream host for Moonlight. License: GPLv3-only -URL: https://github.com/LizardByte/Sunshine +URL: https://github.com/SunshineStream/Sunshine Source0: tarball.tar.gz # Common BuildRequires @@ -58,8 +58,8 @@ BuildRequires: boost-devel >= 1.89.0 BuildRequires: boost-static >= 1.89.0 # needed for npm from nvm BuildRequires: libatomic -BuildRequires: xz %endif +BuildRequires: xz BuildRequires: libgudev BuildRequires: mesa-libGL-devel BuildRequires: mesa-libgbm-devel @@ -112,21 +112,19 @@ BuildRequires: gcc13 BuildRequires: gcc13-c++ %global gcc_version 13 %global cuda_version 12.9.1 -%global cuda_build 575.57.08 %elif 0%{?fedora} >= 42 && 0%{?fedora} <= 43 BuildRequires: gcc14 BuildRequires: gcc14-c++ %global gcc_version 14 %global cuda_version 12.9.1 -%global cuda_build 575.57.08 %elif 0%{?fedora} >= 44 BuildRequires: gcc15 BuildRequires: gcc15-c++ %global gcc_version 15 -%global cuda_version 13.1.1 -%global cuda_build 590.48.01 -%global cuda_redist_compiler_version 13.1.115 -%global cuda_redist_runtime_version 13.1.80 +%global cuda_version 13.5.0 +%global cuda_redist_compiler_version 13.5.37 +%global cuda_redist_cccl_version 13.3.5.0.6 +%global cuda_redist_culibos_version 13.5.25 %global cuda_use_redistributables 1 %endif %endif @@ -135,10 +133,10 @@ BuildRequires: gcc15-c++ BuildRequires: gcc15 BuildRequires: gcc15-c++ %global gcc_version 15 -%global cuda_version 13.1.1 -%global cuda_build 590.48.01 -%global cuda_redist_compiler_version 13.1.115 -%global cuda_redist_runtime_version 13.1.80 +%global cuda_version 13.5.0 +%global cuda_redist_compiler_version 13.5.37 +%global cuda_redist_cccl_version 13.3.5.0.6 +%global cuda_redist_culibos_version 13.5.25 %global cuda_use_redistributables 1 %endif @@ -258,10 +256,10 @@ function install_cuda_from_redistributables() { local cuda_components=( "cuda_nvcc:%{cuda_redist_compiler_version}:root" "libnvvm:%{cuda_redist_compiler_version}:root" - "cuda_cccl:%{cuda_redist_compiler_version}:target" + "cccl:%{cuda_redist_cccl_version}:target" "cuda_crt:%{cuda_redist_compiler_version}:target" - "cuda_cudart:%{cuda_redist_runtime_version}:target" - "cuda_culibos:%{cuda_redist_compiler_version}:target" + "cuda_cudart:%{cuda_redist_compiler_version}:target" + "cuda_culibos:%{cuda_redist_culibos_version}:target" "libnvptxcompiler:%{cuda_redist_compiler_version}:target" ) @@ -297,6 +295,68 @@ function install_cuda_from_redistributables() { } %endif +# CUDA 12.9.1 bundled NVVM and CRT with NVCC, and culibos with cudart. +# Names, versions, and checksums: NVIDIA's redistrib_12.9.1.json manifest. +function install_cuda_12_from_redistributables() ( + set -e + local cuda_redist_arch cuda_target_arch nvcc_sha cudart_sha cccl_sha + case "$architecture" in + x86_64) + cuda_redist_arch="linux-x86_64" + cuda_target_arch="x86_64-linux" + nvcc_sha="7a1a5b652e5ef85c82b721d10672fc9a2dbaab44e9bd3c65a69517bf53998c35" + cudart_sha="1f6ad42d4f530b24bfa35894ccf6b7209d2354f59101fd62ec4a6192a184ce99" + cccl_sha="8b1a5095669e94f2f9afd7715533314d418179e9452be61e2fde4c82a3e542aa" + ;; + aarch64) + cuda_redist_arch="linux-sbsa" + cuda_target_arch="sbsa-linux" + nvcc_sha="0aa1fce92dbae76c059c27eefb9d0ffb58e1291151e44ff7c7f1fc2dd9376c0d" + cudart_sha="8b422a3b2cb8452cb678181b0bf9d7aa7342df168b5319c5488ae3b8514101fc" + cccl_sha="8c3da24801b500f1d9217d191bb4b63e5d2096c8e7d0b7695e876853180ba82f" + ;; + *) + return 1 + ;; + esac + + local staging + staging="$(mktemp -d "%{_builddir}/cuda.XXXXXX")" + trap 'rm -rf "$staging"' EXIT + local root_dir="${staging}/toolkit" + local target_dir="${root_dir}/targets/${cuda_target_arch}" + mkdir -p "${target_dir}" "${root_dir}/licenses" + + local components=( + "cuda_nvcc:12.9.86:${nvcc_sha}:root" + "cuda_cudart:12.9.79:${cudart_sha}:target" + "cuda_cccl:12.9.27:${cccl_sha}:target" + ) + local component + for component in "${components[@]}"; do + local name version checksum destination + IFS=: read -r name version checksum destination <<< "${component}" + local archive="${name}-${cuda_redist_arch}-${version}-archive.tar.xz" + local url="https://developer.download.nvidia.com/compute/cuda/redist/${name}/${cuda_redist_arch}/${archive}" + local extract_dir="${target_dir}" + if [[ "${destination}" == root ]]; then + extract_dir="${root_dir}" + fi + + echo "cuda component url: ${url}" + wget "${url}" --progress=bar:force:noscroll --retry-connrefused --tries=3 \ + -q -O "${staging}/${archive}" + sha256sum --check --strict <<< "${checksum} ${staging}/${archive}" + tar -xJf "${staging}/${archive}" --directory="${extract_dir}" --strip-components=1 + mv "${extract_dir}/LICENSE" "${root_dir}/licenses/${name}.txt" + rm "${staging}/${archive}" + done + + # NVCC 12 ships its CRT headers at the archive root but looks under the target. + cp -a "${root_dir}/include/." "${target_dir}/include/" + mv -T "${root_dir}" "%{cuda_dir}" +) + function install_cuda() { # check if we need to install cuda if [ -f "%{cuda_dir}/bin/nvcc" ]; then @@ -307,55 +367,16 @@ function install_cuda() { %if 0%{?cuda_use_redistributables} install_cuda_from_redistributables %else - local cuda_prefix="https://developer.download.nvidia.com/compute/cuda/" - local cuda_suffix="" - if [ "$architecture" == "aarch64" ]; then - local cuda_suffix="_sbsa" - fi - - local url="${cuda_prefix}%{cuda_version}/local_installers/cuda_%{cuda_version}_%{cuda_build}_linux${cuda_suffix}.run" - echo "cuda url: ${url}" - wget \ - "$url" \ - --progress=bar:force:noscroll \ - --retry-connrefused \ - --tries=3 \ - -q -O "%{_builddir}/cuda.run" - chmod a+x "%{_builddir}/cuda.run" - "%{_builddir}/cuda.run" \ - --no-drm \ - --no-man-page \ - --no-opengl-libs \ - --override \ - --silent \ - --toolkit \ - --toolkitpath="%{cuda_dir}" - rm "%{_builddir}/cuda.run" + install_cuda_12_from_redistributables %endif - # we need to patch math_functions.h depending on the CUDA major version - # see https://forums.developer.nvidia.com/t/error-exception-specification-is-incompatible-for-cospi-sinpi-cospif-sinpif-with-glibc-2-41/323591/3 - local cuda_major - cuda_major=$(echo "%{cuda_version}" | cut -d. -f1) - local patch_file="" - if [ "${cuda_major}" -eq 12 ]; then - # CUDA 12.x: the extern declarations lack noexcept(true); add it to match glibc 2.41. - patch_file="cuda-12-math_functions.patch" - elif [ "${cuda_major}" -eq 13 ]; then - # CUDA 13.x: the extern declarations already have noexcept(true), but the __func__() - # macro invocations at the bottom still lack it, causing a redeclaration conflict. - patch_file="cuda-13-math_functions.patch" - else - echo "Warning: no math_functions.h patch available for CUDA ${cuda_major}.x, skipping." - fi - - if [ -n "${patch_file}" ]; then - echo "Applying CUDA patch: ${patch_file}" + # CUDA 12 needs the glibc 2.41 exception-specifier workaround. CUDA 13.5 already supplies it. + if [[ "%{cuda_version}" == 12.* ]]; then patch -p2 \ --backup \ --directory="%{cuda_dir}" \ --verbose \ - < "%{_builddir}/Sunshine/packaging/linux/patches/${architecture}/${patch_file}" + < "%{_builddir}/Sunshine/packaging/linux/patches/${architecture}/cuda-12-math_functions.patch" fi } diff --git a/packaging/linux/dev.lizardbyte.app.Sunshine.metainfo.xml b/packaging/linux/dev.lizardbyte.app.Sunshine.metainfo.xml index 3be80304555..9176a3760ab 100644 --- a/packaging/linux/dev.lizardbyte.app.Sunshine.metainfo.xml +++ b/packaging/linux/dev.lizardbyte.app.Sunshine.metainfo.xml @@ -16,7 +16,7 @@ @PROJECT_HOMEPAGE_URL@ - https://github.com/LizardByte/Sunshine/issues + https://github.com/SunshineStream/Sunshine/issues https://docs.lizardbyte.dev/projects/sunshine/latest/md_docs_2troubleshooting.html https://docs.lizardbyte.dev/projects/sunshine https://app.lizardbyte.dev/#Donate @@ -35,7 +35,7 @@ - https://github.com/LizardByte/Sunshine/releases/tag/v@PROJECT_VERSION@ + https://github.com/SunshineStream/Sunshine/releases/tag/v@PROJECT_VERSION@

See the changelog on GitHub

@@ -47,7 +47,7 @@ - https://app.lizardbyte.dev/Sunshine/assets/img/screenshots/01-sunshine-welcome-page.png + https://sunshine.lizardbyte.dev/assets/sunshine-web-ui-light.jpg Sunshine welcome page diff --git a/packaging/linux/flatpak/README.md b/packaging/linux/flatpak/README.md index 684f986e65e..8969c29d957 100644 --- a/packaging/linux/flatpak/README.md +++ b/packaging/linux/flatpak/README.md @@ -1,5 +1,5 @@
- +

Sunshine

Self-hosted game stream host for Moonlight.

@@ -18,5 +18,5 @@ LizardByte has the full documentation hosted on [Read the Docs](https://docs.liz * [Stable](https://docs.lizardbyte.dev/projects/sunshine/latest/) * [Beta](https://docs.lizardbyte.dev/projects/sunshine/master/) -This repo is synced from the upstream [Sunshine](https://github.com/LizardByte/Sunshine) repo. +This repo is synced from the upstream [Sunshine](https://github.com/SunshineStream/Sunshine) repo. Please report issues and contribute to the upstream repo. diff --git a/packaging/linux/flatpak/dev.lizardbyte.app.Sunshine.yml b/packaging/linux/flatpak/dev.lizardbyte.app.Sunshine.yml index 951def77498..eee204aadfe 100644 --- a/packaging/linux/flatpak/dev.lizardbyte.app.Sunshine.yml +++ b/packaging/linux/flatpak/dev.lizardbyte.app.Sunshine.yml @@ -24,6 +24,7 @@ finish-args: - --socket=fallback-x11 # show windows using X11 - --system-talk-name=org.freedesktop.Avahi # talk to avahi on the system bus - --talk-name=org.freedesktop.Flatpak # talk to flatpak on the session bus + - --talk-name=org.kde.KWin # assign virtual touch and pen devices to the streamed output - --talk-name=org.kde.StatusNotifierWatcher # talk to system tray on the session bus cleanup: @@ -50,7 +51,7 @@ modules: # WebRTC transport; flatpak-builder has no network, so CMake's FetchContent fallback cannot be used here - "modules/libdatachannel.json" - # Caching is configured until here, not including CUDA, since it is too large for GitHub cache + # CI caches the modules above and starts the next build stage at CUDA. - "modules/cuda.json" # FFmpeg prebuilt binaries @@ -95,6 +96,16 @@ modules: - -DSUNSHINE_PUBLISHER_NAME='LizardByte' - -DSUNSHINE_PUBLISHER_WEBSITE='https://app.lizardbyte.dev' - -DSUNSHINE_PUBLISHER_ISSUE_URL='https://app.lizardbyte.dev/support' + # Use the sources that Flatpak Builder stages from modules/sunshine/. + - -DCPM_glad_SOURCE=/run/build/sunshine/flatpak-cpm/glad + - -DCPM_libdisplaydevice_SOURCE=/run/build/sunshine/flatpak-cpm/libdisplaydevice + - -DCPM_libvirtualhid_SOURCE=/run/build/sunshine/flatpak-cpm/libvirtualhid + - -DCPM_moonlight-common-c_SOURCE=/run/build/sunshine/flatpak-cpm/moonlight-common-c + - -DCPM_plasma_wayland_protocols_SOURCE=/run/build/sunshine/flatpak-cpm/plasma_wayland_protocols + - -DCPM_simple_web_server_SOURCE=/run/build/sunshine/flatpak-cpm/simple_web_server + - -DCPM_tray_SOURCE=/run/build/sunshine/flatpak-cpm/tray + - -DCPM_wayland_protocols_SOURCE=/run/build/sunshine/flatpak-cpm/wayland_protocols + - -DCPM_wlr_protocols_SOURCE=/run/build/sunshine/flatpak-cpm/wlr_protocols no-make-install: false post-install: - install -D $FLATPAK_BUILDER_BUILDDIR/packaging/linux/flatpak/scripts/* /app/bin @@ -108,5 +119,14 @@ modules: - type: git url: "@GITHUB_CLONE_URL@" commit: "@GITHUB_COMMIT@" + - modules/sunshine/glad.json + - modules/sunshine/libdisplaydevice.json + - modules/sunshine/libvirtualhid.json + - modules/sunshine/moonlight-common-c.json + - modules/sunshine/plasma-wayland-protocols.json + - modules/sunshine/simple-web-server.json + - modules/sunshine/tray.json + - modules/sunshine/wayland-protocols.json + - modules/sunshine/wlr-protocols.json - type: file path: package-lock.json diff --git a/packaging/linux/flatpak/modules/avahi.json b/packaging/linux/flatpak/modules/avahi.json index faa4cc6ee4f..7dc03e18484 100644 --- a/packaging/linux/flatpak/modules/avahi.json +++ b/packaging/linux/flatpak/modules/avahi.json @@ -32,9 +32,14 @@ "sources": [ { "type": "git", + "x-renovate": { + "datasource": "github-tags", + "depName": "avahi/avahi", + "versioning": "regex:^v(?[0-9]+)[.](?[0-9]+)(?:[.](?[0-9]+))?$" + }, "url": "https://github.com/avahi/avahi.git", - "commit": "f060abee2807c943821d88839c013ce15db17b58", "tag": "v0.8", + "commit": "f060abee2807c943821d88839c013ce15db17b58", "x-checker-data": { "type": "git", "tag-pattern": "^v([\\d.]+)$" diff --git a/packaging/linux/flatpak/modules/boost.json b/packaging/linux/flatpak/modules/boost.json index 1901fc2b3e3..c98131d081a 100644 --- a/packaging/linux/flatpak/modules/boost.json +++ b/packaging/linux/flatpak/modules/boost.json @@ -9,8 +9,19 @@ "sources": [ { "type": "archive", + "x-renovate": { + "datasource": "github-release-attachments", + "depName": "boostorg/boost", + "versioning": "regex:^boost-(?[0-9]+)[.](?[0-9]+)[.](?[0-9]+)(?[.][A-Za-z0-9.-]+)?$" + }, "url": "https://github.com/boostorg/boost/releases/download/boost-1.92.0/boost-1.92.0-cmake.tar.xz", - "sha256": "9bed76128d4e46755dbe818487788c6fceb6f72b378f4daa49b7e1e600d9088d" + "sha256": "9bed76128d4e46755dbe818487788c6fceb6f72b378f4daa49b7e1e600d9088d", + "x-checker-data": { + "type": "json", + "url": "https://api.github.com/repos/boostorg/boost/releases?per_page=30", + "version-query": "map(select((.draft or .prerelease | not) and (.tag_name | test(\"^boost-[0-9]+[.][0-9]+[.][0-9]+$\")))) | first | .tag_name", + "url-query": ".[] | select(.tag_name == $version) | .assets[] | select(.name == ($version + \"-cmake.tar.xz\")) | .browser_download_url" + } } ] } diff --git a/packaging/linux/flatpak/modules/cuda.json b/packaging/linux/flatpak/modules/cuda.json index f7e0e9c2585..b8daa83bc76 100644 --- a/packaging/linux/flatpak/modules/cuda.json +++ b/packaging/linux/flatpak/modules/cuda.json @@ -1,60 +1,157 @@ { "name": "cuda", "build-options": { - "no_debuginfo": true, - "prepend-ld-library-path": "/app/lib:/app/lib64" + "no_debuginfo": true }, "buildsystem": "simple", "cleanup": [ "*" ], "build-commands": [ - "chmod u+x ./cuda.run", - "./cuda.run --silent --toolkit --toolkitpath=$FLATPAK_DEST/cuda --no-opengl-libs --no-man-page --no-drm --tmpdir=$FLATPAK_BUILDER_BUILDDIR || { echo '=== cuda-installer.log ==='; cat /tmp/cuda-installer.log 2>/dev/null; true; }", - "test -f $FLATPAK_DEST/cuda/bin/nvcc", - "rm -rf $FLATPAK_DEST/cuda/nsight-systems-*", - "rm ./cuda.run" - ], - "modules": [ - { - "name": "libxml2", - "config-opts": [ - "--without-python", - "--without-debug", - "--without-history" - ], - "cleanup": [ - "/share", - "/include", - "/bin" - ], - "sources": [ - { - "type": "archive", - "url": "https://download.gnome.org/sources/libxml2/2.13/libxml2-2.13.9.tar.xz", - "sha256": "a2c9ae7b770da34860050c309f903221c67830c86e4a7e760692b803df95143a" - } - ] - } + "set -eu; case \"$FLATPAK_ARCH\" in x86_64) target=x86_64-linux ;; aarch64) target=sbsa-linux ;; *) echo \"Unsupported CUDA Flatpak architecture: $FLATPAK_ARCH\" >&2; exit 1 ;; esac; mv cuda/include/fatbinary_section.h \"cuda/targets/$target/include/\"", + "test -x cuda/bin/nvcc", + "mv cuda \"$FLATPAK_DEST/\"" ], "sources": [ { - "type": "file", + "type": "archive", + "only-arches": [ + "x86_64" + ], + "url": "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvcc/linux-x86_64/cuda_nvcc-linux-x86_64-13.5.37-archive.tar.xz", + "sha256": "ac41262734f3c62cd75a502081cfae093b03b846d7f9274d8b1eb41f83209b96", + "dest": "cuda", + "strip-components": 1 + }, + { + "type": "archive", + "only-arches": [ + "x86_64" + ], + "url": "https://developer.download.nvidia.com/compute/cuda/redist/libnvvm/linux-x86_64/libnvvm-linux-x86_64-13.5.37-archive.tar.xz", + "sha256": "8dd4866e387f0ce2259e8dcc91bebdbb59f84c6d4505b3bba46ae91b9a11dd16", + "dest": "cuda", + "strip-components": 1 + }, + { + "type": "archive", + "only-arches": [ + "x86_64" + ], + "url": "https://developer.download.nvidia.com/compute/cuda/redist/cccl/linux-x86_64/cccl-linux-x86_64-13.3.5.0.6-archive.tar.xz", + "sha256": "5139f641e72df6b0c64ee9e68cabaeafa9a5e36a4b1f7d370a1dc0dac62dd72f", + "dest": "cuda/targets/x86_64-linux", + "strip-components": 1 + }, + { + "type": "archive", + "only-arches": [ + "x86_64" + ], + "url": "https://developer.download.nvidia.com/compute/cuda/redist/cuda_crt/linux-x86_64/cuda_crt-linux-x86_64-13.5.37-archive.tar.xz", + "sha256": "0df5c0ca27392152f370751c82b27ff1ab67661e4810cfc7248e2e03479c9ae0", + "dest": "cuda/targets/x86_64-linux", + "strip-components": 1 + }, + { + "type": "archive", + "only-arches": [ + "x86_64" + ], + "url": "https://developer.download.nvidia.com/compute/cuda/redist/cuda_cudart/linux-x86_64/cuda_cudart-linux-x86_64-13.5.37-archive.tar.xz", + "sha256": "26ca1b8963ce1b73e0e77113c711730545cacaaee7233c0526477d96d4c621fe", + "dest": "cuda/targets/x86_64-linux", + "strip-components": 1 + }, + { + "type": "archive", + "only-arches": [ + "x86_64" + ], + "url": "https://developer.download.nvidia.com/compute/cuda/redist/cuda_culibos/linux-x86_64/cuda_culibos-linux-x86_64-13.5.25-archive.tar.xz", + "sha256": "4c03a0e737f474923823687c93b43a0727e424dcbc53eb44fb116995c87df713", + "dest": "cuda/targets/x86_64-linux", + "strip-components": 1 + }, + { + "type": "archive", "only-arches": [ "x86_64" ], - "url": "https://developer.download.nvidia.com/compute/cuda/13.2.0/local_installers/cuda_13.2.0_595.45.04_linux.run", - "sha256": "c599b651582c8f345ebde7bcf089b7dcfcd8afd7d3ea7f50525698c563a239d7", - "dest-filename": "cuda.run" + "url": "https://developer.download.nvidia.com/compute/cuda/redist/libnvptxcompiler/linux-x86_64/libnvptxcompiler-linux-x86_64-13.5.37-archive.tar.xz", + "sha256": "e92761c2c83fdbe1c582aab568e684371c3023e88b7b4c6fb3d92e3feb160b67", + "dest": "cuda/targets/x86_64-linux", + "strip-components": 1 + }, + { + "type": "archive", + "only-arches": [ + "aarch64" + ], + "url": "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvcc/linux-sbsa/cuda_nvcc-linux-sbsa-13.5.37-archive.tar.xz", + "sha256": "0c6756fdda5a4c5159dc5181788bd68c9d261e71d6f299ebb241185e113254a3", + "dest": "cuda", + "strip-components": 1 + }, + { + "type": "archive", + "only-arches": [ + "aarch64" + ], + "url": "https://developer.download.nvidia.com/compute/cuda/redist/libnvvm/linux-sbsa/libnvvm-linux-sbsa-13.5.37-archive.tar.xz", + "sha256": "6c79308860d5eb47c6dd3693652a4d7cd430050438d31d5f036aa0b19583f2ea", + "dest": "cuda", + "strip-components": 1 + }, + { + "type": "archive", + "only-arches": [ + "aarch64" + ], + "url": "https://developer.download.nvidia.com/compute/cuda/redist/cccl/linux-sbsa/cccl-linux-sbsa-13.3.5.0.6-archive.tar.xz", + "sha256": "c308969d8ad6de704c3f8be9ccf5ff2c9b40dd6e23b43b6e4057d255779d5ada", + "dest": "cuda/targets/sbsa-linux", + "strip-components": 1 + }, + { + "type": "archive", + "only-arches": [ + "aarch64" + ], + "url": "https://developer.download.nvidia.com/compute/cuda/redist/cuda_crt/linux-sbsa/cuda_crt-linux-sbsa-13.5.37-archive.tar.xz", + "sha256": "65d373eead42f1544363027c9ee3e6e6eb223c27743749e84ce1e9595bc71b33", + "dest": "cuda/targets/sbsa-linux", + "strip-components": 1 + }, + { + "type": "archive", + "only-arches": [ + "aarch64" + ], + "url": "https://developer.download.nvidia.com/compute/cuda/redist/cuda_cudart/linux-sbsa/cuda_cudart-linux-sbsa-13.5.37-archive.tar.xz", + "sha256": "9da80d6aa87f5bc46971c1343024f30a850aca9aac03da95219880aaf854154f", + "dest": "cuda/targets/sbsa-linux", + "strip-components": 1 + }, + { + "type": "archive", + "only-arches": [ + "aarch64" + ], + "url": "https://developer.download.nvidia.com/compute/cuda/redist/cuda_culibos/linux-sbsa/cuda_culibos-linux-sbsa-13.5.25-archive.tar.xz", + "sha256": "78d7ce9b78d69196b85fd1bfae591d7c1537393242c3a39e616ca8dfade68a99", + "dest": "cuda/targets/sbsa-linux", + "strip-components": 1 }, { - "type": "file", + "type": "archive", "only-arches": [ "aarch64" ], - "url": "https://developer.download.nvidia.com/compute/cuda/13.2.0/local_installers/cuda_13.2.0_595.45.04_linux_sbsa.run", - "sha256": "9684ebc64988f71ef1c70846cc9d158fb27950c1355bf37c8795c346346b6a72", - "dest-filename": "cuda.run" + "url": "https://developer.download.nvidia.com/compute/cuda/redist/libnvptxcompiler/linux-sbsa/libnvptxcompiler-linux-sbsa-13.5.37-archive.tar.xz", + "sha256": "8f5503e8a7ced0e676ce327eb83f5a1650b59f54d66e6cf704d2d4ee9583eb2d", + "dest": "cuda/targets/sbsa-linux", + "strip-components": 1 } ] } diff --git a/packaging/linux/flatpak/modules/ffmpeg.json b/packaging/linux/flatpak/modules/ffmpeg.json index c3b3c2a0e0b..7555e76b8b2 100644 --- a/packaging/linux/flatpak/modules/ffmpeg.json +++ b/packaging/linux/flatpak/modules/ffmpeg.json @@ -8,6 +8,11 @@ "sources": [ { "type": "file", + "x-renovate": { + "datasource": "github-release-attachments", + "depName": "LizardByte/build-deps", + "versioning": "semver" + }, "url": "https://github.com/LizardByte/build-deps/releases/download/v2026.1017.131201/Linux-x86_64-ffmpeg.tar.gz", "sha256": "b2de5119cb0ab89cb6038acb75299b213f97a0c79d34557068add639511f8815", "dest-filename": "ffmpeg.tar.gz", @@ -23,6 +28,11 @@ }, { "type": "file", + "x-renovate": { + "datasource": "github-release-attachments", + "depName": "LizardByte/build-deps", + "versioning": "semver" + }, "url": "https://github.com/LizardByte/build-deps/releases/download/v2026.1017.131201/Linux-aarch64-ffmpeg.tar.gz", "sha256": "fa6ca8f716922ebd4be222647bf972ec050af145406186787c43bfa0353f0a1d", "dest-filename": "ffmpeg.tar.gz", diff --git a/packaging/linux/flatpak/modules/libevdev.json b/packaging/linux/flatpak/modules/libevdev.json index 394d78b5583..8f766d4661d 100644 --- a/packaging/linux/flatpak/modules/libevdev.json +++ b/packaging/linux/flatpak/modules/libevdev.json @@ -8,9 +8,15 @@ "sources": [ { "type": "git", + "x-renovate": { + "datasource": "github-tags", + "depName": "libevdev/libevdev", + "packageName": "LizardByte-infrastructure/libevdev", + "versioning": "regex:^libevdev-(?[0-9]+)[.](?[0-9]+)[.](?[0-9]{1,2}|[1-8][0-9]{2}|[0-9]{4,})$" + }, "url": "https://github.com/LizardByte-infrastructure/libevdev.git", - "commit": "ac0056961c3332a260db063ab4fccc7747638a1d", - "tag": "libevdev-1.13.4", + "tag": "libevdev-1.14.0", + "commit": "d9af2e4580297e9c14715fef06621dd39d9d8a3a", "x-checker-data": { "type": "anitya", "project-id": 20540, diff --git a/packaging/linux/flatpak/modules/miniupnpc.json b/packaging/linux/flatpak/modules/miniupnpc.json index 9920633c62f..be3d61b484d 100644 --- a/packaging/linux/flatpak/modules/miniupnpc.json +++ b/packaging/linux/flatpak/modules/miniupnpc.json @@ -13,9 +13,14 @@ "sources": [ { "type": "git", + "x-renovate": { + "datasource": "github-tags", + "depName": "miniupnp/miniupnp", + "versioning": "regex:^miniupnpc_(?[0-9]+)_(?[0-9]+)_(?[0-9]+)$" + }, "url": "https://github.com/miniupnp/miniupnp.git", - "tag": "miniupnpc_2_3_3", - "commit": "bf4215a7574f88aa55859db9db00e3ae58cf42d6", + "tag": "miniupnpc_2_3_5", + "commit": "e1db7c47295d38b2b416c892779dae9afa434016", "x-checker-data": { "type": "anitya", "project-id": 1986, diff --git a/packaging/linux/flatpak/modules/nlohmann_json.json b/packaging/linux/flatpak/modules/nlohmann_json.json index 158f8b5bc87..3cbce31955e 100644 --- a/packaging/linux/flatpak/modules/nlohmann_json.json +++ b/packaging/linux/flatpak/modules/nlohmann_json.json @@ -8,8 +8,18 @@ "sources": [ { "type": "archive", - "url": "https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz", - "sha256": "d6c65aca6b1ed68e7a182f4757257b107ae403032760ed6ef121c9d55e81757d" + "x-renovate": { + "datasource": "github-release-attachments", + "depName": "nlohmann/json", + "versioning": "semver" + }, + "url": "https://github.com/nlohmann/json/releases/download/v3.12.0/json.tar.xz", + "sha256": "42f6e95cad6ec532fd372391373363b62a14af6d771056dbfc86160e6dfff7aa", + "x-checker-data": { + "type": "github", + "repo": "nlohmann/json", + "asset-name": "json.tar.xz" + } } ] } diff --git a/packaging/linux/flatpak/modules/numactl.json b/packaging/linux/flatpak/modules/numactl.json index b0a48beaa25..d85b1fc0946 100644 --- a/packaging/linux/flatpak/modules/numactl.json +++ b/packaging/linux/flatpak/modules/numactl.json @@ -3,6 +3,11 @@ "sources": [ { "type": "git", + "x-renovate": { + "datasource": "github-tags", + "depName": "numactl/numactl", + "versioning": "semver" + }, "url": "https://github.com/numactl/numactl.git", "tag": "v2.0.19", "commit": "3bc85e37d5a30da6790cb7e8bb488bb8f679170f", diff --git a/packaging/linux/flatpak/modules/sunshine/glad.json b/packaging/linux/flatpak/modules/sunshine/glad.json new file mode 100644 index 00000000000..b1d82db442f --- /dev/null +++ b/packaging/linux/flatpak/modules/sunshine/glad.json @@ -0,0 +1,14 @@ +[ + { + "type": "git", + "x-renovate": { + "datasource": "github-tags", + "depName": "Dav1dde/glad" + }, + "url": "https://github.com/Dav1dde/glad.git", + "tag": "v2.0.8", + "commit": "73db193f853e2ee079bf3ca8a64aa2eaf6459043", + "dest": "flatpak-cpm/glad", + "disable-submodules": true + } +] diff --git a/packaging/linux/flatpak/modules/sunshine/libdisplaydevice.json b/packaging/linux/flatpak/modules/sunshine/libdisplaydevice.json new file mode 100644 index 00000000000..8458d906c38 --- /dev/null +++ b/packaging/linux/flatpak/modules/sunshine/libdisplaydevice.json @@ -0,0 +1,14 @@ +[ + { + "type": "git", + "x-renovate": { + "datasource": "github-tags", + "depName": "LizardByte/libdisplaydevice" + }, + "url": "https://github.com/LizardByte/libdisplaydevice.git", + "tag": "v2026.1008.124543", + "commit": "a2afc0430d44223c25a2ebc598000f78b338aa52", + "dest": "flatpak-cpm/libdisplaydevice", + "disable-submodules": true + } +] diff --git a/packaging/linux/flatpak/modules/sunshine/libvirtualhid.json b/packaging/linux/flatpak/modules/sunshine/libvirtualhid.json new file mode 100644 index 00000000000..9c988f27579 --- /dev/null +++ b/packaging/linux/flatpak/modules/sunshine/libvirtualhid.json @@ -0,0 +1,15 @@ +[ + { + "type": "git", + "x-renovate": { + "datasource": "git-refs", + "depName": "LizardByte/libvirtualhid", + "versioning": "exact", + "ref": "master" + }, + "url": "https://github.com/LizardByte/libvirtualhid.git", + "commit": "dd8153df338c6fb399ea4a048fa97b4c536f12a0", + "dest": "flatpak-cpm/libvirtualhid", + "disable-submodules": true + } +] diff --git a/packaging/linux/flatpak/modules/sunshine/moonlight-common-c.json b/packaging/linux/flatpak/modules/sunshine/moonlight-common-c.json new file mode 100644 index 00000000000..373f1066eea --- /dev/null +++ b/packaging/linux/flatpak/modules/sunshine/moonlight-common-c.json @@ -0,0 +1,14 @@ +[ + { + "type": "git", + "x-renovate": { + "datasource": "git-refs", + "depName": "moonlight-stream/moonlight-common-c", + "versioning": "exact", + "ref": "master" + }, + "url": "https://github.com/moonlight-stream/moonlight-common-c.git", + "commit": "b4ee1cea3d19e13c0b37c26585e6b1ee174effcb", + "dest": "flatpak-cpm/moonlight-common-c" + } +] diff --git a/packaging/linux/flatpak/modules/sunshine/plasma-wayland-protocols.json b/packaging/linux/flatpak/modules/sunshine/plasma-wayland-protocols.json new file mode 100644 index 00000000000..3d0cbf38c53 --- /dev/null +++ b/packaging/linux/flatpak/modules/sunshine/plasma-wayland-protocols.json @@ -0,0 +1,14 @@ +[ + { + "type": "git", + "x-renovate": { + "datasource": "github-tags", + "depName": "KDE/plasma-wayland-protocols" + }, + "url": "https://github.com/KDE/plasma-wayland-protocols.git", + "tag": "v1.23.0", + "commit": "c5ac4db818f4a575a6ccfe0065b73ecfaba6e93e", + "dest": "flatpak-cpm/plasma_wayland_protocols", + "disable-submodules": true + } +] diff --git a/packaging/linux/flatpak/modules/sunshine/simple-web-server.json b/packaging/linux/flatpak/modules/sunshine/simple-web-server.json new file mode 100644 index 00000000000..dde96b3ef50 --- /dev/null +++ b/packaging/linux/flatpak/modules/sunshine/simple-web-server.json @@ -0,0 +1,16 @@ +[ + { + "type": "git", + "x-renovate": { + "datasource": "git-refs", + "depName": "eidheim/Simple-Web-Server", + "packageName": "https://github.com/LizardByte-infrastructure/Simple-Web-Server.git", + "versioning": "exact", + "ref": "master" + }, + "url": "https://github.com/LizardByte-infrastructure/Simple-Web-Server.git", + "commit": "546895a93a29062bb178367b46c7afb72da9881e", + "dest": "flatpak-cpm/simple_web_server", + "disable-submodules": true + } +] diff --git a/packaging/linux/flatpak/modules/sunshine/tray.json b/packaging/linux/flatpak/modules/sunshine/tray.json new file mode 100644 index 00000000000..6feeba54ce0 --- /dev/null +++ b/packaging/linux/flatpak/modules/sunshine/tray.json @@ -0,0 +1,14 @@ +[ + { + "type": "git", + "x-renovate": { + "datasource": "github-tags", + "depName": "LizardByte/tray" + }, + "url": "https://github.com/LizardByte/tray.git", + "tag": "v2026.1117.200659", + "commit": "c7b35bb6e3d32b5ce03ce9ef14c25cc178927b2e", + "dest": "flatpak-cpm/tray", + "disable-submodules": true + } +] diff --git a/packaging/linux/flatpak/modules/sunshine/wayland-protocols.json b/packaging/linux/flatpak/modules/sunshine/wayland-protocols.json new file mode 100644 index 00000000000..52125370f1c --- /dev/null +++ b/packaging/linux/flatpak/modules/sunshine/wayland-protocols.json @@ -0,0 +1,15 @@ +[ + { + "type": "git", + "x-renovate": { + "datasource": "github-tags", + "depName": "wayland/wayland-protocols", + "packageName": "LizardByte-infrastructure/wayland-protocols" + }, + "url": "https://github.com/LizardByte-infrastructure/wayland-protocols.git", + "tag": "1.50", + "commit": "3eab2dccf4bfdd85c16d312a6c8c8fbc2a6e73a8", + "dest": "flatpak-cpm/wayland_protocols", + "disable-submodules": true + } +] diff --git a/packaging/linux/flatpak/modules/sunshine/wlr-protocols.json b/packaging/linux/flatpak/modules/sunshine/wlr-protocols.json new file mode 100644 index 00000000000..509cd7330ba --- /dev/null +++ b/packaging/linux/flatpak/modules/sunshine/wlr-protocols.json @@ -0,0 +1,16 @@ +[ + { + "type": "git", + "x-renovate": { + "datasource": "git-refs", + "depName": "wlroots/wlr-protocols", + "packageName": "https://github.com/LizardByte-infrastructure/wlr-protocols.git", + "versioning": "exact", + "ref": "master" + }, + "url": "https://github.com/LizardByte-infrastructure/wlr-protocols.git", + "commit": "1106a4a1c57562ddd438c547da4c0d6dc150d624", + "dest": "flatpak-cpm/wlr_protocols", + "disable-submodules": true + } +] diff --git a/packaging/linux/flatpak/modules/xvfb/xvfb.json b/packaging/linux/flatpak/modules/xvfb/xvfb.json index 866409282bb..807f6fe84c7 100644 --- a/packaging/linux/flatpak/modules/xvfb/xvfb.json +++ b/packaging/linux/flatpak/modules/xvfb/xvfb.json @@ -12,9 +12,15 @@ "sources": [ { "type": "git", + "x-renovate": { + "datasource": "github-tags", + "depName": "xorg/xserver", + "packageName": "LizardByte-infrastructure/xserver", + "versioning": "regex:^xorg-server-(?[0-9]+)[.](?[0-9]+)[.](?[0-9]+)$" + }, "url": "https://github.com/LizardByte-infrastructure/xserver.git", - "tag": "xorg-server-21.1.13", - "commit": "be2767845d6ed3c6dbd25a151051294d0908a995", + "tag": "xorg-server-21.1.26", + "commit": "7dbd8d0dd1929c2011009fd1770c8aa470df97fb", "x-checker-data": { "type": "anitya", "project-id": 5250, @@ -34,9 +40,15 @@ "sources": [ { "type": "git", + "x-renovate": { + "datasource": "github-tags", + "depName": "xorg/lib/libxcvt", + "packageName": "LizardByte-infrastructure/libxcvt", + "versioning": "regex:^libxcvt-(?[0-9]+)[.](?[0-9]+)[.](?[0-9]+)$" + }, "url": "https://github.com/LizardByte-infrastructure/libxcvt.git", - "tag": "libxcvt-0.1.2", - "commit": "d9ca87eea9eecddaccc3a77227bcb3acf84e89df", + "tag": "libxcvt-0.1.3", + "commit": "dd8631c61465cc0de5e476c7a98e56528d62b163", "x-checker-data": { "type": "anitya", "project-id": 235147, @@ -51,9 +63,15 @@ "sources": [ { "type": "git", + "x-renovate": { + "datasource": "github-tags", + "depName": "xorg/lib/libxmu", + "packageName": "LizardByte-infrastructure/libxmu", + "versioning": "regex:^libXmu-(?[0-9]+)[.](?[0-9]+)[.](?[0-9]+)$" + }, "url": "https://github.com/LizardByte-infrastructure/libxmu.git", - "tag": "libXmu-1.2.1", - "commit": "792f80402ee06ce69bca3a8f2a84295999c3a170", + "tag": "libXmu-1.3.1", + "commit": "cdf280f6611932f79ab872832974e8043b1cad6d", "x-checker-data": { "type": "anitya", "project-id": 1785, @@ -68,9 +86,15 @@ "sources": [ { "type": "git", + "x-renovate": { + "datasource": "github-tags", + "depName": "xorg/font/util", + "packageName": "LizardByte-infrastructure/font-util", + "versioning": "regex:^font-util-(?[0-9]+)[.](?[0-9]+)[.](?[0-9]+)$" + }, "url": "https://github.com/LizardByte-infrastructure/font-util.git", - "tag": "font-util-1.4.1", - "commit": "b5ca142f81a6f14eddb23be050291d1c25514777", + "tag": "font-util-1.4.2", + "commit": "5c92c11482e017fa7210a71b6f44e40042816209", "x-checker-data": { "type": "anitya", "project-id": 15055, @@ -85,9 +109,15 @@ "sources": [ { "type": "git", + "x-renovate": { + "datasource": "github-tags", + "depName": "xorg/lib/libfontenc", + "packageName": "LizardByte-infrastructure/libfontenc", + "versioning": "regex:^libfontenc-(?[0-9]+)[.](?[0-9]+)[.](?[0-9]+)$" + }, "url": "https://github.com/LizardByte-infrastructure/libfontenc.git", - "tag": "libfontenc-1.1.8", - "commit": "92a85fda2acb4e14ec0b2f6d8fe3eaf2b687218c", + "tag": "libfontenc-1.1.10", + "commit": "eb42c925cab00d235b05e649eb4fb4a1858b67b9", "x-checker-data": { "type": "anitya", "project-id": 1613, @@ -107,15 +137,26 @@ ], "sources": [ { - "type": "archive", - "url": "https://downloads.sourceforge.net/sourceforge/libtirpc/libtirpc-1.3.4.tar.bz2", - "sha256": "1e0b0c7231c5fa122e06c0609a76723664d068b0dba3b8219b63e6340b347860", + "type": "git", + "x-renovate": { + "datasource": "github-tags", + "depName": "libtirpc", + "packageName": "linux-nfs/libtirpc", + "versioning": "regex:^libtirpc-(?[0-9]+)-(?[0-9]+)-(?[0-9]+)$" + }, + "url": "https://github.com/linux-nfs/libtirpc.git", + "tag": "libtirpc-1-3-8", + "commit": "b2a58e4ac15dd5f45952210ef466e9fd88dda553", "x-checker-data": { - "type": "anitya", - "project-id": 1740, - "stable-only": true, - "url-template": "https://downloads.sourceforge.net/sourceforge/libtirpc/libtirpc-$version.tar.bz2" + "type": "git", + "tag-pattern": "^libtirpc-([0-9]+-[0-9]+-[0-9]+)$" } + }, + { + "type": "shell", + "commands": [ + "chmod u+x autogen.sh" + ] } ] }, @@ -124,9 +165,15 @@ "sources": [ { "type": "git", + "x-renovate": { + "datasource": "github-tags", + "depName": "xorg/lib/libxfont", + "packageName": "LizardByte-infrastructure/libxfont", + "versioning": "regex:^libXfont2-(?[0-9]+)[.](?[0-9]+)[.](?[0-9]+)$" + }, "url": "https://github.com/LizardByte-infrastructure/libxfont.git", - "tag": "libXfont2-2.0.6", - "commit": "d54aaf2483df6a1f98fadc09004157e657b7f73e", + "tag": "libXfont2-2.0.10", + "commit": "112d4254f13f2372bdfd1da9ad1eff950cef22b9", "x-checker-data": { "type": "anitya", "project-id": 17165, @@ -141,9 +188,15 @@ "sources": [ { "type": "git", + "x-renovate": { + "datasource": "github-tags", + "depName": "xorg/app/xauth", + "packageName": "LizardByte-infrastructure/xauth", + "versioning": "regex:^xauth-(?[0-9]+)[.](?[0-9]+)[.](?[0-9]+)$" + }, "url": "https://github.com/LizardByte-infrastructure/xauth.git", - "tag": "xauth-1.1.3", - "commit": "c29eef23683f0e3575a3c60d9314de8156fbe2c2", + "tag": "xauth-1.1.5", + "commit": "6fe9365f11181a043f151f2e67f36015c278791d", "x-checker-data": { "type": "anitya", "project-id": 5253, diff --git a/packaging/sunshine.rb b/packaging/sunshine.rb index aacfcc6bb7e..8e74ff3f07a 100644 --- a/packaging/sunshine.rb +++ b/packaging/sunshine.rb @@ -15,7 +15,7 @@ class Sunshine < Formula LLVM_PROFILE_FILE_ENV = "LLVM_PROFILE_FILE".freeze TEST_BINARY = "test_sunshine".freeze TEST_RESULTS_XML = "tests/test_results.xml".freeze - IS_UPSTREAM_REPO = ENV.fetch("GITHUB_REPOSITORY", "") == "LizardByte/Sunshine" + IS_UPSTREAM_REPO = ENV.fetch("GITHUB_REPOSITORY", "") == "SunshineStream/Sunshine" desc "@PROJECT_DESCRIPTION@" homepage "@PROJECT_HOMEPAGE_URL@" @@ -40,11 +40,6 @@ class Sunshine < Formula bottle do root_url "https://ghcr.io/v2/lizardbyte/homebrew" - sha256 arm64_tahoe: "0000000000000000000000000000000000000000000000000000000000000000" - sha256 arm64_sequoia: "0000000000000000000000000000000000000000000000000000000000000000" - sha256 arm64_sonoma: "0000000000000000000000000000000000000000000000000000000000000000" - sha256 arm64_linux: "0000000000000000000000000000000000000000000000000000000000000000" - sha256 x86_64_linux: "0000000000000000000000000000000000000000000000000000000000000000" end option "with-docs", "Enable docs build" @@ -139,12 +134,18 @@ class Sunshine < Formula cause "Array out of bounds error when compiling glad sources" end + ## @brief Configure build metadata, the Linux compiler, and the glad Python environment. def setup_build_environment ENV["BRANCH"] = "@GITHUB_BRANCH@" ENV["BUILD_VERSION"] = "@BUILD_VERSION@" ENV["COMMIT"] = "@GITHUB_COMMIT@" - setup_linux_gcc_environment if OS.linux? + if OS.linux? + # Use GCC because gcov from llvm cannot handle our paths + gcc_path = Formula[GCC_FORMULA] + ENV["CC"] = "#{gcc_path.opt_bin}/gcc-#{GCC_VERSION}" + ENV["CXX"] = "#{gcc_path.opt_bin}/g++-#{GCC_VERSION}" + end return unless OS.linux? @@ -154,108 +155,15 @@ def setup_build_environment # to prevent cmake from trying to install Python dependencies again. # Follows https://docs.brew.sh/Formula-Cookbook#python-dependencies venv = virtualenv_create(buildpath/"venv", "python3") - venv.pip_install resources + venv.pip_install [resource("markupsafe"), resource("jinja2")] @glad_python = (buildpath/"venv/bin/python3").to_s end - def setup_linux_gcc_environment - # Use GCC because gcov from llvm cannot handle our paths - gcc_path = Formula[GCC_FORMULA] - ENV["CC"] = "#{gcc_path.opt_bin}/gcc-#{GCC_VERSION}" - ENV["CXX"] = "#{gcc_path.opt_bin}/g++-#{GCC_VERSION}" - end - - ## @brief Generate CMake arguments with Homebrew dependency and Linux runtime paths. - ## @return CMake command-line arguments. - def base_cmake_args - args = %W[ - -DBUILD_WERROR=ON - -DCMAKE_INSTALL_PREFIX=#{prefix} - -DGLAD_SKIP_PIP_INSTALL=ON - -DHOMEBREW_ALLOW_FETCHCONTENT=ON - -DOPENSSL_ROOT_DIR=#{formula_opt_prefix("openssl@4")} - -DSUNSHINE_ASSETS_DIR=sunshine/assets - -DSUNSHINE_BUILD_HOMEBREW=ON - -DSUNSHINE_PUBLISHER_NAME='LizardByte' - -DSUNSHINE_PUBLISHER_WEBSITE='https://app.lizardbyte.dev' - -DSUNSHINE_PUBLISHER_ISSUE_URL='https://app.lizardbyte.dev/support' - ] - if OS.linux? - # GCC treats Homebrew's lib directory as implicit, so CMake omits its automatic rpath. - # Keep curl's indirect dependencies ahead of incompatible system libraries when linking and running. - args << "-DCMAKE_BUILD_RPATH=#{HOMEBREW_PREFIX}/lib" - args << "-DCMAKE_INSTALL_RPATH=#{HOMEBREW_PREFIX}/lib" - end - args << "-DSUNSHINE_EXECUTABLE_PATH=#{opt_bin}/sunshine" if OS.linux? - # Point cmake at the venv Python that has jinja2 installed (set up in setup_build_environment) - args << "-DPython_EXECUTABLE=#{@glad_python}" if @glad_python - args - end - - def add_test_args(args) - if IS_UPSTREAM_REPO - args << "-DBUILD_TESTS=ON" - test_runtime = opt_libexec/"tests" - args << "-DSUNSHINE_TEST_SOURCE_DIR=#{test_runtime}" - args << "-DSUNSHINE_TEST_RUNTIME_DIR=#{test_runtime}" - coverage_arg = if OS.mac? - "-DSUNSHINE_LLVM_COVERAGE=ON" - else - # gcovr writes intermediate files next to the mapped sources, so use Homebrew's writable temp tree. - coverage_runtime = HOMEBREW_TEMP/"coverage" - "-DSUNSHINE_TEST_GCOV_ROOT=#{coverage_runtime}" - end - args << coverage_arg - ohai "Building tests: enabled" - else - args << "-DBUILD_TESTS=OFF" - ohai "Building tests: disabled" - end - end - - def add_docs_args(args) - if build.with? "docs" - ohai "Building docs: enabled" - args << "-DBUILD_DOCS=ON" - else - ohai "Building docs: disabled" - args << "-DBUILD_DOCS=OFF" - end - end - - def add_boost_args(args) - if build.without? "static-boost" - args << "-DBOOST_USE_STATIC=OFF" - ohai "Disabled statically linking Boost libraries" - else - configure_static_boost(args) - end - end - - def configure_static_boost(args) - args << "-DBOOST_USE_STATIC=ON" - ohai "Enabled statically linking Boost libraries" - - unless formula_any_version_installed?("icu4c") - odie <<~EOS - icu4c must be installed to link against static Boost libraries, - either install icu4c or use brew install sunshine --with-static-boost instead - EOS - end - ENV.append "CXXFLAGS", "-I#{formula_opt_include("icu4c")}" - icu4c_lib_path = formula_opt_lib("icu4c").to_s - ENV.append "LDFLAGS", "-L#{icu4c_lib_path}" - ENV["LIBRARY_PATH"] = icu4c_lib_path - ohai "Linking against ICU libraries at: #{icu4c_lib_path}" - end - + ## @brief Add CUDA compiler arguments for Linux builds. + ## @param args CMake arguments to extend. def add_cuda_args(args) return unless OS.linux? - configure_cuda(args) - end - - def configure_cuda(args) cuda_path = Formula["lizardbyte/homebrew/#{CUDA_FORMULA}"] nvcc_path = "#{cuda_path.opt_libexec}/homebrew/bin/nvcc" gcc_path = Formula[GCC_FORMULA] @@ -283,21 +191,6 @@ def ensure_artifact_exists(path) odie "#{path} was not created" unless path.exist? end - def run_test_suite(artifact_dir) - mkdir_p artifact_dir/"tests" - test_results = artifact_dir/TEST_RESULTS_XML - - if OS.mac? - with_llvm_profile_file(artifact_dir) do - system bin/TEST_BINARY, "--gtest_color=yes", "--gtest_output=xml:#{test_results}" - end - else - system bin/TEST_BINARY, "--gtest_color=yes", "--gtest_output=xml:#{test_results}" - end - - ensure_artifact_exists test_results - end - def with_llvm_profile_file(artifact_dir) original_profile_file = ENV.fetch(LLVM_PROFILE_FILE_ENV, nil) ENV[LLVM_PROFILE_FILE_ENV] = "#{artifact_dir}/sunshine-%p.profraw" @@ -310,80 +203,53 @@ def with_llvm_profile_file(artifact_dir) end end - def coverage_gcov_options - gcc_path = Formula[GCC_FORMULA] - ["--gcov-executable", "#{gcc_path.opt_bin}/gcov-#{GCC_VERSION}"] - end - - def llvm_profdata_executable - Utils.safe_popen_read("xcrun", "--find", "llvm-profdata").strip - end - - def llvm_cov_executable - Utils.safe_popen_read("xcrun", "--find", "llvm-cov").strip - end - def coverage_report_path(artifact_dir) artifact_dir/(OS.mac? ? COVERAGE_LCOV : COVERAGE_XML) end - def coverage_common_options(coverage_report) - [ - "--exclude-noncode-lines", - "--exclude-throw-branches", - "--exclude-unreachable-branches", - "--xml-pretty", - "-o=#{coverage_report}", - ] - end - + ## @brief Export and validate source coverage with LLVM on macOS or gcovr on Linux. + ## @param artifact_dir Directory containing test profiles and receiving the report. + ## @param coverage_buildpath Source build path used to map coverage records. def generate_coverage_report(artifact_dir, coverage_buildpath) return if coverage_buildpath.to_s.empty? coverage_report = coverage_report_path(artifact_dir) if OS.mac? - generate_llvm_coverage_report artifact_dir, coverage_buildpath, coverage_report + profile_files = Dir["#{artifact_dir}/*.profraw"] + odie "No LLVM profile data was created" if profile_files.empty? + + profile_data = artifact_dir/COVERAGE_PROFDATA + llvm_profdata = Utils.safe_popen_read("xcrun", "--find", "llvm-profdata").strip + system llvm_profdata, "merge", "--sparse", "-o", profile_data.to_s, *profile_files + lcov = Utils.safe_popen_read( + Utils.safe_popen_read("xcrun", "--find", "llvm-cov").strip, + "export", + "-format=lcov", + "-instr-profile=#{profile_data}", + (bin/TEST_BINARY).to_s, + ) + coverage_report.write lcov_for_source_files(lcov, coverage_buildpath) + has_lines = coverage_report.read.lines.any? { |line| line.start_with?("DA:") } + odie "#{coverage_report} does not contain any source lines" unless has_lines else - generate_gcov_coverage_report coverage_report, coverage_buildpath - end - - ensure_artifact_exists coverage_report - end - - def generate_llvm_coverage_report(artifact_dir, coverage_buildpath, coverage_report) - profile_files = Dir["#{artifact_dir}/*.profraw"] - odie "No LLVM profile data was created" if profile_files.empty? - - profile_data = artifact_dir/COVERAGE_PROFDATA - system llvm_profdata_executable, "merge", "--sparse", "-o", profile_data.to_s, *profile_files - lcov = Utils.safe_popen_read( - llvm_cov_executable, - "export", - "-format=lcov", - "-instr-profile=#{profile_data}", - (bin/TEST_BINARY).to_s, - ) - coverage_report.write lcov_for_source_files(lcov, coverage_buildpath) - ensure_lcov_report_has_lines coverage_report - end + cd "#{coverage_buildpath}/build" do + gcc_path = Formula[GCC_FORMULA] + system "gcovr", "tests/CMakeFiles/#{TEST_BINARY}.dir/__/src", + "-r", "../src", + "--gcov-executable", "#{gcc_path.opt_bin}/gcov-#{GCC_VERSION}", + "--exclude-noncode-lines", + "--exclude-throw-branches", + "--exclude-unreachable-branches", + "--xml-pretty", + "-o=#{coverage_report}" + end - def generate_gcov_coverage_report(coverage_report, coverage_buildpath) - cd "#{coverage_buildpath}/build" do - system "gcovr", "tests/CMakeFiles/#{TEST_BINARY}.dir/__/src", - "-r", "../src", - *coverage_gcov_options, - *coverage_common_options(coverage_report) + lines_valid = coverage_report.read[/lines-valid="(\d+)"/, 1].to_i + odie "#{coverage_report} does not contain any source lines" if lines_valid.zero? end - ensure_cobertura_report_has_lines coverage_report - end - - def coverage_source_prefixes(coverage_buildpath) - coverage_buildpath = Pathname.new(coverage_buildpath.to_s) - paths = [coverage_buildpath.to_s] - paths << coverage_buildpath.realpath.to_s if coverage_buildpath.exist? - paths.uniq.map { |path| "#{path}/src/" } + ensure_artifact_exists coverage_report end def relative_lcov_record(record, source_prefixes) @@ -408,22 +274,19 @@ def relative_lcov_record(record, source_prefixes) "#{lines.join}end_of_record\n" end + ## @brief Retain LCOV records for source files and normalize their paths. + ## @param lcov LCOV report contents. + ## @param coverage_buildpath Source build path used to identify absolute records. + ## @return LCOV records with paths relative to the repository root. def lcov_for_source_files(lcov, coverage_buildpath) - source_prefixes = coverage_source_prefixes(coverage_buildpath) + coverage_buildpath = Pathname.new(coverage_buildpath.to_s) + paths = [coverage_buildpath.to_s] + paths << coverage_buildpath.realpath.to_s if coverage_buildpath.exist? + source_prefixes = paths.uniq.map { |path| "#{path}/src/" } records = lcov.split("end_of_record\n") records.filter_map { |record| relative_lcov_record(record, source_prefixes) }.join end - def ensure_cobertura_report_has_lines(path) - lines_valid = path.read[/lines-valid="(\d+)"/, 1].to_i - odie "#{path} does not contain any source lines" if lines_valid.zero? - end - - def ensure_lcov_report_has_lines(path) - has_lines = path.read.lines.any? { |line| line.start_with?("DA:") } - odie "#{path} does not contain any source lines" unless has_lines - end - def collect_test_artifacts artifact_dir = release_homebrew_testpath return unless IS_UPSTREAM_REPO @@ -434,81 +297,152 @@ def collect_test_artifacts (artifact_dir/COVERAGE_BUILDPATH_FILE).write coverage_buildpath.to_s end - def build_cmake_args - args = base_cmake_args - add_test_args(args) - add_docs_args(args) - add_boost_args(args) - add_cuda_args(args) - args - end - - def build_and_install_project - system "cmake", "-S", ".", "-B", "build", "-G", "Unix Makefiles", - *std_cmake_args, - *build_cmake_args + ## @brief Configure the bundled tests and platform coverage tooling. + ## @param args CMake arguments to extend. + def add_test_args(args) + unless IS_UPSTREAM_REPO + args << "-DBUILD_TESTS=OFF" + ohai "Building tests: disabled" + return + end - system "make", "-C", "build" - system "make", "-C", "build", "install" + args << "-DBUILD_TESTS=ON" + test_runtime = opt_libexec/"tests" + args << "-DSUNSHINE_TEST_SOURCE_DIR=#{test_runtime}" + args << "-DSUNSHINE_TEST_RUNTIME_DIR=#{test_runtime}" + coverage_arg = if OS.mac? + "-DSUNSHINE_LLVM_COVERAGE=ON" + else + # gcovr writes intermediate files next to the mapped sources, so use Homebrew's writable temp tree. + coverage_runtime = HOMEBREW_TEMP/"coverage" + "-DSUNSHINE_TEST_GCOV_ROOT=#{coverage_runtime}" + end + args << coverage_arg + ohai "Building tests: enabled" end - def install_platform_specific_files - if IS_UPSTREAM_REPO - bin.install "build/tests/#{TEST_BINARY}" + ## @brief Install the test binary and fixtures used by the upstream Homebrew jobs. + def install_test_fixtures + return unless IS_UPSTREAM_REPO - test_runtime = libexec/"tests" - %w[docs src src_assets test_assets].each do |directory| - test_runtime.install "build/tests/#{directory}" - end - boost_test_fixtures = %w[ - cmake/compile_definitions/macos.cmake - cmake/dependencies/Boost_Sunshine.cmake - cmake/macros/common.cmake - cmake/prep/options.cmake - package-lock.cmake - packaging/linux/Arch/PKGBUILD - packaging/linux/copr/Sunshine.spec - packaging/linux/flatpak/modules/boost.json - packaging/linux/flatpak/scripts/additional-install.sh - scripts/linux_build.sh - tests/scripts/test_additional_install.sh + bin.install "build/tests/#{TEST_BINARY}" + + test_runtime = libexec/"tests" + %w[docs src src_assets test_assets].each do |directory| + test_runtime.install "build/tests/#{directory}" + end + boost_test_fixtures = %w[ + cmake/compile_definitions/macos.cmake + cmake/dependencies/Boost_Sunshine.cmake + cmake/macros/common.cmake + cmake/prep/options.cmake + package-lock.cmake + packaging/linux/Arch/PKGBUILD + packaging/linux/copr/Sunshine.spec + packaging/linux/flatpak/modules/boost.json + packaging/linux/flatpak/scripts/additional-install.sh + scripts/linux_build.sh + tests/scripts/test_additional_install.sh + ] + if OS.mac? + boost_test_fixtures += %w[ + .github/workflows/ci-macos.yml + scripts/macos_build.sh ] - if OS.mac? - boost_test_fixtures += %w[ - .github/workflows/ci-macos.yml - scripts/macos_build.sh - ] - end - boost_test_fixtures.each do |fixture| - (test_runtime/Pathname.new(fixture).dirname).install "build/tests/#{fixture}" + end + boost_test_fixtures.each do |fixture| + (test_runtime/Pathname.new(fixture).dirname).install "build/tests/#{fixture}" + end + test_runtime.install "sunshine.png" + (test_runtime/"tests/unit").install "tests/unit/test_video.cpp" + + if OS.linux? + coverage_runtime = test_runtime/"coverage" + coverage_runtime.install "src" + (test_runtime/GCOV_PREFIX_STRIP_FILE).write "#{buildpath.each_filename.count}\n" + coverage_notes = buildpath.glob("build/**/*.gcno") + odie "No gcov notes were created" if coverage_notes.empty? + + coverage_notes.each do |coverage_note| + relative_note = coverage_note.relative_path_from(buildpath) + (coverage_runtime/relative_note.dirname).install coverage_note end - test_runtime.install "sunshine.png" - (test_runtime/"tests/unit").install "tests/unit/test_video.cpp" - - if OS.linux? - coverage_runtime = test_runtime/"coverage" - coverage_runtime.install "src" - (test_runtime/GCOV_PREFIX_STRIP_FILE).write "#{buildpath.each_filename.count}\n" - coverage_notes = buildpath.glob("build/**/*.gcno") - odie "No gcov notes were created" if coverage_notes.empty? - - coverage_notes.each do |coverage_note| - relative_note = coverage_note.relative_path_from(buildpath) - (coverage_runtime/relative_note.dirname).install coverage_note - end + end + end + + ## @brief Build and install Sunshine with platform dependencies and optional CI test fixtures. + def install + setup_build_environment + standard_args = std_cmake_args + + args = %W[ + -DBUILD_WERROR=ON + -DCMAKE_INSTALL_PREFIX=#{prefix} + -DGLAD_SKIP_PIP_INSTALL=ON + -DHOMEBREW_ALLOW_FETCHCONTENT=ON + -DOPENSSL_ROOT_DIR=#{formula_opt_prefix("openssl@4")} + -DSUNSHINE_ASSETS_DIR=sunshine/assets + -DSUNSHINE_BUILD_HOMEBREW=ON + -DSUNSHINE_PUBLISHER_NAME='LizardByte' + -DSUNSHINE_PUBLISHER_WEBSITE='https://app.lizardbyte.dev' + -DSUNSHINE_PUBLISHER_ISSUE_URL='https://app.lizardbyte.dev/support' + ] + if OS.linux? + # GCC treats Homebrew's lib directory as implicit, so CMake omits its automatic rpath. + # Keep curl's indirect dependencies ahead of incompatible system libraries when linking and running. + args << "-DCMAKE_BUILD_RPATH=#{HOMEBREW_PREFIX}/lib" + args << "-DCMAKE_INSTALL_RPATH=#{HOMEBREW_PREFIX}/lib" + end + args << "-DSUNSHINE_EXECUTABLE_PATH=#{opt_bin}/sunshine" if OS.linux? + # Point cmake at the venv Python that has jinja2 installed (set up in setup_build_environment) + args << "-DPython_EXECUTABLE=#{@glad_python}" if @glad_python + + add_test_args(args) + + if build.with? "docs" + ohai "Building docs: enabled" + args << "-DBUILD_DOCS=ON" + else + ohai "Building docs: disabled" + args << "-DBUILD_DOCS=OFF" + end + + if build.without? "static-boost" + args << "-DBOOST_USE_STATIC=OFF" + ohai "Disabled statically linking Boost libraries" + else + args << "-DBOOST_USE_STATIC=ON" + ohai "Enabled statically linking Boost libraries" + + unless formula_any_version_installed?("icu4c") + odie <<~EOS + icu4c must be installed to link against static Boost libraries, + either install icu4c or use brew install sunshine --with-static-boost instead + EOS end + ENV.append "CXXFLAGS", "-I#{formula_opt_include("icu4c")}" + icu4c_lib_path = formula_opt_lib("icu4c").to_s + ENV.append "LDFLAGS", "-L#{icu4c_lib_path}" + ENV["LIBRARY_PATH"] = icu4c_lib_path + ohai "Linking against ICU libraries at: #{icu4c_lib_path}" end + add_cuda_args(args) + + system "cmake", "-S", ".", "-B", "build", "-G", "Unix Makefiles", + *standard_args, + *args + + system "make", "-C", "build" + system "make", "-C", "build", "install" + + install_test_fixtures + # codesign the binary on intel macs system "codesign", "-s", "-", "--force", "--deep", bin/"sunshine" if OS.mac? && Hardware::CPU.intel? bin.install "src_assets/linux/misc/postinst" if OS.linux? - end - def install - setup_build_environment - build_and_install_project - install_platform_specific_files collect_test_artifacts end @@ -541,6 +475,7 @@ def caveats EOS end + ## @brief Verify the installed binary, CI fixtures, test results, and normalized source coverage. test do # test that the binary runs at all system bin/"sunshine", "--version" @@ -581,7 +516,19 @@ def caveats assert_path_exists coverage_report_path(artifact_dir) end elsif ENV.fetch("HOMEBREW_BOTTLE_BUILD", "false") != "true" - run_test_suite testpath + artifact_dir = testpath + mkdir_p artifact_dir/"tests" + test_results = artifact_dir/TEST_RESULTS_XML + + if OS.mac? + with_llvm_profile_file(artifact_dir) do + system bin/TEST_BINARY, "--gtest_color=yes", "--gtest_output=xml:#{test_results}" + end + else + system bin/TEST_BINARY, "--gtest_color=yes", "--gtest_output=xml:#{test_results}" + end + + ensure_artifact_exists test_results generate_coverage_report testpath, ENV.fetch("HOMEBREW_BUILDPATH", "") end diff --git a/patches/boost-locale-cmake-4.5.patch b/patches/boost-locale-cmake-4.5.patch new file mode 100644 index 00000000000..3b6c41c7510 --- /dev/null +++ b/patches/boost-locale-cmake-4.5.patch @@ -0,0 +1,11 @@ +diff --git a/libs/locale/CMakeLists.txt b/libs/locale/CMakeLists.txt +--- a/libs/locale/CMakeLists.txt ++++ b/libs/locale/CMakeLists.txt +@@ -232,6 +232,7 @@ set(sources_src ${sources}) + list(FILTER sources_src INCLUDE REGEX "^src/") + set(sources_inc ${sources}) + list(FILTER sources_inc EXCLUDE REGEX "^src/") ++list(REMOVE_ITEM sources_inc "${CMAKE_CURRENT_SOURCE_DIR}/include/boost/locale.hpp") + source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}/src" PREFIX "sources" FILES ${sources_src}) + source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}/include/boost/locale" PREFIX "headers" FILES ${sources_inc}) + source_group("headers" FILES "include/boost/locale.hpp") diff --git a/pyproject.toml b/pyproject.toml index 705b97bf89f..ef4546d140b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,10 +17,9 @@ dependencies = [ ] [dependency-groups] -# glad2 declares Jinja2>=2.7,<4.0 as a dependency, so installing it pulls in jinja2 transitively. -# The platform marker limits this to Linux where the glad generator is actually used. +# The CPM-fetched glad generator runs from its source tree and needs Jinja2. glad = [ - "glad2", + "jinja2>=2.7,<4.0", ] flatpak = [ @@ -29,9 +28,9 @@ flatpak = [ ] [project.urls] -Homepage = "https://app.lizardbyte.dev/Sunshine" -Repository = "https://github.com/LizardByte/Sunshine" -Issues = "https://github.com/LizardByte/Sunshine/issues" +Homepage = "https://sunshine.lizardbyte.dev" +Repository = "https://github.com/SunshineStream/Sunshine" +Issues = "https://github.com/SunshineStream/Sunshine/issues" [tool.setuptools] py-modules = [] @@ -39,5 +38,4 @@ py-modules = [] [tool.uv.sources] flatpak_node_generator = { path = "packaging/linux/flatpak/deps/flatpak-builder-tools/node" } flatpak_pip_generator = { path = "packaging/linux/flatpak/deps/flatpak-builder-tools/pip" } -glad2 = { path = "third-party/glad" } lizardbyte-common = { path = "third-party/lizardbyte-common" } diff --git a/scripts/linux_build.sh b/scripts/linux_build.sh index 8767860ece2..fb4bb73097f 100755 --- a/scripts/linux_build.sh +++ b/scripts/linux_build.sh @@ -7,17 +7,17 @@ target_cmake_version="4.3.0" doxygen_min="1.10.0" _doxygen_min="${doxygen_min//\./_}" # Convert dots to underscores for URL doxygen_max="1.12.0" -default_cuda_version="13.1.1" -default_cuda_build="590.48.01" +default_cuda_version="13.5.0" +default_cuda_system_minor_version="13.1" # Default value for arguments appimage_build=0 cuda_version="$default_cuda_version" -cuda_build="$default_cuda_build" cuda_patches=0 cuda_system_package=0 cuda_system_package_name="" force_cuda_runfile=0 +require_local_cuda=0 num_processors=$(nproc) publisher_name="Third Party Publisher" publisher_website="" @@ -52,7 +52,10 @@ function setup_cuda_system_package_environment() { } function cuda_system_toolkit_path() { - local cuda_minor_version="${cuda_version%.*}" + local cuda_minor_version="$default_cuda_system_minor_version" + if [[ "$cuda_system_package_name" =~ ^cuda-toolkit-([0-9]+)-([0-9]+)$ ]]; then + cuda_minor_version="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}" + fi echo "/usr/local/cuda-${cuda_minor_version}" } @@ -64,6 +67,20 @@ function cuda_target_dir() { fi } +function use_cuda_redistributables() { + # Use archives only for toolkit versions with a verified set of pins. + [[ "$force_cuda_runfile" == 0 && "$cuda_system_package" == 0 && + "$cuda_version" == "13.5.0" && ( "$architecture" == "x86_64" || "$architecture" == "$AARCH64" ) ]] +} + +function cuda_local_toolkit_path() { + if use_cuda_redistributables; then + echo "${build_dir}/cuda/redistributables-${cuda_version}" + else + echo "${build_dir}/cuda" + fi +} + function cuda_math_functions_patch_applied() { local cuda_toolkit_path=$1 local math_functions_file @@ -73,7 +90,7 @@ function cuda_math_functions_patch_applied() { return 1 fi - # Ubuntu's CUDA packages provide the same glibc fix through this specifier macro. + # Newer CUDA headers provide the same glibc fix through this specifier macro. local exception_specifier='(noexcept[[:space:]]*\(true\)|_NV_RSQRT_SPECIFIER)' grep -Eq "rsqrt\(double x\) ${exception_specifier};" "$math_functions_file" && \ grep -Eq "rsqrtf\(float x\) ${exception_specifier};" "$math_functions_file" && \ @@ -134,18 +151,24 @@ function apply_cuda_patches() { # Reusable function to detect nvcc path function detect_nvcc_path() { - local nvcc_path="" + local nvcc_path - # First check for system-installed CUDA - nvcc_path=$(command -v nvcc 2>/dev/null) || true - if [[ -n "$nvcc_path" ]]; then - echo "$nvcc_path" - return 0 + if [[ "$force_cuda_runfile" == 0 && "$require_local_cuda" == 0 ]]; then + # Keep system-installed CUDA and existing local runfile installs when allowed. + if nvcc_path=$(command -v nvcc 2>/dev/null); then + echo "$nvcc_path" + return 0 + fi + if [[ -f "${build_dir}/cuda/bin/nvcc" ]]; then + echo "${build_dir}/cuda/bin/nvcc" + return 0 + fi fi - # Then check for locally installed CUDA in build directory - if [[ -f "${build_dir}/cuda/bin/nvcc" ]]; then - echo "${build_dir}/cuda/bin/nvcc" + # Keep archive and runfile installs separate so --cuda-runfile can override. + nvcc_path="$(cuda_local_toolkit_path)/bin/nvcc" + if [[ -f "$nvcc_path" ]]; then + echo "$nvcc_path" return 0 fi @@ -189,7 +212,7 @@ Options: --cuda-patches Apply cuda patches. Enabled automatically on Ubuntu 26.04. --cuda-runfile Force CUDA installation from the NVIDIA runfile. --cuda-system-package=* The CUDA package to install when system CUDA is enabled. - Default for Ubuntu 26.04 and 26.10 is cuda-toolkit-13-1. + Opt in on Ubuntu 26.04/26.10 instead of downloading the pinned NVIDIA toolkit. --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. @@ -376,10 +399,14 @@ function add_debian_based_deps() { "qt6-base-dev" "systemd" "udev" - "wget" # necessary for cuda install with `run` file + "wget" # necessary for CUDA installation "xvfb" # necessary for headless unit testing ) + if [[ "$skip_cuda" == 0 ]] && use_cuda_redistributables; then + dependencies+=("xz-utils") + fi + # appstream-glib was removed in Ubuntu 26.10; appstreamcli remains available. if [[ "$distro" != "$DISTRO_UBUNTU" ]] || [[ "$version" < "$UBUNTU_APPSTREAM_GLIB_REMOVAL_VERSION" ]]; then dependencies+=("appstream-util") @@ -498,11 +525,15 @@ function add_fedora_deps() { "qt6-qtsvg-devel" "rpm-build" # if you want to build an RPM binary package "vulkan-loader-devel" - "wget" # necessary for cuda install with `run` file + "wget" # necessary for CUDA installation "which" # necessary for cuda install with `run` file "xorg-x11-server-Xvfb" # necessary for headless unit testing ) + if [[ "$skip_cuda" == 0 ]] && use_cuda_redistributables; then + dependencies+=("xz") + fi + # Fedora 44+ provides Boost 1.90 or newer and packages its static libraries separately. if [[ "$version" =~ ^[0-9]+$ ]] && (( version >= 44 )); then dependencies+=( @@ -519,16 +550,79 @@ function add_fedora_deps() { return 0 } +function install_cuda_redistributables() ( + local cuda_redist_arch="linux-x86_64" + if [[ "$architecture" == "${AARCH64}" ]]; then + cuda_redist_arch="linux-sbsa" + fi + + local cuda_base_url="https://developer.download.nvidia.com/compute/cuda/redist" + local staging_dir + mkdir -p -- "${build_dir}/cuda" + staging_dir=$(mktemp -d "${build_dir}/cuda/.redistributables.XXXXXX") + trap 'rm -rf -- "$staging_dir"' EXIT + + local toolkit_dir="${staging_dir}/toolkit" + local target_dir + target_dir="${toolkit_dir}/targets/$(cuda_target_dir)" + mkdir -p -- "$target_dir" + + # Component versions and architecture-specific SHA-256 digests from + # https://developer.download.nvidia.com/compute/cuda/redist/redistrib_13.5.0.json + # component:version:destination:x86_64_sha256:sbsa_sha256 + local -a components=( + "cuda_nvcc:13.5.37:root:ac41262734f3c62cd75a502081cfae093b03b846d7f9274d8b1eb41f83209b96:0c6756fdda5a4c5159dc5181788bd68c9d261e71d6f299ebb241185e113254a3" + "libnvvm:13.5.37:root:8dd4866e387f0ce2259e8dcc91bebdbb59f84c6d4505b3bba46ae91b9a11dd16:6c79308860d5eb47c6dd3693652a4d7cd430050438d31d5f036aa0b19583f2ea" + "cccl:13.3.5.0.6:target:5139f641e72df6b0c64ee9e68cabaeafa9a5e36a4b1f7d370a1dc0dac62dd72f:c308969d8ad6de704c3f8be9ccf5ff2c9b40dd6e23b43b6e4057d255779d5ada" + "cuda_crt:13.5.37:target:0df5c0ca27392152f370751c82b27ff1ab67661e4810cfc7248e2e03479c9ae0:65d373eead42f1544363027c9ee3e6e6eb223c27743749e84ce1e9595bc71b33" + "cuda_cudart:13.5.37:target:26ca1b8963ce1b73e0e77113c711730545cacaaee7233c0526477d96d4c621fe:9da80d6aa87f5bc46971c1343024f30a850aca9aac03da95219880aaf854154f" + "cuda_culibos:13.5.25:target:4c03a0e737f474923823687c93b43a0727e424dcbc53eb44fb116995c87df713:78d7ce9b78d69196b85fd1bfae591d7c1537393242c3a39e616ca8dfade68a99" + "libnvptxcompiler:13.5.37:target:e92761c2c83fdbe1c582aab568e684371c3023e88b7b4c6fb3d92e3feb160b67:8f5503e8a7ced0e676ce327eb83f5a1650b59f54d66e6cf704d2d4ee9583eb2d" + ) + + local start_seconds=$SECONDS + echo "Installing CUDA ${cuda_version} redistributables (${cuda_redist_arch})" + local component name component_version destination sha_x86_64 sha_sbsa sha archive extract_dir url + for component in "${components[@]}"; do + IFS=: read -r name component_version destination sha_x86_64 sha_sbsa <<< "$component" + archive="${name}-${cuda_redist_arch}-${component_version}-archive.tar.xz" + sha="$sha_x86_64" + if [[ "$architecture" == "${AARCH64}" ]]; then + sha="$sha_sbsa" + fi + extract_dir="$target_dir" + if [[ "$destination" == "root" ]]; then + extract_dir="$toolkit_dir" + fi + + url="${cuda_base_url}/${name}/${cuda_redist_arch}/${archive}" + echo "CUDA component URL: ${url}" + wget "$url" --max-redirect=0 --progress=bar:force:noscroll -q --show-progress -O "${staging_dir}/${archive}" + if ! printf '%s %s\n' "$sha" "${staging_dir}/${archive}" | sha256sum --check; then + exit 1 + fi + tar -xJf "${staging_dir}/${archive}" --directory="$extract_dir" --strip-components=1 + rm -- "${staging_dir}/${archive}" + done + + # nvcc expects this header under the target-specific include directory. + mv -- "${toolkit_dir}/include/fatbinary_section.h" "${target_dir}/include/" + apply_cuda_patches "$toolkit_dir" + + # Publish the complete directory only after verification and extraction. + mv -T -- "$toolkit_dir" "$(cuda_local_toolkit_path)" + echo "Installed CUDA redistributables in $((SECONDS - start_seconds)) seconds" +) + function install_cuda() { setup_cuda_system_package_environment # Check if CUDA is already available - if [[ "$force_cuda_runfile" == 1 ]] && [[ -f "${build_dir}/cuda/bin/nvcc" ]]; then - apply_cuda_patches "${build_dir}/cuda" - return - elif [[ "$force_cuda_runfile" == 0 ]] && detect_nvcc_path > /dev/null 2>&1; then + if detect_nvcc_path > /dev/null 2>&1; then if [[ "$cuda_system_package" == 1 ]]; then apply_cuda_patches "$(cuda_system_toolkit_path)" + elif [[ "$force_cuda_runfile" == 1 || "$require_local_cuda" == 1 ]]; then + apply_cuda_patches "$(cuda_local_toolkit_path)" fi return fi @@ -538,9 +632,9 @@ function install_cuda() { return 1 fi - local cuda_override_arg="" + local cuda_override_args=() if [[ "$distro" == "$DISTRO_FEDORA" ]]; then - cuda_override_arg="--override" + cuda_override_args+=(--override) fi local cuda_prefix="https://developer.download.nvidia.com/compute/cuda/" @@ -570,11 +664,16 @@ function install_cuda() { fi fi - local url="${cuda_prefix}${cuda_version}/local_installers/cuda_${cuda_version}_${cuda_build}_linux${cuda_suffix}.run" + if use_cuda_redistributables; then + install_cuda_redistributables + return + fi + + local url="${cuda_prefix}${cuda_version}/local_installers/cuda_${cuda_version}_linux${cuda_suffix}.run" echo "cuda url: ${url}" wget "$url" --max-redirect=0 --progress=bar:force:noscroll -q --show-progress -O "${build_dir}/cuda.run" chmod a+x "${build_dir}/cuda.run" - "${build_dir}/cuda.run" --silent --toolkit --toolkitpath="${build_dir}/cuda" --no-opengl-libs --no-man-page --no-drm "$cuda_override_arg" + "${build_dir}/cuda.run" --silent --toolkit --toolkitpath="${build_dir}/cuda" --no-man-page "${cuda_override_args[@]}" rm "${build_dir}/cuda.run" apply_cuda_patches "${build_dir}/cuda" @@ -719,12 +818,9 @@ function run_step_cmake() { # Detect CUDA path using the reusable function nvcc_path="" - if [[ "$skip_cuda" == 0 ]]; then - if [[ "$force_cuda_runfile" == 1 ]] && [[ -f "${build_dir}/cuda/bin/nvcc" ]]; then - nvcc_path="${build_dir}/cuda/bin/nvcc" - else - nvcc_path=$(detect_nvcc_path) - fi + if [[ "$skip_cuda" == 0 ]] && ! nvcc_path=$(detect_nvcc_path); then + echo "CUDA compiler not found. Run the dependency installation step with the same CUDA options." + return 1 fi #set gcc version based on distros @@ -911,8 +1007,6 @@ case "${distro}:${version}" in "${DISTRO_FEDORA}":45) package_update_command="${sudo_cmd} dnf update -y" package_install_command="${sudo_cmd} dnf install -y" - cuda_version="13.1.1" - cuda_build="590.48.01" gcc_version="15" nvm_node=0 ;; @@ -928,27 +1022,16 @@ case "${distro}:${version}" in gcc_version="14" nvm_node=0 ;; - "${DISTRO_UBUNTU}":26.04) + "${DISTRO_UBUNTU}":26.04|"${DISTRO_UBUNTU}":26.10) package_update_command="${sudo_cmd} apt-get update" package_install_command="${sudo_cmd} apt-get install -y" - cuda_patches=1 - if [[ "$force_cuda_runfile" == 0 ]]; then - cuda_system_package=1 - if [[ -z "$cuda_system_package_name" ]]; then - cuda_system_package_name="cuda-toolkit-13-1" - fi + if [[ "$version" == "26.04" ]]; then + cuda_patches=1 fi - gcc_version="14" - nvm_node=0 - ;; - "${DISTRO_UBUNTU}":26.10) - package_update_command="${sudo_cmd} apt-get update" - package_install_command="${sudo_cmd} apt-get install -y" - if [[ "$force_cuda_runfile" == 0 ]]; then + if [[ "$force_cuda_runfile" == 0 && -n "$cuda_system_package_name" ]]; then cuda_system_package=1 - if [[ -z "$cuda_system_package_name" ]]; then - cuda_system_package_name="cuda-toolkit-13-1" - fi + else + require_local_cuda=1 fi gcc_version="14" nvm_node=0 diff --git a/sonar-project.properties b/sonar-project.properties index 44e8c51d050..78563717004 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,7 +1,7 @@ # Sonar project analysis properties overrides # Automatic analysis ignores this file, and uses .sonarcloud.properties instead -sonar.projectKey=LizardByte_Sunshine +sonar.projectKey=SunshineStream_Sunshine sonar.exclusions=third-party/**, packaging/linux/flatpak/deps/** diff --git a/src/boost_process_compat.h b/src/compat/boost_process.h similarity index 92% rename from src/boost_process_compat.h rename to src/compat/boost_process.h index d5441db3a12..47907e97695 100644 --- a/src/boost_process_compat.h +++ b/src/compat/boost_process.h @@ -1,5 +1,5 @@ /** - * @file src/boost_process_compat.h + * @file src/compat/boost_process.h * @brief Includes Boost.Process while isolating third-party deprecation diagnostics. */ #pragma once diff --git a/src/compat/moonlight.h b/src/compat/moonlight.h new file mode 100644 index 00000000000..144fab1a4a8 --- /dev/null +++ b/src/compat/moonlight.h @@ -0,0 +1,14 @@ +/** + * @file src/compat/moonlight.h + * @brief Import Moonlight's internal C declarations with C++ atomic support. + */ +#pragma once + +// standard includes +// C++23's compatibility header defines atomic types using C++ templates. Load it before the C linkage block. +#include + +// lib includes +extern "C" { +#include +} diff --git a/src/config.cpp b/src/config.cpp index 9952c1719bc..596177646c1 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -5,6 +5,8 @@ // standard includes #include #include +#include +#include #include #include #include @@ -532,34 +534,6 @@ namespace config { return -1; } - /** - * @brief Parse whether VideoToolbox software encoding is allowed. - * - * @param software Whether the software encoder path is being configured. - * @return Parsed enum value, or the setting-specific default when the text is unknown. - */ - int allow_software_from_view(const std::string_view &software) { - if (software == "allowed"sv || software == "forced") { - return 1; - } - - return 0; - } - - /** - * @brief Parse whether VideoToolbox software encoding is forced. - * - * @param software Whether the software encoder path is being configured. - * @return Parsed enum value, or the setting-specific default when the text is unknown. - */ - int force_software_from_view(const std::string_view &software) { - if (software == "forced") { - return 1; - } - - return 0; - } - /** * @brief Parse the VideoToolbox realtime encoder flag. * @@ -739,8 +713,13 @@ namespace config { 0, // hevc_mode 0, // av1_mode + 0, // mpeg2_mode + 0, // h263p_mode 2, // min_threads + + 0, // max_stream_width + 0, // max_stream_height { "superfast"s, // preset "zerolatency"s, // tune @@ -777,8 +756,6 @@ namespace config { }, // amd { - 0, - 0, 1, -1, }, // vt @@ -844,6 +821,7 @@ namespace config { ENCRYPTION_MODE_NEVER, // lan_encryption_mode ENCRYPTION_MODE_OPPORTUNISTIC, // wan_encryption_mode 0, // packetsize + true, // dscp_tagging }; /** @@ -1649,6 +1627,62 @@ namespace config { } } + bool cap_stream_resolution(int &width, int &height) { + if (video.max_stream_width <= 0 || video.max_stream_height <= 0 || width <= 0 || height <= 0 || (width <= video.max_stream_width && height <= video.max_stream_height)) { + return false; + } + + // Scale by whichever dimension is further over its limit, in integer math so that dimension + // lands exactly on the cap. + const std::int64_t w = width; + const std::int64_t h = height; + const bool width_limited = w * video.max_stream_height >= h * video.max_stream_width; + const auto scaled_width = width_limited ? video.max_stream_width : static_cast(w * video.max_stream_height / h); + const auto scaled_height = width_limited ? static_cast(h * video.max_stream_width / w) : video.max_stream_height; + // Encoders and decoders expect even dimensions + const int capped_width = std::max(2, scaled_width & ~1); + const int capped_height = std::max(2, scaled_height & ~1); + BOOST_LOG(info) << "Capping stream resolution: "sv << width << 'x' << height + << " -> "sv << capped_width << 'x' << capped_height; + width = capped_width; + height = capped_height; + return true; + } + + /** + * @brief Parse a `x` resolution string. + * + * @param value Resolution text such as `2560x1440`. + * @param width Parsed width, written only on success. + * @param height Parsed height, written only on success. + * @return `true` when both dimensions are at least 2, the smallest even size the cap can produce. + */ + bool parse_stream_resolution(const std::string_view &value, int &width, int &height) { + const auto separator = value.find('x'); + if (separator == std::string::npos) { + return false; + } + + const auto *const begin = value.data(); + const auto *const end = begin + value.size(); + + int parsed_width = 0; + const auto [width_end, width_ec] = std::from_chars(begin, begin + separator, parsed_width); + if (width_ec != std::errc {} || width_end != begin + separator || parsed_width < 2) { + return false; + } + + int parsed_height = 0; + const auto [height_end, height_ec] = std::from_chars(begin + separator + 1, end, parsed_height); + if (height_ec != std::errc {} || height_end != end || parsed_height < 2) { + return false; + } + + width = parsed_width; + height = parsed_height; + return true; + } + /** * @brief Apply parsed configuration entries to the global runtime configuration. * @@ -1660,7 +1694,16 @@ namespace config { int_f(vars, "qp", video.qp); int_between_f(vars, "hevc_mode", video.hevc_mode, {0, 3}); int_between_f(vars, "av1_mode", video.av1_mode, {0, 3}); + int_between_f(vars, "mpeg2_mode", video.mpeg2_mode, {0, 2}); + int_between_f(vars, "h263p_mode", video.h263p_mode, {0, 2}); int_f(vars, "min_threads", video.min_threads); + + std::string max_stream_resolution; + string_f(vars, "max_stream_resolution", max_stream_resolution); + if (!max_stream_resolution.empty() && !parse_stream_resolution(max_stream_resolution, video.max_stream_width, video.max_stream_height)) { + BOOST_LOG(warning) << "max_stream_resolution must be formatted as x, e.g. 2560x1440: "sv << max_stream_resolution; + } + string_f(vars, "sw_preset", video.sw.sw_preset); if (!video.sw.sw_preset.empty()) { video.sw.svtav1_preset = sw::svtav1_preset_from_view(video.sw.sw_preset); @@ -1728,8 +1771,6 @@ namespace config { } int_f(vars, "vt_coder", video.vt.vt_coder, vt::coder_from_view); - int_f(vars, "vt_software", video.vt.vt_allow_sw, vt::allow_software_from_view); - int_f(vars, "vt_software", video.vt.vt_require_sw, vt::force_software_from_view); int_f(vars, "vt_realtime", video.vt.vt_realtime, vt::rt_from_view); std::string vaapi_quality; @@ -1842,6 +1883,7 @@ namespace config { int_between_f(vars, "lan_encryption_mode", stream.lan_encryption_mode, {0, 2}); int_between_f(vars, "wan_encryption_mode", stream.wan_encryption_mode, {0, 2}); int_between_f(vars, "packetsize", stream.packetsize, {0, PACKETSIZE_MAX}); + bool_f(vars, "dscp_tagging", stream.dscp_tagging); path_f(vars, "file_apps", stream.file_apps); #ifndef __ANDROID__ diff --git a/src/config.h b/src/config.h index 0f2ac52f173..c3e59e8d13b 100644 --- a/src/config.h +++ b/src/config.h @@ -76,9 +76,14 @@ namespace config { int hevc_mode; ///< HEVC support mode advertised to clients. int av1_mode; ///< AV1 support mode advertised to clients. + int mpeg2_mode; ///< MPEG-2 codec advertisement mode. + int h263p_mode; ///< H.263+ codec advertisement mode. int min_threads; ///< Minimum number of threads or slices for CPU encoding. + int max_stream_width; ///< Maximum streamed video width; larger client requests are downscaled. 0 disables the cap. + int max_stream_height; ///< Maximum streamed video height; larger client requests are downscaled. 0 disables the cap. + struct { std::string sw_preset; ///< FFmpeg software-encoder preset. std::string sw_tune; ///< FFmpeg software-encoder tuning profile. @@ -122,8 +127,6 @@ namespace config { } amd; ///< AMD AMF encoder options. struct { - int vt_allow_sw; ///< Whether VideoToolbox may use software encoding. - int vt_require_sw; ///< Whether VideoToolbox must use software encoding. int vt_realtime; ///< Whether VideoToolbox uses realtime encoding mode. int vt_coder; ///< VideoToolbox entropy-coding mode. } vt; ///< VideoToolbox encoder options. @@ -273,6 +276,8 @@ namespace config { // Limit the packetsize to avoid fragmentation on a low MTU link int packetsize; ///< Maximum payload size for network packets. + + bool dscp_tagging; ///< Allow DSCP tagging of audio and video traffic when requested by the client. }; /** @@ -501,4 +506,15 @@ namespace config { * @return True when the `all` preference was persisted and applied; otherwise, false. */ bool select_all_gamepad_drivers_if_licensed(bool virtualhid_licensed); + + /** + * @brief Apply the configured stream resolution cap to a client-requested resolution. + * + * The result preserves the aspect ratio of the request and is rounded down to even + * dimensions as required by encoders and decoders. + * @param width Client-requested width, updated in place when the cap applies. + * @param height Client-requested height, updated in place when the cap applies. + * @return `true` when the resolution was capped. + */ + bool cap_stream_resolution(int &width, int &height); } // namespace config diff --git a/src/confighttp.cpp b/src/confighttp.cpp index 89966c351e1..580ad16c706 100644 --- a/src/confighttp.cpp +++ b/src/confighttp.cpp @@ -1135,6 +1135,103 @@ namespace confighttp { } } + /** + * @brief Remove object members whose values are JSON null. + * + * @param object JSON object to mutate. + * @param members Member names to inspect. + */ + void erase_null_members(nlohmann::json &object, std::initializer_list members) { + for (const char *member : members) { + if (object.contains(member) && object[member].is_null()) { + object.erase(member); + } + } + } + + /** + * @brief Drop empty or invalid prep-cmd arrays and null prep-command members. + * + * @param input_tree Application JSON from the save request, mutated in place. + */ + void normalize_prep_cmd_field(nlohmann::json &input_tree) { + if (!input_tree.contains("prep-cmd")) { + return; + } + if (!input_tree["prep-cmd"].is_array() || input_tree["prep-cmd"].empty()) { + input_tree.erase("prep-cmd"); + return; + } + + for (auto &cmd : input_tree["prep-cmd"]) { + if (!cmd.is_object()) { + continue; + } + erase_null_members(cmd, {"do", "undo", "elevated"}); + } + } + + /** + * @brief Drop empty or invalid detached command arrays. + * + * @param input_tree Application JSON from the save request, mutated in place. + */ + void normalize_detached_field(nlohmann::json &input_tree) { + if (!input_tree.contains("detached")) { + return; + } + if (!input_tree["detached"].is_array() || input_tree["detached"].empty()) { + input_tree.erase("detached"); + } + } + + /** + * @brief Trim cover paths and omit missing, non-string, empty, or whitespace-only values. + * + * @param input_tree Application JSON from the save request, mutated in place. + */ + void normalize_image_path_field(nlohmann::json &input_tree) { + std::string image_path; + if (input_tree.contains("image-path") && input_tree["image-path"].is_string()) { + image_path = input_tree["image-path"].get(); + } + boost::trim(image_path); + if (image_path.empty()) { + input_tree.erase("image-path"); + return; + } + input_tree["image-path"] = image_path; + } + + /** + * @brief Omit null optional application fields and normalize empty collections and cover paths. + * + * Required `name`/`index` handling stays with the caller. Explicit `false` and `0` values are kept. + * Null `do`, `undo`, and `elevated` members are removed from preparation-command objects. + * Missing, non-string, empty, or whitespace-only image-path values are omitted from the saved + * application. Nonempty string values are trimmed before saving. + * + * @param input_tree Application JSON from the save request, mutated in place. + */ + void normalize_optional_app_fields(nlohmann::json &input_tree) { + erase_null_members(input_tree, { + "prep-cmd", + "detached", + "exclude-global-prep-cmd", + "elevated", + "auto-detach", + "wait-all", + "exit-timeout", + "cmd", + "output", + "working-dir", + "image-path", + }); + normalize_prep_cmd_field(input_tree); + normalize_detached_field(input_tree); + normalize_image_path_field(input_tree); + } + /** * @brief Save an application. To save a new application, the index must be `-1`. To update an existing application, you must provide the current index of the application. * @param response The HTTP response object. @@ -1165,6 +1262,10 @@ namespace confighttp { * } * @endcode * + * Missing, non-string, empty, or whitespace-only image-path values are omitted + * from the saved application. Nonempty string values are trimmed before saving. + * Null optional fields are omitted before persistence; explicit `false` and `0` are preserved. + * * @api_examples{/api/apps|:| POST|:| {"name":"Hello, World!","index":-1}} */ void saveApp(const resp_https_t &response, const req_https_t &request) { @@ -1192,13 +1293,7 @@ namespace confighttp { BOOST_LOG(info) << file; nlohmann::json file_tree = nlohmann::json::parse(file); - if (input_tree["prep-cmd"].empty()) { - input_tree.erase("prep-cmd"); - } - - if (input_tree["detached"].empty()) { - input_tree.erase("detached"); - } + normalize_optional_app_fields(input_tree); auto &apps_node = file_tree["apps"]; int index = input_tree["index"].get(); // this will intentionally cause an exception if the provided value is the wrong type diff --git a/src/confighttp.h b/src/confighttp.h index acd43d8f85b..199b308745b 100644 --- a/src/confighttp.h +++ b/src/confighttp.h @@ -204,6 +204,11 @@ namespace confighttp { void resetPortalToken(const resp_https_t &response, const req_https_t &request); + /** + * @brief Save an application with optional fields normalized before persistence. + */ + void saveApp(const resp_https_t &response, const req_https_t &request); + #ifdef SUNSHINE_TESTS /** * @brief Replace native permission statuses for deterministic HTTP tests. diff --git a/src/input.cpp b/src/input.cpp index 1facd6afd23..860ad573113 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -13,6 +13,7 @@ extern "C" { #include #include #include +#include #include #include #include @@ -68,6 +69,16 @@ namespace input { constexpr auto VKEY_LMENU = 0xA4; ///< Windows virtual-key code for lmenu. constexpr auto VKEY_RMENU = 0xA5; ///< Windows virtual-key code for rmenu. + constexpr auto SS_KEY_UNDO = 0x0100; ///< Non-normalized client keycode for undo. + constexpr auto SS_KEY_CUT = 0x0101; ///< Non-normalized client keycode for cut. + constexpr auto SS_KEY_COPY = 0x0102; ///< Non-normalized client keycode for copy. + constexpr auto SS_KEY_PASTE = 0x0103; ///< Non-normalized client keycode for paste. + + constexpr auto SS_SCANCODE_UNDO = 0x7A; ///< SDL scancode delivered for undo when non-normalized. + constexpr auto SS_SCANCODE_CUT = 0x7B; ///< SDL scancode delivered for cut when non-normalized. + constexpr auto SS_SCANCODE_COPY = 0x7C; ///< SDL scancode delivered for copy when non-normalized. + constexpr auto SS_SCANCODE_PASTE = 0x7D; ///< SDL scancode delivered for paste when non-normalized. + /** * @brief Enumerates supported button state options. */ @@ -742,6 +753,31 @@ namespace input { } } + /** + * @brief Turn a point on a rotated output into the output's own orientation. + * @details A rotated output is captured in its native orientation, so a point read off the stream is in that + * orientation. Absolute input targets the output's logical (rotated) coordinates. + * + * @param point Point relative to the output's top-left corner, in the output's native orientation. + * @param output Output geometry; `logical_width` and `logical_height` are the rotated logical size. + * @return The point relative to the output's top-left corner, in its logical orientation. + */ + std::pair rotate_to_output(const std::pair &point, const platf::touch_port_t &output) { + const auto [x, y] = point; + const auto width = static_cast(output.logical_width); + const auto height = static_cast(output.logical_height); + switch (output.transform) { + case 1: // 90 + return {width - y, x}; + case 2: // 180 + return {width - x, height - y}; + case 3: // 270 + return {y, height - x}; + default: + return point; + } + } + /** * @brief Convert stream touch geometry to platform pointer bounds. * @@ -759,6 +795,7 @@ namespace input { touch_port.logical_height, touch_port.env_offset_x, touch_port.env_offset_y, + touch_port.output_name, }; } @@ -908,7 +945,8 @@ namespace input { auto &touch_port = input->touch_port; - platf::abs_mouse(platf_input, platform_touch_port(touch_port), tpcoords->first, tpcoords->second); + const auto [x_out, y_out] = rotate_to_output({tpcoords->first - touch_port.offset_x, tpcoords->second - touch_port.offset_y}, touch_port); + platf::abs_mouse(platf_input, platform_touch_port(touch_port), x_out + touch_port.offset_x, y_out + touch_port.offset_y); } /** @@ -1196,12 +1234,42 @@ namespace input { } auto release = util::endian::little(packet->header.magic) == KEY_UP_EVENT_MAGIC; - auto keyCode = packet->keyCode & 0x00FF; + // Keycodes carrying the legacy 0x8000 flag are normalized Windows virtual-key + // codes for which only the low byte is significant. Non-normalized keycodes + // (such as the Undo/Cut/Copy/Paste editing keys) are interpreted as-is. + const bool normalized_prefix = (packet->keyCode & 0x8000) != 0; + auto keyCode = normalized_prefix ? (packet->keyCode & 0x00FF) : (packet->keyCode & 0xFFFF); + + int modifiers = packet->modifiers; + + // Clients deliver the Undo/Cut/Copy/Paste editing keys as non-normalized + // keycodes, either as the SDL scancode or a dedicated value. Normalize the + // scancode form to the canonical keycode that the platform backend maps to + // the native editing key. Requiring the absence of the 0x8000 prefix keeps + // the F11-F14 virtual keys (which some clients send with the non-normalized + // flag set) from being reinterpreted as editing keys. + if (!normalized_prefix && (static_cast(packet->flags) & static_cast(SS_KBE_FLAG_NON_NORMALIZED)) != std::byte {}) { + switch (keyCode) { + case SS_SCANCODE_UNDO: + keyCode = SS_KEY_UNDO; + break; + case SS_SCANCODE_CUT: + keyCode = SS_KEY_CUT; + break; + case SS_SCANCODE_COPY: + keyCode = SS_KEY_COPY; + break; + case SS_SCANCODE_PASTE: + keyCode = SS_KEY_PASTE; + break; + default: + break; + } + } update_modifier_state(*input, keyCode, release); // Right-alt maps to meta, so it must not also register as ALT - int modifiers = packet->modifiers; if (config::input.key_rightalt_to_key_win && input->alt_keys.right_pressed && !input->alt_keys.left_pressed) { modifiers &= ~MODIFIER_ALT; } @@ -1378,14 +1446,15 @@ namespace input { } /** - * @brief Normalizes coordinates to monitor-local logical touch dimensions. + * @brief Normalize coordinates within the streamed monitor, excluding client letterboxing. + * * @param touch_port The current touch port metadata. * @param coords The in/out coordinate pair to normalize. * @return The monitor-local touch port, or std::nullopt if dimensions are invalid. */ std::optional monitor_touch_port(const input::touch_port_t &touch_port, std::pair &coords) { - const float monitor_logical_w = (touch_port.width * touch_port.scalar_inv) / touch_port.scalar_tpcoords; - const float monitor_logical_h = (touch_port.height * touch_port.scalar_inv) / touch_port.scalar_tpcoords; + const float monitor_logical_w = ((touch_port.width - 2.0f * touch_port.client_offsetX) * touch_port.scalar_inv) / touch_port.scalar_tpcoords; + const float monitor_logical_h = ((touch_port.height - 2.0f * touch_port.client_offsetY) * touch_port.scalar_inv) / touch_port.scalar_tpcoords; if (monitor_logical_w <= 0.0f || monitor_logical_h <= 0.0f) { BOOST_LOG(warning) << "Ignoring touch/pen input due to invalid logical touch dimensions"sv; return std::nullopt; @@ -1401,6 +1470,9 @@ namespace input { static_cast(monitor_logical_h), static_cast(monitor_logical_w), static_cast(monitor_logical_h), + touch_port.env_offset_x, + touch_port.env_offset_y, + touch_port.output_name, }; } @@ -2287,7 +2359,9 @@ namespace input { // key_press is keyed on the client's unmapped virtual-key code, but the press was // emitted through map_keycode(). Release the host key that actually went down, // otherwise a remapped modifier stays latched after the client disconnects. - emit_keyboard_update(map_keycode(vk_from_kpid(key) & 0x00FF), true, flags_from_kpid(key), state.extended); + // The full 16-bit code is preserved so the Undo/Cut/Copy/Paste keycodes + // (0x0100-0x0103) are released with the same code they were pressed with. + emit_keyboard_update(map_keycode(vk_from_kpid(key)), true, flags_from_kpid(key), state.extended); state.pressed = false; } } @@ -2472,6 +2546,10 @@ namespace input { gamepadMask.reset(); } + platf::client_input_t *client_context(const std::shared_ptr &input) { + return input->client_context.get(); + } + int alloc_gamepad(std::shared_ptr &input, std::uint8_t client_index, const platf::gamepad_arrival_t &metadata) { return ::input::alloc_gamepad(input, client_index, metadata); } @@ -2523,6 +2601,18 @@ namespace input { ::input::passthrough(input, &packet); } + void send_absolute_mouse_packet(std::shared_ptr &input, std::int16_t x, std::int16_t y, std::int16_t width, std::int16_t height) { + NV_ABS_MOUSE_MOVE_PACKET packet {}; + packet.header.size = util::endian::big(sizeof(packet) - sizeof(packet.header.size)); + packet.header.magic = util::endian::little(MOUSE_MOVE_ABS_MAGIC); + packet.x = util::endian::big(x); + packet.y = util::endian::big(y); + packet.width = util::endian::big(width); + packet.height = util::endian::big(height); + + ::input::passthrough(input, &packet); + } + void reset_keyboard_state() { task_pool.cancel(key_press_repeat_id); key_press_repeat_id = nullptr; diff --git a/src/input.h b/src/input.h index f181f633611..3aaa15d1cca 100644 --- a/src/input.h +++ b/src/input.h @@ -93,6 +93,14 @@ namespace input { */ void set_platform_input(platf::input_t input); + /** + * @brief Access a retained stream's platform client devices in a unit test. + * + * @param input Retained input state. + * @return Borrowed platform client input context. + */ + platf::client_input_t *client_context(const std::shared_ptr &input); + /** * @brief Allocate a gamepad directly in retained input state for a unit test. * @@ -173,6 +181,17 @@ namespace input { */ void send_relative_mouse_packet(std::shared_ptr &input, std::int16_t delta_x, std::int16_t delta_y); + /** + * @brief Process one client absolute-mouse packet on the calling thread. + * + * @param input Retained input state. + * @param x Horizontal position on the client surface. + * @param y Vertical position on the client surface. + * @param width Width of the client surface. + * @param height Height of the client surface. + */ + void send_absolute_mouse_packet(std::shared_ptr &input, std::int16_t x, std::int16_t y, std::int16_t width, std::int16_t height); + /** * @brief Forget every key Sunshine tracks as pressed and cancel any pending key repeat. */ diff --git a/src/nvhttp.cpp b/src/nvhttp.cpp index 73bdefe50f3..de6a815ed0f 100644 --- a/src/nvhttp.cpp +++ b/src/nvhttp.cpp @@ -510,6 +510,10 @@ namespace nvhttp { } x++; } + // Cap the session resolution up front so downstream consumers (e.g. the display device + // configuration that switches the host display mode) target the actual streamed size + // instead of the uncapped client request. + config::cap_stream_resolution(launch_session->width, launch_session->height); launch_session->unique_id = (get_arg(args, "uniqueid", "unknown")); launch_session->appid = (int) util::from_view(get_arg(args, "appid", "unknown")); launch_session->enable_sops = util::from_view(get_arg(args, "sops", "0")); @@ -1202,8 +1206,9 @@ namespace nvhttp { } uint32_t get_codec_mode_flags() { - uint32_t codec_mode_flags = SCM_H264; - if (video::last_encoder_probe_supported_yuv444_for_codec[0]) { + const auto &modes = video::probed_codec_modes(); + uint32_t codec_mode_flags = modes.h264 ? SCM_H264 : 0; + if (modes.h264 && video::last_encoder_probe_supported_yuv444_for_codec[0]) { codec_mode_flags |= SCM_H264_HIGH8_444; } if (video::active_hevc_mode >= 2) { @@ -1231,6 +1236,12 @@ namespace nvhttp { if ((video::active_av1_mode == 4 || video::active_av1_mode == 5) && video::last_encoder_probe_supported_dynamic_range_yuv444_for_codec[2]) { codec_mode_flags |= SCM_AV1_HIGH10_444; } + if (modes.mpeg2 >= 2) { + codec_mode_flags |= SCM_MPEG2; + } + if (modes.h263p == 2) { + codec_mode_flags |= SCM_H263P; + } return codec_mode_flags; } diff --git a/src/platform/common.h b/src/platform/common.h index 62961d7a310..de03e7c7549 100644 --- a/src/platform/common.h +++ b/src/platform/common.h @@ -20,7 +20,7 @@ // local includes #ifndef _WIN32 - #include "src/boost_process_compat.h" + #include "src/compat/boost_process.h" #endif #include "src/config.h" #include "src/logging.h" @@ -395,6 +395,8 @@ namespace platf { int logical_height; ///< Logical height after display scaling. int env_offset_x {}; ///< Horizontal origin of the full input environment in native desktop coordinates. int env_offset_y {}; ///< Vertical origin of the full input environment in native desktop coordinates. + std::string output_name {}; ///< Native connector name used to assign compositor-managed touch and pen devices. + int transform {}; ///< Wayland output transform (rotation) of the display. }; // These values must match Limelight-internal.h's SS_FF_* constants! @@ -684,6 +686,38 @@ namespace platf { nvenc::nvenc_encoder *nvenc = nullptr; ///< NVENC encoder instance owned by the encode device. }; + /** + * @brief A single encoded frame produced by a native VideoToolbox encoder. + */ + struct vt_encoded_frame { + std::vector data; ///< Annex-B elementary stream for exactly one frame. + uint64_t frame_index = 0; ///< Frame index the data corresponds to. + bool idr = false; ///< Whether the frame is an IDR frame. + }; + + /** + * @brief Native VideoToolbox-backed encode device state. + */ + struct vt_encode_device_t: encode_device_t { + /** + * @brief Initialize the platform encoder for the client stream configuration. + * + * @param client_config Client stream configuration negotiated for this session. + * @param colorspace Colorimetry information used for conversion or encoding. + * @return True when the backend successfully completes the requested action. + */ + virtual bool init_encoder(const video::config_t &client_config, const video::sunshine_colorspace_t &colorspace) = 0; + + /** + * @brief Encode the frame most recently supplied via convert(). + * + * @param frame_index Frame index to associate with the encoded output. + * @param force_idr Whether the frame must be encoded as an IDR frame. + * @return Encoded frame, or one with empty data on failure. + */ + virtual vt_encoded_frame encode_frame(uint64_t frame_index, bool force_idr) = 0; + }; + /** * @brief Enumerates supported capture options. */ @@ -769,6 +803,16 @@ namespace platf { return nullptr; } + /** + * @brief Create a native VideoToolbox encode device. + * + * @param pix_fmt Sunshine pixel format to convert or allocate for. + * @return Constructed VideoToolbox encode device object. + */ + virtual std::unique_ptr make_vt_encode_device(pix_fmt_e pix_fmt) { + return nullptr; + } + /** * @brief Report whether the active display mode is HDR. * @@ -802,6 +846,7 @@ namespace platf { virtual ~display_t() = default; // Offsets for when streaming a specific monitor. By default, they are 0. + std::string output_name; ///< Native connector name of the captured display for absolute input assignment. int offset_x {0}; ///< Horizontal capture offset in physical pixels. int offset_y {0}; ///< Vertical capture offset in physical pixels. int env_offset_x {0}; ///< Horizontal origin of the full capture environment in native desktop coordinates. @@ -814,6 +859,7 @@ namespace platf { int height {0}; ///< Height of the captured display in physical pixels. int logical_width {0}; ///< Width of the captured display after display scaling. int logical_height {0}; ///< Height of the captured display after display scaling. + int transform {0}; ///< Wayland output transform (rotation) of the captured display. protected: // collect capture timing data (at loglevel debug) diff --git a/src/platform/linux/cuda.cpp b/src/platform/linux/cuda.cpp index f065074cb4c..8f3613d2f03 100644 --- a/src/platform/linux/cuda.cpp +++ b/src/platform/linux/cuda.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -100,7 +101,9 @@ namespace cuda { static cdf_t cdf; /** - * @brief Log a failed call through a CUDA function table. + * @brief Log a failed CUDA call with its numeric result and safe fallback error text. + * + * Error lookups may fail or return null, so only use text from successful, non-null lookups. * * @param functions CUDA function table. * @param result Result of the call. @@ -109,13 +112,17 @@ namespace cuda { */ inline static int check(const CudaFunctions &functions, CUresult result, const std::string_view &sv) { if (result != CUDA_SUCCESS) { - const char *name; - const char *description; + const char *name = nullptr; + const char *description = nullptr; - functions.cuGetErrorName(result, &name); - functions.cuGetErrorString(result, &description); + if (functions.cuGetErrorName(result, &name) != CUDA_SUCCESS || !name) { + name = "Unknown CUDA error"; + } + if (functions.cuGetErrorString(result, &description) != CUDA_SUCCESS || !description) { + description = "No error description available"; + } - BOOST_LOG(error) << sv << name << ':' << description; + BOOST_LOG(error) << sv << name << " (" << static_cast(result) << "): " << description; return -1; } @@ -165,23 +172,44 @@ namespace cuda { }; /** - * @brief Map CUDA graphics resources for use as an image. + * @brief Load a CUDA function table unless it is already loaded, and initialize CUDA through it. * - * @return 0 on success; nonzero or negative platform status on failure. + * @param table Table to load. + * @param load Function that fills the table, returning 0 on success. + * @return 0 on success, -1 on failure. */ - int init() { - auto status = cuda_load_functions(&cdf, nullptr); - if (status) { - BOOST_LOG(error) << "Couldn't load cuda: "sv << status; + int init(CudaFunctions **table, const function_table_loader_t &load) { + // Load the table only once: running streams call through it on every frame, and reloading empties + // it first. The mutex stops streams that start at the same time from loading it concurrently. + static std::mutex load_mutex; + std::scoped_lock lock {load_mutex}; - return -1; + if (*table == nullptr) { + if (auto status = load(table)) { + BOOST_LOG(error) << "Couldn't load cuda: "sv << status; + + return -1; + } } - CU_CHECK(cdf->cuInit(0), "Couldn't initialize cuda"); + if (check(**table, (*table)->cuInit(0), "Couldn't initialize cuda: "sv)) { + return -1; + } return 0; } + /** + * @brief Load the CUDA driver library the first time, and initialize CUDA. + * + * @return 0 on success; nonzero or negative platform status on failure. + */ + int init() { + return init(&cdf, [](CudaFunctions **table) { + return cuda_load_functions(table, nullptr); + }); + } + /** * @brief CUDA encode device that imports captured frames into CUDA memory. */ diff --git a/src/platform/linux/cuda.h b/src/platform/linux/cuda.h index c1137ae3a34..b2346a7be6f 100644 --- a/src/platform/linux/cuda.h +++ b/src/platform/linux/cuda.h @@ -523,6 +523,22 @@ namespace cuda { int create_gl_cuda_target(const gl_cuda_target_ops_t &ops); int init(); + + /** + * @brief Fill a CUDA function table the way `cuda_load_functions` does. + */ + using function_table_loader_t = std::function; + + /** + * @brief Load a CUDA function table unless it is already loaded, and initialize CUDA through it. + * + * `init()` passes the table every encode device shares and the real loader. + * + * @param table Table to load. + * @param load Function that fills the table, returning 0 on success. + * @return 0 on success, -1 on failure. + */ + int init(CudaFunctions **table, const function_table_loader_t &load); } // namespace cuda /** diff --git a/src/platform/linux/display_geometry.h b/src/platform/linux/display_geometry.h new file mode 100644 index 00000000000..ab38dae2520 --- /dev/null +++ b/src/platform/linux/display_geometry.h @@ -0,0 +1,79 @@ +/** + * @file src/platform/linux/display_geometry.h + * @brief Desktop bounds for absolute input across Linux capture backends. + */ +#pragma once + +// standard includes +#include + +// local includes +#include "src/platform/common.h" + +namespace platf { + /** + * @brief Accumulate monitor extents while preserving a negative desktop origin. + * + * Output offsets are compositor coordinates. Logical dimensions define the + * absolute input desktop; physical dimensions retain capture's pixel extents. + */ + class desktop_geometry_t { + public: + /** + * @brief Include an active monitor in the desktop bounds. + * + * @param viewport Monitor position and physical/logical dimensions. + */ + void add(const touch_port_t &viewport) { + if (viewport.width <= 0 || viewport.height <= 0) { + return; + } + const bool has_logical_size = viewport.logical_width > 0 && viewport.logical_height > 0; + const int logical_width = has_logical_size ? viewport.logical_width : viewport.width; + const int logical_height = has_logical_size ? viewport.logical_height : viewport.height; + if (!initialized_) { + bounds_ = viewport; + bounds_.logical_width = logical_width; + bounds_.logical_height = logical_height; + bounds_.output_name.clear(); + initialized_ = true; + return; + } + const int left = std::min(bounds_.offset_x, viewport.offset_x); + const int top = std::min(bounds_.offset_y, viewport.offset_y); + bounds_.width = std::max(bounds_.offset_x + bounds_.width, viewport.offset_x + viewport.width) - left; + bounds_.height = std::max(bounds_.offset_y + bounds_.height, viewport.offset_y + viewport.height) - top; + bounds_.logical_width = std::max(bounds_.offset_x + bounds_.logical_width, viewport.offset_x + logical_width) - left; + bounds_.logical_height = std::max(bounds_.offset_y + bounds_.logical_height, viewport.offset_y + logical_height) - top; + bounds_.offset_x = left; + bounds_.offset_y = top; + } + + /** + * @brief Get the union of included monitors. + * + * @return Desktop origin and extents, or zero dimensions if no valid monitor was included. + */ + const touch_port_t &bounds() const { + return bounds_; + } + + /** + * @brief Publish the accumulated input desktop on a capture display. + * + * @param display Capture display receiving physical and logical desktop geometry. + */ + void apply(display_t &display) const { + display.env_offset_x = bounds_.offset_x; + display.env_offset_y = bounds_.offset_y; + display.env_width = bounds_.width; + display.env_height = bounds_.height; + display.env_logical_width = bounds_.logical_width; + display.env_logical_height = bounds_.logical_height; + } + + private: + touch_port_t bounds_ {}; ///< Union of all valid monitor extents. + bool initialized_ = false; ///< Whether a valid monitor has established the origin. + }; +} // namespace platf diff --git a/src/platform/linux/kms_display.h b/src/platform/linux/kms_display.h new file mode 100644 index 00000000000..b4861005f7d --- /dev/null +++ b/src/platform/linux/kms_display.h @@ -0,0 +1,82 @@ +/** + * @file src/platform/linux/kms_display.h + * @brief Display enumeration data for one KMS capture backend. + */ +#pragma once + +// standard includes +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// local includes +#include "display_geometry.h" + +namespace platf::kms { + /** + * @brief Connector identity and geometry for one KMS monitor. + */ + struct monitor_t { + std::uint32_t type; ///< DRM connector type. + std::uint32_t index; ///< Index within the connector type. + std::uint32_t monitor_index; ///< Index in the capture backend's display list. + touch_port_t viewport; ///< Monitor geometry for capture and absolute input. + }; + + /** + * @brief DRM card and its monitor descriptors indexed by CRTC ID. + */ + struct card_descriptor_t { + std::string path; ///< DRM card device path. + std::map crtc_to_monitor; ///< Monitors associated with the card. + }; + + /** + * @brief A display discovered on a particular card and plane. + */ + struct output_t { + std::string name; ///< DRM connector name. + std::size_t card_index; ///< Index into this enumeration's card descriptors. + std::uint32_t plane_id; ///< ID of the DRM plane that was scanning out this output. + std::uint32_t crtc_id; ///< CRTC the plane was attached to during enumeration. + }; + + /** + * @brief Display names, card descriptors, and desktop geometry enumerated together for one memory type. + */ + struct display_enumeration_t { + std::vector outputs; ///< Displays in capture order. + std::vector cards; ///< DRM cards in capture order. + desktop_geometry_t desktop; ///< Geometry of this enumeration's available outputs. + + /** + * @brief Map a connector name or a legacy numeric display name to a capture index. + * + * @param name Display name from the stream or host configuration. + * @return Display index, zero for the default name, or no value for an unknown connector. + */ + std::optional display_index(std::string_view name) const { + if (name.empty()) { + return 0; + } + + std::size_t index; + const auto [end, parse_error] = std::from_chars(name.data(), name.data() + name.size(), index); + if (end == name.data() + name.size() && parse_error == std::errc {}) { + return index; + } + + auto position = std::ranges::find(outputs, name, &output_t::name); + if (position == outputs.end()) { + return std::nullopt; + } + return static_cast(position - outputs.begin()); + } + }; +} // namespace platf::kms diff --git a/src/platform/linux/kmsgrab.cpp b/src/platform/linux/kmsgrab.cpp index 0274f0b755a..41197559a38 100644 --- a/src/platform/linux/kmsgrab.cpp +++ b/src/platform/linux/kmsgrab.cpp @@ -25,6 +25,7 @@ // local includes #include "cuda.h" #include "graphics.h" +#include "kms_display.h" #include "kms_plane.h" #include "src/config.h" #include "src/logging.h" @@ -343,12 +344,6 @@ namespace platf { */ using conn_type_count_t = std::map; - static int env_width; - static int env_height; - - static int env_logical_width; - static int env_logical_height; - /** * @brief Convert a DRM plane type value to a diagnostic string. * @@ -387,31 +382,6 @@ namespace platf { bool connected; ///< Whether the DRM connector is connected. }; - /** - * @brief KMS monitor capture state and DRM resources. - */ - struct monitor_t { - // Connector attributes - std::uint32_t type; ///< Type. - std::uint32_t index; ///< Index. - - // Monitor index in the global list - std::uint32_t monitor_index; ///< Monitor index. - - platf::touch_port_t viewport; ///< Viewport. - }; - - /** - * @brief DRM card, device path, and render-node metadata. - */ - struct card_descriptor_t { - std::string path; ///< Path. - - std::map crtc_to_monitor; ///< Crtc to monitor. - }; - - static std::vector card_descriptors; - static std::uint32_t from_view(const std::string_view &string) { #ifndef DOXYGEN #define _CONVERT(x, y) \ @@ -752,17 +722,15 @@ namespace platf { /** * @brief Return framebuffer metadata for the current CRTC. * - * @param plane DRM or EGL plane index being described. + * @param plane DRM plane whose framebuffer metadata should be read. * @return Framebuffer metadata wrapper, or nullptr when the framebuffer cannot be read. */ - fb_t fb(plane_t::pointer plane) { - auto fb2 = platf::kms::privileged_drm_worker::drmModeGetFB2_privileged(fd.el, plane->fb_id); - if (fb2) { + fb_t fb(const drmModePlane *plane) { + if (auto fb2 = platf::kms::privileged_drm_worker::drmModeGetFB2_privileged(fd.el, plane->fb_id); fb2) { return std::make_unique(fd.el, fb2); } - auto fb = platf::kms::privileged_drm_worker::drmModeGetFB_privileged(fd.el, plane->fb_id); - if (fb) { + if (auto fb = platf::kms::privileged_drm_worker::drmModeGetFB_privileged(fd.el, plane->fb_id); fb) { return std::make_unique(fd.el, fb); } @@ -937,8 +905,7 @@ namespace platf { file_t handleFD(std::uint32_t handle) { file_t fb_fd; - auto status = drmPrimeHandleToFD(fd.el, handle, 0 /* flags */, &fb_fd.el); - if (status) { + if (const auto status = drmPrimeHandleToFD(fd.el, handle, 0 /* flags */, &fb_fd.el); status) { return {}; } @@ -1072,7 +1039,7 @@ namespace platf { /** * @brief Write a debug log representation of the input packet. * - * @param plane DRM or EGL plane index being described. + * @param plane DRM plane whose framebuffer metadata should be read. * @param fb Framebuffer object to bind or update. * @param crtc DRM CRTC identifier to map. */ @@ -1108,30 +1075,6 @@ namespace platf { BOOST_LOG(debug) << ss.str(); } - /** - * @brief Map display name to monitor index - * - * @param display_name Name of the display to determine monitor index for (or monitor index string value) - * @return monitor's display index - */ - static int64_t map_display_name_to_monitor_index(const std::string_view &display_name) { - // Handle (legacy) monitor index strings by converting them to integer - if (display_name.empty() || std::ranges::all_of(display_name, ::isdigit)) { - return util::from_view(display_name); - } - // display_name is a connector name (not empty and containing non-digits) - for (auto &card_descriptor : kms::card_descriptors) { - for (const auto &monitor_descriptor : card_descriptor.crtc_to_monitor | std::views::values) { - if (display_name == std::format("{}-{}", drmModeGetConnectorTypeName(monitor_descriptor.type), monitor_descriptor.index)) { - BOOST_LOG(info) << "Mapped '"sv << display_name << "' to kmsgrab monitor index " << monitor_descriptor.monitor_index; - return monitor_descriptor.monitor_index; - } - } - } - BOOST_LOG(warning) << "Couldn't map '"sv << display_name << "' to a monitor index. Falling back to first monitor in list (index=0)."; - return 0; // Fallback to first index if nothing can be matched - } - /** * @brief Base KMS display capture backend shared by RAM and VRAM paths. */ @@ -1152,206 +1095,129 @@ namespace platf { * * @param display_name Display name. * @param config Configuration values to apply. + * @param enumeration Displays and geometry for this capture backend. * @return 0 on success; nonzero or negative platform status on failure. */ - int init(const std::string &display_name, const ::video::config_t &config) { + int init(const std::string &display_name, const ::video::config_t &config, const display_enumeration_t &enumeration) { delay = ::video::capture_frame_interval(config); - int monitor_index = map_display_name_to_monitor_index(display_name); - int monitor = 0; + const auto index = enumeration.display_index(display_name); + if (!index.has_value()) { + BOOST_LOG(warning) << "Couldn't map '"sv << display_name << "' to a kmsgrab monitor. Falling back to the first output."sv; + } + const auto monitor_index = index.value_or(0); + if (monitor_index >= enumeration.outputs.size()) { + BOOST_LOG(error) << "Couldn't find monitor ["sv << monitor_index << ']'; + return -1; + } - fs::path card_dir {"/dev/dri"sv}; - for (auto &entry : fs::directory_iterator {card_dir}) { - auto file = entry.path().filename(); + const auto &output = enumeration.outputs[monitor_index]; + const auto &descriptor = enumeration.cards[output.card_index]; + if (card.init(descriptor.path.c_str())) { + return -1; + } - auto filestring = file.generic_string(); - if (filestring.size() < 4 || std::string_view {filestring}.substr(0, 4) != "card"sv) { - continue; - } + plane_t plane {drmModeGetPlane(card.fd.el, output.plane_id)}; + if (!plane || !plane->fb_id || plane->crtc_id != output.crtc_id) { + BOOST_LOG(warning) << "KMS output changed during capture initialization: "sv << output.name; + return -1; + } - kms::card_t card; - if (card.init(entry.path().c_str())) { - continue; - } + auto fb = card.fb(plane.get()); + if (!fb) { + BOOST_LOG(error) << "Couldn't get drm fb for plane ["sv << plane->fb_id << "]: "sv << strerror(errno); + return -1; + } - // Skip non-Nvidia cards if we're looking for CUDA devices - // unless NVENC is selected manually by the user - if (mem_type == mem_type_e::cuda && !card.is_nvidia()) { - BOOST_LOG(debug) << file << " is not a CUDA device"sv; - if (config::video.encoder != "nvenc") { - continue; - } - } + if (!fb->handles[0]) { + BOOST_LOG(error) << "Couldn't get handle for DRM Framebuffer ["sv << plane->fb_id << "]: Probably not permitted"sv; + return -1; + } - // Skip Nvidia cards if we're looking for VAAPI devices - // This is important for hybrid GPU laptops where the display - // may be connected through NVIDIA but rendering happens on Intel - if (mem_type == mem_type_e::vaapi && card.is_nvidia()) { - BOOST_LOG(debug) << file << " is an NVIDIA card, skipping for VAAPI"sv; - continue; + for (int i = 0; i < 4 && fb->handles[i]; ++i) { + auto fb_fd = card.handleFD(fb->handles[i]); + if (fb_fd.el < 0) { + BOOST_LOG(error) << "Couldn't get primary file descriptor for Framebuffer ["sv << fb->fb_id << "]: "sv << strerror(errno); } + } - auto end = std::end(card); - for (auto plane = std::begin(card); plane != end; ++plane) { - // Skip unused planes - if (!plane->fb_id) { - continue; - } - - if (card.is_cursor(plane->plane_id)) { - continue; - } - - if (monitor != monitor_index) { - ++monitor; - continue; - } - - auto fb = card.fb(plane.get()); - if (!fb) { - BOOST_LOG(error) << "Couldn't get drm fb for plane ["sv << plane->fb_id << "]: "sv << strerror(errno); - return -1; - } - - if (!fb->handles[0]) { - BOOST_LOG(error) << "Couldn't get handle for DRM Framebuffer ["sv << plane->fb_id << "]: Probably not permitted"sv; - return -1; - } - - for (int i = 0; i < 4; ++i) { - if (!fb->handles[i]) { - break; - } - - auto fb_fd = card.handleFD(fb->handles[i]); - if (fb_fd.el < 0) { - BOOST_LOG(error) << "Couldn't get primary file descriptor for Framebuffer ["sv << fb->fb_id << "]: "sv << strerror(errno); - continue; - } - } - - auto crtc = card.crtc(plane->crtc_id); - if (!crtc) { - BOOST_LOG(error) << "Couldn't get CRTC info: "sv << strerror(errno); - continue; - } - - BOOST_LOG(info) << "Found monitor for DRM screencasting"sv; - - // We need to find the correct /dev/dri/card{nr} to correlate the crtc_id with the monitor descriptor - auto pos = std::find_if(std::begin(card_descriptors), std::end(card_descriptors), [&](card_descriptor_t &cd) { - return cd.path == filestring; - }); - - if (pos == std::end(card_descriptors)) { - // This code path shouldn't happen, but it's there just in case. - // card_descriptors is part of the guesswork after all. - BOOST_LOG(error) << "Couldn't find ["sv << entry.path() << "]: This shouldn't have happened :/"sv; - return -1; - } - - // TODO: surf_sd = fb->to_sd(); - - kms::print(plane.get(), fb.get(), crtc.get()); - - img_width = fb->width; - img_height = fb->height; - img_offset_x = crtc->x; - img_offset_y = crtc->y; - - this->env_width = ::platf::kms::env_width; - this->env_height = ::platf::kms::env_height; - - this->env_logical_width = ::platf::kms::env_logical_width; - this->env_logical_height = ::platf::kms::env_logical_height; - - auto monitor_pos = pos->crtc_to_monitor.find(plane->crtc_id); - if (monitor_pos != std::end(pos->crtc_to_monitor)) { - auto &viewport = monitor_pos->second.viewport; - - width = viewport.width; - height = viewport.height; - - logical_width = viewport.logical_width; - logical_height = viewport.logical_height; - - switch (card.get_panel_orientation(plane->plane_id)) { - case DRM_MODE_ROTATE_270: - BOOST_LOG(debug) << "Detected panel orientation at 90, swapping width and height."; - width = viewport.height; - height = viewport.width; - break; - case DRM_MODE_ROTATE_90: - case DRM_MODE_ROTATE_180: - BOOST_LOG(warning) << "Panel orientation is unsupported, screen capture may not work correctly."; - break; - } - - offset_x = viewport.offset_x; - offset_y = viewport.offset_y; - } - - // This code path shouldn't happen, but it's there just in case. - // crtc_to_monitor is part of the guesswork after all. - else { - BOOST_LOG(warning) << "Couldn't find crtc_id, this shouldn't have happened :\\"sv; - width = crtc->width; - height = crtc->height; - offset_x = crtc->x; - offset_y = crtc->y; - } - - plane_id = plane->plane_id; - crtc_id = plane->crtc_id; - crtc_index = card.get_crtc_index_by_id(plane->crtc_id); - - // Find the connector for this CRTC - kms::conn_type_count_t conn_type_count; - for (auto &connector : card.monitors(conn_type_count)) { - if (connector.crtc_id == crtc_id) { - BOOST_LOG(info) << "Found connector ID ["sv << connector.connector_id << ']'; - - connector_id = connector.connector_id; + auto crtc = card.crtc(plane->crtc_id); + if (!crtc) { + BOOST_LOG(error) << "Couldn't get CRTC info: "sv << strerror(errno); + return -1; + } - auto connector_props = card.connector_props(*connector_id); - hdr_metadata_blob_id = card.prop_value_by_name(connector_props, "HDR_OUTPUT_METADATA"sv); - } - } + BOOST_LOG(info) << "Found monitor for DRM screencasting: "sv << output.name; + kms::print(plane.get(), fb.get(), crtc.get()); - this->card = std::move(card); - goto break_loop; + img_width = fb->width; + img_height = fb->height; + img_offset_x = crtc->x; + img_offset_y = crtc->y; + enumeration.desktop.apply(*this); + + const auto &viewport = descriptor.crtc_to_monitor.at(plane->crtc_id).viewport; + width = viewport.width; + height = viewport.height; + logical_width = viewport.logical_width; + logical_height = viewport.logical_height; + + switch (card.get_panel_orientation(plane->plane_id)) { + case DRM_MODE_ROTATE_270: + BOOST_LOG(debug) << "Detected panel orientation at 90, swapping width and height."; + width = viewport.height; + height = viewport.width; + break; + case DRM_MODE_ROTATE_90: + case DRM_MODE_ROTATE_180: + BOOST_LOG(warning) << "Panel orientation is unsupported, screen capture may not work correctly."; + break; + } + + offset_x = viewport.offset_x; + offset_y = viewport.offset_y; + output_name = viewport.output_name; + + plane_id = plane->plane_id; + crtc_id = plane->crtc_id; + crtc_index = card.get_crtc_index_by_id(plane->crtc_id); + + // Find the connector for this CRTC + kms::conn_type_count_t conn_type_count; + for (auto &connector : card.monitors(conn_type_count)) { + if (connector.crtc_id == crtc_id) { + BOOST_LOG(info) << "Found connector ID ["sv << connector.connector_id << ']'; + + connector_id = connector.connector_id; + + auto connector_props = card.connector_props(*connector_id); + hdr_metadata_blob_id = card.prop_value_by_name(connector_props, "HDR_OUTPUT_METADATA"sv); } } - BOOST_LOG(error) << "Couldn't find monitor ["sv << monitor_index << ']'; - return -1; - - // Neatly break from nested for loop - break_loop: - // Look for the cursor plane for this CRTC cursor_plane_id = -1; auto end = std::end(card); - for (auto plane = std::begin(card); plane != end; ++plane) { - if (!card.is_cursor(plane->plane_id)) { + for (auto cursor_plane = std::begin(card); cursor_plane != end; ++cursor_plane) { + if (!card.is_cursor(cursor_plane->plane_id)) { continue; } // NB: We do not skip unused planes here because cursor planes // will look unused if the cursor is currently hidden. - if (!(plane->possible_crtcs & (1 << crtc_index))) { + if (!(cursor_plane->possible_crtcs & (1 << crtc_index))) { // Skip cursor planes for other CRTCs continue; - } else if (plane->possible_crtcs != (1 << crtc_index)) { + } else if (cursor_plane->possible_crtcs != (1 << crtc_index)) { // We assume a 1:1 mapping between cursor planes and CRTCs, which seems to // match the behavior of drivers in the real world. If it's violated, we'll // proceed anyway but print a warning in the log. BOOST_LOG(warning) << "Cursor plane spans multiple CRTCs!"sv; } - BOOST_LOG(info) << "Found cursor plane ["sv << plane->plane_id << ']'; - cursor_plane_id = plane->plane_id; + BOOST_LOG(info) << "Found cursor plane ["sv << cursor_plane->plane_id << ']'; + cursor_plane_id = cursor_plane->plane_id; break; } @@ -1763,15 +1629,16 @@ namespace platf { * * @param display_name Display name. * @param config Configuration values to apply. + * @param enumeration Displays and geometry for this capture backend. * @return 0 on success; nonzero or negative platform status on failure. */ - int init(const std::string &display_name, const ::video::config_t &config) { + int init(const std::string &display_name, const ::video::config_t &config, const display_enumeration_t &enumeration) { if (!gbm::create_device) { BOOST_LOG(warning) << "libgbm not initialized"sv; return -1; } - if (display_t::init(display_name, config)) { + if (display_t::init(display_name, config, enumeration)) { return -1; } @@ -2119,12 +1986,14 @@ namespace platf { /** * @brief Capture a display frame into the provided image object. * - * @param pull_free_image_cb Pull free image cb. + * @tparam PullFreeImage Callback type used to retrieve a free capture image. + * @param pull_free_image_cb Callback retrieving a free capture image. * @param img_out Captured KMS image descriptor returned to the streaming pipeline. * @param cursor Cursor image or visibility state to composite. * @return Capture status reported to the streaming pipeline. */ - capture_e snapshot(const pull_free_image_cb_t &pull_free_image_cb, std::shared_ptr &img_out, std::chrono::milliseconds /* timeout */, bool cursor) { + template + capture_e snapshot(const PullFreeImage &pull_free_image_cb, std::shared_ptr &img_out, std::chrono::milliseconds /* timeout */, bool cursor) { std::array fb_fd; if (!pull_free_image_cb(img_out)) { @@ -2133,8 +2002,7 @@ namespace platf { auto img = (egl::img_descriptor_t *) img_out.get(); img->reset(); - auto status = refresh(fb_fd.data(), &img->sd, img->frame_timestamp); - if (status != capture_e::ok) { + if (const auto status = refresh(fb_fd.data(), &img->sd, img->frame_timestamp); status != capture_e::ok) { return status; } @@ -2171,10 +2039,11 @@ namespace platf { * * @param display_name Display name. * @param config Configuration values to apply. + * @param enumeration Displays and geometry for this capture backend. * @return 0 on success; nonzero or negative platform status on failure. */ - int init(const std::string &display_name, const ::video::config_t &config) { - if (display_t::init(display_name, config)) { + int init(const std::string &display_name, const ::video::config_t &config, const display_enumeration_t &enumeration) { + if (display_t::init(display_name, config, enumeration)) { return -1; } @@ -2200,34 +2069,6 @@ namespace platf { } // namespace kms - /** - * @brief Create a KMS display capture backend. - * - * @param hwdevice_type Hardware device type requested for capture or encode. - * @param display_name Display name. - * @param config Configuration values to apply. - * @return KMS display backend, or nullptr when initialization fails. - */ - std::shared_ptr kms_display(mem_type_e hwdevice_type, const std::string &display_name, const ::video::config_t &config) { - if (hwdevice_type == mem_type_e::vaapi || hwdevice_type == mem_type_e::cuda || hwdevice_type == mem_type_e::vulkan) { - auto disp = std::make_shared(hwdevice_type); - - if (!disp->init(display_name, config)) { - return disp; - } - - // In the case of failure, attempt the old method for VAAPI - } - - auto disp = std::make_shared(hwdevice_type); - - if (disp->init(display_name, config)) { - return nullptr; - } - - return disp; - } - /** * 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, @@ -2264,6 +2105,7 @@ namespace platf { for (auto &card_descriptor : cds) { for (auto &[_, monitor_descriptor] : card_descriptor.crtc_to_monitor) { if (monitor_descriptor.index == index && monitor_descriptor.type == type) { + monitor_descriptor.viewport.output_name = monitor->name; monitor_descriptor.viewport.offset_x = monitor->viewport.offset_x; monitor_descriptor.viewport.offset_y = monitor->viewport.offset_y; monitor_descriptor.viewport.logical_width = monitor->viewport.logical_width; @@ -2294,16 +2136,13 @@ namespace platf { BOOST_LOG(info) << "--------- End of KMS monitor list ---------"sv; } - // A list of names of displays accepted as display_name /** - * @brief Enumerate display names accepted by the KMS backend. + * @brief Enumerate the displays, planes, and geometry available to one KMS backend. * * @param hwdevice_type Hardware device type requested for capture or encode. - * @return KMS display names, or an empty list when KMS capture is unavailable. + * @return An independent snapshot of the available KMS displays. */ - std::vector kms_display_names(mem_type_e hwdevice_type) { - int count = 0; - + static kms::display_enumeration_t enumerate_kms_displays(mem_type_e hwdevice_type) { if (!fs::exists("/dev/dri")) { BOOST_LOG(warning) << "Couldn't find /dev/dri, kmsgrab won't be enabled"sv; return {}; @@ -2316,8 +2155,7 @@ namespace platf { kms::conn_type_count_t conn_type_count; - std::vector cds; - std::vector display_names; + kms::display_enumeration_t enumeration; fs::path card_dir {"/dev/dri"sv}; for (auto &entry : fs::directory_iterator {card_dir}) { @@ -2388,61 +2226,76 @@ namespace platf { } auto it = crtc_to_monitor.find(plane->crtc_id); - if (it != std::end(crtc_to_monitor)) { - it->second.viewport = platf::touch_port_t { - .offset_x = (int) crtc->x, - .offset_y = (int) crtc->y, - .width = (int) crtc->width, - .height = (int) crtc->height, - }; - it->second.monitor_index = count; + if (it == crtc_to_monitor.end()) { + continue; } - - kms::env_width = std::max(kms::env_width, (int) (crtc->x + crtc->width)); - kms::env_height = std::max(kms::env_height, (int) (crtc->y + crtc->height)); + const auto output_name = std::format("{}-{}", drmModeGetConnectorTypeName(it->second.type), it->second.index); + it->second.viewport = platf::touch_port_t { + .offset_x = (int) crtc->x, + .offset_y = (int) crtc->y, + .width = (int) crtc->width, + .height = (int) crtc->height, + .output_name = output_name, + }; + it->second.monitor_index = enumeration.outputs.size(); kms::print(plane.get(), fb.get(), crtc.get()); - display_names.emplace_back(std::format("{}-{}", drmModeGetConnectorTypeName(it->second.type), it->second.index)); - count++; + enumeration.outputs.emplace_back(output_name, enumeration.cards.size(), plane->plane_id, plane->crtc_id); } - cds.emplace_back(kms::card_descriptor_t { - std::move(file), - std::move(crtc_to_monitor), - }); + enumeration.cards.emplace_back(entry.path().string(), std::move(crtc_to_monitor)); } if (!wl::init()) { - correlate_to_wayland(cds); + correlate_to_wayland(enumeration.cards); } - // Deduce the full virtual desktop size - kms::env_width = 0; - kms::env_height = 0; - - kms::env_logical_width = 0; - kms::env_logical_height = 0; - - for (auto &card_descriptor : cds) { - for (auto &[_, monitor_descriptor] : card_descriptor.crtc_to_monitor) { - BOOST_LOG(debug) << "Monitor description"sv; - BOOST_LOG(debug) << "Resolution: "sv << monitor_descriptor.viewport.width << 'x' << monitor_descriptor.viewport.height; - BOOST_LOG(debug) << "Offset: "sv << monitor_descriptor.viewport.offset_x << 'x' << monitor_descriptor.viewport.offset_y; - - kms::env_width = std::max(kms::env_width, monitor_descriptor.viewport.offset_x + monitor_descriptor.viewport.width); - kms::env_height = std::max(kms::env_height, monitor_descriptor.viewport.offset_y + monitor_descriptor.viewport.height); - - kms::env_logical_height = std::max(kms::env_logical_height, monitor_descriptor.viewport.offset_y + monitor_descriptor.viewport.logical_height); - kms::env_logical_width = std::max(kms::env_logical_width, monitor_descriptor.viewport.offset_x + monitor_descriptor.viewport.logical_width); + for (const auto &card_descriptor : enumeration.cards) { + for (const auto &[_, monitor_descriptor] : card_descriptor.crtc_to_monitor) { + enumeration.desktop.add(monitor_descriptor.viewport); } } + const auto &bounds = enumeration.desktop.bounds(); + BOOST_LOG(debug) << "Desktop resolution: "sv << bounds.width << 'x' << bounds.height; - BOOST_LOG(debug) << "Desktop resolution: "sv << kms::env_width << 'x' << kms::env_height; - - kms::card_descriptors = std::move(cds); + return enumeration; + } + /** + * @brief Enumerate display names accepted by the KMS backend. + * + * @param hwdevice_type Hardware device type requested for capture or encode. + * @return KMS display names, or an empty list when KMS capture is unavailable. + */ + std::vector kms_display_names(mem_type_e hwdevice_type) { + auto enumeration = enumerate_kms_displays(hwdevice_type); + auto display_names = enumeration.outputs | std::views::transform(&kms::output_t::name) | std::ranges::to(); BOOST_LOG(debug) << "Final KMS display_names return list: " << (display_names | std::views::join_with(' ') | std::ranges::to()); return display_names; } + /** + * @brief Create a KMS capture display from its own enumeration of the available outputs. + * + * @param hwdevice_type Hardware device type requested for capture or encode. + * @param display_name Display name. + * @param config Configuration values to apply. + * @return KMS display backend, or nullptr when initialization fails. + */ + std::shared_ptr kms_display(mem_type_e hwdevice_type, const std::string &display_name, const ::video::config_t &config) { + const auto enumeration = enumerate_kms_displays(hwdevice_type); + if (hwdevice_type == mem_type_e::vaapi || hwdevice_type == mem_type_e::cuda || hwdevice_type == mem_type_e::vulkan) { + auto disp = std::make_shared(hwdevice_type); + if (!disp->init(display_name, config, enumeration)) { + return disp; + } + } + + auto disp = std::make_shared(hwdevice_type); + if (disp->init(display_name, config, enumeration)) { + return nullptr; + } + return disp; + } + } // namespace platf diff --git a/src/platform/linux/kwingrab.cpp b/src/platform/linux/kwingrab.cpp index 0fcfb507d10..d0f3cbd0786 100644 --- a/src/platform/linux/kwingrab.cpp +++ b/src/platform/linux/kwingrab.cpp @@ -689,6 +689,7 @@ namespace kwin { out_pipewire_node = screencast->out_node_id; out_pipewire_objectserial = screencast->out_objectserial; // Set/update basic stream parameters on display_t + this->output_name = screencast->out_params->name; this->offset_x = screencast->out_params->pos_x; this->offset_y = screencast->out_params->pos_y; this->width = screencast->out_params->width; diff --git a/src/platform/linux/misc.cpp b/src/platform/linux/misc.cpp index b89b9b97dd0..9e2d2a7c582 100644 --- a/src/platform/linux/misc.cpp +++ b/src/platform/linux/misc.cpp @@ -59,7 +59,7 @@ // local includes #include "graphics.h" #include "misc.h" -#include "src/boost_process_compat.h" +#include "src/compat/boost_process.h" #include "src/config.h" #include "src/entry_handler.h" #include "src/globals.h" @@ -198,6 +198,20 @@ namespace platf { return true; } + bool log_missing_graphical_session_hint() { + // KMS capture runs without a session, so the hint does not apply to it. + if (std::string value; config::video.capture == "kms" || lizardbyte::common::get_env("WAYLAND_DISPLAY", value) || lizardbyte::common::get_env("DISPLAY", value)) { + return false; + } + + // Without a session the encoder probe fails too, and its final message + // points at the display instead of at the missing session. + BOOST_LOG(error) << "Neither WAYLAND_DISPLAY nor DISPLAY is set, so Sunshine is not running inside a graphical session. "sv + << "If it runs as a systemd user service, make sure the session exports its environment to systemd, "sv + << "for example with \"systemctl --user import-environment WAYLAND_DISPLAY DISPLAY\"."sv; + return true; + } + /** * @brief Owning pointer for `getifaddrs` results. */ @@ -1500,6 +1514,7 @@ namespace platf { if (sources.none()) { BOOST_LOG(error) << "Unable to initialize capture method"sv; + log_missing_graphical_session_hint(); return nullptr; } diff --git a/src/platform/linux/misc.h b/src/platform/linux/misc.h index 056db4dd014..f7b143e2e4e 100644 --- a/src/platform/linux/misc.h +++ b/src/platform/linux/misc.h @@ -96,6 +96,18 @@ namespace portal { * @return Path of the selected test token. */ std::filesystem::path get_saved_token_path_for_testing(const std::filesystem::path &directory, const std::string &desktop); + + /** + * @brief Override the token path used by portal persistence in unit tests. + * + * @param path Token path used by load, save, clear and existence checks. + */ + void set_saved_token_path_for_testing(const std::filesystem::path &path); + + /** + * @brief Restore the production token path after a unit test. + */ + void reset_saved_token_path_for_testing(); #endif /** @@ -121,6 +133,17 @@ namespace platf { */ bool sanitize_process_environment(); + /** + * @brief Log a hint when no graphical session is visible to Sunshine. + * + * Called after every capture method failed to initialize. When neither `WAYLAND_DISPLAY` nor `DISPLAY` is set + * and the configured capture method is not KMS, an error explains that Sunshine is not running inside a + * graphical session and how to export the session environment to systemd. + * + * @return `true` when the hint was logged; `false` when a session variable is set or KMS capture is configured. + */ + bool log_missing_graphical_session_hint(); + /** * @brief Open a DRM card node and drop implicit DRM master, if any. * diff --git a/src/platform/linux/pipewire.cpp b/src/platform/linux/pipewire.cpp index 0715f971a54..4430c24197a 100644 --- a/src/platform/linux/pipewire.cpp +++ b/src/platform/linux/pipewire.cpp @@ -16,6 +16,7 @@ // local includes #include "cuda.h" +#include "display_geometry.h" #include "graphics.h" #include "src/main.h" #include "src/platform/common.h" @@ -82,6 +83,7 @@ namespace pipewire { std::atomic color_primaries {0}; ///< PipeWire color-primaries metadata for the stream. std::atomic transfer_function {0}; ///< PipeWire transfer-function metadata for the stream. std::atomic stream_dead {false}; ///< Whether the PipeWire stream has been destroyed. + std::atomic has_streamed {false}; ///< Whether this stream has ever reached PW_STREAM_STATE_STREAMING. pw_stream_state previous_state; ///< Previous PipeWire stream state reported by callbacks. pw_stream_state current_state; ///< Current PipeWire stream state reported by callbacks. std::string err_msg; ///< Last PipeWire error message reported by the stream. @@ -270,6 +272,7 @@ namespace pipewire { node = stream_node; object_serial = stream_object_serial; stream_data.shared = std::move(shared_state); + stream_data.shared->has_streamed.store(false); pw_thread_loop_lock(loop); BOOST_LOG(debug) << "[pipewire] Setup PW context"sv; @@ -780,6 +783,15 @@ namespace pipewire { .error = on_core_error_cb, }; + public: + /** + * @brief Record stream transitions, retaining startup success after subsequent pauses or errors. + * + * @param user_data Stream data registered with the PipeWire listener. + * @param old Previous PipeWire stream state. + * @param state New PipeWire stream state. + * @param err_msg Error description, or nullptr for a normal transition. + */ static void on_stream_state_changed(void *user_data, enum pw_stream_state old, enum pw_stream_state state, const char *err_msg) { // NOSONAR(cpp:S5008): PipeWire event callbacks require a void pointer for user data. if (err_msg != nullptr) { BOOST_LOG(info) << "[pipewire] PipeWire stream error '" << err_msg << "' on state: " << pw_stream_state_as_string(old) @@ -792,6 +804,11 @@ namespace pipewire { auto *d = static_cast(user_data); switch (state) { + case PW_STREAM_STATE_STREAMING: + if (d->shared) { + d->shared->has_streamed.store(true); + } + break; case PW_STREAM_STATE_PAUSED: if (d->shared && old == PW_STREAM_STATE_STREAMING) { { @@ -825,6 +842,7 @@ namespace pipewire { } } + private: static void on_process(void *user_data) { // NOSONAR(cpp:S5008): PipeWire event callbacks require a void pointer for user data. const auto d = static_cast(user_data); struct pw_buffer *b = nullptr; @@ -1010,42 +1028,25 @@ namespace pipewire { virtual int configure_stream(const std::string &display_name, int &out_pipewire_fd, uint32_t &out_pipewire_node, uint64_t &out_pipewire_objectserial) = 0; /** - * @brief Verify and update display parameters for logical dimensions, desktop dimensions and logical desktop dimensions (default is adapted from wlgrab) + * @brief Resolve the streamed connector and full desktop bounds for absolute input. */ virtual void verify_and_update_display_parameters() { - // Query outputs directly using wayland wl::monitors() - if (logical_height <= 0 || logical_width <= 0 || env_logical_height <= 0 || env_logical_width <= 0 || env_height <= 0 || env_width <= 0) { - int desktop_width = 0; - int desktop_height = 0; - int desktop_logical_width = 0; - int desktop_logical_height = 0; - for (const auto &monitor : wl::monitors()) { - BOOST_LOG(debug) << "[pipewire] Found output: '"sv << monitor->name << "' offset: "sv << monitor->viewport.offset_x << 'x' << monitor->viewport.offset_y << " resolution: "sv << monitor->viewport.width << 'x' << monitor->viewport.height << " logical resolution: "sv << monitor->viewport.logical_width << 'x' << monitor->viewport.logical_height; - // If logical_width and logical_height are not valid try to update them to correct values by matching to monitor - // position/dimension or position/logical dimensions here since we're iterating for maximum environment size anyway - if ((logical_width <= 0 || logical_height <= 0) && monitor->viewport.offset_x == offset_x && monitor->viewport.offset_y == offset_y && ((monitor->viewport.width == width && monitor->viewport.height == height) || (monitor->viewport.logical_width == width && monitor->viewport.logical_height == height))) { - this->logical_width = monitor->viewport.logical_width; - this->logical_height = monitor->viewport.logical_height; - BOOST_LOG(debug) << "[pipewire] Set logical resolution: "sv << logical_width << 'x' << logical_height; + platf::desktop_geometry_t desktop; + for (const auto &monitor : wl::monitors()) { + desktop.add(monitor->viewport); + if (monitor->viewport.offset_x == offset_x && monitor->viewport.offset_y == offset_y && ((monitor->viewport.width == width && monitor->viewport.height == height) || (monitor->viewport.logical_width == width && monitor->viewport.logical_height == height))) { + if (logical_width <= 0 || logical_height <= 0) { + logical_width = monitor->viewport.logical_width; + logical_height = monitor->viewport.logical_height; + } + if (output_name.empty()) { + output_name = monitor->name; } - // Update desktop dimensions to setup maximum environment size over all screens - desktop_width = std::max(desktop_width, monitor->viewport.offset_x + monitor->viewport.width); - desktop_height = std::max(desktop_height, monitor->viewport.offset_y + monitor->viewport.height); - // Update desktop logical dimensions to setup maximum logical environment size over all screens - desktop_logical_width = std::max(desktop_logical_width, monitor->viewport.offset_x + monitor->viewport.logical_width); - desktop_logical_height = std::max(desktop_logical_height, monitor->viewport.offset_y + monitor->viewport.logical_height); - } - if (env_height <= 0 || env_width <= 0) { - this->env_width = desktop_width; - this->env_height = desktop_height; - BOOST_LOG(debug) << "[pipewire] Set desktop resolution: "sv << env_width << 'x' << env_height; - } - if (env_logical_height <= 0 || env_logical_width <= 0) { - this->env_logical_width = desktop_logical_width; - this->env_logical_height = desktop_logical_height; - BOOST_LOG(debug) << "[pipewire] Set desktop logical resolution: "sv << env_logical_width << 'x' << env_logical_height; } } + if (desktop.bounds().width > 0 && desktop.bounds().height > 0) { + desktop.apply(*this); + } } /** diff --git a/src/platform/linux/portalgrab.cpp b/src/platform/linux/portalgrab.cpp index 6a442abafbc..9245f58b305 100644 --- a/src/platform/linux/portalgrab.cpp +++ b/src/platform/linux/portalgrab.cpp @@ -80,7 +80,7 @@ namespace portal { * @brief Load persisted state from its backing store. */ static void load() { - std::ifstream file(get_file_path()); + std::ifstream file(active_file_path()); if (file.is_open()) { std::getline(file, *token_); if (!token_->empty()) { @@ -96,7 +96,7 @@ namespace portal { */ static bool exists() { std::error_code ec; - return std::filesystem::exists(get_file_path(), ec); + return std::filesystem::exists(active_file_path(), ec); } /** @@ -105,7 +105,7 @@ namespace portal { static void clear() { std::error_code ec; token_->clear(); - std::filesystem::remove(get_file_path(), ec); + std::filesystem::remove(active_file_path(), ec); } /** @@ -115,7 +115,7 @@ namespace portal { if (token_->empty()) { return; } - std::ofstream file(get_file_path()); + std::ofstream file(active_file_path()); if (file.is_open()) { file << *token_; BOOST_LOG(info) << "[portalgrab] Saved portal restore token to disk"sv; @@ -173,8 +173,43 @@ namespace portal { return suffixed_path; } +#ifdef SUNSHINE_TESTS + /** + * @brief Override the token path used by persistence operations in unit tests. + * + * @param path Token path, or an empty path to restore the production path. + */ + static void set_file_path_for_testing(const std::filesystem::path &path) { + test_file_path_ = path; + } + + /** + * @brief Restore the production token path after a unit test. + */ + static void reset_file_path_for_testing() { + test_file_path_.clear(); + } +#endif + private: + /** + * @brief Get the path used by persistence operations. + * + * @return Test override path when set, otherwise the production session token path. + */ + static std::filesystem::path active_file_path() { +#ifdef SUNSHINE_TESTS + if (!test_file_path_.empty()) { + return test_file_path_; + } +#endif + return get_file_path(); + } + static inline const std::unique_ptr token_ = std::make_unique(); +#ifdef SUNSHINE_TESTS + static inline std::filesystem::path test_file_path_; +#endif }; /** @@ -270,6 +305,14 @@ namespace portal { std::filesystem::path get_saved_token_path_for_testing(const std::filesystem::path &directory, const std::string &desktop) { return restore_token_t::get_file_path(directory, desktop); } + + void set_saved_token_path_for_testing(const std::filesystem::path &path) { + restore_token_t::set_file_path_for_testing(path); + } + + void reset_saved_token_path_for_testing() { + restore_token_t::reset_file_path_for_testing(); + } #endif /** @@ -308,6 +351,15 @@ namespace portal { } }; + /** + * @brief Result of asking the portal to start a screencast session. + */ + enum class portal_start_e { + success, ///< The portal returned at least one stream. + no_streams, ///< The portal accepted the request but returned no streams. + failure, ///< The request failed, was cancelled, or timed out. + }; + /** * @brief DBus connection and portal request helpers for screencast setup. */ @@ -319,29 +371,7 @@ namespace portal { ~dbus_t() noexcept { try { - if (conn && !session_handle.empty()) { - g_autoptr(GError) err = nullptr; - // This is a blocking C call; it won't throw, but we wrap for safety - g_dbus_connection_call_sync( - conn, - "org.freedesktop.portal.Desktop", - session_handle.c_str(), - "org.freedesktop.portal.Session", - "Close", - nullptr, - nullptr, - G_DBUS_CALL_FLAGS_NONE, - dbus_timeout * 1000, - nullptr, - &err - ); - - if (err) { - BOOST_LOG(warning) << "[portalgrab] Failed to explicitly close portal session: "sv << err->message; - } else { - BOOST_LOG(debug) << "[portalgrab] Explicitly closed portal session: "sv << session_handle; - } - } + close_session(); } catch (const std::exception &e) { BOOST_LOG(error) << "[portalgrab] Standard exception caught in ~dbus_t: "sv << e.what(); } catch (...) { @@ -421,33 +451,51 @@ namespace portal { /** * @brief Connect to xdg-desktop-portal and restore or create a screencast session. * + * A saved restore token that no longer matches the current monitor setup is discarded and the + * connection is retried once without it. + * * @param allow_start_timeout True if "Start" DBus call is allowed to time out. * @return 0 when a portal session is ready; nonzero when D-Bus or portal setup fails. */ int connect_to_portal(bool allow_start_timeout) { g_autoptr(GMainContext) context = g_main_context_new(); g_autoptr(GMainLoop) loop = g_main_loop_new(context, false); - g_autofree gchar *session_path = nullptr; - g_autofree gchar *session_token = nullptr; - create_session_path(conn, nullptr, &session_token); - // Try combined RemoteDesktop + ScreenCast session first - bool use_screencast_only = !try_remote_desktop_session(loop, &session_path, session_token); + for (int attempt = 0; attempt < 2; ++attempt) { + const bool used_restore_token = !restore_token_t::empty(); + pipewire_streams.clear(); - // Fall back to ScreenCast-only if RemoteDesktop failed - if (use_screencast_only && try_screencast_only_session(loop, &session_path) < 0) { - return -1; - } + g_autofree gchar *session_path = nullptr; + g_autofree gchar *session_token = nullptr; + create_session_path(conn, nullptr, &session_token); - if (start_portal_session(loop, session_path, pipewire_streams, use_screencast_only, allow_start_timeout) < 0) { - return -1; - } + // Try combined RemoteDesktop + ScreenCast session first + bool use_screencast_only = !try_remote_desktop_session(loop, &session_path, session_token); - if (open_pipewire_remote(session_path, pipewire_fd) < 0) { - return -1; + // Fall back to ScreenCast-only if RemoteDesktop failed + if (use_screencast_only && try_screencast_only_session(loop, &session_path) < 0) { + return -1; + } + + const auto start_result = start_portal_session(loop, session_path, pipewire_streams, use_screencast_only, allow_start_timeout); + if (start_result != portal_start_e::success) { + if (start_result == portal_start_e::no_streams && used_restore_token && attempt == 0) { + BOOST_LOG(warning) << "[portalgrab] Portal returned no streams for the saved restore token; discarding the stale token and retrying without it"sv; + restore_token_t::clear(); + close_session(); + continue; + } + return -1; + } + + if (open_pipewire_remote(session_path, pipewire_fd) < 0) { + return -1; + } + + return 0; } - return 0; + return -1; } // Try to create a combined RemoteDesktop + ScreenCast session @@ -537,14 +585,45 @@ namespace portal { } std::vector pipewire_streams; ///< Pipewire streams. - int pipewire_fd; ///< Pipewire fd. + int pipewire_fd = -1; ///< Pipewire fd. private: - GDBusConnection *conn; - GDBusProxy *screencast_proxy; - GDBusProxy *remote_desktop_proxy; + GDBusConnection *conn = nullptr; + GDBusProxy *screencast_proxy = nullptr; + GDBusProxy *remote_desktop_proxy = nullptr; std::string session_handle; + /** + * @brief Close the portal session created for the current connection. + */ + void close_session() { + if (!conn || session_handle.empty()) { + return; + } + + g_autoptr(GError) err = nullptr; + g_dbus_connection_call_sync( + conn, + PORTAL_NAME, + session_handle.c_str(), + "org.freedesktop.portal.Session", + "Close", + nullptr, + nullptr, + G_DBUS_CALL_FLAGS_NONE, + dbus_timeout * 1000, + nullptr, + &err + ); + + if (err) { + BOOST_LOG(warning) << "[portalgrab] Failed to explicitly close portal session: "sv << err->message; + } else { + BOOST_LOG(debug) << "[portalgrab] Explicitly closed portal session: "sv << session_handle; + } + session_handle.clear(); + } + int create_portal_session(GMainLoop *loop, gchar **session_path_out, const gchar *session_token, bool use_screencast) { GDBusProxy *proxy = use_screencast ? screencast_proxy : remote_desktop_proxy; const char *session_type = use_screencast ? "ScreenCast" : "RemoteDesktop"; @@ -702,7 +781,7 @@ namespace portal { return 0; } - int start_portal_session(GMainLoop *loop, const gchar *session_path, std::vector &out_pipewire_streams, bool use_screencast, bool allow_start_timeout) { + portal_start_e start_portal_session(GMainLoop *loop, const gchar *session_path, std::vector &out_pipewire_streams, bool use_screencast, bool allow_start_timeout) { GDBusProxy *proxy = use_screencast ? screencast_proxy : remote_desktop_proxy; const char *session_type = use_screencast ? "ScreenCast" : "RemoteDesktop"; @@ -722,7 +801,7 @@ namespace portal { g_autoptr(GVariant) reply = g_dbus_proxy_call_sync(proxy, "Start", g_variant_builder_end(&builder), G_DBUS_CALL_FLAGS_NONE, dbus_timeout * 1000, nullptr, &err); if (err) { BOOST_LOG(error) << "[portalgrab] Could not start "sv << session_type << " session: "sv << err->message; - return -1; + return portal_start_e::failure; } dbus_response_follow_handle(&response, reply); @@ -731,7 +810,7 @@ namespace portal { if (!start_response) { BOOST_LOG(error) << "[portalgrab] " << session_type << " Start: no response received"sv; - return -1; + return portal_start_e::failure; } guint32 response_code; @@ -743,13 +822,13 @@ namespace portal { if (response_code != 0) { BOOST_LOG(error) << "[portalgrab] " << session_type << " Start failed with response code: "sv << response_code; - return -1; + return portal_start_e::failure; } streams = g_variant_lookup_value(dict, "streams", G_VARIANT_TYPE("a(ua{sv})")); - if (!streams) { + if (!streams || g_variant_n_children(streams) == 0) { BOOST_LOG(error) << "[portalgrab] " << session_type << " Start: no streams in response"sv; - return -1; + return portal_start_e::no_streams; } if (const gchar *new_token = nullptr; g_variant_lookup(dict, "restore_token", "s", &new_token) && new_token && new_token[0] != '\0' && restore_token_t::get() != new_token) { @@ -813,7 +892,7 @@ namespace portal { return a.pos_x < b.pos_x || a.pos_y < b.pos_y; }); - return 0; + return portal_start_e::success; } int open_pipewire_remote(const gchar *session_path, int &fd) { @@ -1083,6 +1162,7 @@ namespace portal { out_pipewire_node = stream.pipewire_node; out_pipewire_object_serial = stream.pipewire_object_serial; // Set/update basic stream parameters on display_t + this->output_name = stream.monitor_name; this->offset_x = stream.pos_x; this->offset_y = stream.pos_y; this->width = stream.width; @@ -1094,10 +1174,10 @@ namespace portal { } /** - * @brief Check stream dead. + * @brief Handle portal closure or retry failed startup negotiation without maxFramerate. * - * @param out_status Out status. - * @return True when the PipeWire stream can no longer produce frames. + * @param out_status Capture status selected when portal-specific handling is needed. + * @return True when portal-specific handling selected a capture status; false to use the default stream reset. */ bool check_stream_dead(platf::capture_e &out_status) override { // If the pipewire stream stopped due to closed portal session stop the capture with an error @@ -1108,7 +1188,7 @@ namespace portal { return true; // Stop capture with error (due to out_status) } // Disable maxframerate negotiation if the stream died without having ever started (e.g. GNOME mutter does not support it) - if (shared_state->previous_state != PW_STREAM_STATE_STREAMING && negotiate_maxframerate.load()) { + if (!shared_state->has_streamed.load() && negotiate_maxframerate.load()) { BOOST_LOG(warning) << "[portalgrab] Negotiation failed, will retry without maxFramerate"sv; negotiate_maxframerate.store(false); pipewire.set_negotiate_maxframerate(false); @@ -1124,6 +1204,42 @@ namespace portal { // Class variable to store runtime state of maxFramerate negotiation static inline std::atomic negotiate_maxframerate {true}; ///< Whether portal negotiation should request the maximum frame rate. }; + +#ifdef SUNSHINE_TESTS + /** + * @brief Exercise the portal's dead-stream handling without opening a real portal session. + * + * @param shared_state Stream state populated by PipeWire callbacks. + * @param negotiate_maxframerate Negotiation setting before and after handling the dead stream. + * @param out_status Capture status selected by the handler. + * @return True when portal-specific handling selected a capture status. + */ + bool check_stream_dead_for_testing(std::shared_ptr shared_state, bool &negotiate_maxframerate, platf::capture_e &out_status) { + /** + * @brief Portal display with injected callback state and no D-Bus session. + */ + class test_portal_t: public portal_t { + public: + /** + * @brief Install the stream state to be examined by the portal handler. + * @param state Stream state populated by PipeWire callbacks. + */ + explicit test_portal_t(std::shared_ptr state): + portal_t {} { + this->shared_state = std::move(state); + dbus.pipewire_fd = -1; + } + } display {std::move(shared_state)}; + + const bool saved = portal_t::negotiate_maxframerate.exchange(negotiate_maxframerate); + auto restore = util::fail_guard([saved]() { + portal_t::negotiate_maxframerate.store(saved); + }); + const bool handled = display.check_stream_dead(out_status); + negotiate_maxframerate = portal_t::negotiate_maxframerate.load(); + return handled; + } +#endif } // namespace portal namespace platf { diff --git a/src/platform/linux/wayland.h b/src/platform/linux/wayland.h index 19ceae4f2b9..86115335912 100644 --- a/src/platform/linux/wayland.h +++ b/src/platform/linux/wayland.h @@ -188,6 +188,23 @@ namespace wl { */ bool use_damage_capture(std::uint32_t screencopy_version, double stream_fps, std::int32_t refresh_mhz); + /** + * @brief Decide whether a received frame means capture has to be reinitialized. + * + * The display's size and transform feed the touch port, so a change in either has to rebuild it. + * Turning an output between 90 and 270 degrees changes neither its native nor its logical size, + * so the transform is compared on its own. + * + * @param frame_width Width of the received frame. + * @param frame_height Height of the received frame. + * @param width Width the capture was initialized with. + * @param height Height the capture was initialized with. + * @param output_transform Current transform of the captured output. + * @param transform Transform the capture was initialized with. + * @return `true` when capture has to be reinitialized. + */ + bool capture_needs_reinit(int frame_width, int frame_height, int width, int height, int output_transform, int transform); + /** * @brief Move the earliest time of the next damage-driven request on by one captured frame. * @@ -675,11 +692,13 @@ namespace wl { } /** - * @brief Ignore physical wl-output geometry; monitor placement comes from xdg-output metadata. - * @details Retain the wl-output listener signature while ignoring all event arguments. + * @brief Record the wl-output transform; monitor placement comes from xdg-output metadata. + * @details Physical geometry is ignored. A rotated output is captured in its native orientation, so absolute + * input needs the transform to map points onto it. + * @param transform Wayland output transform value. */ - void wl_geometry(wl_output *, std::int32_t, std::int32_t, std::int32_t, std::int32_t, std::int32_t, const char *, const char *, std::int32_t) { - // Logical placement comes from xdg-output, so physical geometry has nothing to update. + void wl_geometry(wl_output *, std::int32_t, std::int32_t, std::int32_t, std::int32_t, std::int32_t, const char *, const char *, std::int32_t transform) { // NOSONAR(cpp:S107): libwayland's wl_output geometry callback signature. + viewport.transform = transform; } /** @@ -718,6 +737,17 @@ namespace wl { zxdg_output_v1_listener xdg_listener; ///< Callback table for xdg-output events. }; + /** + * @brief Copy a monitor's geometry onto the display that captures it. + * + * Capture initialization uses this, so a reinitialization picks up the monitor's current transform for absolute + * input. + * + * @param display Capture display to update. + * @param monitor Monitor selected for capture. + */ + void apply_monitor_geometry(platf::display_t &display, const monitor_t &monitor); + /** * @brief Wayland registry state for screencopy, DMA-BUF, and output globals. */ diff --git a/src/platform/linux/wlgrab.cpp b/src/platform/linux/wlgrab.cpp index f6fb66b205e..810ec64e14a 100644 --- a/src/platform/linux/wlgrab.cpp +++ b/src/platform/linux/wlgrab.cpp @@ -21,6 +21,7 @@ // local includes #include "cuda.h" +#include "display_geometry.h" #include "src/logging.h" #include "src/platform/common.h" #include "src/video.h" @@ -31,8 +32,6 @@ using namespace std::literals; namespace wl { - static int env_width; - static int env_height; static bool force_ram_capture = false; // NOSONAR(cpp:S5421): Retains SHM selection across VRAM-to-RAM capture backend recreation. /** @@ -265,6 +264,21 @@ namespace wl { return screencopy_version >= 2 && stream_fps > 0 && refresh_mhz / 1000.0 >= stream_fps * 1.5; } + bool capture_needs_reinit(int frame_width, int frame_height, int width, int height, int output_transform, int transform) { + return frame_width != width || frame_height != height || output_transform != transform; + } + + void apply_monitor_geometry(platf::display_t &display, const monitor_t &monitor) { + display.offset_x = monitor.viewport.offset_x; + display.offset_y = monitor.viewport.offset_y; + display.width = monitor.viewport.width; + display.height = monitor.viewport.height; + display.output_name = monitor.name; + display.logical_width = monitor.viewport.logical_width; + display.logical_height = monitor.viewport.logical_height; + display.transform = monitor.viewport.transform; + } + std::chrono::steady_clock::time_point next_damage_request( std::chrono::steady_clock::time_point next_request, std::chrono::steady_clock::time_point frame_time, @@ -417,27 +431,14 @@ namespace wl { event_driven = use_damage_capture(interface.screencopy_version, stream_fps, monitor->refresh_mhz); BOOST_LOG(info) << "[wlgrab] Frame capture: "sv << (event_driven ? "event-driven"sv : "paced"sv) << " (output "sv << output_fps << " Hz, stream "sv << stream_fps << " fps)"sv; - offset_x = monitor->viewport.offset_x; - offset_y = monitor->viewport.offset_y; - width = monitor->viewport.width; - height = monitor->viewport.height; - - this->env_width = ::wl::env_width; - this->env_height = ::wl::env_height; + apply_monitor_geometry(*this, *monitor); + this->monitor = monitor; - this->logical_width = monitor->viewport.logical_width; - this->logical_height = monitor->viewport.logical_height; - - int desktop_logical_width = 0; - int desktop_logical_height = 0; - for (auto &monitor_entry : interface.monitors) { - auto output_monitor = monitor_entry.get(); - desktop_logical_width = std::max(desktop_logical_width, output_monitor->viewport.offset_x + output_monitor->viewport.logical_width); - desktop_logical_height = std::max(desktop_logical_height, output_monitor->viewport.offset_y + output_monitor->viewport.logical_height); + platf::desktop_geometry_t desktop; + for (const auto &monitor_entry : interface.monitors) { + desktop.add(monitor_entry->viewport); } - - this->env_logical_width = desktop_logical_width; - this->env_logical_height = desktop_logical_height; + desktop.apply(*this); BOOST_LOG(info) << "[wlgrab] Selected monitor ["sv << monitor->description << "] for streaming"sv; BOOST_LOG(debug) << "[wlgrab] Offset: "sv << offset_x << 'x' << offset_y; @@ -501,8 +502,7 @@ namespace wl { if ( dmabuf.status == dmabuf_t::REINIT || - current_frame->sd.width != width || - current_frame->sd.height != height + capture_needs_reinit(current_frame->sd.width, current_frame->sd.height, width, height, monitor->viewport.transform, transform) ) { return platf::capture_e::reinit; } @@ -605,6 +605,7 @@ namespace wl { dmabuf_t dmabuf; ///< DMA-BUF feedback and format state advertised by the compositor. wl_output *output; ///< Wayland output selected for capture. + wl::monitor_t *monitor {}; ///< Monitor selected for capture. }; /** @@ -953,9 +954,6 @@ namespace platf { return {}; } - wl::env_width = 0; - wl::env_height = 0; - for (auto &monitor : interface.monitors) { monitor->listen(interface.output_manager); } @@ -967,9 +965,6 @@ namespace platf { for (int x = 0; x < interface.monitors.size(); ++x) { auto monitor = interface.monitors[x].get(); - wl::env_width = std::max(wl::env_width, monitor->viewport.offset_x + monitor->viewport.width); - wl::env_height = std::max(wl::env_height, monitor->viewport.offset_y + monitor->viewport.height); - BOOST_LOG(info) << "[wlgrab] Monitor " << x << " is "sv << monitor->name << ": "sv << monitor->description; display_names.emplace_back(monitor->name.empty() ? std::to_string(x) : monitor->name); diff --git a/src/platform/macos/av_audio.h b/src/platform/macos/av_audio.h index 4a656721330..c1fe2f69852 100644 --- a/src/platform/macos/av_audio.h +++ b/src/platform/macos/av_audio.h @@ -21,7 +21,7 @@ #include // lib includes -#include "third-party/TPCircularBuffer/TPCircularBuffer.h" +#include NS_ASSUME_NONNULL_BEGIN diff --git a/src/platform/macos/display.mm b/src/platform/macos/display.mm index 4aec4ebedd5..acab57cda75 100644 --- a/src/platform/macos/display.mm +++ b/src/platform/macos/display.mm @@ -4,11 +4,14 @@ */ // standard includes +#include #include #include #include +#include #include #include +#include #include // local includes @@ -18,8 +21,12 @@ #include "src/platform/common.h" #include "src/platform/macos/av_img_t.h" #include "src/platform/macos/av_video.h" +#include "src/platform/macos/display_helpers.h" #include "src/platform/macos/misc.h" -#include "src/platform/macos/nv12_zero_device.h" +#import "src/platform/macos/sc_capture.h" +#include "src/platform/macos/sc_capture_loop.h" +#include "src/platform/macos/vt_encoder.h" +#include "src/utility.h" // Avoid conflict between AVFoundation and libavutil both defining AVMediaType /** @@ -50,34 +57,199 @@ return display_id; } + OSType videotoolbox_pixel_format(const video::config_t &config) { + const auto colorspace {video::colorspace_from_client_config(config, false)}; + return colorspace.bit_depth == 10 ? kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange : kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange; + } + /** - * @brief Return the union of active CoreGraphics display bounds. + * @brief Derive a steady_clock capture timestamp from a sample buffer's presentation timestamp. * - * @param fallback_display Display whose bounds are used if enumeration fails. - * @return Full active desktop bounds in CoreGraphics coordinates. + * The PTS is on the mach host clock, so back-dating steady_clock::now() by the frame's age on + * that clock includes AVFoundation's internal queueing delay in the reported frame latency. + * @param sample_buffer Sample buffer received from AVFoundation. + * @return Capture timestamp for the frame. */ - CGRect active_desktop_bounds(CGDirectDisplayID fallback_display) { - std::uint32_t display_count {}; - if (CGGetActiveDisplayList(0, nullptr, &display_count) != kCGErrorSuccess || display_count == 0) { - return CGDisplayBounds(fallback_display); + std::chrono::steady_clock::time_point frame_timestamp_from_pts(CMSampleBufferRef sample_buffer) { + auto timestamp = std::chrono::steady_clock::now(); + const CMTime pts = CMSampleBufferGetPresentationTimeStamp(sample_buffer); + if (CMTIME_IS_NUMERIC(pts)) { + const CMTime frame_age = CMTimeSubtract(CMClockGetTime(CMClockGetHostTimeClock()), pts); + const double frame_age_s = CMTimeGetSeconds(frame_age); + if (frame_age_s > 0) { + timestamp -= std::chrono::duration_cast(std::chrono::duration(frame_age_s)); + } } + return timestamp; + } - std::vector displays(display_count); - if (CGGetActiveDisplayList(display_count, displays.data(), &display_count) != kCGErrorSuccess || display_count == 0) { - return CGDisplayBounds(fallback_display); - } + // Upper bound on how long the ScreenCaptureKit capture loop waits for a frame + // before reporting a timeout and checking for interrupt requests again. + constexpr auto SCKIT_FRAME_POLL_INTERVAL = std::chrono::nanoseconds {std::chrono::seconds {1}} / 60; - auto bounds = CGDisplayBounds(displays.front()); - for (std::uint32_t index = 1; index < display_count; ++index) { - bounds = CGRectUnion(bounds, CGDisplayBounds(displays[index])); + /** + * @brief Wrap a captured sample buffer into a Sunshine image. + * + * @param sample_buffer Sample buffer received from the capture backend. + * @param img Image object to populate. + * @return `true` when the sample buffer contained a usable pixel buffer. + */ + bool process_frame(CMSampleBufferRef sample_buffer, img_t *img) { + auto pixel_buffer = CMSampleBufferGetImageBuffer(sample_buffer); + if (!pixel_buffer) { + return false; } - return bounds; + + auto new_sample_buffer = std::make_shared(sample_buffer); + auto new_pixel_buffer = std::make_shared(new_sample_buffer->buf); + + auto av_img = (av_img_t *) img; + + auto old_data_retainer = std::make_shared( + av_img->sample_buffer, + av_img->pixel_buffer, + img->data + ); + + av_img->sample_buffer = new_sample_buffer; + av_img->pixel_buffer = new_pixel_buffer; + img->data = new_pixel_buffer->data(); + + img->width = (int) CVPixelBufferGetWidth(new_pixel_buffer->buf); + img->height = (int) CVPixelBufferGetHeight(new_pixel_buffer->buf); + img->row_pitch = CVPixelBufferIsPlanar(new_pixel_buffer->buf) ? + (int) CVPixelBufferGetBytesPerRowOfPlane(new_pixel_buffer->buf, 0) : + (int) CVPixelBufferGetBytesPerRow(new_pixel_buffer->buf); + img->pixel_pitch = img->row_pitch / img->width; + img->frame_timestamp = frame_timestamp_from_pts(sample_buffer); + + old_data_retainer = nullptr; + return true; } - OSType videotoolbox_pixel_format(const video::config_t &config) { - const auto colorspace {video::colorspace_from_client_config(config, false)}; - return colorspace.bit_depth == 10 ? kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange : kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange; + /** + * @brief Synthesize a blank frame for capture backends that only deliver frames on screen changes. + * + * @param img Image object to populate. + * @param width Frame width in pixels. + * @param height Frame height in pixels. + * @param pixel_format Pixel format of the synthesized frame. + * @param backend_name Capture backend name used in log messages. + * @return 0 on success; nonzero on failure. + */ + int make_dummy_img(img_t *img, int width, int height, OSType pixel_format, std::string_view backend_name) { + CVPixelBufferRef pixel_buffer = nullptr; + NSDictionary *attrs = @{ + (NSString *) kCVPixelBufferIOSurfacePropertiesKey: @ {}, + }; + + auto status = CVPixelBufferCreate( + kCFAllocatorDefault, + width, + height, + pixel_format, + (__bridge CFDictionaryRef) attrs, + &pixel_buffer + ); + + if (status != kCVReturnSuccess || !pixel_buffer) { + BOOST_LOG(error) << backend_name << " dummy_img: failed to create pixel buffer"sv; + return 1; + } + + display_helpers::fill_black(pixel_buffer); + + CMVideoFormatDescriptionRef format_desc = nullptr; + status = CMVideoFormatDescriptionCreateForImageBuffer(kCFAllocatorDefault, pixel_buffer, &format_desc); + if (status != noErr || !format_desc) { + CVPixelBufferRelease(pixel_buffer); + BOOST_LOG(error) << backend_name << " dummy_img: failed to create format description"sv; + return 1; + } + + CMSampleTimingInfo timing = {kCMTimeInvalid, kCMTimeInvalid, kCMTimeInvalid}; + CMSampleBufferRef sample_buffer = nullptr; + status = CMSampleBufferCreateForImageBuffer(kCFAllocatorDefault, pixel_buffer, YES, nullptr, nullptr, format_desc, &timing, &sample_buffer); + CFRelease(format_desc); + + if (status != noErr || !sample_buffer) { + CVPixelBufferRelease(pixel_buffer); + BOOST_LOG(error) << backend_name << " dummy_img: failed to create sample buffer"sv; + return 1; + } + + auto ret = process_frame(sample_buffer, img) ? 0 : 1; + CFRelease(sample_buffer); + CVPixelBufferRelease(pixel_buffer); + + return ret; } + + /** + * @brief Frame source adapter exposing an SCCapture controller to the capture loop. + */ + class sc_frame_source_t: public sckit::frame_source_t { + public: + /** + * @brief Wrap a capture controller. + * + * @param capture Controller owned by the display; it must outlive the adapter. + */ + explicit sc_frame_source_t(SCCapture *capture): + capture(capture) { + } + + ~sc_frame_source_t() override { + release_frame_signal(); + } + + bool start() override { + if (![capture captureVideo]) { + BOOST_LOG(error) << "SCCapture failed to start the capture stream"sv; + return false; + } + + frame_signal = capture.frameSignal; + if (!frame_signal) { + BOOST_LOG(error) << "SCCapture failed to create frame signal"sv; + [capture stopCapture]; + return false; + } + dispatch_retain(frame_signal); + return true; + } + + void wait_frame(std::chrono::nanoseconds timeout) override { + dispatch_semaphore_wait(frame_signal, dispatch_time(DISPATCH_TIME_NOW, timeout.count())); + } + + [[nodiscard]] bool stopped() const override { + return capture.streamFailed; + } + + CMSampleBufferRef copy_latest_sample_buffer() override { + return [capture copyLatestSampleBuffer]; + } + + void stop() override { + [capture stopCapture]; + release_frame_signal(); + } + + private: + /** + * @brief Drop the retained frame semaphore, if any. + */ + void release_frame_signal() { + if (frame_signal) { + dispatch_release(frame_signal); + frame_signal = nullptr; + } + } + + SCCapture *capture; ///< Borrowed capture controller. + dispatch_semaphore_t frame_signal {}; ///< Frame-arrival semaphore, retained while the stream runs. + }; } // namespace /** @@ -94,6 +266,7 @@ OSType videotoolbox_pixel_format(const video::config_t &config) { 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) override { auto signal = [av_capture capture:^(CMSampleBufferRef sampleBuffer) { + const auto frame_timestamp = frame_timestamp_from_pts(sampleBuffer); auto new_sample_buffer = std::make_shared(sampleBuffer); auto new_pixel_buffer = std::make_shared(new_sample_buffer->buf); @@ -119,6 +292,7 @@ capture_e capture(const push_captured_image_cb_t &push_captured_image_cb, const img_out->height = (int) CVPixelBufferGetHeight(new_pixel_buffer->buf); img_out->row_pitch = (int) CVPixelBufferGetBytesPerRow(new_pixel_buffer->buf); img_out->pixel_pitch = img_out->row_pitch / img_out->width; + img_out->frame_timestamp = frame_timestamp; old_data_retainer = nullptr; @@ -157,12 +331,6 @@ capture_e capture(const push_captured_image_cb_t &push_captured_image_cb, const av_capture.pixelFormat = kCVPixelFormatType_32BGRA; return std::make_unique(); - } else if (pix_fmt == pix_fmt_e::nv12 || pix_fmt == pix_fmt_e::p010) { - auto device = std::make_unique(); - - device->init(av_capture, pix_fmt, setResolution, setPixelFormat); - - return device; } else { BOOST_LOG(error) << "Unsupported Pixel Format."sv; return nullptr; @@ -216,27 +384,113 @@ int dummy_img(img_t *img) override { } /** - * A bridge from the pure C++ code of the hwdevice_t class to the pure Objective C code. + * @brief Create a native VideoToolbox encode device. * - * display --> an opaque pointer to an object of this class - * width --> the intended capture width - * height --> the intended capture height - * @param display Display object or identifier associated with the operation. - * @param width Frame or display width in pixels. - * @param height Frame or display height in pixels. + * @param pix_fmt Sunshine pixel format to convert or allocate for. + * @return Constructed VideoToolbox encode device object. */ - static void setResolution(AVVideo *display, int width, int height) { - [display setFrameWidth:width frameHeight:height]; + std::unique_ptr make_vt_encode_device(pix_fmt_e pix_fmt) override { + auto *capture = av_capture; + return vt::make_encode_device( + pix_fmt, + [capture](int width, int height) { + [capture setFrameWidth:width frameHeight:height]; + }, + [capture](int pixel_format) { + capture.pixelFormat = pixel_format; + } + ); + } + }; + + /** + * @brief ScreenCaptureKit-based macOS display capture source. + */ + struct sc_display_t: public display_t { + SCCapture *sc_capture {}; ///< ScreenCaptureKit capture controller. + CGDirectDisplayID display_id {}; ///< Display ID. + std::unique_ptr display_power_guard; ///< Display power guard. + + ~sc_display_t() override { + [sc_capture stopCapture]; + [sc_capture release]; + } + + 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) override { + sc_frame_source_t source {sc_capture}; + auto &policy = sckit::backend_policy(); + + const auto status = sckit::run_capture_loop(source, policy, push_captured_image_cb, pull_free_image_cb, process_frame, SCKIT_FRAME_POLL_INTERVAL); + if (status == capture_e::reinit) { + if (policy.stream_start_failed()) { + BOOST_LOG(warning) << "SCCapture stream could not be started; reinitializing capture on AVFoundation"sv; + } else { + BOOST_LOG(warning) << "SCCapture stream stopped unexpectedly; reinitializing capture"sv; + } + } + return status; + } + + /** + * @brief Allocate an image buffer compatible with this display backend. + * + * @return Allocated img object, or null when unavailable. + */ + std::shared_ptr alloc_img() override { + return std::make_shared(); + } + + /** + * @brief Create AVCodec encode device. + * + * @param pix_fmt Sunshine pixel format to convert or allocate for. + * @return Constructed AVCodec encode device object. + */ + std::unique_ptr make_avcodec_encode_device(pix_fmt_e pix_fmt) override { + if (pix_fmt == pix_fmt_e::yuv420p) { + sc_capture.pixelFormat = kCVPixelFormatType_32BGRA; + + return std::make_unique(); + } else { + BOOST_LOG(error) << "Unsupported Pixel Format."sv; + return nullptr; + } + } + + /** + * @brief Create a native VideoToolbox encode device. + * + * @param pix_fmt Sunshine pixel format to convert or allocate for. + * @return Constructed VideoToolbox encode device object. + */ + std::unique_ptr make_vt_encode_device(pix_fmt_e pix_fmt) override { + auto *capture = sc_capture; + return vt::make_encode_device( + pix_fmt, + [capture](int width, int height) { + [capture setFrameWidth:width frameHeight:height]; + }, + [capture](int pixel_format) { + capture.pixelFormat = pixel_format; + } + ); } /** - * @brief Set pixel format. + * @brief Populate a fallback image when real capture data is unavailable. * - * @param display Display object or identifier associated with the operation. - * @param pixelFormat Pixel format. + * @param img Image or frame object to read from or populate. + * @return Capture status reported to the streaming pipeline. */ - static void setPixelFormat(AVVideo *display, OSType pixelFormat) { - display.pixelFormat = pixelFormat; + int dummy_img(img_t *img) override { + if (!platf::is_screen_capture_allowed()) { + // A non-zero return value indicates failure to the calling function. + return 1; + } + + // ScreenCaptureKit only delivers frames on screen updates, so synthesize a blank frame + // instead of waiting for one. + return make_dummy_img(img, sc_capture.frameWidth, sc_capture.frameHeight, sc_capture.pixelFormat, "SCCapture"sv); } }; @@ -246,29 +500,27 @@ static void setPixelFormat(AVVideo *display, OSType pixelFormat) { return nullptr; } - auto display = std::make_shared(); - BOOST_LOG(debug) << "Waking display for capture selector ["sv << display_name << ']'; if (!display_device::wake_display(display_name, 1s)) { BOOST_LOG(debug) << "Display wake attempt did not expose the requested display ["sv << display_name << ']'; } - display->display_power_guard = display_device::keep_display_awake("Sunshine display capture"); - if (display->display_power_guard) { + auto display_power_guard = display_device::keep_display_awake("Sunshine display capture"); + if (display_power_guard) { BOOST_LOG(debug) << "Keeping display awake for capture"sv; } else { BOOST_LOG(debug) << "Unable to create display sleep prevention assertion"sv; } // Default to main display - display->display_id = CGMainDisplayID(); + CGDirectDisplayID display_id = CGMainDisplayID(); if (const auto configured_display_id {parse_display_id(display_name)}) { - display->display_id = *configured_display_id; + display_id = *configured_display_id; } else if (!display_name.empty()) { BOOST_LOG(warning) << "Configured display ["sv << display_name << "] is not a valid macOS capture display id. Falling back to main display ["sv - << display->display_id << "]."sv; + << display_id << "]."sv; } // Print all displays available with their names and ids @@ -282,25 +534,44 @@ static void setPixelFormat(AVVideo *display, OSType pixelFormat) { << " (id: "sv << device.m_display_name << ") connected: true"sv; } - BOOST_LOG(info) << "Configuring selected display ("sv << display->display_id << ") to stream"sv; - - const auto selected_display_bounds = CGDisplayBounds(display->display_id); - const auto desktop_bounds = active_desktop_bounds(display->display_id); - display->offset_x = static_cast(selected_display_bounds.origin.x); - display->offset_y = static_cast(selected_display_bounds.origin.y); - display->logical_width = static_cast(selected_display_bounds.size.width); - display->logical_height = static_cast(selected_display_bounds.size.height); - display->env_offset_x = static_cast(desktop_bounds.origin.x); - display->env_offset_y = static_cast(desktop_bounds.origin.y); - display->env_logical_width = static_cast(desktop_bounds.size.width); - display->env_logical_height = static_cast(desktop_bounds.size.height); - display->env_width = display->env_logical_width; - display->env_height = display->env_logical_height; - - BOOST_LOG(debug) << "Selected display bounds: "sv << display->offset_x << 'x' << display->offset_y << ' ' - << display->logical_width << 'x' << display->logical_height; - BOOST_LOG(debug) << "Active desktop bounds: "sv << display->env_offset_x << 'x' << display->env_offset_y << ' ' - << display->env_logical_width << 'x' << display->env_logical_height; + BOOST_LOG(info) << "Configuring selected display ("sv << display_id << ") to stream"sv; + + // Prefer ScreenCaptureKit: it composites the cursor into frames server-side, which avoids + // an AVCaptureScreenInput bug where a hidden cursor never reappears in the captured frames. + if (@available(macOS 14.0, *)) { + auto &policy = sckit::backend_policy(); + if (policy.stream_start_failed()) { + BOOST_LOG(info) << "ScreenCaptureKit disabled after a stream start failure; using AVFoundation"sv; + } else if (policy.prefer_sckit([SCCapture isAvailable])) { + auto display = std::make_shared(); + display->display_id = display_id; + display->display_power_guard = std::move(display_power_guard); + display->sc_capture = [[SCCapture alloc] initWithDisplay:display_id frameRate:config.framerate]; + + if (display->sc_capture) { + display->width = display->sc_capture.frameWidth; + display->height = display->sc_capture.frameHeight; + display_helpers::init_display_geometry(*display, display_id); + + if (hwdevice_type == platf::mem_type_e::videotoolbox) { + const auto pixel_format {videotoolbox_pixel_format(config)}; + [display->sc_capture setFrameWidth:config.width frameHeight:config.height]; + display->sc_capture.pixelFormat = pixel_format; + } + + return display; + } + + display_power_guard = std::move(display->display_power_guard); + BOOST_LOG(error) << "SCCapture setup failed, trying AVFoundation..."sv; + } + } + + auto display = std::make_shared(); + display->display_id = display_id; + display->display_power_guard = std::move(display_power_guard); + + display_helpers::init_display_geometry(*display, display->display_id); display->av_capture = [[AVVideo alloc] initWithDisplay:display->display_id frameRate:config.framerate]; diff --git a/src/platform/macos/display_helpers.h b/src/platform/macos/display_helpers.h new file mode 100644 index 00000000000..d0eca8fb9e1 --- /dev/null +++ b/src/platform/macos/display_helpers.h @@ -0,0 +1,52 @@ +/** + * @file src/platform/macos/display_helpers.h + * @brief Declarations for display geometry and pixel buffer helpers shared by the macOS capture backends. + */ +#pragma once + +// platform includes +#include +#include + +// local includes +#include "src/platform/common.h" + +namespace platf::display_helpers { + /** + * @brief Fill a pixel buffer with black. + * + * Video-range bi-planar formats get legal black luma and neutral chroma (8-bit `420v` and + * 10-bit `x420`); any other format is zero-filled, which is black for BGRA. + * + * @param pixel_buffer Pixel buffer to fill. + */ + void fill_black(CVPixelBufferRef pixel_buffer); + + /** + * @brief Return the union of active CoreGraphics display bounds. + * + * @param fallback_display Display whose bounds are used if enumeration fails. + * @return Full active desktop bounds in CoreGraphics coordinates. + */ + CGRect active_desktop_bounds(CGDirectDisplayID fallback_display); + + /** + * @brief Store the selected display and desktop geometry used for input mapping. + * + * @param display Display to update. + * @param selected_display_bounds Bounds of the captured display in CoreGraphics (logical) coordinates. + * @param desktop_bounds Bounds of the full active desktop in CoreGraphics (logical) coordinates. + */ + void apply_display_geometry(display_t &display, CGRect selected_display_bounds, CGRect desktop_bounds); + + /** + * @brief Initialize the input-mapping geometry of a display from CoreGraphics. + * + * Every capture backend calls this so the mouse viewport and display scaling do not depend on + * which backend captures the frames. + * + * @param display Display to update. + * @param display_id Display being captured. + */ + void init_display_geometry(display_t &display, CGDirectDisplayID display_id); +} // namespace platf::display_helpers diff --git a/src/platform/macos/display_helpers.mm b/src/platform/macos/display_helpers.mm new file mode 100644 index 00000000000..122ec443d19 --- /dev/null +++ b/src/platform/macos/display_helpers.mm @@ -0,0 +1,104 @@ +/** + * @file src/platform/macos/display_helpers.mm + * @brief Definitions for display geometry and pixel buffer helpers shared by the macOS capture backends. + */ +// standard includes +#include +#include +#include +#include + +// local includes +#include "src/logging.h" +#include "src/platform/macos/display_helpers.h" + +namespace platf::display_helpers { + using namespace std::literals; + + namespace { + /** + * @brief Fill one plane of a locked pixel buffer. + * + * @param base Base address of the plane. + * @param bytes Size of the plane in bytes, including row padding. + * @param format Pixel format of the buffer. + * @param plane Plane index; 0 is luma, 1 is interleaved chroma. + */ + void fill_plane_black(void *base, std::size_t bytes, OSType format, std::size_t plane) { + if (format == kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange) { + std::memset(base, plane == 0 ? 16 : 128, bytes); + } else if (format == kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange) { + // x420 stores each 10-bit sample in the high bits of a 16-bit word. + const auto value = static_cast((plane == 0 ? 64 : 512) << 6); + std::fill_n(static_cast(base), bytes / sizeof(std::uint16_t), value); + } else { + std::memset(base, 0, bytes); + } + } + } // namespace + + void fill_black(CVPixelBufferRef pixel_buffer) { + CVPixelBufferLockBaseAddress(pixel_buffer, 0); + + const auto format = CVPixelBufferGetPixelFormatType(pixel_buffer); + if (CVPixelBufferIsPlanar(pixel_buffer)) { + for (std::size_t plane = 0; plane < CVPixelBufferGetPlaneCount(pixel_buffer); ++plane) { + fill_plane_black( + CVPixelBufferGetBaseAddressOfPlane(pixel_buffer, plane), + CVPixelBufferGetBytesPerRowOfPlane(pixel_buffer, plane) * CVPixelBufferGetHeightOfPlane(pixel_buffer, plane), + format, + plane + ); + } + } else { + fill_plane_black( + CVPixelBufferGetBaseAddress(pixel_buffer), + CVPixelBufferGetBytesPerRow(pixel_buffer) * CVPixelBufferGetHeight(pixel_buffer), + format, + 0 + ); + } + + CVPixelBufferUnlockBaseAddress(pixel_buffer, 0); + } + + CGRect active_desktop_bounds(CGDirectDisplayID fallback_display) { + std::uint32_t display_count {}; + if (CGGetActiveDisplayList(0, nullptr, &display_count) != kCGErrorSuccess || display_count == 0) { + return CGDisplayBounds(fallback_display); + } + + std::vector displays(display_count); + if (CGGetActiveDisplayList(display_count, displays.data(), &display_count) != kCGErrorSuccess || display_count == 0) { + return CGDisplayBounds(fallback_display); + } + + auto bounds = CGDisplayBounds(displays.front()); + for (std::uint32_t index = 1; index < display_count; ++index) { + bounds = CGRectUnion(bounds, CGDisplayBounds(displays[index])); + } + return bounds; + } + + void apply_display_geometry(display_t &display, CGRect selected_display_bounds, CGRect desktop_bounds) { + display.offset_x = static_cast(selected_display_bounds.origin.x); + display.offset_y = static_cast(selected_display_bounds.origin.y); + display.logical_width = static_cast(selected_display_bounds.size.width); + display.logical_height = static_cast(selected_display_bounds.size.height); + display.env_offset_x = static_cast(desktop_bounds.origin.x); + display.env_offset_y = static_cast(desktop_bounds.origin.y); + display.env_logical_width = static_cast(desktop_bounds.size.width); + display.env_logical_height = static_cast(desktop_bounds.size.height); + display.env_width = display.env_logical_width; + display.env_height = display.env_logical_height; + } + + void init_display_geometry(display_t &display, CGDirectDisplayID display_id) { + apply_display_geometry(display, CGDisplayBounds(display_id), active_desktop_bounds(display_id)); + + BOOST_LOG(debug) << "Selected display bounds: "sv << display.offset_x << 'x' << display.offset_y << ' ' + << display.logical_width << 'x' << display.logical_height; + BOOST_LOG(debug) << "Active desktop bounds: "sv << display.env_offset_x << 'x' << display.env_offset_y << ' ' + << display.env_logical_width << 'x' << display.env_logical_height; + } +} // namespace platf::display_helpers diff --git a/src/platform/macos/misc.mm b/src/platform/macos/misc.mm index 9fde3784788..e4ed3c27872 100644 --- a/src/platform/macos/misc.mm +++ b/src/platform/macos/misc.mm @@ -38,7 +38,7 @@ // local includes #include "misc.h" -#include "src/boost_process_compat.h" +#include "src/compat/boost_process.h" #include "src/config.h" #include "src/entry_handler.h" #include "src/logging.h" diff --git a/src/platform/macos/nv12_zero_device.cpp b/src/platform/macos/nv12_zero_device.cpp deleted file mode 100644 index 80b98e60a1b..00000000000 --- a/src/platform/macos/nv12_zero_device.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/** - * @file src/platform/macos/nv12_zero_device.cpp - * @brief Definitions for NV12 zero copy device on macOS. - */ -// standard includes -#include - -// local includes -#include "src/platform/macos/av_img_t.h" -#include "src/platform/macos/nv12_zero_device.h" -#include "src/video.h" - -extern "C" { -#include "libavutil/imgutils.h" -} - -namespace platf { - - /** - * @brief Release an FFmpeg frame allocated by the capture or conversion backend. - */ - void free_frame(AVFrame *frame) { - av_frame_free(&frame); - } - - /** - * @brief Release a backend buffer allocated for capture or conversion. - * - * @param opaque Opaque user pointer provided to the callback. - * @param data Payload or state data to serialize, deserialize, or forward. - */ - void free_buffer(void *opaque, uint8_t *data) { - CVPixelBufferRelease((CVPixelBufferRef) data); - } - - util::safe_ptr av_frame; ///< AV frame. - - int nv12_zero_device::convert(platf::img_t &img) { - auto *av_img = (av_img_t *) &img; - - // Release any existing CVPixelBuffer previously retained for encoding - av_buffer_unref(&av_frame->buf[0]); - - // Attach an AVBufferRef to this frame which will retain ownership of the CVPixelBuffer - // until av_buffer_unref() is called (above) or the frame is freed with av_frame_free(). - // - // The presence of the AVBufferRef allows FFmpeg to simply add a reference to the buffer - // rather than having to perform a deep copy of the data buffers in avcodec_send_frame(). - av_frame->buf[0] = av_buffer_create((uint8_t *) CFRetain(av_img->pixel_buffer->buf), 0, free_buffer, nullptr, 0); - - // Place a CVPixelBufferRef at data[3] as required by AV_PIX_FMT_VIDEOTOOLBOX - av_frame->data[3] = (uint8_t *) av_img->pixel_buffer->buf; - - return 0; - } - - int nv12_zero_device::set_frame(AVFrame *new_frame, AVBufferRef *hw_frames_ctx) { - this->frame = new_frame; - - av_frame.reset(new_frame); - - resolution_fn(this->display, new_frame->width, new_frame->height); - - return 0; - } - - int nv12_zero_device::init(AVVideo *capture_display, pix_fmt_e pix_fmt, resolution_fn_t set_resolution, const pixel_format_fn_t &pixel_format_fn) { - pixel_format_fn(capture_display, pix_fmt == pix_fmt_e::nv12 ? kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange : kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange); - - this->display = capture_display; - this->resolution_fn = std::move(set_resolution); - - hardware = true; - - return 0; - } - -} // namespace platf diff --git a/src/platform/macos/nv12_zero_device.h b/src/platform/macos/nv12_zero_device.h deleted file mode 100644 index 693ab6f4f7d..00000000000 --- a/src/platform/macos/nv12_zero_device.h +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @file src/platform/macos/nv12_zero_device.h - * @brief Declarations for NV12 zero copy device on macOS. - */ -#pragma once - -// local includes -#include "src/platform/common.h" - -struct AVFrame; - -#ifdef __OBJC__ -@class AVVideo; -#else -/** - * @brief Opaque AVFoundation capture controller, defined in Objective-C. - */ -struct AVVideo; -#endif - -namespace platf { - /** - * @brief Release an FFmpeg frame allocated by the capture or conversion backend. - * - * @param frame Video or graphics frame being processed. - */ - void free_frame(AVFrame *frame); - - /** - * @brief macOS zero-copy encode device that forwards NV12 frames from AVFoundation to FFmpeg. - */ - class nv12_zero_device: public avcodec_encode_device_t { - AVVideo *display = nullptr; ///< Borrowed AVFoundation controller, forward-declared to avoid FFmpeg name conflicts. - - public: - // this function is used to set the resolution on an av_video object that we cannot - // call directly because of namespace collisions between AVFoundation and FFMPEG - /** - * @brief Callback signature used to update the opaque AVFoundation display resolution. - */ - using resolution_fn_t = std::function; - resolution_fn_t resolution_fn; ///< Callback stored for later AVFoundation resolution updates. - /** - * @brief Callback signature used to update the opaque AVFoundation pixel format. - */ - using pixel_format_fn_t = std::function; - - /** - * @brief Initialize zero-copy NV12 encoding for an AVFoundation display. - * - * @param capture_display Display object or identifier associated with the operation. - * @param pix_fmt Sunshine pixel format to convert or allocate for. - * @param set_resolution Callback used to resize the AVFoundation capture output. - * @param pixel_format_fn Pixel format. - * @return 0 on success; nonzero or negative platform status on failure. - */ - int init(AVVideo *capture_display, pix_fmt_e pix_fmt, resolution_fn_t set_resolution, const pixel_format_fn_t &pixel_format_fn); - - /** - * @brief Forward a captured AVFoundation frame to FFmpeg without copying. - * - * @param img Image or frame object to read from or populate. - * @return Conversion status. - */ - int convert(img_t &img) override; - /** - * @brief Attach frame resources used by the next conversion or encode operation. - * - * @param new_frame Video or graphics frame being processed. - * @param hw_frames_ctx FFmpeg hardware frames context associated with the frame. - * @return Status from updating frame. - */ - int set_frame(AVFrame *new_frame, AVBufferRef *hw_frames_ctx) override; - - private: - util::safe_ptr av_frame; - }; - -} // namespace platf diff --git a/src/platform/macos/sc_capture.h b/src/platform/macos/sc_capture.h new file mode 100644 index 00000000000..51cb93c7091 --- /dev/null +++ b/src/platform/macos/sc_capture.h @@ -0,0 +1,149 @@ +/** + * @file src/platform/macos/sc_capture.h + * @brief Declarations for ScreenCaptureKit-based display capture on macOS. + */ +#pragma once + +// platform includes +#import +#import +#import +#import + +/** + * @brief ScreenCaptureKit display capture controller used by the macOS backend. + * + * Frames are delivered by an SCStream and latched into a single latest-wins slot; the + * capture loop consumes the newest frame and the encoder duplicates the previous frame + * when the screen is static. Delivery reliability depends on configuration discipline + * (matching OBS's): `minimumFrameInterval` must sit ~10% below the target interval or + * frames get suppressed by clock beating, the pipeline must hold well fewer sample + * buffers at once than `queueDepth` (capped at 8 by the API) or WindowServer stalls + * delivery until one is returned, and frames must never be filtered by SCFrameStatus. + */ +API_AVAILABLE(macos(14.0)) +@interface SCCapture: NSObject + +/** + * @def kMaxDisplays + * @brief Maximum number of displays queried from CoreGraphics. + */ +#define kMaxDisplays 32 + +/** + * @brief Display ID property. + */ +@property (nonatomic, assign) CGDirectDisplayID displayID; +/** + * @brief Capture frame rate property. + */ +@property (nonatomic, assign) int frameRate; +/** + * @brief Output pixel format property. + */ +@property (nonatomic, assign) OSType pixelFormat; +/** + * @brief Output frame width property. + */ +@property (nonatomic, assign) int frameWidth; +/** + * @brief Output frame height property. + */ +@property (nonatomic, assign) int frameHeight; + +/** + * @brief Content filter selecting the captured display. + */ +@property (nonatomic, strong) SCContentFilter *contentFilter; +/** + * @brief Stream configuration used for the capture stream. + */ +@property (nonatomic, strong) SCStreamConfiguration *streamConfiguration; +/** + * @brief Active capture stream delivering frames, or nil when stopped. + */ +@property (nonatomic, strong) SCStream *stream; +/** + * @brief Cached shareable content used for display lookup. + */ +@property (nonatomic, strong) SCShareableContent *shareableContent; + +/** + * @brief Semaphore signalled when capture stops. + */ +@property (nonatomic, assign) dispatch_semaphore_t captureSignal; +/** + * @brief Semaphore signalled when a new frame is available. + */ +@property (nonatomic, assign) dispatch_semaphore_t frameSignal; +/** + * @brief Whether the capture is shutting down. + */ +@property (nonatomic, assign) BOOL stopping; +/** + * @brief Whether the stream stopped on its own since capture started. + */ +@property (nonatomic, assign) BOOL streamFailed; +/** + * @brief Latest captured sample buffer, replaced as newer frames arrive. + */ +@property (nonatomic, assign) CMSampleBufferRef latestSampleBuffer; + +/** + * @brief Check whether ScreenCaptureKit screenshot capture is available on this system. + * + * @return `YES` when the running macOS version supports the capture backend. + */ ++ (BOOL)isAvailable; +/** + * @brief Enumerate active displays. + * + * @return Array of dictionaries describing each active display. + */ ++ (NSArray *)displayNames; +/** + * @brief Look up the localized name of a display. + * + * @param displayID Display to look up. + * @return Localized display name, or nil when unknown. + */ ++ (NSString *)getDisplayName:(CGDirectDisplayID)displayID; + +/** + * @brief Initialize capture for a display. + * + * @param displayID Display to capture. + * @param frameRate Requested capture frame rate. + * @return Initialized instance, or nil on failure. + */ +- (instancetype)initWithDisplay:(CGDirectDisplayID)displayID + frameRate:(int)frameRate; + +/** + * @brief Set the capture output dimensions. + * + * @param frameWidth Output frame width in pixels. + * @param frameHeight Output frame height in pixels. + */ +- (void)setFrameWidth:(int)frameWidth frameHeight:(int)frameHeight; +/** + * @brief Create, configure, and start the capture stream. + * + * When a 10-bit capture format is rejected by the runtime, capture falls back to + * 8-bit and the encoder continues the negotiated session with 8-bit-sourced frames. + * + * @return Semaphore signalled when capture stops, or nil on failure. + */ +- (dispatch_semaphore_t)captureVideo; +/** + * @brief Take ownership of the most recent captured frame. + * + * @return Retained sample buffer, or NULL when no new frame is available. + */ +- (CMSampleBufferRef)copyLatestSampleBuffer; +/** + * @brief Stop capture and release capture state. + */ +- (void)stopCapture; + +@end diff --git a/src/platform/macos/sc_capture.mm b/src/platform/macos/sc_capture.mm new file mode 100644 index 00000000000..ce7fad8d8f4 --- /dev/null +++ b/src/platform/macos/sc_capture.mm @@ -0,0 +1,376 @@ +/** + * @file src/platform/macos/sc_capture.mm + * @brief ScreenCaptureKit-based display capture implementation. + */ +#import "sc_capture.h" + +// local includes +#include "src/logging.h" + +using namespace std::literals; + +/** + * @brief Describe an NSError for logging. + * + * @param error Error to describe, or nil. + * @return UTF-8 description of the error. + */ +static const char *error_description(NSError *error) { + return error && error.localizedDescription ? error.localizedDescription.UTF8String : "unknown error"; +} + +static SCShareableContent *copyShareableContent(void) { + __block SCShareableContent *shareableContent = nil; + dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); + + [SCShareableContent getShareableContentWithCompletionHandler:^(SCShareableContent *content, NSError *content_error) { + if (content_error) { + BOOST_LOG(error) << "SCCapture failed to get shareable content: "sv << error_description(content_error); + } else { + shareableContent = [content retain]; + } + + dispatch_semaphore_signal(semaphore); + }]; + + dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); + dispatch_release(semaphore); + + return shareableContent; +} + +static BOOL isUsableImageSampleBuffer(CMSampleBufferRef sampleBuffer) { + return sampleBuffer && CMSampleBufferIsValid(sampleBuffer) && CMSampleBufferGetImageBuffer(sampleBuffer); +} + +API_AVAILABLE(macos(14.0)) +@implementation SCCapture + ++ (BOOL)isAvailable { + if (@available(macOS 14.0, *)) { + return YES; + } + return NO; +} + ++ (NSArray *)displayNames { + CGDirectDisplayID displays[kMaxDisplays]; + uint32_t count; + if (CGGetActiveDisplayList(kMaxDisplays, displays, &count) != kCGErrorSuccess) { + return [NSArray array]; + } + + NSMutableArray *result = [NSMutableArray array]; + + for (uint32_t i = 0; i < count; i++) { + [result addObject:@{ + @"id": [NSNumber numberWithUnsignedInt:displays[i]], + @"name": [NSString stringWithFormat:@"%d", displays[i]], + @"displayName": [self getDisplayName:displays[i]] ?: @"Unknown Display", + }]; + } + + return [NSArray arrayWithArray:result]; +} + ++ (NSString *)getDisplayName:(CGDirectDisplayID)displayID { + for (NSScreen *screen in [NSScreen screens]) { + if ([screen.deviceDescription[@"NSScreenNumber"] isEqualToNumber:[NSNumber numberWithUnsignedInt:displayID]]) { + return screen.localizedName; + } + } + + return nil; +} + +- (instancetype)initWithDisplay:(CGDirectDisplayID)displayID + frameRate:(int)frameRate { + self = [super init]; + if (self) { + CGDisplayModeRef mode = CGDisplayCopyDisplayMode(displayID); + + self.displayID = displayID; + self.frameRate = frameRate; + self.pixelFormat = kCVPixelFormatType_32BGRA; + + if (mode) { + self.frameWidth = (int) CGDisplayModeGetPixelWidth(mode); + self.frameHeight = (int) CGDisplayModeGetPixelHeight(mode); + CFRelease(mode); + } else { + self.frameWidth = (int) CGDisplayPixelsWide(displayID); + self.frameHeight = (int) CGDisplayPixelsHigh(displayID); + } + + SCShareableContent *content = copyShareableContent(); + if (!content) { + [self release]; + return nil; + } + + self.shareableContent = content; + [content release]; + } + + return self; +} + +- (void)dealloc { + [self stopCapture]; + self.shareableContent = nil; + + [super dealloc]; +} + +- (void)setFrameWidth:(int)frameWidth frameHeight:(int)frameHeight { + self.frameWidth = frameWidth; + self.frameHeight = frameHeight; +} + +- (SCDisplay *)findDisplayWithID:(CGDirectDisplayID)displayID { + for (SCDisplay *display in self.shareableContent.displays) { + if (display.displayID == displayID) { + return display; + } + } + + return nil; +} + +- (SCDisplay *)findDisplayWithIDRetrying:(CGDirectDisplayID)displayID { + SCDisplay *display = [self findDisplayWithID:displayID]; + if (display) { + return display; + } + + for (int attempt = 1; attempt <= 3; attempt++) { + BOOST_LOG(warning) << "SCCapture display "sv << displayID << " not found in SCShareableContent, refreshing (attempt "sv << attempt << "/3)"sv; + [NSThread sleepForTimeInterval:1.0]; + + SCShareableContent *content = copyShareableContent(); + if (!content) { + continue; + } + + self.shareableContent = content; + [content release]; + + display = [self findDisplayWithID:displayID]; + if (display) { + BOOST_LOG(info) << "SCCapture found display "sv << displayID << " after refresh"sv; + return display; + } + } + + return nil; +} + +- (void)releaseCaptureSignals { + if (self.frameSignal) { + dispatch_semaphore_signal(self.frameSignal); + dispatch_release(self.frameSignal); + self.frameSignal = NULL; + } + + if (self.captureSignal) { + dispatch_semaphore_signal(self.captureSignal); + dispatch_release(self.captureSignal); + self.captureSignal = NULL; + } +} + +- (void)clearLatestSampleBuffer { + if (self.latestSampleBuffer) { + CFRelease(self.latestSampleBuffer); + self.latestSampleBuffer = NULL; + } +} + +- (void)storeSampleBuffer:(CMSampleBufferRef)sampleBuffer { + @synchronized(self) { + if (self.stopping) { + return; + } + + BOOL shouldSignal = self.latestSampleBuffer == NULL; + + [self clearLatestSampleBuffer]; + self.latestSampleBuffer = (CMSampleBufferRef) CFRetain(sampleBuffer); + + if (shouldSignal && self.frameSignal) { + dispatch_semaphore_signal(self.frameSignal); + } + } +} + +/** + * @brief Create and start a capture stream for the current filter and configuration. + * + * @return Started stream (retained), or nil on failure. + */ +- (SCStream *)startConfiguredStream { + SCStream *stream = [[SCStream alloc] initWithFilter:self.contentFilter configuration:self.streamConfiguration delegate:self]; + NSError *output_error = nil; + if (!stream || ![stream addStreamOutput:self type:SCStreamOutputTypeScreen sampleHandlerQueue:nil error:&output_error]) { + BOOST_LOG(error) << "SCCapture failed to create stream output: "sv << error_description(output_error); + [stream release]; + return nil; + } + + __block NSError *start_error = nil; + dispatch_semaphore_t started = dispatch_semaphore_create(0); + [stream startCaptureWithCompletionHandler:^(NSError *completion_error) { + start_error = [completion_error retain]; + dispatch_semaphore_signal(started); + }]; + dispatch_semaphore_wait(started, DISPATCH_TIME_FOREVER); + dispatch_release(started); + + if (start_error) { + BOOST_LOG(error) << "SCCapture failed to start capture stream: "sv << error_description(start_error); + [start_error release]; + [stream release]; + return nil; + } + + return stream; +} + +- (dispatch_semaphore_t)captureVideo { + dispatch_semaphore_t capture_signal = nil; + + @synchronized(self) { + [self clearLatestSampleBuffer]; + [self releaseCaptureSignals]; + + self.stopping = NO; + self.streamFailed = NO; + self.captureSignal = dispatch_semaphore_create(0); + self.frameSignal = dispatch_semaphore_create(0); + + SCDisplay *display = [self findDisplayWithIDRetrying:self.displayID]; + if (!display) { + BOOST_LOG(error) << "SCCapture display not found after retries: "sv << self.displayID; + [self releaseCaptureSignals]; + return nil; + } + + SCContentFilter *filter = [[SCContentFilter alloc] initWithDisplay:display excludingWindows:@[]]; + self.contentFilter = filter; + [filter release]; + + SCStreamConfiguration *config = [[SCStreamConfiguration alloc] init]; + config.width = self.frameWidth; + config.height = self.frameHeight; + config.pixelFormat = self.pixelFormat; + config.showsCursor = YES; + config.captureResolution = SCCaptureResolutionBest; + config.preservesAspectRatio = YES; + // Slightly below the target interval: an interval of exactly 1/fps beats against + // WindowServer's delivery clock and suppresses frames that arrive marginally early. + const int fps = MAX(self.frameRate, 1); + config.minimumFrameInterval = CMTimeMake(9, fps * 10); + // Request the documented maximum explicitly (the default has varied across macOS + // releases). WindowServer only delivers while it has a free surface, so the pipeline + // must keep the number of sample buffers it holds at once (latest-wins slot, image in + // flight, encoder reference) well below this, or delivery stalls until one is returned. + config.queueDepth = 8; + self.streamConfiguration = config; + [config release]; + + capture_signal = self.captureSignal; + } + + // Start the stream outside the lock: delivery callbacks synchronize on self. + SCStream *stream = [self startConfiguredStream]; + + // Apple documents only BGRA, l10r, 420v and 420f for SCStreamConfiguration.pixelFormat; + // 10-bit sessions request the undocumented (but in practice accepted) x420. If the + // runtime rejects it, retry with 8-bit 420v: VideoToolbox accepts 8-bit input into a + // Main10 encode session, so the negotiated stream survives with 8-bit-sourced content. + if (!stream && self.pixelFormat == kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange) { + BOOST_LOG(warning) << "SCCapture 10-bit capture format was rejected, falling back to 8-bit capture"sv; + @synchronized(self) { + self.pixelFormat = kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange; + self.streamConfiguration.pixelFormat = self.pixelFormat; + } + stream = [self startConfiguredStream]; + } + + if (!stream) { + @synchronized(self) { + [self releaseCaptureSignals]; + } + return nil; + } + + self.stream = stream; + [stream release]; + + BOOST_LOG(info) << "SCCapture stream configured: "sv << self.frameWidth << 'x' << self.frameHeight << " @ "sv << self.frameRate << " fps"sv; + + return capture_signal; +} + +- (CMSampleBufferRef)copyLatestSampleBuffer { + @synchronized(self) { + CMSampleBufferRef sampleBuffer = self.latestSampleBuffer; + self.latestSampleBuffer = NULL; + return sampleBuffer; + } +} + +- (void)stream:(SCStream *)stream didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer ofType:(SCStreamOutputType)type { + if (type != SCStreamOutputTypeScreen) { + return; + } + + // No SCFrameStatus filtering: any sample buffer carrying pixels is a real update. + if (!isUsableImageSampleBuffer(sampleBuffer)) { + return; + } + + [self storeSampleBuffer:sampleBuffer]; +} + +- (void)stream:(SCStream *)stream didStopWithError:(NSError *)stop_error { + @synchronized(self) { + if (self.stopping) { + return; + } + + BOOST_LOG(error) << "SCCapture stream stopped: "sv << error_description(stop_error); + self.streamFailed = YES; + + // Wake the capture loop so the pipeline tears down and reinitializes. + if (self.frameSignal) { + dispatch_semaphore_signal(self.frameSignal); + } + if (self.captureSignal) { + dispatch_semaphore_signal(self.captureSignal); + } + } +} + +- (void)stopCapture { + SCStream *stream = nil; + + @synchronized(self) { + self.stopping = YES; + + stream = [self.stream retain]; + self.stream = nil; + self.contentFilter = nil; + self.streamConfiguration = nil; + + [self clearLatestSampleBuffer]; + [self releaseCaptureSignals]; + } + + if (stream) { + [stream stopCaptureWithCompletionHandler:^(NSError *stop_error) {}]; + [stream release]; + } +} + +@end diff --git a/src/platform/macos/sc_capture_loop.cpp b/src/platform/macos/sc_capture_loop.cpp new file mode 100644 index 00000000000..a240762d577 --- /dev/null +++ b/src/platform/macos/sc_capture_loop.cpp @@ -0,0 +1,91 @@ +/** + * @file src/platform/macos/sc_capture_loop.cpp + * @brief Definitions for the ScreenCaptureKit capture loop and backend fallback policy on macOS. + */ +// standard includes +#include +#include + +// local includes +#include "src/platform/macos/sc_capture_loop.h" +#include "src/utility.h" + +namespace platf::sckit { + void backend_policy_t::note_stream_start_failure() { + _stream_start_failed = true; + } + + bool backend_policy_t::stream_start_failed() const { + return _stream_start_failed; + } + + bool backend_policy_t::prefer_sckit(bool sckit_available) const { + return sckit_available && !_stream_start_failed; + } + + backend_policy_t &backend_policy() { + static backend_policy_t policy; + return policy; + } + + capture_e run_capture_loop( + frame_source_t &source, + backend_policy_t &policy, + const display_t::push_captured_image_cb_t &push_captured_image_cb, + const display_t::pull_free_image_cb_t &pull_free_image_cb, + const process_frame_fn_t &process_frame, + std::chrono::nanoseconds poll_interval + ) { + if (!source.start()) { + // The display was built for ScreenCaptureKit but the stream never came up: ask the + // capture thread to rebuild the display, which the policy now steers to AVFoundation. + policy.note_stream_start_failure(); + return capture_e::reinit; + } + + auto stop_source = util::fail_guard([&source]() { + source.stop(); + }); + + while (true) { + // The stream pushes frames on its own; wait for the next one, waking periodically + // to report a timeout and to notice interrupt requests. + source.wait_frame(poll_interval); + + if (source.stopped()) { + // The stream died underneath us (display change, permission revoked, ...); + // only a display rebuild gets capture going again. + return capture_e::reinit; + } + + CMSampleBufferRef sample_buffer = source.copy_latest_sample_buffer(); + + if (!sample_buffer) { + // No new frame within the poll interval: report a timeout like the other backends + // so the pipeline can repeat the previous frame. + std::shared_ptr img_out; + if (!pull_free_image_cb(img_out) || !push_captured_image_cb(std::move(img_out), false)) { + return capture_e::ok; + } + continue; + } + + auto release_sample_buffer = util::fail_guard([sample_buffer]() { + CFRelease(sample_buffer); + }); + + std::shared_ptr img_out; + if (!pull_free_image_cb(img_out)) { + return capture_e::ok; + } + + if (!process_frame(sample_buffer, img_out.get())) { + continue; + } + + if (!push_captured_image_cb(std::move(img_out), true)) { + return capture_e::ok; + } + } + } +} // namespace platf::sckit diff --git a/src/platform/macos/sc_capture_loop.h b/src/platform/macos/sc_capture_loop.h new file mode 100644 index 00000000000..5bc85a00988 --- /dev/null +++ b/src/platform/macos/sc_capture_loop.h @@ -0,0 +1,133 @@ +/** + * @file src/platform/macos/sc_capture_loop.h + * @brief Declarations for the ScreenCaptureKit capture loop and backend fallback policy on macOS. + */ +#pragma once + +// standard includes +#include +#include +#include + +// platform includes +#include + +// local includes +#include "src/platform/common.h" + +namespace platf::sckit { + /** + * @brief Process-wide policy deciding whether ScreenCaptureKit is still the preferred capture backend. + * + * ScreenCaptureKit is selected when a display is created, but its stream can only be started once + * capture begins. A stream that fails to start flips this policy so that the display is rebuilt + * on AVFoundation instead. + */ + class backend_policy_t { + public: + /** + * @brief Record that an SCStream could not be started. + */ + void note_stream_start_failure(); + + /** + * @brief Check whether an SCStream previously failed to start in this process. + * + * @return `true` once a stream start failure was recorded. + */ + [[nodiscard]] bool stream_start_failed() const; + + /** + * @brief Decide whether ScreenCaptureKit should be used for a new display. + * + * @param sckit_available Whether the running system supports ScreenCaptureKit capture. + * @return `true` when ScreenCaptureKit is available and has not failed to start a stream. + */ + [[nodiscard]] bool prefer_sckit(bool sckit_available) const; + + private: + std::atomic _stream_start_failed {false}; ///< Set once an SCStream fails to start. + }; + + /** + * @brief Access the process-wide backend policy. + * + * @return Shared policy instance. + */ + backend_policy_t &backend_policy(); + + /** + * @brief Minimal view of an SCStream as seen by the capture loop. + * + * The loop only needs to start and stop the stream, wait for and take the latest frame, and + * learn when the stream stopped on its own, so tests can drive it with a scripted source. + */ + class frame_source_t { + public: + virtual ~frame_source_t() = default; + + /** + * @brief Start the stream. + * + * @return `true` when frames may be expected; `false` when the stream could not be started. + */ + virtual bool start() = 0; + + /** + * @brief Wait until a new frame is available or the timeout expires. + * + * @param timeout Maximum time to wait. + */ + virtual void wait_frame(std::chrono::nanoseconds timeout) = 0; + + /** + * @brief Check whether the stream stopped without being asked to. + * + * @return `true` once the stream reported an unexpected stop. + */ + [[nodiscard]] virtual bool stopped() const = 0; + + /** + * @brief Take ownership of the most recent frame. + * + * @return Retained sample buffer, or `NULL` when no new frame arrived. + */ + virtual CMSampleBufferRef copy_latest_sample_buffer() = 0; + + /** + * @brief Stop the stream and release its resources. + */ + virtual void stop() = 0; + }; + + /** + * @brief Callback that converts a sample buffer into a Sunshine image. + * + * Returns `false` when the sample buffer carried no usable pixel buffer. + */ + using process_frame_fn_t = std::function; + + /** + * @brief Run the ScreenCaptureKit capture loop until the pipeline interrupts it or the stream fails. + * + * Frames are pushed as they arrive; a poll interval without a frame is reported as a timeout so + * the pipeline can repeat the previous frame. A stream that fails to start or stops on its own + * yields `capture_e::reinit`, which makes the capture thread rebuild the display; a start failure + * also updates the backend policy, so that rebuild falls back to AVFoundation. + * @param source Stream to capture from; started here and stopped before returning unless the start failed. + * @param policy Backend policy updated when the stream cannot be started. + * @param push_captured_image_cb Pipeline callback receiving captured or repeated images. + * @param pull_free_image_cb Pipeline callback providing free images. + * @param process_frame Converts a sample buffer into the pulled image. + * @param poll_interval Longest time to wait for a frame before reporting a timeout. + * @return `capture_e::ok` when the pipeline interrupted capture; `capture_e::reinit` when the stream failed. + */ + capture_e run_capture_loop( + frame_source_t &source, + backend_policy_t &policy, + const display_t::push_captured_image_cb_t &push_captured_image_cb, + const display_t::pull_free_image_cb_t &pull_free_image_cb, + const process_frame_fn_t &process_frame, + std::chrono::nanoseconds poll_interval + ); +} // namespace platf::sckit diff --git a/src/platform/macos/vt_encoder.h b/src/platform/macos/vt_encoder.h new file mode 100644 index 00000000000..4b74c990201 --- /dev/null +++ b/src/platform/macos/vt_encoder.h @@ -0,0 +1,90 @@ +/** + * @file src/platform/macos/vt_encoder.h + * @brief Declarations for the native VideoToolbox encoder on macOS. + */ +#pragma once + +// standard includes +#include +#include +#include +#include + +// platform includes +#include + +// local includes +#include "src/platform/common.h" + +namespace platf::vt { + /** + * @brief Callback that resizes the capture output to the encoder resolution. + */ + using resolution_fn_t = std::function; + + /** + * @brief Callback that selects the capture pixel format. + */ + using pixel_format_fn_t = std::function; + + /** + * @brief Decide whether to request low-latency rate control before standard rate control. + * + * A session without low-latency rate control is always tried next, so encoders that reject + * it still get a session. FFmpeg only enabled it for HEVC on Apple silicon, so HEVC on Intel + * goes straight to standard rate control. + * + * @param codec CoreMedia codec type of the session. + * @param arm64 Whether the host is Apple silicon. + * @return True when low-latency rate control should be tried first. + */ + bool try_low_latency(CMVideoCodecType codec, bool arm64); + + /** + * @brief Map the `vt_coder` setting to an H.264 entropy mode. + * + * @param coder Value of `config::video.vt.vt_coder` (1 = CABAC, 2 = CAVLC, anything else = auto). + * @return Entropy mode to set, or null to leave the encoder default. + */ + CFStringRef h264_entropy_mode(int coder); + + /** + * @brief Convert one encoded sample buffer from AVCC framing to an Annex-B elementary stream. + * + * On IDR frames the parameter sets held out-of-band in the format description are emitted + * first (H.264: SPS, PPS; HEVC: VPS, SPS, PPS), because Moonlight identifies IDR frames by + * the leading parameter-set NAL and decodes each packet as a self-contained frame. + * + * @param sample_buffer Encoded sample buffer delivered by the compression session. + * @param idr Whether the sample buffer holds a sync (IDR) frame. + * @param out Vector that receives the Annex-B bytes; left unchanged when conversion fails. + * @return True when the complete frame was converted. + */ + bool append_annexb(CMSampleBufferRef sample_buffer, bool idr, std::vector &out); + + /** + * @brief Compute the frame rate to declare to a VideoToolbox compression session. + * + * Low-latency H.264 sessions drop every frame when the declared rate exceeds what H.264 + * level 5.2 (the highest level the hardware encoder offers) allows at the session's + * resolution, so H.264 rates are capped at that limit. Frames are still submitted at the + * negotiated rate; only the rate-control hint changes. Other codecs are not capped. + * + * @param codec CoreMedia codec type of the session. + * @param width Encoded width in pixels. + * @param height Encoded height in pixels. + * @param framerate Negotiated stream frame rate. + * @return Frame rate to set as `kVTCompressionPropertyKey_ExpectedFrameRate`. + */ + int expected_frame_rate(CMVideoCodecType codec, int width, int height, int framerate); + + /** + * @brief Create a native VideoToolbox encode device bound to the capture display. + * + * @param pix_fmt Sunshine pixel format to capture and encode. + * @param resolution_fn Callback that resizes the capture output. + * @param pixel_format_fn Callback that selects the capture pixel format; invoked before capture starts. + * @return Constructed encode device object, or null on failure. + */ + std::unique_ptr make_encode_device(pix_fmt_e pix_fmt, resolution_fn_t resolution_fn, const pixel_format_fn_t &pixel_format_fn); +} // namespace platf::vt diff --git a/src/platform/macos/vt_encoder.mm b/src/platform/macos/vt_encoder.mm new file mode 100644 index 00000000000..6da3b8132ba --- /dev/null +++ b/src/platform/macos/vt_encoder.mm @@ -0,0 +1,564 @@ +/** + * @file src/platform/macos/vt_encoder.mm + * @brief Definitions for the native VideoToolbox encoder on macOS. + * + * Encodes captured CVPixelBuffers directly through a VTCompressionSession. The session is driven strictly one frame in flight: each + * submission blocks until the output callback delivers the encoded frame, so packets + * come back in submission order with exactly one packet per frame index. + */ +// standard includes +#include +#include +#include +#include +#include +#include +#include + +// platform includes +#include +#include + +// local includes +#include "src/logging.h" +#include "src/platform/macos/av_img_t.h" +#include "src/platform/macos/vt_encoder.h" +#include "src/utility.h" +#include "src/video.h" + +namespace { + using namespace std::literals; + + /** + * @brief Blocking one-frame-in-flight wrapper around a VTCompressionSession. + */ + class vt_compression_session_t { + public: + ~vt_compression_session_t() { + if (session) { + VTCompressionSessionCompleteFrames(session, kCMTimeInvalid); + // Guarantees no output callbacks after return + VTCompressionSessionInvalidate(session); + CFRelease(session); + } + } + + /** + * @brief Create and configure the compression session. + * + * @param codec CoreMedia codec type to encode. + * @param config Client stream configuration negotiated for this session. + * @param colorspace Colorimetry information used for encoding. + * @return True when the session is ready to encode. + */ + bool init(CMVideoCodecType codec, const video::config_t &config, const video::sunshine_colorspace_t &colorspace) { + width = config.width; + height = config.height; + framerate = config.framerate; + +#if defined(__arm64__) || defined(__aarch64__) + constexpr bool arm64 = true; +#else + constexpr bool arm64 = false; +#endif + const bool try_low_latency = platf::vt::try_low_latency(codec, arm64); + bool low_latency = try_low_latency && create_session(codec, config, true); + if (!low_latency && !create_session(codec, config, false)) { + BOOST_LOG(error) << "VideoToolbox could not create a compression session"sv; + return false; + } + if (try_low_latency && !low_latency) { + BOOST_LOG(info) << "VideoToolbox low-latency rate control is unavailable; using standard rate control"sv; + } + BOOST_LOG(info) << "VideoToolbox session uses "sv << (low_latency ? "low-latency"sv : "standard"sv) << " rate control"sv; + + set_property(kVTCompressionPropertyKey_RealTime, config::video.vt.vt_realtime ? kCFBooleanTrue : kCFBooleanFalse, "RealTime"sv); + set_property(kVTCompressionPropertyKey_AllowFrameReordering, kCFBooleanFalse, "AllowFrameReordering"sv); + if (codec == kCMVideoCodecType_H264) { + // Low-latency H.264 sessions mark pictures as long-term references by default; some + // client hardware decoders mishandle that and freeze, so keep to short-term references. + set_property(kVTCompressionPropertyKey_EnableLTR, kCFBooleanFalse, "EnableLTR"sv); + if (const auto entropy_mode = platf::vt::h264_entropy_mode(config::video.vt.vt_coder)) { + set_property(kVTCompressionPropertyKey_H264EntropyMode, entropy_mode, "H264EntropyMode"sv); + } + } + + CFStringRef profile; + if (codec == kCMVideoCodecType_HEVC) { + profile = colorspace.bit_depth == 10 ? kVTProfileLevel_HEVC_Main10_AutoLevel : kVTProfileLevel_HEVC_Main_AutoLevel; + } else { + profile = kVTProfileLevel_H264_High_AutoLevel; + } + if (!set_property(kVTCompressionPropertyKey_ProfileLevel, profile, "ProfileLevel"sv) && colorspace.bit_depth == 10) { + // 10-bit output without the Main10 profile would be broken + return false; + } + + // Honor the host-side bitrate ceiling, matching the avcodec path + const int bitrate_kbps = config::video.max_bitrate > 0 ? std::min(config.bitrate, config::video.max_bitrate) : config.bitrate; + // No DataRateLimits under low-latency rate control: with a hard byte window it drops frames + // that would exceed it (e.g. full-screen changes at 4K120). Without it, AverageBitRate still + // steers the rate and oversized frames cost quality on later frames instead of a drop. + set_int_property(kVTCompressionPropertyKey_AverageBitRate, bitrate_kbps * 1000, "AverageBitRate"sv); + if (!low_latency) { + // Standard rate control treats AverageBitRate as a long-term target, so bound each second + // to the bitrate, matching what the avcodec path requested for these sessions. + set_data_rate_limit(bitrate_kbps * 1000 / 8); + } + const int expected_rate = platf::vt::expected_frame_rate(codec, config.width, config.height, config.framerate); + if (expected_rate != config.framerate) { + BOOST_LOG(info) << "VideoToolbox H.264 expected frame rate capped at "sv << expected_rate << " (level 5.2 limit for "sv + << config.width << 'x' << config.height << ")"sv; + } + set_int_property(kVTCompressionPropertyKey_ExpectedFrameRate, expected_rate, "ExpectedFrameRate"sv); + set_int_property(kVTCompressionPropertyKey_MaxKeyFrameInterval, std::numeric_limits::max(), "MaxKeyFrameInterval"sv); + apply_colorspace(colorspace); + + const auto prepare_status = VTCompressionSessionPrepareToEncodeFrames(session); + if (prepare_status != noErr) { + BOOST_LOG(warning) << "VTCompressionSessionPrepareToEncodeFrames failed: "sv << prepare_status; + } + return true; + } + + /** + * @brief Encode one frame, blocking until the encoded output is available. + * + * @param pixel_buffer Captured pixel buffer to encode. + * @param frame_index Monotonic frame index assigned by the video pipeline. + * @param force_idr Whether the frame must be encoded as an IDR frame. + * @return Encoded frame, or one with empty data on failure. + */ + platf::vt_encoded_frame encode(CVPixelBufferRef pixel_buffer, uint64_t frame_index, bool force_idr) { + if (!session) { + return {}; + } + + if (CVPixelBufferGetWidth(pixel_buffer) != (size_t) width || CVPixelBufferGetHeight(pixel_buffer) != (size_t) height) { + BOOST_LOG(error) << "VideoToolbox captured frame is "sv << CVPixelBufferGetWidth(pixel_buffer) << 'x' << CVPixelBufferGetHeight(pixel_buffer) + << " but the session expects "sv << width << 'x' << height; + return {}; + } + + { + std::lock_guard lg {mutex}; + if (need_idr) { + force_idr = true; + } + ready = false; + failed = false; + annexb.clear(); + } + + CFDictionaryRef frame_options = nullptr; + if (force_idr) { + CFMutableDictionaryRef options = CFDictionaryCreateMutable(kCFAllocatorDefault, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); + CFDictionarySetValue(options, kVTEncodeFrameOptionKey_ForceKeyFrame, kCFBooleanTrue); + frame_options = options; + } + const auto encode_status = VTCompressionSessionEncodeFrame(session, pixel_buffer, CMTimeMake(frame_index, framerate), kCMTimeInvalid, frame_options, nullptr, nullptr); + if (frame_options) { + CFRelease(frame_options); + } + if (encode_status != noErr) { + BOOST_LOG(error) << "VTCompressionSessionEncodeFrame failed: "sv << encode_status; + return {}; + } + + std::unique_lock lock {mutex}; + if (!cv.wait_for(lock, 1s, [this] { + return ready; + })) { + BOOST_LOG(error) << "VideoToolbox encode timed out"sv; + return {}; + } + if (failed) { + return {}; + } + if (force_idr && !idr_out) { + BOOST_LOG(error) << "VideoToolbox did not honor the IDR request"sv; + } + if (idr_out) { + need_idr = false; + } + + frame_size_logger.collect_and_log(annexb.size() / 1000.); + + platf::vt_encoded_frame result; + result.data = std::move(annexb); + result.frame_index = frame_index; + result.idr = idr_out; + return result; + } + + private: + static void output_callback(void *refcon, void *, OSStatus status, VTEncodeInfoFlags flags, CMSampleBufferRef sample_buffer) { + auto self = static_cast(refcon); + std::lock_guard lg {self->mutex}; + self->ready = true; + self->failed = true; + do { + if (status != noErr) { + BOOST_LOG(error) << "VideoToolbox encode failed: "sv << status; + break; + } + if ((flags & kVTEncodeInfo_FrameDropped) || !sample_buffer) { + // A dropped frame would leave a gap in the frame index sequence, which the + // client treats as fatal, so the session is torn down and recreated instead. + BOOST_LOG(error) << "VideoToolbox dropped a frame"sv; + break; + } + + bool sync = true; + CFArrayRef attachments = CMSampleBufferGetSampleAttachmentsArray(sample_buffer, false); + if (attachments && CFArrayGetCount(attachments) > 0) { + auto dict = (CFDictionaryRef) CFArrayGetValueAtIndex(attachments, 0); + auto not_sync = (CFBooleanRef) CFDictionaryGetValue(dict, kCMSampleAttachmentKey_NotSync); + sync = !not_sync || !CFBooleanGetValue(not_sync); + } + + // New parameter sets on a non-IDR frame would never reach the client, which only + // receives them prepended to IDR frames. + CMFormatDescriptionRef format = CMSampleBufferGetFormatDescription(sample_buffer); + if (!sync && self->last_format && format != self->last_format) { + BOOST_LOG(warning) << "VideoToolbox format description changed without a keyframe, forcing IDR"sv; + self->need_idr = true; + } + self->last_format = format; + + if (!platf::vt::append_annexb(sample_buffer, sync, self->annexb)) { + self->annexb.clear(); + break; + } + self->idr_out = sync; + self->failed = false; + } while (false); + self->cv.notify_one(); + } + + /** + * @brief Try to create a hardware compression session. + * + * @param codec CoreMedia codec type to encode. + * @param config Client stream configuration negotiated for this session. + * @param low_latency Whether to request low-latency rate control. + * @return True when the session was created. + */ + bool create_session(CMVideoCodecType codec, const video::config_t &config, bool low_latency) { + CFMutableDictionaryRef specification = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); + // VideoToolbox's software encoder is far slower than Sunshine's own software encoder, so + // fail without hardware and let encoder selection fall back to that instead. + CFDictionarySetValue(specification, kVTVideoEncoderSpecification_RequireHardwareAcceleratedVideoEncoder, kCFBooleanTrue); + if (low_latency) { + CFDictionarySetValue(specification, kVTVideoEncoderSpecification_EnableLowLatencyRateControl, kCFBooleanTrue); + } + + const auto status = VTCompressionSessionCreate(kCFAllocatorDefault, config.width, config.height, codec, specification, nullptr, nullptr, output_callback, this, &session); + CFRelease(specification); + if (status != noErr || !session) { + BOOST_LOG(warning) << "VTCompressionSessionCreate failed (low latency: "sv << low_latency << "): "sv << status; + session = nullptr; + return false; + } + return true; + } + + /** + * @brief Limit the encoded data to a number of bytes per second. + * + * @param bytes_per_second Maximum encoded bytes in any one-second window. + */ + void set_data_rate_limit(std::int64_t bytes_per_second) { + constexpr std::int64_t one_second = 1; + CFNumberRef bytes = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &bytes_per_second); + CFNumberRef seconds = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &one_second); + const void *values[] = {bytes, seconds}; + CFArrayRef limits = CFArrayCreate(kCFAllocatorDefault, values, 2, &kCFTypeArrayCallBacks); + set_property(kVTCompressionPropertyKey_DataRateLimits, limits, "DataRateLimits"sv); + CFRelease(limits); + CFRelease(seconds); + CFRelease(bytes); + } + + bool set_property(CFStringRef key, CFTypeRef value, std::string_view name) { + const auto status = VTSessionSetProperty(session, key, value); + if (status != noErr) { + BOOST_LOG(warning) << "VideoToolbox rejected "sv << name << ": "sv << status; + return false; + } + return true; + } + + bool set_int_property(CFStringRef key, int value, std::string_view name) { + CFNumberRef number = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &value); + const auto ok = set_property(key, number, name); + CFRelease(number); + return ok; + } + + void apply_colorspace(const video::sunshine_colorspace_t &colorspace) { + CFStringRef primaries; + CFStringRef transfer; + CFStringRef matrix; + switch (colorspace.colorspace) { + case video::colorspace_e::rec601: + primaries = kCVImageBufferColorPrimaries_SMPTE_C; + transfer = kCVImageBufferTransferFunction_ITU_R_709_2; + matrix = kCVImageBufferYCbCrMatrix_ITU_R_601_4; + break; + case video::colorspace_e::rec709: + primaries = kCVImageBufferColorPrimaries_ITU_R_709_2; + transfer = kCVImageBufferTransferFunction_ITU_R_709_2; + matrix = kCVImageBufferYCbCrMatrix_ITU_R_709_2; + break; + case video::colorspace_e::bt2020sdr: + primaries = kCVImageBufferColorPrimaries_ITU_R_2020; + transfer = kCVImageBufferTransferFunction_ITU_R_709_2; + matrix = kCVImageBufferYCbCrMatrix_ITU_R_2020; + break; + case video::colorspace_e::bt2020: + primaries = kCVImageBufferColorPrimaries_ITU_R_2020; + transfer = kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ; + matrix = kCVImageBufferYCbCrMatrix_ITU_R_2020; + break; + } + set_property(kVTCompressionPropertyKey_ColorPrimaries, primaries, "ColorPrimaries"sv); + set_property(kVTCompressionPropertyKey_TransferFunction, transfer, "TransferFunction"sv); + set_property(kVTCompressionPropertyKey_YCbCrMatrix, matrix, "YCbCrMatrix"sv); + } + + VTCompressionSessionRef session = nullptr; + int width = 0; + int height = 0; + int framerate = 60; + + std::mutex mutex; + std::condition_variable cv; + bool ready = false; + bool failed = false; + bool idr_out = false; + bool need_idr = false; + std::vector annexb; + logging::min_max_avg_periodic_logger frame_size_logger = {debug, "VideoToolbox: encoded frame sizes in kB", ""}; ///< Periodic encoded frame size statistics. + // Pointer identity only, never dereferenced; used to notice mid-stream parameter set changes + CMFormatDescriptionRef last_format = nullptr; + }; + + /** + * @brief Native VideoToolbox encode device bound to a macOS capture pipeline. + */ + class vt_encode_device final: public platf::vt_encode_device_t { + public: + /** + * @brief Bind the device to the capture display and select the capture pixel format. + * + * @param pix_fmt Sunshine pixel format to capture and encode. + * @param resolution_fn Callback that resizes the capture output. + * @param pixel_format_fn Callback that selects the capture pixel format. + * @return 0 on success. + */ + int init(platf::pix_fmt_e pix_fmt, platf::vt::resolution_fn_t resolution_fn, const platf::vt::pixel_format_fn_t &pixel_format_fn) { + this->resolution_fn = std::move(resolution_fn); + // Must happen before capture starts; the capture backend snapshots it when the stream is created + pixel_format_fn(pix_fmt == platf::pix_fmt_e::p010 ? kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange : kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange); + return 0; + } + + bool init_encoder(const video::config_t &client_config, const video::sunshine_colorspace_t &colorspace) override { + if (client_config.videoFormat == 2) { + BOOST_LOG(info) << "VideoToolbox encoder doesn't support AV1"sv; + return false; + } + if (client_config.videoFormat == 0 && colorspace.bit_depth == 10) { + BOOST_LOG(error) << "VideoToolbox encoder doesn't support 10-bit H.264"sv; + return false; + } + + resolution_fn(client_config.width, client_config.height); + + session = std::make_unique(); + const CMVideoCodecType codec = client_config.videoFormat == 1 ? kCMVideoCodecType_HEVC : kCMVideoCodecType_H264; + if (!session->init(codec, client_config, colorspace)) { + session.reset(); + return false; + } + return true; + } + + int convert(platf::img_t &img) override { + auto av_img = (platf::av_img_t *) &img; + if (!av_img->pixel_buffer || !av_img->pixel_buffer->buf) { + return -1; + } + + // Keep the frame's backing sample buffer retained while VideoToolbox reads it; + // the img_t pool recycles the image (and releases its buffers) at any time. + // Release order matters: the old pixel buffer must unlock (av_pixel_buf_t dtor) + // before the old sample buffer that owns it is released. + pixel_buffer = av_img->pixel_buffer; + sample_buffer = av_img->sample_buffer; + return 0; + } + + platf::vt_encoded_frame encode_frame(uint64_t frame_index, bool force_idr) override { + if (!session || !pixel_buffer) { + return {}; + } + return session->encode(pixel_buffer->buf, frame_index, force_idr); + } + + private: + platf::vt::resolution_fn_t resolution_fn; + std::unique_ptr session; + std::shared_ptr sample_buffer; + std::shared_ptr pixel_buffer; + }; +} // namespace + +namespace platf::vt { + bool append_annexb(CMSampleBufferRef sample_buffer, bool idr, std::vector &out) { + constexpr uint8_t start_code[] = {0, 0, 0, 1}; + const auto start_size = out.size(); + auto restore_out = util::fail_guard([&]() { + out.resize(start_size); + }); + + CMFormatDescriptionRef format = CMSampleBufferGetFormatDescription(sample_buffer); + if (!format) { + BOOST_LOG(error) << "VideoToolbox sample buffer has no format description"sv; + return false; + } + const bool hevc = CMFormatDescriptionGetMediaSubType(format) == kCMVideoCodecType_HEVC; + + size_t parameter_set_count = 0; + int nal_length_size = 4; + { + const uint8_t *ps = nullptr; + size_t ps_size = 0; + const auto status = hevc ? + CMVideoFormatDescriptionGetHEVCParameterSetAtIndex(format, 0, &ps, &ps_size, ¶meter_set_count, &nal_length_size) : + CMVideoFormatDescriptionGetH264ParameterSetAtIndex(format, 0, &ps, &ps_size, ¶meter_set_count, &nal_length_size); + if (status != noErr) { + BOOST_LOG(error) << "VideoToolbox parameter set query failed: "sv << status; + return false; + } + } + + if (idr) { + for (size_t i = 0; i < parameter_set_count; ++i) { + const uint8_t *ps = nullptr; + size_t ps_size = 0; + const auto status = hevc ? + CMVideoFormatDescriptionGetHEVCParameterSetAtIndex(format, i, &ps, &ps_size, nullptr, nullptr) : + CMVideoFormatDescriptionGetH264ParameterSetAtIndex(format, i, &ps, &ps_size, nullptr, nullptr); + if (status != noErr || !ps_size) { + BOOST_LOG(error) << "VideoToolbox parameter set "sv << i << " query failed: "sv << status; + return false; + } + if (i == 0) { + const int nal_type = hevc ? ((ps[0] >> 1) & 0x3f) : (ps[0] & 0x1f); + const int expected = hevc ? 32 : 7; // Moonlight requires VPS-first (HEVC) / SPS-first (H.264) IDR frames + if (nal_type != expected) { + BOOST_LOG(error) << "VideoToolbox emitted unexpected leading parameter set NAL type "sv << nal_type; + } + } + out.insert(out.end(), std::begin(start_code), std::end(start_code)); + out.insert(out.end(), ps, ps + ps_size); + } + } + + CMBlockBufferRef block = CMSampleBufferGetDataBuffer(sample_buffer); + if (!block) { + BOOST_LOG(error) << "VideoToolbox sample buffer has no data buffer"sv; + return false; + } + + char *data = nullptr; + size_t contiguous_length = 0; + size_t total_length = 0; + CMBlockBufferRef contiguous = nullptr; + auto status = CMBlockBufferGetDataPointer(block, 0, &contiguous_length, &total_length, &data); + if (status != kCMBlockBufferNoErr || contiguous_length < total_length) { + if (CMBlockBufferCreateContiguous(kCFAllocatorDefault, block, nullptr, nullptr, 0, 0, 0, &contiguous) != kCMBlockBufferNoErr) { + BOOST_LOG(error) << "VideoToolbox block buffer could not be made contiguous"sv; + return false; + } + status = CMBlockBufferGetDataPointer(contiguous, 0, &contiguous_length, &total_length, &data); + if (status != kCMBlockBufferNoErr || contiguous_length < total_length) { + CFRelease(contiguous); + BOOST_LOG(error) << "VideoToolbox contiguous block buffer access failed: "sv << status; + return false; + } + } + + bool ok = true; + size_t offset = 0; + while (offset + nal_length_size <= total_length) { + uint64_t nal_length = 0; + for (int i = 0; i < nal_length_size; ++i) { + nal_length = (nal_length << 8) | (uint8_t) data[offset + i]; + } + offset += nal_length_size; + if (!nal_length || nal_length > total_length - offset) { + ok = false; + break; + } + out.insert(out.end(), std::begin(start_code), std::end(start_code)); + out.insert(out.end(), data + offset, data + offset + nal_length); + offset += nal_length; + } + if (offset != total_length) { + ok = false; + } + if (!ok) { + BOOST_LOG(error) << "VideoToolbox produced a malformed AVCC bitstream"sv; + } + if (contiguous) { + CFRelease(contiguous); + } + if (ok) { + restore_out.disable(); + } + return ok; + } + + bool try_low_latency(CMVideoCodecType codec, bool arm64) { + return codec == kCMVideoCodecType_H264 || arm64; + } + + CFStringRef h264_entropy_mode(int coder) { + switch (coder) { + case 1: + return kVTH264EntropyMode_CABAC; + case 2: + return kVTH264EntropyMode_CAVLC; + default: + return nullptr; + } + } + + int expected_frame_rate(CMVideoCodecType codec, int width, int height, int framerate) { + if (codec != kCMVideoCodecType_H264 || width <= 0 || height <= 0) { + return framerate; + } + + // H.264 level 5.2 MaxMBPS (macroblocks per second), Table A-1 + constexpr std::int64_t max_macroblocks_per_second = 2073600; + const std::int64_t macroblocks_per_frame = static_cast((width + 15) / 16) * ((height + 15) / 16); + const auto level_limit = static_cast(std::max(1, max_macroblocks_per_second / macroblocks_per_frame)); + return std::min(framerate, level_limit); + } + + std::unique_ptr make_encode_device(pix_fmt_e pix_fmt, resolution_fn_t resolution_fn, const pixel_format_fn_t &pixel_format_fn) { + if (pix_fmt != pix_fmt_e::nv12 && pix_fmt != pix_fmt_e::p010) { + BOOST_LOG(error) << "Unsupported pixel format for the VideoToolbox encoder"sv; + return nullptr; + } + + auto device = std::make_unique<::vt_encode_device>(); + if (device->init(pix_fmt, std::move(resolution_fn), pixel_format_fn)) { + return nullptr; + } + return device; + } +} // namespace platf::vt diff --git a/src/platform/virtualhid_input.cpp b/src/platform/virtualhid_input.cpp index c9a50f91477..4c212a1dc62 100644 --- a/src/platform/virtualhid_input.cpp +++ b/src/platform/virtualhid_input.cpp @@ -18,6 +18,9 @@ #include #include +// lib includes +#include + // local includes #include "src/config.h" #include "src/logging.h" @@ -107,6 +110,15 @@ namespace platf::virtualhid { } } + /** + * @brief Scope a libvirtualhid profile name to the target seat. + * + * @param profile Profile whose advertised device name is updated. + */ + void apply_target_seat(lvh::DeviceProfile &profile) { + profile.name = device_name_for_seat(profile.name, target_seat()); + } + /** * @brief Compare two pointer viewports. * @@ -371,6 +383,7 @@ namespace platf::virtualhid { .offset_y = touch_port.offset_y, .width = touch_port.width, .height = touch_port.height, + .output_name = touch_port.output_name, }; } @@ -536,6 +549,7 @@ namespace platf::virtualhid { lvh::CreateKeyboardOptions options; options.profile = lvh::profiles::keyboard(); + apply_target_seat(options.profile); options.stable_id = "sunshine-keyboard"; auto created = runtime->create_keyboard(options); if (created) { @@ -559,6 +573,7 @@ namespace platf::virtualhid { lvh::CreateMouseOptions options; options.profile = lvh::profiles::mouse(); + apply_target_seat(options.profile); options.stable_id = "sunshine-mouse"; options.desktop = desktop; options.viewport = viewport; @@ -589,6 +604,7 @@ namespace platf::virtualhid { if (capabilities.supports_touchscreen) { lvh::CreateTouchscreenOptions options; options.profile = lvh::profiles::touchscreen(); + apply_target_seat(options.profile); options.stable_id = "sunshine-touchscreen"; auto created = global->runtime->create_touchscreen(options); if (created) { @@ -600,6 +616,7 @@ namespace platf::virtualhid { if (capabilities.supports_pen_tablet) { lvh::CreatePenTabletOptions options; options.profile = lvh::profiles::pen_tablet(); + apply_target_seat(options.profile); options.stable_id = "sunshine-pen-tablet"; auto created = global->runtime->create_pen_tablet(options); if (created) { @@ -705,6 +722,7 @@ namespace platf::virtualhid { const auto &selection = profile_for_metadata(metadata); auto profile = selection.profile(); profile.name = std::format("Sunshine {}", profile.name); + apply_target_seat(profile); if (config::input.gamepad != "auto"sv) { BOOST_LOG(info) << "Gamepad "sv << id.globalIndex << " will be "sv << profile.name << " (manual selection)"sv; } else { @@ -1099,6 +1117,18 @@ namespace platf::virtualhid { return support.supports_touchpad || support.supports_motion; } + std::string target_seat() { + return lizardbyte::common::get_env("XDG_SEAT"); + } + + std::string device_name_for_seat(std::string_view base_name, std::string_view seat) { + if (seat.empty() || seat == "seat0"sv) { + return std::string {base_name}; + } + + return std::format("{} ({})", base_name, seat); + } + } // namespace platf::virtualhid namespace platf { diff --git a/src/platform/virtualhid_input.h b/src/platform/virtualhid_input.h index 47431963bae..b0e0658da0c 100644 --- a/src/platform/virtualhid_input.h +++ b/src/platform/virtualhid_input.h @@ -356,4 +356,20 @@ namespace platf::virtualhid { */ bool configured_gamepad_supports_controller_extensions(); + /** + * @brief Determine the logind seat targeted by this Sunshine instance. + * + * @return Value of `XDG_SEAT`, or an empty string when it is unset. + */ + std::string target_seat(); + + /** + * @brief Append a seat suffix to a virtual device name for multi-seat udev rules. + * + * @param base_name Device name advertised by the libvirtualhid profile. + * @param seat Target logind seat. + * @return `base_name` unchanged for an empty seat or `seat0`, otherwise `" ()"`. + */ + std::string device_name_for_seat(std::string_view base_name, std::string_view seat); + } // namespace platf::virtualhid diff --git a/src/platform/windows/display.h b/src/platform/windows/display.h index 814d5f82889..d35871dbd7b 100644 --- a/src/platform/windows/display.h +++ b/src/platform/windows/display.h @@ -236,6 +236,18 @@ namespace platf::dxgi { bool visible; ///< Whether the cursor is visible. }; + /** + * @brief Copy a mapped desktop texture into a RAM image in desktop orientation. + * + * Source and destination row padding are independent. Quarter turns exchange the source dimensions; + * the destination dimensions must already describe the rotated desktop. + * + * @param source Mapped texture containing the unrotated pixels. + * @param destination Allocated image in desktop coordinates. + * @param rotation Clockwise rotation from the source surface to the desktop image. + */ + void copy_mapped_image(const D3D11_MAPPED_SUBRESOURCE &source, ::platf::img_t &destination, DXGI_MODE_ROTATION rotation); + /** * @brief GPU resources used to render a captured cursor shape. */ @@ -549,11 +561,11 @@ namespace platf::dxgi { */ int dummy_img(img_t *img) override; /** - * @brief Finish cursor composition into a GPU-backed image. + * @brief Allocate a tightly packed RAM image in desktop orientation. * * @param img Image or frame object to read from or populate. - * @param dummy Unused placeholder required by the interface signature. - * @return Capture status after finalizing the captured image. + * @param dummy Whether to allow an unknown capture format for a fallback image. + * @return 0 on success, or -1 if a real frame's capture format is unknown. */ int complete_img(img_t *img, bool dummy) override; /** diff --git a/src/platform/windows/display_base.cpp b/src/platform/windows/display_base.cpp index 60aebfe1468..99f662f2827 100644 --- a/src/platform/windows/display_base.cpp +++ b/src/platform/windows/display_base.cpp @@ -15,7 +15,7 @@ // local includes required before library includes // Boost.Process must be included before MinHook pulls in Windows.h so Boost.Asio sees WinSock2.h first. -#include "src/boost_process_compat.h" +#include "src/compat/boost_process.h" // lib includes #include diff --git a/src/platform/windows/display_ram.cpp b/src/platform/windows/display_ram.cpp index 947346806ba..a6dd3903b88 100644 --- a/src/platform/windows/display_ram.cpp +++ b/src/platform/windows/display_ram.cpp @@ -2,6 +2,9 @@ * @file src/platform/windows/display_ram.cpp * @brief Definitions for handling ram. */ +// standard includes +#include + // local includes #include "display.h" #include "misc.h" @@ -25,6 +28,39 @@ namespace platf::dxgi { } }; + void copy_mapped_image(const D3D11_MAPPED_SUBRESOURCE &source, ::platf::img_t &destination, DXGI_MODE_ROTATION rotation) { + const auto source_data = static_cast(source.pData); + const auto source_pitch = static_cast(source.RowPitch); + const auto pixel_pitch = destination.pixel_pitch; + + for (int y = 0; y < destination.height; ++y) { + auto destination_row = destination.data + y * destination.row_pitch; + const std::uint8_t *source_row; + std::ptrdiff_t source_step; + switch (rotation) { + case DXGI_MODE_ROTATION_ROTATE90: + source_row = source_data + (destination.width - 1) * source_pitch + y * pixel_pitch; + source_step = -source_pitch; + break; + case DXGI_MODE_ROTATION_ROTATE180: + source_row = source_data + (destination.height - 1 - y) * source_pitch + (destination.width - 1) * pixel_pitch; + source_step = -pixel_pitch; + break; + case DXGI_MODE_ROTATION_ROTATE270: + source_row = source_data + (destination.height - 1 - y) * pixel_pitch; + source_step = source_pitch; + break; + default: + std::copy_n(source_data + y * source_pitch, destination.width * pixel_pitch, destination_row); + continue; + } + + for (int x = 0; x < destination.width; ++x) { + std::copy_n(source_row + x * source_step, pixel_pitch, destination_row + x * pixel_pitch); + } + } + } + /** * @brief Blend a monochrome cursor shape into a RAM frame. * @@ -270,8 +306,8 @@ namespace platf::dxgi { BOOST_LOG(info) << "Capture format ["sv << dxgi_format_to_string(capture_format) << ']'; D3D11_TEXTURE2D_DESC t {}; - t.Width = width; - t.Height = height; + t.Width = width_before_rotation; + t.Height = height_before_rotation; t.MipLevels = 1; t.ArraySize = 1; t.SampleDesc.Count = 1; @@ -289,8 +325,8 @@ namespace platf::dxgi { // It's possible for our display enumeration to race with mode changes and result in // mismatched image pool and desktop texture sizes. If this happens, just reinit again. - if (desc.Width != width || desc.Height != height) { - BOOST_LOG(info) << "Capture size changed ["sv << width << 'x' << height << " -> "sv << desc.Width << 'x' << desc.Height << ']'; + if (desc.Width != width_before_rotation || desc.Height != height_before_rotation) { + BOOST_LOG(info) << "Capture size changed ["sv << width_before_rotation << 'x' << height_before_rotation << " -> "sv << desc.Width << 'x' << desc.Height << ']'; return capture_e::reinit; } @@ -334,7 +370,8 @@ namespace platf::dxgi { return capture_e::capture_error; } - std::copy_n((std::uint8_t *) img_info.pData, height * img_info.RowPitch, (std::uint8_t *) img->data); + // Rotate before cursor composition so both pixels and pointer use desktop coordinates. + copy_mapped_image(img_info, *img, display_rotation); // Unmap the staging texture to allow GPU access again device_ctx->Unmap(texture.get(), 0); @@ -375,15 +412,11 @@ namespace platf::dxgi { img->pixel_pitch = get_pixel_pitch(); - if (dummy && !img->row_pitch) { - // Assume our dummy image will have no padding - img->row_pitch = img->pixel_pitch * img->width; - } - - // Reallocate the image buffer if the pitch changes - if (!dummy && img->row_pitch != img_info.RowPitch) { - img->row_pitch = img_info.RowPitch; - delete img->data; + // The mapped texture may have different dimensions and padding before rotation. + const auto row_pitch = img->pixel_pitch * img->width; + if (img->row_pitch != row_pitch) { + img->row_pitch = row_pitch; + delete[] img->data; img->data = nullptr; } diff --git a/src/platform/windows/display_wgc.cpp b/src/platform/windows/display_wgc.cpp index 26fcb3b5487..ef16b39154d 100644 --- a/src/platform/windows/display_wgc.cpp +++ b/src/platform/windows/display_wgc.cpp @@ -336,7 +336,8 @@ namespace platf::dxgi { return capture_e::capture_error; } - std::copy_n((std::uint8_t *) img_info.pData, height * img_info.RowPitch, (std::uint8_t *) img->data); + // WGC already supplies pixels in desktop orientation. + copy_mapped_image(img_info, *img, DXGI_MODE_ROTATION_IDENTITY); // Unmap the staging texture to allow GPU access again device_ctx->Unmap(texture.get(), 0); diff --git a/src/platform/windows/misc.cpp b/src/platform/windows/misc.cpp index 36be737b162..95848029ce1 100644 --- a/src/platform/windows/misc.cpp +++ b/src/platform/windows/misc.cpp @@ -31,7 +31,7 @@ #include // local includes required before platform includes -#include "src/boost_process_compat.h" +#include "src/compat/boost_process.h" // platform includes // prevent clang format from "optimizing" the header include order diff --git a/src/platform/windows/session_input.cpp b/src/platform/windows/session_input.cpp index c79d5b24482..fc669bd0eed 100644 --- a/src/platform/windows/session_input.cpp +++ b/src/platform/windows/session_input.cpp @@ -20,12 +20,14 @@ // platform includes #include +// lib includes +#include + // local includes #include "misc.h" #include "session_input.h" #include "src/config.h" #include "src/logging.h" -#include "third-party/libvirtualhid/src/platform/windows/keylayout.hpp" using namespace std::literals; diff --git a/src/platform/windows/windows.rc b/src/platform/windows/windows.rc index 417fcf0d047..ba1289da7e1 100644 --- a/src/platform/windows/windows.rc +++ b/src/platform/windows/windows.rc @@ -24,7 +24,7 @@ BEGIN VALUE "InternalName", TOSTRING(PROJECT_NAME) VALUE "ProductName", TOSTRING(PROJECT_NAME) VALUE "ProductVersion", TOSTRING(PROJECT_VERSION) - VALUE "LegalCopyright", "https://raw.githubusercontent.com/LizardByte/Sunshine/master/LICENSE" + VALUE "LegalCopyright", "https://raw.githubusercontent.com/SunshineStream/Sunshine/master/LICENSE" END END diff --git a/src/process.h b/src/process.h index 132178be709..774b0bacd26 100644 --- a/src/process.h +++ b/src/process.h @@ -20,7 +20,7 @@ #include "config.h" #include "platform/common.h" #include "rtsp.h" -#include "src/boost_process_compat.h" +#include "src/compat/boost_process.h" #include "utility.h" /** diff --git a/src/rtsp.cpp b/src/rtsp.cpp index 1255b023b04..c3e6b37c5df 100644 --- a/src/rtsp.cpp +++ b/src/rtsp.cpp @@ -4,8 +4,9 @@ */ #define BOOST_BIND_GLOBAL_PLACEHOLDERS +#include "compat/moonlight.h" + extern "C" { -#include #include } @@ -27,6 +28,7 @@ extern "C" { #include "input.h" #include "logging.h" #include "network.h" +#include "nvhttp.h" #include "rtsp.h" #include "stream.h" #include "sync.h" @@ -40,6 +42,23 @@ using asio::ip::udp; using namespace std::literals; namespace rtsp_stream { + std::string describe_video_codecs(uint32_t codec_modes) { + std::string result; + if (codec_modes & SCM_MASK_HEVC) { + result += "sprop-parameter-sets=AAAAAU\r\n"; + } + if (codec_modes & SCM_MASK_AV1) { + result += "a=rtpmap:98 AV1/90000\r\n"; + } + if (codec_modes & SCM_MPEG2) { + result += "a=rtpmap:98 MPV/90000\r\n"; + } + if (codec_modes & SCM_H263P) { + result += "a=rtpmap:98 H263-1998/90000\r\n"; + } + return result; + } + /** * @brief Release msg resources. * @@ -901,13 +920,7 @@ namespace rtsp_stream { ss << "a=x-nv-video[0].refPicInvalidation:1"sv << std::endl; } - if (video::active_hevc_mode != 1) { - ss << "sprop-parameter-sets=AAAAAU"sv << std::endl; - } - - if (video::active_av1_mode != 1) { - ss << "a=rtpmap:98 AV1/90000"sv << std::endl; - } + ss << describe_video_codecs(nvhttp::get_codec_mode_flags()); if (!session.surround_params.empty()) { // If we have our own surround parameters, advertise them twice first @@ -1133,6 +1146,10 @@ namespace rtsp_stream { config.monitor.height = (int) util::from_view(args.at("x-nv-video[0].clientViewportHt"sv)); config.monitor.width = (int) util::from_view(args.at("x-nv-video[0].clientViewportWd"sv)); + + // Optionally cap the encode resolution below what the client requested: encoder latency + // scales with pixel count, and the capture backend already scales to the encode resolution. + config::cap_stream_resolution(config.monitor.width, config.monitor.height); config.monitor.framerate = (int) util::from_view(args.at("x-nv-video[0].maxFPS"sv)); config.monitor.framerateX100 = (int) util::from_view(args.at("x-nv-video[0].clientRefreshRateX100"sv)); // Validate framerateX100 against framerate. Some clients (e.g. Moonlight Android) send the @@ -1225,20 +1242,40 @@ namespace rtsp_stream { config.monitor.bitrate = (int) configuredBitrateKbps; } - if (config.monitor.videoFormat == 1 && video::active_hevc_mode == 1) { + if (config.monitor.videoFormat == video::format_hevc && video::active_hevc_mode == 1) { BOOST_LOG(warning) << "HEVC is disabled, yet the client requested HEVC"sv; respond(sock, session, &option, 400, "BAD REQUEST", req->sequenceNumber, {}); return; } - if (config.monitor.videoFormat == 2 && video::active_av1_mode == 1) { + if (config.monitor.videoFormat == video::format_av1 && video::active_av1_mode == 1) { BOOST_LOG(warning) << "AV1 is disabled, yet the client requested AV1"sv; respond(sock, session, &option, 400, "BAD REQUEST", req->sequenceNumber, {}); return; } + if (config.monitor.videoFormat == video::format_mpeg2 && video::probed_codec_modes().mpeg2 < 2) { + BOOST_LOG(warning) << "MPEG-2 is disabled, yet the client requested MPEG-2"sv; + + respond(sock, session, &option, 400, "BAD REQUEST", req->sequenceNumber, {}); + return; + } + + if (config.monitor.videoFormat == video::format_h263p && video::probed_codec_modes().h263p != 2) { + BOOST_LOG(warning) << "H.263+ is disabled, yet the client requested H.263+"sv; + + respond(sock, session, &option, 400, "BAD REQUEST", req->sequenceNumber, {}); + return; + } + + if (config.monitor.videoFormat == video::format_h263p && (config.monitor.width <= 0 || config.monitor.height <= 0 || config.monitor.width % 4 != 0 || config.monitor.height % 4 != 0)) { + BOOST_LOG(warning) << "H.263+ requires a positive width and height divisible by four"sv; + respond(sock, session, &option, 400, "BAD REQUEST", req->sequenceNumber, {}); + return; + } + // Check that any required encryption is enabled auto encryption_mode = net::encryption_mode_for_address(sock.remote_endpoint().address()); if (encryption_mode == config::ENCRYPTION_MODE_MANDATORY && (config.encryptionFlagsEnabled & (SS_ENC_VIDEO | SS_ENC_AUDIO)) != (SS_ENC_VIDEO | SS_ENC_AUDIO)) { diff --git a/src/rtsp.h b/src/rtsp.h index 108c881e200..bfbd7be6975 100644 --- a/src/rtsp.h +++ b/src/rtsp.h @@ -9,12 +9,21 @@ #include #include #include +#include // local includes #include "crypto.h" #include "thread_safe.h" namespace rtsp_stream { + /** + * @brief Describe the codecs advertised by a host, independently of client identity. + * + * @param codec_modes Validated ServerCodecModeSupport capability bits. + * @return GameStream DESCRIBE codec attributes; these do not change RTP packetization. + */ + std::string describe_video_codecs(uint32_t codec_modes); + constexpr auto RTSP_SETUP_PORT = 21; ///< GameStream base-port offset used for the RTSP setup listener. #pragma pack(push, 1) diff --git a/src/stream.cpp b/src/stream.cpp index ab9125dc90b..a222b4045e2 100644 --- a/src/stream.cpp +++ b/src/stream.cpp @@ -17,11 +17,8 @@ #include #include -extern "C" { - // clang-format off -#include - // clang-format on -} +// Keep this separate so clang-format preserves the include order. +#include "compat/moonlight.h" // local includes #include "config.h" @@ -2227,7 +2224,7 @@ namespace stream { // Enable local prioritization and QoS tagging on video traffic if requested by the client auto address = session->video.peer.address(); - session->video.qos = platf::enable_socket_qos(ref->video_sock.native_handle(), address, session->video.peer.port(), platf::qos_data_type_e::video, session->config.videoQosType != 0); + session->video.qos = platf::enable_socket_qos(ref->video_sock.native_handle(), address, session->video.peer.port(), platf::qos_data_type_e::video, config::stream.dscp_tagging && session->config.videoQosType != 0); BOOST_LOG(debug) << "Start capturing Video"sv; video::capture(session->mail, session->config.monitor, session); @@ -2254,7 +2251,7 @@ namespace stream { // Enable local prioritization and QoS tagging on audio traffic if requested by the client auto address = session->audio.peer.address(); - session->audio.qos = platf::enable_socket_qos(ref->audio_sock.native_handle(), address, session->audio.peer.port(), platf::qos_data_type_e::audio, session->config.audioQosType != 0); + session->audio.qos = platf::enable_socket_qos(ref->audio_sock.native_handle(), address, session->audio.peer.port(), platf::qos_data_type_e::audio, config::stream.dscp_tagging && session->config.audioQosType != 0); BOOST_LOG(debug) << "Start capturing Audio"sv; audio::capture(session->mail, session->config.audio, session); diff --git a/src/thread_safe.h b/src/thread_safe.h index 80093ee89f8..b0a8df12593 100644 --- a/src/thread_safe.h +++ b/src/thread_safe.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -699,14 +700,15 @@ namespace safe { /** * @brief Return a shared reference to the protected object. * - * @return Reference handle that keeps the protected object alive. + * @return Reference handle that keeps the protected object alive, or an empty handle after failed initialization. */ [[nodiscard]] ptr_t ref() { std::lock_guard lg {_lock}; if (!_count) { - new (_object_buf.data()) element_type; - if (_construct(*reinterpret_cast(_object_buf.data())) != 0) { + auto *object = new (_object_buf.data()) element_type; + if (_construct(*object) != 0) { + std::destroy_at(object); return ptr_t {nullptr}; } } @@ -722,7 +724,7 @@ namespace safe { std::array _object_buf; - std::uint32_t _count; + std::uint32_t _count = 0; ///< Number of active references, including dynamically allocated storage. std::mutex _lock; }; diff --git a/src/video.cpp b/src/video.cpp index c77067dc896..cac08c264ab 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -35,6 +36,7 @@ extern "C" { #include "platform/common.h" #include "sync.h" #include "video.h" +#include "video_capture_groups.h" #ifdef _WIN32 extern "C" { @@ -46,34 +48,44 @@ using namespace std::literals; namespace video { - namespace { - /** - * @brief Check if we can allow probing for the encoders. - * @return True if there should be no issues with the probing, false if we should prevent it. - */ - bool allow_encoder_probing() { - const auto devices {display_device::enumerate_devices()}; + bool allow_encoder_probing(const std::vector &devices) { + // If there are no devices, then either the API is not working correctly or OS does not support the lib. + // Either way we should not block the probing in this case as we can't tell what's wrong. + if (devices.empty()) { + return true; + } - // If there are no devices, then either the API is not working correctly or OS does not support the lib. - // Either way we should not block the probing in this case as we can't tell what's wrong. - if (devices.empty()) { - return true; - } +#ifdef _WIN32 + // Since Windows 11 24H2, it is possible that there will be no active devices present + // for some reason (probably a bug). Trying to probe encoders in such a state locks/breaks the DXGI + // and also the display device for Windows. So we must have at least 1 active device. + const bool at_least_one_device_is_active = std::ranges::any_of(devices, [](const auto &device) { + // If device has additional info, it is active. + return static_cast(device.m_info); + }); - // Since Windows 11 24H2, it is possible that there will be no active devices present - // for some reason (probably a bug). Trying to probe encoders in such a state locks/breaks the DXGI - // and also the display device for Windows. So we must have at least 1 active device. - const bool at_least_one_device_is_active = std::any_of(std::begin(devices), std::end(devices), [](const auto &device) { - // If device has additional info, it is active. - return static_cast(device.m_info); - }); + if (at_least_one_device_is_active) { + return true; + } - if (at_least_one_device_is_active) { - return true; - } + BOOST_LOG(error) << "No display devices are active at the moment! Cannot probe the encoders."; + return false; +#else + // A sleeping display enumerates as inactive on other platforms, and the wake-up call + // lives in platf::display(), which probing must reach for the display to ever wake. + return true; +#endif + } - BOOST_LOG(error) << "No display devices are active at the moment! Cannot probe the encoders."; - return false; + namespace { + /** + * @brief Identify the legacy video formats supported for compatibility clients. + * + * @param video_format Requested GameStream video codec identifier. + * @return Whether the format is MPEG-2 or H.263+. + */ + bool is_legacy_video_format(int video_format) { + return video_format == format_mpeg2 || video_format == format_h263p; } } // namespace @@ -207,13 +219,6 @@ namespace video { * @return Hardware buffer on success, or an error code on failure. */ util::Either cuda_init_avcodec_hardware_input_buffer(platf::avcodec_encode_device_t *); - /** - * @brief Create an FFmpeg hardware device buffer for VideoToolbox input. - * - * @param encode_device Encode device. - * @return Hardware buffer on success, or an error code on failure. - */ - util::Either vt_init_avcodec_hardware_input_buffer(platf::avcodec_encode_device_t *); /** * @brief Create an FFmpeg hardware device buffer for Vulkan input. * @@ -476,6 +481,7 @@ namespace video { replacements = std::move(other.replacements); sps = std::move(other.sps); vps = std::move(other.vps); + frame_timestamps = std::move(other.frame_timestamps); inject = other.inject; @@ -538,6 +544,8 @@ namespace video { // inject sps/vps data into idr pictures int inject; ///< Number of upcoming IDR frames that should receive rewritten parameter sets. + + frame_timestamp_queue_t frame_timestamps; ///< Capture timestamps of in-flight frames keyed by pts, awaiting their encoded packets. }; /** @@ -618,6 +626,79 @@ namespace video { bool force_idr = false; }; + /** + * @brief Native VideoToolbox encode session and device state for hardware encoding. + */ + class vt_encode_session_t: public encode_session_t { + public: + /** + * @brief Initialize a VideoToolbox encode session and take ownership of its device. + * + * @param encode_device Encode device. + */ + vt_encode_session_t(std::unique_ptr encode_device): + device(std::move(encode_device)) { + } + + /** + * @brief Supply the next captured image to the encode device. + * + * @param img Image or frame object to read from or populate. + * @return Conversion status. + */ + int convert(platf::img_t &img) override { + if (!device) { + return -1; + } + return device->convert(img); + } + + /** + * @brief Mark the frame as a request for an IDR frame. + */ + void request_idr_frame() override { + force_idr = true; + } + + /** + * @brief Mark the frame as a request for a normal inter frame. + */ + void request_normal_frame() override { + force_idr = false; + } + + /** + * @brief Mark the frame range whose references must be invalidated. + * @note VideoToolbox has no reference frame invalidation; recover with an IDR frame instead. + * + * @param first_frame First frame. + * @param last_frame Last frame. + */ + void invalidate_ref_frames(int64_t first_frame, int64_t last_frame) override { + force_idr = true; + } + + /** + * @brief Submit the next frame to VideoToolbox and return the encoded payload. + * + * @param frame_index Monotonic frame index assigned by the video pipeline. + * @return Encoded frame payload and frame metadata. + */ + platf::vt_encoded_frame encode_frame(uint64_t frame_index) { + if (!device) { + return {}; + } + + auto result = device->encode_frame(frame_index, force_idr); + force_idr = false; + return result; + } + + private: + std::unique_ptr device; + bool force_idr = false; + }; + /** * @brief Context object used while synchronizing encode sessions. */ @@ -630,6 +711,7 @@ namespace video { safe::mail_raw_t::event_t touch_port_events; ///< Event carrying updated touch viewport metadata. config_t config; ///< Stream or encoder configuration captured for the worker. + const encoder_t *encoder_p; ///< Encoder selected for this stream's video format. int frame_nr; ///< Next capture-frame number assigned to encoded packets. stream::session_t *channel_data; ///< Stream session forwarded to packet senders. }; @@ -657,6 +739,7 @@ namespace video { struct capture_ctx_t { img_event_t images; ///< Queue of captured images waiting for encode. config_t config; ///< Stream or encoder configuration captured for the worker. + const encoder_t *encoder_p; ///< Encoder selected for this stream's video format. }; /** @@ -667,7 +750,6 @@ namespace video { std::jthread capture_thread; ///< Capture thread. safe::signal_t reinit_event; ///< Reinit event. - const encoder_t *encoder_p; ///< Encoder p. sync_util::sync_t> display_wp; ///< Display wp. }; @@ -676,21 +758,11 @@ namespace video { */ struct capture_thread_sync_ctx_t { encode_session_ctx_queue_t encode_session_ctx_queue {30}; ///< Encode session ctx queue. + std::jthread capture_thread; ///< Worker owned by this encoder's capture group. }; - /** - * @brief Start the synchronous multi-client capture thread. - * - * @param ctx Unused state required by the shared capture lifetime callback signature. - * @return 0 when the capture thread is started. - */ - int start_capture_sync(capture_thread_sync_ctx_t &ctx); - /** - * @brief Leave synchronous capture cleanup to the capture thread. - * - * @param ctx Unused state required by the shared capture lifetime callback signature. - */ - void end_capture_sync(capture_thread_sync_ctx_t &ctx); + int start_capture_sync(capture_thread_sync_ctx_t &context); + void end_capture_sync(capture_thread_sync_ctx_t &context); /** * @brief Start the asynchronous capture thread. * @@ -705,9 +777,45 @@ namespace video { */ void end_capture_async(capture_thread_async_ctx_t &ctx); - // Keep a reference counter to ensure the capture thread only runs when other threads have a reference to the capture thread - auto capture_thread_async = safe::make_shared(start_capture_async, end_capture_async); ///< Capture thread async. - auto capture_thread_sync = safe::make_shared(start_capture_sync, end_capture_sync); ///< Capture thread sync. + namespace { + /** + * @brief Access the monitor switch requests shared by the capture workers. + * + * @return Monitor switch state for active capture groups. + */ + display_switch_state_t &capture_display_switches() { + static display_switch_state_t switches; + return switches; + } + + /** + * @brief Access the pool whose references keep each encoder's capture worker alive. + * + * @tparam Context Capture worker context. + * @tparam Start Callback starting one worker. + * @tparam Stop Callback stopping one worker. + * @return Pool of capture workers for the specified context type. + */ + template + capture_group_pool_t &capture_groups() { + auto &switches = capture_display_switches(); + static capture_group_pool_t groups { + [&switches](Context &context) { + switches.start_worker(); + const auto status = Start(context); + if (status != 0) { + switches.stop_worker(); + } + return status; + }, + [&switches](Context &context) { + Stop(context); + switches.stop_worker(); + }, + }; + return groups; + } + } // namespace #ifdef _WIN32 /** @@ -752,6 +860,8 @@ namespace video { "h264_nvenc"s, {}, // capabilities }, + {}, // MPEG-2 + {}, // H.263+ PARALLEL_ENCODING | REF_FRAMES_INVALIDATION | YUV444_SUPPORT | ASYNC_TEARDOWN // flags }; #elif !defined(__APPLE__) @@ -854,6 +964,8 @@ namespace video { "h264_nvenc"s, {}, // capabilities }, + {}, // MPEG-2 + {}, // H.263+ PARALLEL_ENCODING | YUV444_SUPPORT }; #endif @@ -970,6 +1082,27 @@ namespace video { "h264_qsv"s, {}, // capabilities }, + { + // Common options + { + {"preset"s, &config::video.qsv.qsv_preset}, + {"forced_idr"s, 1}, + {"async_depth"s, 1}, + {"low_delay_brc"s, 1}, + {"low_power"s, 1}, + }, + {}, // SDR-specific options + {}, // HDR-specific options + {}, // YUV444 SDR-specific options + {}, // YUV444 HDR-specific options + { + // Fallback options + {"low_power"s, 0}, + }, + "mpeg2_qsv"s, + {}, // capabilities + }, + {}, // H.263+ PARALLEL_ENCODING | CBR_WITH_VBR | RELAXED_COMPLIANCE | NO_RC_BUF_LIMIT | YUV444_SUPPORT }; @@ -1084,6 +1217,8 @@ namespace video { "h264_amf"s, {}, // capabilities }, + {}, // MPEG-2 + {}, // H.263+ PARALLEL_ENCODING }; @@ -1147,6 +1282,8 @@ namespace video { "h264_mf"s, {}, // capabilities }, + {}, // MPEG-2 + {}, // H.263+ PARALLEL_ENCODING | FIXED_GOP_SIZE // MF encoder doesn't support on-demand IDR frames }; #endif @@ -1224,6 +1361,32 @@ namespace video { "libx264"s, {}, // capabilities }, + { + { + // Required when AV_CODEC_FLAG_CLOSED_GOP is set. + {"sc_threshold"s, 1000000000}, + }, + {}, // SDR-specific options + {}, // HDR-specific options + {}, // YUV444 SDR-specific options + {}, // YUV444 HDR-specific options + {}, // Fallback options + "mpeg2video"s, + {}, // capabilities + }, + { + { + // Required when AV_CODEC_FLAG_CLOSED_GOP is set. + {"sc_threshold"s, 1000000000}, + }, + {}, // SDR-specific options + {}, // HDR-specific options + {}, // YUV444 SDR-specific options + {}, // YUV444 HDR-specific options + {}, // Fallback options + "h263p"s, + {}, // capabilities + }, H264_ONLY | PARALLEL_ENCODING | ALWAYS_REPROBE | YUV444_SUPPORT }; @@ -1290,6 +1453,20 @@ namespace video { "h264_vaapi"s, {}, // capabilities }, + encoder_t::codec_t { + .common_options = { + {"async_depth"s, 1}, + {"idr_interval"s, std::numeric_limits::max()}, + }, + .sdr_options = {}, + .hdr_options = {}, + .sdr444_options = {}, + .hdr444_options = {}, + .fallback_options = {}, + .name = "mpeg2_vaapi"s, + .capabilities = {}, + }, + {}, // H.263+ // RC buffer size will be set in platform code if supported LIMITED_GOP_SIZE | PARALLEL_ENCODING | NO_RC_BUF_LIMIT }; @@ -1364,6 +1541,8 @@ namespace video { "h264_vulkan"s, {}, // capabilities }, + {}, // MPEG-2 + {}, // H.263+ LIMITED_GOP_SIZE | PARALLEL_ENCODING }; #endif // SUNSHINE_BUILD_VULKAN @@ -1371,78 +1550,52 @@ namespace video { #ifdef __APPLE__ /** - * @brief Videotoolbox. + * @brief VideoToolbox, driven directly through VTCompressionSession. */ encoder_t videotoolbox { "videotoolbox"sv, - std::make_unique( - AV_HWDEVICE_TYPE_VIDEOTOOLBOX, - AV_HWDEVICE_TYPE_NONE, - AV_PIX_FMT_VIDEOTOOLBOX, - AV_PIX_FMT_NV12, - AV_PIX_FMT_P010, - AV_PIX_FMT_NONE, - AV_PIX_FMT_NONE, - vt_init_avcodec_hardware_input_buffer + std::make_unique( + platf::mem_type_e::videotoolbox, + platf::pix_fmt_e::nv12, + platf::pix_fmt_e::p010, + platf::pix_fmt_e::unknown, + platf::pix_fmt_e::unknown ), { // Common options - { - {"allow_sw"s, &config::video.vt.vt_allow_sw}, - {"require_sw"s, &config::video.vt.vt_require_sw}, - {"realtime"s, &config::video.vt.vt_realtime}, - {"prio_speed"s, 1}, - {"max_ref_frames"s, 1}, - }, + {}, {}, // SDR-specific options {}, // HDR-specific options {}, // YUV444 SDR-specific options {}, // YUV444 HDR-specific options {}, // Fallback options - "av1_videotoolbox"s, + "av1_vt"s, {}, // capabilities }, { // Common options - { - {"allow_sw"s, &config::video.vt.vt_allow_sw}, - {"require_sw"s, &config::video.vt.vt_require_sw}, - {"realtime"s, &config::video.vt.vt_realtime}, - {"prio_speed"s, 1}, - {"max_ref_frames"s, 1}, - }, + {}, {}, // SDR-specific options {}, // HDR-specific options {}, // YUV444 SDR-specific options {}, // YUV444 HDR-specific options {}, // Fallback options - "hevc_videotoolbox"s, + "hevc_vt"s, {}, // capabilities }, { // Common options - // Note: max_ref_frames is intentionally omitted for H.264 because - // VideoToolbox on Apple Silicon produces all-IDR output when - // ReferenceBufferCount=1 is set for H.264, causing massive bandwidth - // inflation (~3x) and frame drops. HEVC and AV1 are unaffected and - // retain max_ref_frames=1. See LizardByte/Sunshine#5013. - { - {"allow_sw"s, &config::video.vt.vt_allow_sw}, - {"require_sw"s, &config::video.vt.vt_require_sw}, - {"realtime"s, &config::video.vt.vt_realtime}, - {"prio_speed"s, 1}, - }, + {}, {}, // SDR-specific options {}, // HDR-specific options {}, // YUV444 SDR-specific options {}, // YUV444 HDR-specific options - { - // Fallback options - {"flags"s, "-low_delay"}, - }, - "h264_videotoolbox"s, + {}, // Fallback options + "h264_vt"s, {}, // capabilities }, + {}, // MPEG-2 + {}, // H.263+ PARALLEL_ENCODING }; #endif @@ -1469,6 +1622,31 @@ namespace video { }; static encoder_t *chosen_encoder; + + namespace { + /** + * @brief Track the selected backend and advertised modes from encoder probing. + */ + struct encoder_probe_state_t { + std::array encoders_by_format {}; ///< Backend selected for each wire codec. + probed_codec_modes_t modes; ///< Baseline and legacy codec modes from the probe. + }; + + /** + * @brief Access the state refreshed by encoder probing. + * + * @return Selected encoder backends and codec modes. + */ + encoder_probe_state_t &encoder_probe_state() { + static encoder_probe_state_t state; + return state; + } + } // namespace + + probed_codec_modes_t &probed_codec_modes() { + return encoder_probe_state().modes; + } + int active_hevc_mode; ///< HEVC mode selected by the most recent encoder probe. int active_av1_mode; ///< AV1 mode selected by the most recent encoder probe. bool last_encoder_probe_supported_ref_frames_invalidation = false; ///< Whether the last probe found reference-frame invalidation support. @@ -1476,6 +1654,43 @@ namespace video { std::array last_encoder_probe_supported_dynamic_range_for_codec = {}; ///< 10-bit 4:2:0 support discovered for each probed codec. std::array last_encoder_probe_supported_dynamic_range_yuv444_for_codec = {}; ///< 10-bit YUV444 support discovered for each probed codec. + /** + * @brief Check whether an encoder passed validation for a requested video format. + * + * @param encoder Encoder whose codec capabilities should be checked. + * @param video_format Requested GameStream video codec identifier. + * @return Whether the encoder supports the requested video format. + */ + bool encoder_supports_video_format(const encoder_t &encoder, int video_format) { + switch (video_format) { + case format_mpeg2: + return encoder.mpeg2[encoder_t::PASSED]; + case format_h263p: + return encoder.h263p[encoder_t::PASSED]; + case format_h264: + return encoder.h264[encoder_t::PASSED]; + case format_hevc: + return encoder.hevc[encoder_t::PASSED]; + case format_av1: + return encoder.av1[encoder_t::PASSED]; + default: + return false; + } + } + + /** + * @brief Select the encoder for a modern or legacy video stream. + * + * @param config Video configuration requested by the client. + * @return Selected encoder, or nullptr when encoder probing found no suitable backend. + */ + encoder_t *encoder_for_config(const config_t &config) { + if (config.videoFormat < 0 || config.videoFormat >= VIDEO_FORMAT_COUNT) { + return nullptr; + } + return encoder_probe_state().encoders_by_format[config.videoFormat]; + } + /** * @brief Recreate a display capture object after a capture failure. * @@ -1559,13 +1774,11 @@ namespace video { * @param capture_ctx_queue Capture context queue. * @param display_wp Weak pointer holder for the active display. * @param reinit_event Signal raised while the display is being reinitialized. - * @param encoder Selected encoder. */ void captureThread( std::shared_ptr> capture_ctx_queue, sync_util::sync_t> &display_wp, - safe::signal_t &reinit_event, - const encoder_t &encoder + safe::signal_t &reinit_event ) { std::vector capture_ctxs; @@ -1582,6 +1795,7 @@ namespace video { }); auto switch_display_event = mail::man->event(mail::switch_display); + std::uint64_t applied_display_generation = 0; // Wait for the initial capture context or a request to stop the queue auto initial_capture_ctx = capture_ctx_queue->pop(); @@ -1589,12 +1803,14 @@ namespace video { return; } capture_ctxs.emplace_back(std::move(*initial_capture_ctx)); + const auto &encoder = *capture_ctxs.front().encoder_p; // Get all the monitor names now, rather than at boot, to // get the most up-to-date list available monitors std::vector display_names; int display_p = -1; refresh_displays(encoder.platform_formats->dev_type, display_names, display_p); + capture_display_switches().poll(switch_display_event).apply(display_p, display_names.size(), applied_display_generation); auto disp = platf::display(encoder.platform_formats->dev_type, display_names[display_p], capture_ctxs.front().config); if (!disp) { return; @@ -1705,7 +1921,7 @@ namespace video { while (capture_ctx_queue->running()) { bool artificial_reinit = false; - auto push_captured_image_callback = [&capture_ctxs, &capture_ctx_queue, &switch_display_event, &artificial_reinit](std::shared_ptr &&img, bool frame_captured) { + auto push_captured_image_callback = [&capture_ctxs, &capture_ctx_queue, &switch_display_event, &applied_display_generation, &artificial_reinit](std::shared_ptr &&img, bool frame_captured) { KITTY_WHILE_LOOP(auto capture_ctx = std::begin(capture_ctxs), capture_ctx != std::end(capture_ctxs), { if (!capture_ctx->images->running()) { capture_ctx = capture_ctxs.erase(capture_ctx); @@ -1728,7 +1944,7 @@ namespace video { capture_ctxs.emplace_back(std::move(*capture_ctx_queue->pop())); } - if (switch_display_event->peek()) { + if (capture_display_switches().poll(switch_display_event).generation != applied_display_generation) { artificial_reinit = true; return false; } @@ -1786,9 +2002,7 @@ namespace video { refresh_displays(encoder.platform_formats->dev_type, display_names, display_p); // Process any pending display switch with the new list of displays - if (switch_display_event->peek()) { - display_p = std::clamp(*switch_display_event->pop(), 0, static_cast(display_names.size()) - 1); - } + capture_display_switches().poll(switch_display_event).apply(display_p, display_names.size(), applied_display_generation); // reset_display() will sleep between retries reset_display(disp, encoder.platform_formats->dev_type, display_names[display_p], capture_ctxs.front().config); @@ -1817,6 +2031,31 @@ namespace video { } } + void remember_frame_timestamp(frame_timestamp_queue_t ×tamps, int64_t frame_nr, const std::optional &frame_timestamp) { + if (!frame_timestamp) { + return; + } + + timestamps.emplace_back(frame_nr, *frame_timestamp); + if (timestamps.size() > 128) { + timestamps.pop_front(); + } + } + + std::optional match_frame_timestamp(frame_timestamp_queue_t ×tamps, int64_t pts) { + while (!timestamps.empty() && timestamps.front().first < pts) { + timestamps.pop_front(); + } + + if (!timestamps.empty() && timestamps.front().first == pts) { + auto timestamp = timestamps.front().second; + timestamps.pop_front(); + return timestamp; + } + + return std::nullopt; + } + /** * @brief Drain encoded packets from an FFmpeg encoder session. * @@ -1831,6 +2070,8 @@ namespace video { auto &frame = session.device->frame; frame->pts = frame_nr; + remember_frame_timestamp(session.frame_timestamps, frame_nr, frame_timestamp); + auto &ctx = session.avcodec_ctx; auto &sps = session.sps; @@ -1889,9 +2130,7 @@ namespace video { ); } - if (av_packet && av_packet->pts == frame_nr) { - packet->frame_timestamp = frame_timestamp; - } + packet->frame_timestamp = match_frame_timestamp(session.frame_timestamps, av_packet->pts); packet->replacements = &session.replacements; packet->channel_data = channel_data; @@ -1931,6 +2170,35 @@ namespace video { return 0; } + /** + * @brief Encode one frame through VideoToolbox and queue the resulting packet. + * + * @param frame_nr Monotonic frame index assigned by the video pipeline. + * @param session Active VideoToolbox encoder session. + * @param packets Output queue that receives the encoded packet. + * @param channel_data Stream session that receives the encoded packet. + * @param frame_timestamp Capture timestamp associated with the encoded frame. + * @return 0 when packets are queued; nonzero when VideoToolbox encoding fails. + */ + int encode_vt(int64_t frame_nr, vt_encode_session_t &session, safe::mail_raw_t::queue_t &packets, stream::session_t *channel_data, std::optional frame_timestamp) { + auto encoded_frame = session.encode_frame(frame_nr); + if (encoded_frame.data.empty()) { + BOOST_LOG(error) << "VideoToolbox returned empty packet"; + return -1; + } + + if (frame_nr != encoded_frame.frame_index) { + BOOST_LOG(error) << "VideoToolbox frame index mismatch " << frame_nr << " " << encoded_frame.frame_index; + } + + auto packet = std::make_unique(std::move(encoded_frame.data), encoded_frame.frame_index, encoded_frame.idr); + packet->channel_data = channel_data; + packet->frame_timestamp = frame_timestamp; + packets->raise(std::move(packet)); + + return 0; + } + /** * @brief Encode one captured frame and queue packets for transmission. * @@ -1946,6 +2214,8 @@ namespace video { return encode_avcodec(frame_nr, *avcodec_session, packets, channel_data, frame_timestamp); } else if (auto nvenc_session = dynamic_cast(&session)) { return encode_nvenc(frame_nr, *nvenc_session, packets, channel_data, frame_timestamp); + } else if (auto vt_session = dynamic_cast(&session)) { + return encode_vt(frame_nr, *vt_session, packets, channel_data, frame_timestamp); } return -1; @@ -1978,7 +2248,7 @@ namespace video { bool hardware = platform_formats->avcodec_base_dev_type != AV_HWDEVICE_TYPE_NONE; auto &video_format = encoder.codec_from_config(config); - if (!video_format[encoder_t::PASSED] || !disp->is_codec_supported(video_format.name, config)) { + if (video_format.name.empty() || !video_format[encoder_t::PASSED] || !disp->is_codec_supported(video_format.name, config)) { BOOST_LOG(error) << encoder.name << ": "sv << video_format.name << " mode not supported"sv; return nullptr; } @@ -2014,6 +2284,9 @@ namespace video { (colorspace.bit_depth == 10 && config.chromaSamplingType == 0) ? platform_formats->avcodec_pix_fmt_10bit : (colorspace.bit_depth == 10 && config.chromaSamplingType == 1) ? platform_formats->avcodec_pix_fmt_yuv444_10bit : AV_PIX_FMT_NONE; + if (!hardware && is_legacy_video_format(config.videoFormat)) { + sw_fmt = AV_PIX_FMT_YUV420P; + } // Allow up to 1 retry to apply the set of fallback options. // @@ -2030,13 +2303,13 @@ namespace video { ctx->time_base = AVRational {fps.den, fps.num}; switch (config.videoFormat) { - case 0: + case format_h264: // 10-bit h264 encoding is not supported by our streaming protocol assert(!config.dynamicRange); ctx->profile = select_h264_profile(video_format.name, config, config::video.amd.amd_coder); break; - case 1: + case format_hevc: if (config.chromaSamplingType == 1) { // HEVC uses the same RExt profile for both 8 and 10 bit YUV 4:4:4 encoding ctx->profile = AV_PROFILE_HEVC_REXT; @@ -2045,23 +2318,33 @@ namespace video { } break; - case 2: + case format_av1: // AV1 supports both 8 and 10 bit encoding with the same Main profile // but YUV 4:4:4 sampling requires High profile ctx->profile = (config.chromaSamplingType == 1) ? AV_PROFILE_AV1_HIGH : AV_PROFILE_AV1_MAIN; break; + + case format_mpeg2: + ctx->profile = AV_PROFILE_MPEG2_MAIN; + break; + + case format_h263p: + break; } // B-frames delay decoder output, so never use them ctx->max_b_frames = 0; - // Use an infinite GOP length since I-frames are generated on demand - // Exception: encoders with FIXED_GOP_SIZE flag don't support on-demand IDR - if (encoder.flags & FIXED_GOP_SIZE) { - // Fixed GOP for encoders that don't support on-demand IDR (e.g. Media Foundation) + if (is_legacy_video_format(config.videoFormat)) { + // FFmpeg's legacy encoders reject the infinite GOP value used by modern codecs. + ctx->gop_size = 600; + ctx->keyint_min = 1; + } else if (encoder.flags & FIXED_GOP_SIZE) { + // Fixed GOP for encoders that don't support on-demand IDR (e.g. Media Foundation). ctx->gop_size = 120; // ~2 seconds at 60 FPS - larger to reduce oversized IDR frame frequency ctx->keyint_min = 120; } else { + // Use an infinite GOP length since I-frames are generated on demand. ctx->gop_size = encoder.flags & LIMITED_GOP_SIZE ? std::numeric_limits::max() : std::numeric_limits::max(); @@ -2227,12 +2510,14 @@ namespace video { ctx->rc_min_rate = bitrate; } - if (encoder.flags & RELAXED_COMPLIANCE) { + if ((encoder.flags & RELAXED_COMPLIANCE) || config.videoFormat == format_h263p) { ctx->strict_std_compliance = FF_COMPLIANCE_UNOFFICIAL; } if (!(encoder.flags & NO_RC_BUF_LIMIT)) { - if (!hardware && (ctx->slices > 1 || config.videoFormat == 1)) { + if (is_legacy_video_format(config.videoFormat)) { + ctx->rc_buffer_size = bitrate; + } else if (!hardware && (ctx->slices > 1 || config.videoFormat == format_hevc)) { // Use a larger rc_buffer_size for software encoding when slices are enabled, // because libx264 can severely degrade quality if the buffer is too small. // libx265 encounters this issue more frequently, so always scale the @@ -2365,6 +2650,21 @@ namespace video { return std::make_unique(std::move(encode_device)); } + /** + * @brief Create native VideoToolbox encode session. + * + * @param client_config Client stream configuration negotiated for this session. + * @param encode_device Encode device. + * @return Constructed VideoToolbox encode session object. + */ + std::unique_ptr make_vt_encode_session(const config_t &client_config, std::unique_ptr encode_device) { + if (!encode_device->init_encoder(client_config, encode_device->colorspace)) { + return nullptr; + } + + return std::make_unique(std::move(encode_device)); + } + /** * @brief Create encode session. * @@ -2383,6 +2683,9 @@ namespace video { } else if (dynamic_cast(encode_device.get())) { auto nvenc_encode_device = boost::dynamic_pointer_cast(std::move(encode_device)); return make_nvenc_encode_session(config, std::move(nvenc_encode_device)); + } else if (dynamic_cast(encode_device.get())) { + auto vt_encode_device = boost::dynamic_pointer_cast(std::move(encode_device)); + return make_vt_encode_session(config, std::move(vt_encode_device)); } return nullptr; @@ -2515,13 +2818,6 @@ namespace video { } } - /** - * @brief Create a port object or message. - * - * @param display Display object or identifier associated with the operation. - * @param config Configuration values to apply. - * @return Constructed port object. - */ input::touch_port_t make_port(platf::display_t *display, const config_t &config) { float wd = display->width; float hd = display->height; @@ -2536,9 +2832,7 @@ namespace video { int display_env_logical_width = 0; int display_env_logical_height = 0; if (display->logical_width > 0 && display->logical_height > 0 && display->env_logical_width > 0 && display->env_logical_height > 0) { - float lwd = display->logical_width; - float lhd = display->logical_height; - scalar_tpcoords = std::fminf(wd / lwd, hd / lhd); + scalar_tpcoords = touch_port_scale(wd, hd, display->logical_width, display->logical_height, display->transform); display_env_logical_width = display->env_logical_width; display_env_logical_height = display->env_logical_height; } @@ -2559,6 +2853,8 @@ namespace video { display->logical_height, display->env_offset_x, display->env_offset_y, + display->output_name, + display->transform, }, display->env_width, display->env_height, @@ -2615,6 +2911,8 @@ namespace video { result = disp.make_avcodec_encode_device(pix_fmt); } else if (dynamic_cast(encoder.platform_formats.get())) { result = disp.make_nvenc_encode_device(pix_fmt); + } else if (dynamic_cast(encoder.platform_formats.get())) { + result = disp.make_vt_encode_device(pix_fmt); } if (result) { @@ -2680,16 +2978,16 @@ namespace video { * @param encode_session_ctx_queue Pending synchronized session context queue. * @param display_names Cached display names. * @param display_p Active display index. + * @param applied_display_generation Last monitor switch applied by this worker. * @return Encoder loop result. */ encode_e encode_run_sync( std::vector> &synced_session_ctxs, encode_session_ctx_queue_t &encode_session_ctx_queue, std::vector &display_names, - int &display_p + int &display_p, + std::uint64_t &applied_display_generation ) { - const auto &encoder = *chosen_encoder; - std::shared_ptr disp; auto switch_display_event = mail::man->event(mail::switch_display); @@ -2703,14 +3001,14 @@ namespace video { synced_session_ctxs.emplace_back(std::make_unique(std::move(*ctx))); } + const auto &encoder = *synced_session_ctxs.front()->encoder_p; + while (encode_session_ctx_queue.running()) { // Refresh display names since a display removal might have caused the reinitialization refresh_displays(encoder.platform_formats->dev_type, display_names, display_p); // Process any pending display switch with the new list of displays - if (switch_display_event->peek()) { - display_p = std::clamp(*switch_display_event->pop(), 0, static_cast(display_names.size()) - 1); - } + capture_display_switches().poll(switch_display_event).apply(display_p, display_names.size(), applied_display_generation); // reset_display() will sleep between retries reset_display(disp, encoder.platform_formats->dev_type, display_names[display_p], synced_session_ctxs.front()->config); @@ -2805,7 +3103,7 @@ namespace video { ++pos; }) - if (switch_display_event->peek()) { + if (capture_display_switches().poll(switch_display_event).generation != applied_display_generation) { ec = platf::capture_e::reinit; return false; } @@ -2835,13 +3133,13 @@ namespace video { /** * @brief Run synchronous capture and encode work on the capture thread. + * + * @param capture_context Encoder-specific worker state kept alive by its stream handles. */ - void captureThreadSync() { - auto ref = capture_thread_sync.ref(); - + void captureThreadSync(capture_thread_sync_ctx_t &capture_context) { std::vector> synced_session_ctxs; - auto &ctx = ref->encode_session_ctx_queue; + auto &ctx = capture_context.encode_session_ctx_queue; auto lg = util::fail_guard([&ctx, &synced_session_ctxs]() { ctx.stop(); @@ -2862,7 +3160,8 @@ namespace video { std::vector display_names; int display_p = -1; - while (encode_run_sync(synced_session_ctxs, ctx, display_names, display_p) == encode_e::reinit) {} + std::uint64_t applied_display_generation = 0; + while (encode_run_sync(synced_session_ctxs, ctx, display_names, display_p, applied_display_generation) == encode_e::reinit) {} } /** @@ -2870,11 +3169,13 @@ namespace video { * * @param mail Session mail bus. * @param config Video configuration. + * @param encoder Encoder selected for the requested video format. * @param channel_data Stream session carried with each encoded packet. */ void capture_async( safe::mail_t mail, config_t &config, + const encoder_t &encoder, stream::session_t *channel_data ) { auto shutdown_event = mail->event(mail::shutdown); @@ -2885,12 +3186,12 @@ namespace video { shutdown_event->raise(true); }); - auto ref = capture_thread_async.ref(); + auto ref = capture_groups().ref(&encoder); if (!ref) { return; } - ref->capture_ctx_queue->raise(capture_ctx_t {images, config}); + ref->capture_ctx_queue->raise(capture_ctx_t {images, config, &encoder}); if (!ref->capture_ctx_queue->running()) { return; @@ -2921,8 +3222,6 @@ namespace video { display = ref->display_wp->lock(); } - auto &encoder = *chosen_encoder; - auto encode_device = make_encode_device(*display, encoder, config); if (!encode_device) { return; @@ -2950,7 +3249,7 @@ namespace video { display, std::move(encode_device), ref->reinit_event, - *ref->encoder_p, + encoder, channel_data ); } @@ -2968,16 +3267,24 @@ namespace video { config_t config, stream::session_t *channel_data ) { - config = resolve_dynamic_range(*chosen_encoder, config); - auto idr_events = mail->event(mail::idr); + auto encoder = encoder_for_config(config); + if (!encoder || !encoder_supports_video_format(*encoder, config.videoFormat)) { + BOOST_LOG(error) << "No encoder is available for video format ["sv << config.videoFormat << ']'; + return; + } + + config = resolve_dynamic_range(*encoder, config); idr_events->raise(true); - if (chosen_encoder->flags & PARALLEL_ENCODING) { - capture_async(std::move(mail), config, channel_data); + if (encoder->flags & PARALLEL_ENCODING) { + capture_async(std::move(mail), config, *encoder, channel_data); } else { safe::signal_t join_event; - auto ref = capture_thread_sync.ref(); + auto ref = capture_groups().ref(encoder); + if (!ref) { + return; + } ref->encode_session_ctx_queue.raise(sync_session_ctx_t { &join_event, mail->event(mail::shutdown), @@ -2986,6 +3293,7 @@ namespace video { mail->event(mail::hdr), mail->event(mail::touch_port), config, + encoder, 1, channel_data, }); @@ -3062,6 +3370,46 @@ namespace video { return flag; } + bool validate_legacy_codec(encoder_t &encoder, int video_format) { + if (!is_legacy_video_format(video_format)) { + return false; + } + auto &codec = video_format == format_mpeg2 ? encoder.mpeg2 : encoder.h263p; + codec.capabilities.reset(); + if (codec.name.empty() || !encoder.platform_formats) { + return false; + } + + config_t config {1920, 1080, 60, 6000, 1000, 1, 1, 1, video_format, 0, 0, 0}; + std::shared_ptr display; + reset_display(display, encoder.platform_formats->dev_type, display_device::map_output_name(config::video.output_name), config); + if (!display || !display->is_codec_supported(codec.name, config)) { + return false; + } + + codec[encoder_t::PASSED] = true; + codec[encoder_t::REF_FRAMES_RESTRICT] = true; + const auto max_ref_frames = validate_config(display, encoder, config); + config.numRefFrames = 0; + const auto autoselect = max_ref_frames >= 0 ? max_ref_frames : validate_config(display, encoder, config); + codec.capabilities.reset(); + codec[encoder_t::REF_FRAMES_RESTRICT] = max_ref_frames >= 0; + codec[encoder_t::PASSED] = autoselect >= 0; + return codec[encoder_t::PASSED]; + } + + encoder_t *select_legacy_encoder(std::span candidates, int video_format, const codec_probe_t &probe) { + if (!is_legacy_video_format(video_format)) { + return nullptr; + } + for (auto *encoder : candidates) { + if (encoder && probe(*encoder, video_format)) { + return encoder; + } + } + return nullptr; + } + /** * @brief Validate encoder before it is used. */ @@ -3119,8 +3467,8 @@ namespace video { encoder.h264[encoder_t::PASSED] = true; if (test_hevc) { - config_max_ref_frames.videoFormat = 1; - config_autoselect.videoFormat = 1; + config_max_ref_frames.videoFormat = format_hevc; + config_autoselect.videoFormat = format_hevc; if (disp->is_codec_supported(encoder.hevc.name, config_autoselect)) { auto max_ref_frames_hevc = validate_config(disp, encoder, config_max_ref_frames); @@ -3147,8 +3495,8 @@ namespace video { } if (test_av1) { - config_max_ref_frames.videoFormat = 2; - config_autoselect.videoFormat = 2; + config_max_ref_frames.videoFormat = format_av1; + config_autoselect.videoFormat = format_av1; if (disp->is_codec_supported(encoder.av1.name, config_autoselect)) { auto max_ref_frames_av1 = validate_config(disp, encoder, config_max_ref_frames); @@ -3241,12 +3589,12 @@ namespace video { encoder.h264[encoder_t::DYNAMIC_RANGE] = false; encoder.h264[encoder_t::DYNAMIC_RANGE_YUV444] = false; - test_yuv444(encoder.hevc, 1); - test_yuv420_hdr(encoder.hevc, 1); - test_yuv444_hdr(encoder.hevc, 1); - test_yuv444(encoder.av1, 2); - test_yuv420_hdr(encoder.av1, 2); - test_yuv444_hdr(encoder.av1, 2); + test_yuv444(encoder.hevc, format_hevc); + test_yuv420_hdr(encoder.hevc, format_hevc); + test_yuv444_hdr(encoder.hevc, format_hevc); + test_yuv444(encoder.av1, format_av1); + test_yuv420_hdr(encoder.av1, format_av1); + test_yuv444_hdr(encoder.av1, format_av1); } encoder.h264[encoder_t::VUI_PARAMETERS] = encoder.h264[encoder_t::VUI_PARAMETERS] && !config::sunshine.flags[config::flag::FORCE_VIDEO_HEADER_REPLACE]; @@ -3264,6 +3612,7 @@ namespace video { } void reset_encoder_probe_results() { + probed_codec_modes().h264 = false; last_encoder_probe_supported_ref_frames_invalidation = false; last_encoder_probe_supported_yuv444_for_codec = {}; last_encoder_probe_supported_dynamic_range_for_codec = {}; @@ -3271,6 +3620,7 @@ namespace video { } void record_encoder_probe_results(const encoder_t &encoder) { + probed_codec_modes().h264 = encoder.h264[encoder_t::PASSED]; last_encoder_probe_supported_ref_frames_invalidation = (encoder.flags & REF_FRAMES_INVALIDATION); last_encoder_probe_supported_yuv444_for_codec[0] = encoder.h264[encoder_t::PASSED] && encoder.h264[encoder_t::YUV444]; @@ -3292,24 +3642,45 @@ namespace video { encoder.av1[encoder_t::DYNAMIC_RANGE_YUV444]; } + /** + * @brief Determine the advertised mode of an automatically configured modern codec. + * + * @param codec Codec capabilities from the selected encoder. + * @return The mode matching the supported profiles, or 1 when unavailable. + */ + static int auto_codec_mode(const encoder_t::codec_t &codec) { + if (!codec[encoder_t::PASSED]) { + return 1; + } + return 2 + static_cast(codec[encoder_t::DYNAMIC_RANGE]) + 2 * static_cast(codec[encoder_t::DYNAMIC_RANGE_YUV444]); + } + + bool is_encoder_probe_cacheable(const encoder_t *encoder) { + return encoder && !(encoder->flags & ALWAYS_REPROBE); + } + int probe_encoders() { - if (!allow_encoder_probing()) { + if (!allow_encoder_probing(display_device::enumerate_devices())) { // Error already logged return -1; } auto encoder_list = encoders; + auto &[codec_encoders, modes] = encoder_probe_state(); - // If we already have a good encoder, check to see if another probe is required - if (chosen_encoder && !(chosen_encoder->flags & ALWAYS_REPROBE) && !platf::needs_encoder_reenumeration()) { + // Legacy settings are read at startup. Cache their results alongside the modern probe. + if (is_encoder_probe_cacheable(chosen_encoder) && !platf::needs_encoder_reenumeration()) { return 0; } // Restart encoder selection auto previous_encoder = chosen_encoder; chosen_encoder = nullptr; + codec_encoders.fill(nullptr); active_hevc_mode = config::video.hevc_mode; active_av1_mode = config::video.av1_mode; + modes.mpeg2 = config::video.mpeg2_mode; + modes.h263p = config::video.h263p_mode; reset_encoder_probe_results(); auto adjust_encoder_constraints_hevc = [&](encoder_t *encoder) { @@ -3416,7 +3787,7 @@ namespace video { }); if (chosen_encoder == nullptr) { - BOOST_LOG(error) << "Couldn't find any working encoder that meets HEVC/AV1 requirements"sv; + BOOST_LOG(error) << "Couldn't find any working encoder that meets codec requirements"sv; } } @@ -3443,7 +3814,40 @@ namespace video { }); } - if (chosen_encoder == nullptr) { + if (chosen_encoder) { + for (int format : {format_h264, format_hevc, format_av1}) { + if (encoder_supports_video_format(*chosen_encoder, format)) { + codec_encoders[format] = chosen_encoder; + } + } + } + + // A failed modern probe must not remove a valid legacy encoder from consideration. + std::vector legacy_candidates(std::begin(encoders), std::end(encoders)); + auto prioritize = [&](encoder_t *encoder) { + const auto position = std::find(legacy_candidates.begin(), legacy_candidates.end(), encoder); + if (position != legacy_candidates.end()) { + std::rotate(legacy_candidates.begin(), position, std::next(position)); + } + }; + prioritize(chosen_encoder); + for (auto *encoder : encoders) { + if (encoder->name == config::video.encoder) { + prioritize(encoder); + break; + } + } + for (const auto &[format, mode] : {std::pair {format_mpeg2, &modes.mpeg2}, std::pair {format_h263p, &modes.h263p}}) { + if (*mode == 2) { + codec_encoders[format] = select_legacy_encoder(legacy_candidates, format, validate_legacy_codec); + if (!codec_encoders[format]) { + BOOST_LOG(warning) << "No encoder supports legacy video format [" << format << ']'; + *mode = 1; + } + } + } + + if (!chosen_encoder && !codec_encoders[format_mpeg2] && !codec_encoders[format_h263p]) { const auto output_name {display_device::map_output_name(config::video.output_name)}; BOOST_LOG(fatal) << "Unable to find display or encoder during startup."sv; if (!config::video.adapter_name.empty() || !output_name.empty()) { @@ -3458,71 +3862,68 @@ namespace video { BOOST_LOG(info) << "// Ignore any errors mentioned above, they are not relevant. //"sv; BOOST_LOG(info); - auto &encoder = *chosen_encoder; - - record_encoder_probe_results(encoder); + if (chosen_encoder) { + auto &encoder = *chosen_encoder; - BOOST_LOG(debug) << "------ h264 ------"sv; - for (int x = 0; x < encoder_t::MAX_FLAGS; ++x) { - auto flag = static_cast(x); - BOOST_LOG(debug) << encoder_t::from_flag(flag) << (encoder.h264[flag] ? ": supported"sv : ": unsupported"sv); - } - BOOST_LOG(debug) << "-------------------"sv; - BOOST_LOG(info) << "Found H.264 encoder: "sv << encoder.h264.name << " ["sv << encoder.name << ']'; + record_encoder_probe_results(encoder); - if (encoder.hevc[encoder_t::PASSED]) { - BOOST_LOG(debug) << "------ hevc ------"sv; + BOOST_LOG(debug) << "------ h264 ------"sv; for (int x = 0; x < encoder_t::MAX_FLAGS; ++x) { auto flag = static_cast(x); - BOOST_LOG(debug) << encoder_t::from_flag(flag) << (encoder.hevc[flag] ? ": supported"sv : ": unsupported"sv); + BOOST_LOG(debug) << encoder_t::from_flag(flag) << (encoder.h264[flag] ? ": supported"sv : ": unsupported"sv); } BOOST_LOG(debug) << "-------------------"sv; + BOOST_LOG(info) << "Found H.264 encoder: "sv << encoder.h264.name << " ["sv << encoder.name << ']'; - BOOST_LOG(info) << "Found HEVC encoder: "sv << encoder.hevc.name << " ["sv << encoder.name << ']'; - } + if (encoder.hevc[encoder_t::PASSED]) { + BOOST_LOG(debug) << "------ hevc ------"sv; + for (int x = 0; x < encoder_t::MAX_FLAGS; ++x) { + auto flag = static_cast(x); + BOOST_LOG(debug) << encoder_t::from_flag(flag) << (encoder.hevc[flag] ? ": supported"sv : ": unsupported"sv); + } + BOOST_LOG(debug) << "-------------------"sv; - if (encoder.av1[encoder_t::PASSED]) { - BOOST_LOG(debug) << "------ av1 ------"sv; - for (int x = 0; x < encoder_t::MAX_FLAGS; ++x) { - auto flag = static_cast(x); - BOOST_LOG(debug) << encoder_t::from_flag(flag) << (encoder.av1[flag] ? ": supported"sv : ": unsupported"sv); + BOOST_LOG(info) << "Found HEVC encoder: "sv << encoder.hevc.name << " ["sv << encoder.name << ']'; } - BOOST_LOG(debug) << "-------------------"sv; - BOOST_LOG(info) << "Found AV1 encoder: "sv << encoder.av1.name << " ["sv << encoder.name << ']'; - } + if (encoder.av1[encoder_t::PASSED]) { + BOOST_LOG(debug) << "------ av1 ------"sv; + for (int x = 0; x < encoder_t::MAX_FLAGS; ++x) { + auto flag = static_cast(x); + BOOST_LOG(debug) << encoder_t::from_flag(flag) << (encoder.av1[flag] ? ": supported"sv : ": unsupported"sv); + } + BOOST_LOG(debug) << "-------------------"sv; - // 2 - passed - // 3 - HDR yuv420 - // 4 - HDR yuv444 - // 5 - HDR yuv420 & HDR yuv444 + BOOST_LOG(info) << "Found AV1 encoder: "sv << encoder.av1.name << " ["sv << encoder.name << ']'; + } - if (active_hevc_mode == 0) { - active_hevc_mode = 1; - if (encoder.hevc[encoder_t::PASSED]) { - active_hevc_mode = 2; - if (encoder.hevc[encoder_t::DYNAMIC_RANGE]) { - active_hevc_mode += 1; - } - if (encoder.hevc[encoder_t::DYNAMIC_RANGE_YUV444]) { - active_hevc_mode += 2; - } + if (active_hevc_mode == 0) { + active_hevc_mode = auto_codec_mode(encoder.hevc); + BOOST_LOG(debug) << "ENCODER STATUS ACTIVE_HEVC_MODE: "sv << active_hevc_mode; } - BOOST_LOG(debug) << "ENCODER STATUS ACTIVE_HEVC_MODE: "sv << active_hevc_mode; - } - if (active_av1_mode == 0) { + if (active_av1_mode == 0) { + active_av1_mode = auto_codec_mode(encoder.av1); + BOOST_LOG(debug) << "ENCODER STATUS ACTIVE_AV1_MODE: "sv << active_av1_mode; + } + } else { + active_hevc_mode = 1; active_av1_mode = 1; - if (encoder.av1[encoder_t::PASSED]) { - active_av1_mode = 2; - if (encoder.av1[encoder_t::DYNAMIC_RANGE]) { - active_av1_mode += 1; - } - if (encoder.av1[encoder_t::DYNAMIC_RANGE_YUV444]) { - active_av1_mode += 2; - } + } + for (int format : {format_mpeg2, format_h263p}) { + if (auto *backend = codec_encoders[format]) { + config_t config {}; + config.videoFormat = format; + BOOST_LOG(info) << "Found legacy encoder: " << backend->codec_from_config(config).name << " [" << backend->name << ']'; } - BOOST_LOG(debug) << "ENCODER STATUS ACTIVE_AV1_MODE: "sv << active_av1_mode; + } + + if (modes.mpeg2 == 0) { + modes.mpeg2 = 1; + } + + if (modes.h263p == 0) { + modes.h263p = 1; } return 0; @@ -3606,22 +4007,6 @@ namespace video { return hw_device_buf; } - /** - * @brief Initialize AVCodec hardware input buffers for VideoToolbox. - */ - util::Either vt_init_avcodec_hardware_input_buffer(platf::avcodec_encode_device_t *encode_device) { - avcodec_buffer_t hw_device_buf; - - auto status = av_hwdevice_ctx_create(&hw_device_buf, AV_HWDEVICE_TYPE_VIDEOTOOLBOX, nullptr, nullptr, 0); - if (status < 0) { - std::array string; - BOOST_LOG(error) << "Failed to create a VideoToolbox device: "sv << av_make_error_string(string.data(), AV_ERROR_MAX_STRING_SIZE, status); - return -1; - } - - return hw_device_buf; - } - #ifdef _WIN32 } @@ -3666,7 +4051,6 @@ namespace video { * @brief Start capture async. */ int start_capture_async(capture_thread_async_ctx_t &capture_thread_ctx) { - capture_thread_ctx.encoder_p = chosen_encoder; capture_thread_ctx.reinit_event.reset(); capture_thread_ctx.capture_ctx_queue = std::make_shared>(30); @@ -3675,8 +4059,7 @@ namespace video { captureThread, capture_thread_ctx.capture_ctx_queue, std::ref(capture_thread_ctx.display_wp), - std::ref(capture_thread_ctx.reinit_event), - std::ref(*capture_thread_ctx.encoder_p) + std::ref(capture_thread_ctx.reinit_event) }; return 0; @@ -3692,19 +4075,24 @@ namespace video { } /** - * @brief Start capture sync. - * @details The shared lifetime callback supplies unused state; the thread accesses the shared capture queue directly. + * @brief Start the synchronous worker for one encoder capture group. + * + * @param context Encoder-specific queue and owned worker thread. + * @return Zero after starting the worker. */ - int start_capture_sync(capture_thread_sync_ctx_t &) { - std::jthread {&captureThreadSync}.detach(); + int start_capture_sync(capture_thread_sync_ctx_t &context) { + context.capture_thread = std::jthread {captureThreadSync, std::ref(context)}; return 0; } /** - * @brief Leave synchronous capture cleanup to the capture thread. + * @brief Stop and join a synchronous group before destroying its queue. + * + * @param context Encoder-specific worker whose last stream has left. */ - void end_capture_sync(capture_thread_sync_ctx_t &) { - // The capture thread stops its queue and signals its sessions when it exits. + void end_capture_sync(capture_thread_sync_ctx_t &context) { + context.encode_session_ctx_queue.stop(); + context.capture_thread.join(); } /** @@ -3725,8 +4113,6 @@ namespace video { return cuda; case AV_HWDEVICE_TYPE_NONE: return system; - case AV_HWDEVICE_TYPE_VIDEOTOOLBOX: - return videotoolbox; default: return unknown; } diff --git a/src/video.h b/src/video.h index 2092fcacf0c..64bac6ae087 100644 --- a/src/video.h +++ b/src/video.h @@ -6,7 +6,13 @@ // standard includes #include +#include +#include +#include +#include #include +#include +#include // local includes #include "input.h" @@ -21,11 +27,22 @@ extern "C" { struct AVPacket; +namespace display_device { + struct EnumeratedDevice; +} + namespace stream { struct session_t; } namespace video { + inline constexpr int format_h264 = 0; ///< H.264 High profile wire identifier. + inline constexpr int format_hevc = 1; ///< HEVC Main/Main10 wire identifier. + inline constexpr int format_av1 = 2; ///< AV1 Main/Main10 wire identifier. + inline constexpr int format_mpeg2 = 3; ///< MPEG-2/H.262 wire identifier. + inline constexpr int format_h263p = 4; ///< H.263+ wire identifier. + + constexpr int VIDEO_FORMAT_COUNT = format_h263p + 1; ///< Number of supported wire codec identifiers. /** * @brief Encoding configuration requested by a remote client. @@ -39,12 +56,21 @@ namespace video { int slicesPerFrame; ///< Number of slices per frame. int numRefFrames; ///< Maximum number of reference frames. int encoderCscMode; ///< Requested color range and SDR colorspace; HDR always uses BT.2020 and ST2084. - int videoFormat; ///< Video codec format: 0 = H.264, 1 = HEVC, 2 = AV1. + int videoFormat; ///< GameStream wire identifier for the requested video codec. int dynamicRange; ///< Encoding color depth: 0 = 8-bit, 1 = 10-bit. int chromaSamplingType; ///< Chroma sampling type: 0 = 4:2:0, 1 = 4:4:4. int enableIntraRefresh; ///< Intra refresh setting: 0 = disabled, 1 = enabled. }; + /** + * @brief Describe the streamed display, desktop bounds, and client letterboxing for absolute input. + * + * @param display Capture display supplying native output identity and geometry. + * @param config Client stream dimensions. + * @return Touch port forwarded from the video pipeline to input handling. + */ + input::touch_port_t make_port(platf::display_t *display, const config_t &config); + namespace amf { /** @@ -68,6 +94,14 @@ namespace video { */ int select_h264_profile(std::string_view encoder_name, const config_t &config, int amd_coder); + /** + * @brief Decide whether encoder probing may proceed with the given display devices. + * + * @param devices Display devices currently enumerated by libdisplaydevice. + * @return True if there should be no issues with the probing, false if it must be prevented. + */ + bool allow_encoder_probing(const std::vector &devices); + /** * @brief Map an FFmpeg hardware device type to Sunshine's memory type. * @@ -191,6 +225,34 @@ namespace video { int offsetH; ///< Offset h. }; + /** + * @brief Capture timestamps of in-flight frames keyed by pts, awaiting their encoded packets. + */ + using frame_timestamp_queue_t = std::deque>; + + /** + * @brief Remember a submitted frame's capture timestamp until its encoded packet surfaces. + * + * Encoders may deliver packets one or more frames behind submission, so the timestamp is + * kept keyed by pts until the corresponding packet arrives. The queue is bounded: once + * 128 timestamps are outstanding, the oldest entry is evicted per insertion. + * @param timestamps Queue of outstanding capture timestamps. + * @param frame_nr Monotonic frame index assigned by the video pipeline, used as the frame pts. + * @param frame_timestamp Capture timestamp associated with the frame, when known. + */ + void remember_frame_timestamp(frame_timestamp_queue_t ×tamps, int64_t frame_nr, const std::optional &frame_timestamp); + + /** + * @brief Match an encoded packet to the capture timestamp of the frame it encodes. + * + * Entries for older frames whose packets never surfaced (e.g. dropped by the encoder) + * are discarded; a packet is never paired with another frame's timestamp. + * @param timestamps Queue of outstanding capture timestamps. + * @param pts Presentation timestamp of the received packet. + * @return Capture timestamp of the packet's frame, when known. + */ + std::optional match_frame_timestamp(frame_timestamp_queue_t ×tamps, int64_t pts); + /** * @brief Pixel formats supported by one encoder backend. */ @@ -288,6 +350,34 @@ namespace video { } }; + /** + * @brief Native VideoToolbox-specific pixel formats supported by a platform. + */ + struct encoder_platform_formats_vt: encoder_platform_formats_t { + /** + * @brief Construct VideoToolbox platform format mappings. + * + * @param dev_type Platform memory type. + * @param pix_fmt_8bit Platform 8-bit pixel format. + * @param pix_fmt_10bit Platform 10-bit pixel format. + * @param pix_fmt_yuv444_8bit Platform 8-bit YUV444 pixel format. + * @param pix_fmt_yuv444_10bit Platform 10-bit YUV444 pixel format. + */ + encoder_platform_formats_vt( + const platf::mem_type_e &dev_type, + const platf::pix_fmt_e &pix_fmt_8bit, + const platf::pix_fmt_e &pix_fmt_10bit, + const platf::pix_fmt_e &pix_fmt_yuv444_8bit, + const platf::pix_fmt_e &pix_fmt_yuv444_10bit + ) { + encoder_platform_formats_t::dev_type = dev_type; + encoder_platform_formats_t::pix_fmt_8bit = pix_fmt_8bit; + encoder_platform_formats_t::pix_fmt_10bit = pix_fmt_10bit; + encoder_platform_formats_t::pix_fmt_yuv444_8bit = pix_fmt_yuv444_8bit; + encoder_platform_formats_t::pix_fmt_yuv444_10bit = pix_fmt_yuv444_10bit; + } + }; + /** * @brief Encoder name and feature flags advertised by Sunshine. */ @@ -363,7 +453,7 @@ namespace video { const std::unique_ptr platform_formats; ///< Platform-specific memory and pixel formats accepted by the encoder. /** - * @brief Codec capabilities for AV1, HEVC, or H.264. + * @brief Codec capabilities for a modern or legacy video format. */ struct codec_t { std::vector common_options; ///< Options applied to every encode mode for this codec. @@ -400,24 +490,30 @@ namespace video { codec_t av1; ///< AV1 codec capability and option set. codec_t hevc; ///< HEVC codec capability and option set. codec_t h264; ///< H.264 codec capability and option set. + codec_t mpeg2; ///< MPEG-2 codec capability and option set. + codec_t h263p; ///< H.263+ codec capability and option set. /** * @brief Select the codec descriptor requested by a stream configuration. * * @param config Configuration values to apply. - * @return Codec descriptor for H.264, HEVC, or AV1. + * @return Codec descriptor for H.264, HEVC, AV1, MPEG-2, or H.263+. */ const codec_t &codec_from_config(const config_t &config) const { switch (config.videoFormat) { default: BOOST_LOG(error) << "Unknown video format " << config.videoFormat << ", falling back to H.264"; // fallthrough - case 0: + case format_h264: return h264; - case 1: + case format_hevc: return hevc; - case 2: + case format_av1: return av1; + case format_mpeg2: + return mpeg2; + case format_h263p: + return h263p; } } @@ -684,6 +780,46 @@ namespace video { */ using hdr_info_t = std::unique_ptr; + /** + * @brief Callback used to probe one encoder for one requested legacy codec. + */ + using codec_probe_t = std::function; + + /** + * @brief Probe MPEG-2 or H.263+ independently of H.264 support. + * + * @param encoder Backend whose requested codec should be validated. + * @param video_format MPEG-2 or H.263+ wire codec identifier. + * @return Whether the backend successfully encoded the requested legacy codec. + */ + bool validate_legacy_codec(encoder_t &encoder, int video_format); + + /** + * @brief Choose the first backend that passes a codec-specific probe. + * + * @param candidates Backend preference order, including software fallbacks. + * @param video_format Requested legacy codec identifier. + * @param probe Callback validating only the requested codec. + * @return Selected backend, or nullptr when no candidate passes. + */ + encoder_t *select_legacy_encoder(std::span candidates, int video_format, const codec_probe_t &probe); + + /** + * @brief Encoder probe results for baseline H.264 and the legacy codec modes. + */ + struct probed_codec_modes_t { + bool h264 = false; ///< Whether baseline H.264 passed its probe. + int mpeg2 = 0; ///< Active MPEG-2 advertisement mode. + int h263p = 0; ///< Active H.263+ advertisement mode. + }; + + /** + * @brief Access the codec modes owned by the encoder probe. + * + * @return Current H.264 probe result and legacy codec advertisement modes. + */ + probed_codec_modes_t &probed_codec_modes(); + extern int active_hevc_mode; extern int active_av1_mode; extern bool last_encoder_probe_supported_ref_frames_invalidation; @@ -735,6 +871,14 @@ namespace video { */ bool validate_encoder(encoder_t &encoder, bool expect_failure); + /** + * @brief Determine whether a backend permits reusing its probe results while the hardware remains unchanged. + * + * @param encoder Previously validated backend, or nullptr before a successful probe. + * @return True when the backend's results can be cached. + */ + bool is_encoder_probe_cacheable(const encoder_t *encoder); + /** * @brief Probe encoders and select the preferred encoder. * This is called once at startup and each time a stream is launched to @@ -788,6 +932,25 @@ namespace video { return AVRational {config.framerate, 1}; } + /** + * @brief Scale from logical to physical pixels for the touch port. + * @details A rotated output (odd transform) is captured in its native orientation, so its logical size is compared + * with the physical size swapped. + * + * @param width Physical width of the captured display. + * @param height Physical height of the captured display. + * @param logical_width Logical width of the display, as rotated. + * @param logical_height Logical height of the display, as rotated. + * @param transform Wayland output transform of the display. + * @return Physical pixels per logical pixel. + */ + inline float touch_port_scale(float width, float height, float logical_width, float logical_height, int transform) { + if (transform % 2 == 1) { + std::swap(logical_width, logical_height); + } + return std::fminf(width / logical_width, height / logical_height); + } + /** * @brief Capture frame interval for the requested framerate. * Uses the exact fractional rate when the client provided an X100 value. diff --git a/src/video_capture_groups.h b/src/video_capture_groups.h new file mode 100644 index 00000000000..ad18ec8d414 --- /dev/null +++ b/src/video_capture_groups.h @@ -0,0 +1,136 @@ +/** + * @file src/video_capture_groups.h + * @brief Share capture workers only between streams using the same encoder backend. + */ +#pragma once + +// standard includes +#include +#include +#include +#include +#include +#include +#include +#include + +// local includes +#include "thread_safe.h" + +namespace video { + struct encoder_t; + + /** + * @brief Broadcast the latest monitor request to every active capture group. + */ + class display_switch_state_t { + public: + /** + * @brief Monitor request observed by one capture worker. + */ + struct request_t { + std::uint64_t generation = 0; ///< Changes whenever a monitor request is consumed. + std::optional index; ///< Requested monitor index for the current stream epoch. + + /** + * @brief Apply a switch once to this worker's refreshed display list. + * + * @param display_index Selected display, already kept by name across re-enumeration. + * @param display_count Number of displays in the refreshed list. + * @param applied_generation Last switch applied by this worker. + */ + void apply(int &display_index, std::size_t display_count, std::uint64_t &applied_generation) const { + if (generation == applied_generation || !index.has_value() || display_count == 0) { + return; + } + display_index = std::clamp(*index, 0, static_cast(display_count) - 1); + applied_generation = generation; + } + }; + + /** + * @brief Start a capture group, resetting stale requests between streaming sessions. + */ + void start_worker() { + std::lock_guard lock {mutex_}; + if (workers_++ == 0) { + request_ = {}; + } + } + + /** + * @brief Release a stopped capture group's participation in the stream epoch. + */ + void stop_worker() { + std::lock_guard lock {mutex_}; + --workers_; + } + + /** + * @brief Consume pending requests once and share their generation with every worker. + * + * @param event Shared monitor-switch event produced by input handling. + * @return Most recent request, even when another worker consumed the raw event. + */ + request_t poll(const safe::mail_raw_t::event_t &event) { + std::lock_guard lock {mutex_}; + if (const auto request = event->try_pop(); request.has_value()) { + request_.index = *request; + ++request_.generation; + } + return request_; + } + + private: + std::mutex mutex_; ///< Serializes event consumption and capture group lifetimes. + std::size_t workers_ = 0; ///< Number of active backend capture groups. + request_t request_; ///< Latest request shared during this streaming epoch. + }; + + /** + * @brief Maintain independent capture worker lifetimes for encoder backends. + * + * @tparam T Capture worker context managed by safe::shared_t. + */ + template + class capture_group_pool_t { + public: + using group_t = safe::shared_t; ///< Reference-counted capture worker storage. + using ptr_t = typename group_t::ptr_t; ///< Handle keeping one backend's worker alive. + + /** + * @brief Configure the callbacks that start and stop each capture worker. + * + * @param construct Callback starting a newly referenced backend group. + * @param destruct Callback stopping a group after its final stream leaves. + */ + capture_group_pool_t(typename group_t::construct_f construct, typename group_t::destruct_f destruct): + construct_ {std::move(construct)}, + destruct_ {std::move(destruct)} { + } + + /** + * @brief Acquire the capture worker belonging to a stream's encoder backend. + * + * @param encoder Stable encoder identity; null does not acquire a group. + * @return Shared worker handle, or an empty handle when startup fails. + */ + ptr_t ref(const encoder_t *encoder) { + if (!encoder) { + return {}; + } + std::lock_guard lock {mutex_}; + auto &group = groups_[encoder]; + if (!group) { + group = std::make_unique(construct_, destruct_); + } + return group->ref(); + } + + private: + typename group_t::construct_f construct_; ///< Worker startup callback. + typename group_t::destruct_f destruct_; ///< Worker shutdown callback. + std::mutex mutex_; ///< Protects stable group allocation. + std::map> groups_; ///< One group per encoder backend. + }; +} // namespace video diff --git a/src_assets/common/assets/web/Apps.vue b/src_assets/common/assets/web/Apps.vue index 1465eb817e9..8aaa73db252 100644 --- a/src_assets/common/assets/web/Apps.vue +++ b/src_assets/common/assets/web/Apps.vue @@ -785,7 +785,7 @@ this.version = new SunshineVersion(null, r.version); }); - fetch("https://api.github.com/repos/LizardByte/Sunshine/releases/latest") + fetch("https://api.github.com/repos/SunshineStream/Sunshine/releases/latest") .then((r) => r.json()) .then((r) => this.githubVersion = new SunshineVersion(r, null)) .catch((e) => console.error(e)); @@ -804,31 +804,34 @@ "exit-timeout": 5, "prep-cmd": [], detached: [], + "working-dir": "", "image-path": "" }; this.editFormError = ""; this.openEditModal(); }, + /** + * @brief Open an application for editing with nullish optional fields defaulted. + * @param {number} id Index of the application to edit. + */ editApp(id) { this.editForm = structuredClone(toRaw(this.apps[id])); this.editForm.index = id; - if (this.editForm["prep-cmd"] === undefined) - this.editForm["prep-cmd"] = []; - if (this.editForm["detached"] === undefined) - this.editForm["detached"] = []; - if (this.editForm["exclude-global-prep-cmd"] === undefined) - this.editForm["exclude-global-prep-cmd"] = false; - if (this.editForm["elevated"] === undefined && this.platform === 'windows') { - this.editForm["elevated"] = false; - } - if (this.editForm["auto-detach"] === undefined) { - this.editForm["auto-detach"] = true; - } - if (this.editForm["wait-all"] === undefined) { - this.editForm["wait-all"] = true; - } - if (this.editForm["exit-timeout"] === undefined) { - this.editForm["exit-timeout"] = 5; + const defaults = { + "prep-cmd": [], + detached: [], + "exclude-global-prep-cmd": false, + elevated: false, + "auto-detach": true, + "wait-all": true, + "exit-timeout": 5, + cmd: "", + output: "", + "working-dir": "", + "image-path": "" + }; + for (const [key, value] of Object.entries(defaults)) { + this.editForm[key] ??= value; } this.editFormError = ""; this.openEditModal(); @@ -1024,10 +1027,13 @@ }, save() { this.editFormError = ""; - this.editForm["image-path"] = this.editForm["image-path"].toString().replaceAll('"', ''); + const currentImagePath = this.editForm["image-path"] == null ? "" : String(this.editForm["image-path"]).trim(); + this.editForm["image-path"] = currentImagePath.replaceAll('"', ''); const imagePath = this.editForm["image-path"]; - if (imagePath && !imagePath.toLowerCase().endsWith('.png')) { + if (!imagePath) { + delete this.editForm["image-path"]; + } else if (!imagePath.toLowerCase().endsWith('.png')) { this.editFormError = this.$t('file_browser.error_invalid_extension', { extensions: '.png' }); const modalBody = this.$refs.editModal.querySelector('.modal-body'); if (modalBody) modalBody.scrollTop = 0; diff --git a/src_assets/common/assets/web/Home.vue b/src_assets/common/assets/web/Home.vue index 261e3c6ac62..594e48ed22f 100644 --- a/src_assets/common/assets/web/Home.vue +++ b/src_assets/common/assets/web/Home.vue @@ -201,9 +201,9 @@ console.error('Failed to fetch permission status:', e); } console.log("Version: ", this.version.version) - this.githubVersion = new SunshineVersion(await fetch("https://api.github.com/repos/LizardByte/Sunshine/releases/latest").then((r) => r.json()), null); + this.githubVersion = new SunshineVersion(await fetch("https://api.github.com/repos/SunshineStream/Sunshine/releases/latest").then((r) => r.json()), null); console.log("GitHub Version: ", this.githubVersion.version) - this.preReleaseVersion = new SunshineVersion((await fetch("https://api.github.com/repos/LizardByte/Sunshine/releases").then((r) => r.json())).find(release => release.prerelease), null); + this.preReleaseVersion = new SunshineVersion((await fetch("https://api.github.com/repos/SunshineStream/Sunshine/releases").then((r) => r.json())).find(release => release.prerelease), null); console.log("Pre-Release Version: ", this.preReleaseVersion.version) // Read the broker version on both platforms to identify development builds. diff --git a/src_assets/common/assets/web/ResourceCard.vue b/src_assets/common/assets/web/ResourceCard.vue index 581a9c07c7f..55139a5138c 100644 --- a/src_assets/common/assets/web/ResourceCard.vue +++ b/src_assets/common/assets/web/ResourceCard.vue @@ -28,12 +28,12 @@

{{ $t('resource_card.legal') }}

{{ $t('resource_card.legal_desc') }}

+ +
+ + +
{{ $t('config.mpeg2_mode_desc') }}
+
+ + +
+ + +
{{ $t('config.h263p_mode_desc') }}
+
+
diff --git a/src_assets/common/assets/web/configs/tabs/AudioVideo.vue b/src_assets/common/assets/web/configs/tabs/AudioVideo.vue index 61144cb39c1..0d70a736bc3 100644 --- a/src_assets/common/assets/web/configs/tabs/AudioVideo.vue +++ b/src_assets/common/assets/web/configs/tabs/AudioVideo.vue @@ -32,11 +32,11 @@ const config = ref(props.config)