Initial support for MacOS

This commit introduces initial support for MacOS as third major host platform.
It relies on the VideoToolbox framework for audio and video processing, which
enables hardware accelerated processing of the stream on most platforms.
Audio capturing requires third party tools as MacOS does not offer the
recording of the audio output like the other platforms do. The commit enables
most features offered by Sunshine for MacOS with the big exception of gamepad
support. The patch sets was tested by a few volunteers, which allowed to remove
some of the early bugs. However, several bugs especially regarding corner
cases have probably not surfaced yet.

Besides instructions how to build from source, the commit also adds a Portfile
that allows a more easy installation. After available on the release branch,
a pull request for the Portfile in the MacPorts project is planned.

Signed-off-by: Anselm Busse <anselm.busse@outlook.com>
This commit is contained in:
Anselm Busse
2022-02-24 21:09:00 +01:00
parent df3e7c5ca1
commit 2b450839a1
27 changed files with 2191 additions and 4 deletions

6
assets/apps_mac.json Normal file
View File

@@ -0,0 +1,6 @@
{
"env":{
"PATH":"$(PATH):$(HOME)/.local/bin"
},
"apps":[ ]
}

12
assets/info.plist Normal file
View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>com.github.sunshinestream.sunshine</string>
<key>CFBundleName</key>
<string>Sunshine</string>
<key>NSMicrophoneUsageDescription</key>
<string>This app requires access to your microphone to stream audio.</string>
</dict>
</plist>

View File

@@ -155,6 +155,10 @@
# to stream audio, while muting the speakers.
# virtual_sink = {0.0.0.00000000}.{8edba70c-1125-467c-b89c-15da389bc1d4}
#
# !! MacOS only !!
# audio_sink = BlackHole 2ch
# !! Windows only !!
# You can select the video card you want to stream:
# The appropriate values can be found using the following command:
@@ -279,6 +283,30 @@
# VAProfileH264High : VAEntrypointEncSlice
# adapter_name = /dev/dri/renderD128
################################# VideoToolbox ###############################
####### software encoding ##########
# Video Toolbox can be allowed/required to use software encoding instead of
# hardware accelerated encoding.
# auto -- let sunshine decide on encoding
# disabled -- disable software encoding
# allowed -- allow software encoding
# forced -- force software encoding
##########################
# vt_software = auto
#
####### realtime encoding ##########
# Disabling realtime encoding might result in a delayed frame encoding or frame drop
##########################
# vt_realtime = enabled
#
###### h264/hevc entropy ######
# auto -- let ffmpeg decide the entropy encoding
# cabac
# cavlc
##########################
# vt_coder = auto
##############################################
# Some configurable parameters, are merely toggles for specific features
# The first occurrence turns it on, the second occurence turns it off, the third occurence turns it on again, etc, etc

View File

@@ -712,6 +712,34 @@
v-model="config.adapter_name"
/>
</div>
<!--VideoToolbox Encoder Settings-->
<div v-if="currentTab === 'vt'" class="config-page">
<!--Presets-->
<div class="mb-3">
<label for="vt_coder" class="form-label">VideoToolbox Coder</label>
<select id="vt_coder" class="form-select" v-model="config.vt_coder">
<option value="auto">auto</option>
<option value="cabac">cabac</option>
<option value="cavlc">cavlc</option>
</select>
</div>
<div class="mb-3">
<label for="vt_software" class="form-label">VideoToolbox Software Encoding</label>
<select id="vt_software" class="form-select" v-model="config.vt_software">
<option value="auto">auto</option>
<option value="disabled">disabled</option>
<option value="allowed">allowed</option>
<option value="forced">forced</option>
</select>
</div>
<div class="mb-3">
<label for="vt_realtime" class="form-label">VideoToolbox Realtime Encoding</label>
<select id="vt_realtime" class="form-select" v-model="config.vt_realtime">
<option value="enabled">enabled</option>
<option value="disabled">disabled</option>
</select>
</div>
</div>
</div>
<div class="alert alert-success my-4" v-if="success">
<b>Success!</b> Restart Sunshine to apply changes
@@ -771,6 +799,10 @@
id: "va-api",
name: "VA-API encoder",
},
{
id: "vt",
name: "VideoToolbox encoder",
},
],
};
},
@@ -812,6 +844,9 @@
this.config.nv_coder = this.config.nv_coder || "auto";
this.config.amd_quality = this.config.amd_quality || "default";
this.config.amd_rc = this.config.amd_rc || "auto";
this.config.vt_coder = this.config.vt_coder || "auto";
this.config.vt_software = this.config.vt_software || "auto";
this.config.vt_realtime = this.config.vt_realtime || "enabled";
this.config.fps = this.config.fps || "[10, 30, 60, 90, 120]";
this.config.resolutions =
this.config.resolutions ||