Skip to content

Commit 4b658cd

Browse files
Merge pull request #73 from SunshineStream/nightly
v0.13.0
2 parents 4a48307 + f6311ce commit 4b658cd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2314
-97
lines changed

.clang-format

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ BraceWrapping:
2323
AfterEnum: false
2424
AfterFunction: false
2525
AfterNamespace: false
26+
AfterObjCDeclaration: false
2627
AfterUnion: false
2728
BeforeCatch: true
2829
BeforeElse: true

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
target-branch: "nightly"
8+
open-pull-requests-limit: 20

.github/workflows/CI.yml

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -51,30 +51,6 @@ jobs:
5151
echo Within 'CMakeLists.txt' change "project(Sunshine VERSION $cmakelists_version)" to "project(Sunshine VERSION ${{ needs.check_changelog.outputs.next_version_bare }})"
5252
exit 1
5353
54-
- name: Check gen-deb.in Version
55-
run: |
56-
version=$(grep -o -E '^Version: [0-9]+\.[0-9]+\.[0-9]+' gen-deb.in | grep -o -E '[0-9]+\.[0-9]+\.[0-9]+')
57-
echo "gendeb_version=${version}" >> $GITHUB_ENV
58-
- name: Compare gen-deb.in Version
59-
if: ${{ env.gendeb_version != needs.check_changelog.outputs.next_version_bare }}
60-
run: |
61-
echo gen-deb.in version: "$gendeb_version"
62-
echo Changelog version: "${{ needs.check_changelog.outputs.next_version_bare }}"
63-
echo Within 'gen-deb.in' change "Version: $gendeb_version" to "Version: ${{ needs.check_changelog.outputs.next_version_bare }}"
64-
exit 1
65-
66-
- name: Check sunshine.desktop Versions
67-
run: |
68-
version=$(grep -o -E '^X-AppImage-Version=[0-9]+\.[0-9]+\.[0-9]+' sunshine.desktop | grep -o -E '[0-9]+\.[0-9]+\.[0-9]+')
69-
echo "appimage_version=${version}" >> $GITHUB_ENV
70-
- name: Compare sunshine.desktop Versions
71-
if: ${{ env.appimage_version != needs.check_changelog.outputs.next_version_bare }}
72-
run: |
73-
echo sunshine.desktop Version: "$appimage_version"
74-
echo Changelog version: "${{ needs.check_changelog.outputs.next_version_bare }}"
75-
echo Within 'sunshine.desktop' change "X-AppImage-Version=$appimage_version" to "X-AppImage-Version=${{ needs.check_changelog.outputs.next_version_bare }}"
76-
exit 1
77-
7854
build_appimage:
7955
name: AppImage
8056
runs-on: ubuntu-20.04
@@ -135,7 +111,7 @@ jobs:
135111
136112
wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage && chmod +x linuxdeploy-x86_64.AppImage
137113
138-
./linuxdeploy-x86_64.AppImage --appdir ../AppDir -e ../appimage-build/sunshine -i "../$ICON_FILE" -d "../$DESKTOP_FILE" --output appimage
114+
./linuxdeploy-x86_64.AppImage --appdir ../AppDir -e ../appimage-build/sunshine -i "../$ICON_FILE" -d "../appimage-build/$DESKTOP_FILE" --output appimage
139115
140116
mv sunshine*.AppImage sunshine.AppImage
141117
mkdir sunshine && mv sunshine.AppImage sunshine/
@@ -160,7 +136,7 @@ jobs:
160136
path: artifacts/
161137
- name: Create Release
162138
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
163-
uses: SunshineStream/actions/create_release@v0
139+
uses: SunshineStream/actions/create_release@master
164140
with:
165141
token: ${{ secrets.GITHUB_TOKEN }}
166142
next_version: ${{ needs.check_changelog.outputs.next_version }}
@@ -211,7 +187,7 @@ jobs:
211187
path: artifacts/
212188
- name: Create Release
213189
if: ${{ matrix.package == '-p' && github.event_name == 'push' && github.ref == 'refs/heads/master' }}
214-
uses: SunshineStream/actions/create_release@v0
190+
uses: SunshineStream/actions/create_release@master
215191
with:
216192
token: ${{ secrets.GITHUB_TOKEN }}
217193
next_version: ${{ needs.check_changelog.outputs.next_version }}
@@ -275,7 +251,7 @@ jobs:
275251
path: artifacts/
276252
- name: Create Release
277253
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
278-
uses: SunshineStream/actions/create_release@v0
254+
uses: SunshineStream/actions/create_release@master
279255
with:
280256
token: ${{ secrets.GITHUB_TOKEN }}
281257
next_version: ${{ needs.check_changelog.outputs.next_version }}

.github/workflows/clang.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: clang-format-lint
2+
3+
on:
4+
pull_request:
5+
branches: [master, nightly]
6+
types: [opened, synchronize, edited, reopened]
7+
8+
jobs:
9+
lint:
10+
name: Clang Format Lint
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false # false to test all, true to fail entire job if any fail
14+
matrix:
15+
inplace: [ true, false ] # removed ubuntu_18_04 for now
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v2
20+
21+
- name: Clang format lint
22+
uses: DoozyX/[email protected]
23+
with:
24+
source: './sunshine'
25+
extensions: 'cpp,h,m,mm'
26+
clangFormatVersion: 13
27+
style: file
28+
inplace: ${{ matrix.inplace }}
29+
30+
- name: Upload Artifacts
31+
if: ${{ matrix.inplace == true }}
32+
uses: actions/upload-artifact@v2
33+
with:
34+
name: sunshine
35+
path: sunshine/

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@
1313
[submodule "third-party/nv-codec-headers"]
1414
path = third-party/nv-codec-headers
1515
url = https://github.com/FFmpeg/nv-codec-headers
16+
[submodule "sunshine/platform/macos/TPCircularBuffer"]
17+
path = sunshine/platform/macos/TPCircularBuffer
18+
url = https://github.com/michaeltyson/TPCircularBuffer

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## [0.13.0] - 2022-02-27
4+
### Added
5+
- (MacOS) Initial support for MacOS (#40)
6+
37
## [0.12.0] - 2022-02-13
48
### Added
59
- New command line argument `--version`

CMakeLists.txt

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.0)
22

3-
project(Sunshine VERSION 0.12.0)
3+
project(Sunshine VERSION 0.13.0)
44

55
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
66

@@ -11,6 +11,22 @@ if(WIN32)
1111
PQOS_FLOWID=UINT32*
1212
QOS_NON_ADAPTIVE_FLOW=2)
1313
endif()
14+
if(APPLE)
15+
macro(ADD_FRAMEWORK fwname appname)
16+
find_library(FRAMEWORK_${fwname}
17+
NAMES ${fwname}
18+
PATHS ${CMAKE_OSX_SYSROOT}/System/Library
19+
PATH_SUFFIXES Frameworks
20+
NO_DEFAULT_PATH)
21+
if( ${FRAMEWORK_${fwname}} STREQUAL FRAMEWORK_${fwname}-NOTFOUND)
22+
MESSAGE(ERROR ": Framework ${fwname} not found")
23+
else()
24+
TARGET_LINK_LIBRARIES(${appname} "${FRAMEWORK_${fwname}}/${fwname}")
25+
MESSAGE(STATUS "Framework ${fwname} found at ${FRAMEWORK_${fwname}}")
26+
endif()
27+
endmacro(ADD_FRAMEWORK)
28+
endif()
29+
1430
add_subdirectory(third-party/moonlight-common-c/enet)
1531
add_subdirectory(third-party/Simple-Web-Server)
1632

@@ -23,7 +39,9 @@ include_directories(third-party/miniupnp)
2339

2440
find_package(Threads REQUIRED)
2541
find_package(OpenSSL REQUIRED)
26-
set(Boost_USE_STATIC_LIBS ON)
42+
if(NOT APPLE)
43+
set(Boost_USE_STATIC_LIBS ON)
44+
endif()
2745
find_package(Boost COMPONENTS log filesystem REQUIRED)
2846

2947
list(APPEND SUNSHINE_COMPILE_OPTIONS -Wall -Wno-missing-braces -Wno-maybe-uninitialized -Wno-sign-compare)
@@ -106,6 +124,46 @@ if(WIN32)
106124

107125
set_source_files_properties(third-party/ViGEmClient/src/ViGEmClient.cpp PROPERTIES COMPILE_DEFINITIONS "UNICODE=1;ERROR_INVALID_DEVICE_OBJECT_PARAMETER=650")
108126
set_source_files_properties(third-party/ViGEmClient/src/ViGEmClient.cpp PROPERTIES COMPILE_FLAGS "-Wno-unknown-pragmas -Wno-misleading-indentation -Wno-class-memaccess")
127+
elseif(APPLE)
128+
add_compile_definitions(SUNSHINE_PLATFORM="macos")
129+
list(APPEND SUNSHINE_DEFINITIONS APPS_JSON="apps_mac.json")
130+
link_directories(/opt/local/lib)
131+
link_directories(/usr/local/lib)
132+
ADD_DEFINITIONS(-DBOOST_LOG_DYN_LINK)
133+
134+
find_package(FFmpeg REQUIRED)
135+
FIND_LIBRARY(APP_SERVICES_LIBRARY ApplicationServices )
136+
FIND_LIBRARY(AV_FOUNDATION_LIBRARY AVFoundation )
137+
FIND_LIBRARY(CORE_MEDIA_LIBRARY CoreMedia )
138+
FIND_LIBRARY(CORE_VIDEO_LIBRARY CoreVideo )
139+
FIND_LIBRARY(FOUNDATION_LIBRARY Foundation )
140+
list(APPEND SUNSHINE_EXTERNAL_LIBRARIES
141+
${APP_SERVICES_LIBRARY}
142+
${AV_FOUNDATION_LIBRARY}
143+
${CORE_MEDIA_LIBRARY}
144+
${CORE_VIDEO_LIBRARY}
145+
${FOUNDATION_LIBRARY})
146+
147+
set(PLATFORM_INCLUDE_DIRS
148+
${Boost_INCLUDE_DIR})
149+
150+
set(PLATFORM_TARGET_FILES
151+
sunshine/platform/macos/av_audio.h
152+
sunshine/platform/macos/av_audio.m
153+
sunshine/platform/macos/av_img_t.h
154+
sunshine/platform/macos/av_video.h
155+
sunshine/platform/macos/av_video.m
156+
sunshine/platform/macos/display.mm
157+
sunshine/platform/macos/input.cpp
158+
sunshine/platform/macos/microphone.mm
159+
sunshine/platform/macos/misc.cpp
160+
sunshine/platform/macos/misc.h
161+
sunshine/platform/macos/nv12_zero_device.cpp
162+
sunshine/platform/macos/nv12_zero_device.h
163+
sunshine/platform/macos/publish.cpp
164+
sunshine/platform/macos/TPCircularBuffer/TPCircularBuffer.c
165+
sunshine/platform/macos/TPCircularBuffer/TPCircularBuffer.h
166+
${CMAKE_CURRENT_SOURCE_DIR}/assets/Info.plist)
109167
else()
110168
add_compile_definitions(SUNSHINE_PLATFORM="linux")
111169
list(APPEND SUNSHINE_DEFINITIONS APPS_JSON="apps_linux.json")
@@ -255,6 +313,7 @@ else()
255313
set(SUNSHINE_EXECUTABLE_PATH "sunshine")
256314
endif()
257315
configure_file(gen-deb.in gen-deb @ONLY)
316+
configure_file(sunshine.desktop.in sunshine.desktop @ONLY)
258317
configure_file(sunshine.service.in sunshine.service @ONLY)
259318
endif()
260319

@@ -352,7 +411,6 @@ list(APPEND SUNSHINE_EXTERNAL_LIBRARIES
352411
libminiupnpc-static
353412
${CBS_EXTERNAL_LIBRARIES}
354413
${CMAKE_THREAD_LIBS_INIT}
355-
stdc++fs
356414
enet
357415
opus
358416
${FFMPEG_LIBRARIES}
@@ -368,7 +426,7 @@ list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_ASSETS_DIR="${SUNSHINE_ASSETS_DIR}")
368426
list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_CONFIG_DIR="${SUNSHINE_CONFIG_DIR}")
369427
list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_DEFAULT_DIR="${SUNSHINE_DEFAULT_DIR}")
370428
add_executable(sunshine ${SUNSHINE_TARGET_FILES})
371-
target_link_libraries(sunshine ${SUNSHINE_EXTERNAL_LIBRARIES})
429+
target_link_libraries(sunshine ${SUNSHINE_EXTERNAL_LIBRARIES} ${EXTRA_LIBS})
372430
target_compile_definitions(sunshine PUBLIC ${SUNSHINE_DEFINITIONS})
373431
set_target_properties(sunshine PROPERTIES CXX_STANDARD 17
374432
VERSION ${PROJECT_VERSION}
@@ -380,6 +438,10 @@ if(NOT DEFINED CMAKE_CUDA_STANDARD)
380438
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
381439
endif()
382440

441+
if(APPLE)
442+
target_link_options(sunshine PRIVATE LINKER:-sectcreate,__TEXT,__info_plist,${CMAKE_CURRENT_SOURCE_DIR}/assets/Info.plist)
443+
endif()
444+
383445
foreach(flag IN LISTS SUNSHINE_COMPILE_OPTIONS)
384446
list(APPEND SUNSHINE_COMPILE_OPTIONS_CUDA "$<$<COMPILE_LANGUAGE:CUDA>:--compiler-options=${flag}>")
385447
endforeach()

Portfile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2+
3+
PortSystem 1.0
4+
PortGroup cmake 1.1
5+
PortGroup github 1.0
6+
PortGroup boost 1.0
7+
8+
github.setup abusse sunshine macos-dev
9+
version 20220224
10+
11+
categories multimedia
12+
platforms darwin
13+
license GPL-2
14+
maintainers {outlook.com:anselm.busse}
15+
16+
fetch.type git
17+
post-fetch {
18+
system -W ${worksrcpath} "${git.cmd} submodule update --init --recursive"
19+
}
20+
21+
description Sunshine is a Gamestream host for Moonlight
22+
long_description Sunshine is a Gamestream host for Moonlight
23+
24+
homepage https://github.com/SunshineStream/Sunshine
25+
26+
depends_lib port:avahi port:ffmpeg port:libopus
27+
28+
29+
boost.version 1.76
30+
31+
configure.args -DBOOST_ROOT=[boost::install_area] \
32+
-DSUNSHINE_ASSETS_DIR=${prefix}/etc/sunshine
33+
34+
cmake.out_of_source yes
35+
36+
destroot {
37+
xinstall -d -m 755 ${destroot}${prefix}/etc/${name}
38+
xinstall ${worksrcpath}/assets/apps_mac.json ${destroot}${prefix}/etc/${name}
39+
xinstall ${worksrcpath}/assets/box.png ${destroot}${prefix}/etc/${name}
40+
xinstall ${worksrcpath}/assets/sunshine.conf ${destroot}${prefix}/etc/${name}
41+
42+
xinstall -d -m 755 ${destroot}${prefix}/etc/${name}/web
43+
xinstall {*}[glob ${worksrcpath}/assets/web/*.html] ${destroot}${prefix}/etc/${name}/web
44+
xinstall -d -m 755 ${destroot}${prefix}/etc/${name}/web/third_party
45+
xinstall {*}[glob ${worksrcpath}/assets/web/third_party/*] ${destroot}${prefix}/etc/${name}/web/third_party
46+
47+
xinstall ${workpath}/build/${name} ${destroot}${prefix}/bin
48+
}

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Sunshine is a Gamestream host for Moonlight
1010

1111
# Building
1212
- [Linux](README.md#linux)
13+
- [MacOS](README.md#macos)
1314
- [Windows](README.md#windows-10)
1415

1516
## Linux
@@ -108,6 +109,53 @@ It's necessary to allow Sunshine to use KMS
108109
- If you use hardware acceleration on Linux using an Intel or an AMD GPU (with VAAPI), you will get tons of [graphical issues](https://github.com/loki-47-6F-64/sunshine/issues/228) if your ffmpeg version is < 4.3. If it is not available in your distribution's repositories, consider using a newer version of your distribution.
109110
- Ubuntu started to ship ffmpeg 4.3 starting with groovy (20.10). If you're using an older version, you could use [this PPA](https://launchpad.net/%7Esavoury1/+archive/ubuntu/ffmpeg4) instead of upgrading. **Using PPAs is dangerous and may break your system. Use it at your own risk.**
110111

112+
## macOS
113+
114+
### Quickstart
115+
116+
- Install [MacPorts](https://www.macports.org)
117+
- Download the `Portfile` from this repository to `/tmp`
118+
- In a Terminal run `cd /tmp && sudo port install`
119+
- Sunshine configuration is in `/opt/local/etc`
120+
- Run `sunshine` to start the Sunshine server
121+
- You will be asked to grant access to screen recording and your microphone to be able to stream it
122+
123+
### Manuel Build
124+
125+
#### Requirements:
126+
macOS Big Sur and Xcode 12.5+:
127+
128+
Either, using [MacPorts](https://www.macports.org), install the following
129+
```
130+
sudo port install cmake boost libopus ffmpeg
131+
```
132+
133+
Or, using [Homebrew](https://brew.sh), install the follwoing:
134+
```
135+
brew install boost cmake ffmpeg libopusenc
136+
# if there are issues with an SSL header that is not found:
137+
cd /usr/local/include
138+
ln -s ../opt/openssl/include/openssl .
139+
```
140+
141+
#### Compilation:
142+
- `git clone https://github.com/SunshineStream/Sunshine.git --recurse-submodules`
143+
- `cd sunshine && mkdir build && cd build`
144+
- `cmake ..`
145+
- `make -j ${nproc}`
146+
147+
If cmake fails complaining to find Boost, try to set the path explicitly: `cmake -DBOOST_ROOT=[boost path] ..`, e.g., `cmake -DBOOST_ROOT=/opt/local/libexec/boost/1.76 ..`
148+
149+
### Setup:
150+
- Sunshine can only access microphones on macOS due to system limitations. To stream system audio use [Soundflower](https://github.com/mattingalls/Soundflower) or [BlackHole](https://github.com/ExistentialAudio/BlackHole) and select their sink as audio device in `sunshine.conf`
151+
- `assets/sunshine.conf` is an example configuration file. Modify it as you see fit, then use it by running:
152+
`sunshine path/to/sunshine.conf`
153+
- `assets/apps.json` is an [example](README.md#application-list) of a list of applications that are started just before running a stream
154+
155+
### Usage & Limitations:
156+
- Command Keys are not forwarded by Moonlight. Right Option-Key is mapped to CMD-Key.
157+
- Gamepads are not supported
158+
111159
## Windows 10
112160

113161
### Requirements:

assets/apps_mac.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"env":{
3+
"PATH":"$(PATH):$(HOME)/.local/bin"
4+
},
5+
"apps":[ ]
6+
}

assets/info.plist

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleIdentifier</key>
6+
<string>com.github.sunshinestream.sunshine</string>
7+
<key>CFBundleName</key>
8+
<string>Sunshine</string>
9+
<key>NSMicrophoneUsageDescription</key>
10+
<string>This app requires access to your microphone to stream audio.</string>
11+
</dict>
12+
</plist>

0 commit comments

Comments
 (0)