Allow negotiation of audio encryption using new encryption flags

This commit is contained in:
Cameron Gutman 2024-01-14 14:10:45 -06:00
parent b74b6e883c
commit 06f18be4bf
2 changed files with 14 additions and 2 deletions

View File

@ -47,6 +47,7 @@ extern uint32_t SunshineFeatureFlags;
// Encryption flags shared by Sunshine and Moonlight in RTSP
#define SS_ENC_CONTROL_V2 0x01
#define SS_ENC_VIDEO 0x02
#define SS_ENC_AUDIO 0x04
extern uint32_t EncryptionFeaturesSupported;
extern uint32_t EncryptionFeaturesRequested;

View File

@ -190,8 +190,8 @@ static int addGen5Options(PSDP_OPTION* head) {
// RI encryption is always enabled
featureFlags = NVFF_BASE | NVFF_RI_ENCRYPTION;
// Enable audio encryption if the client opted in
if (StreamConfig.encryptionFlags & ENCFLG_AUDIO) {
// Enable audio encryption if the client opted in or the host required it
if ((StreamConfig.encryptionFlags & ENCFLG_AUDIO) || (EncryptionFeaturesEnabled & SS_ENC_AUDIO)) {
featureFlags |= NVFF_AUDIO_ENCRYPTION;
AudioEncryptionEnabled = true;
}
@ -288,6 +288,17 @@ static PSDP_OPTION getAttributesList(char*urlSafeAddr) {
EncryptionFeaturesEnabled |= SS_ENC_VIDEO;
}
// If audio encryption is supported by the host and desired by the client, use it
if ((EncryptionFeaturesSupported & SS_ENC_AUDIO) && (StreamConfig.encryptionFlags & ENCFLG_AUDIO)) {
EncryptionFeaturesEnabled |= SS_ENC_AUDIO;
}
else if ((EncryptionFeaturesRequested & SS_ENC_AUDIO) && !(StreamConfig.encryptionFlags & ENCFLG_AUDIO)) {
// If audio encryption is explicitly requested by the host but *not* by the client,
// we'll encrypt anyway (since we are capable of doing so) and print a warning.
Limelog("Enabling audio encryption by host request despite client opt-out. Audio quality may suffer!");
EncryptionFeaturesEnabled |= SS_ENC_AUDIO;
}
snprintf(payloadStr, sizeof(payloadStr), "%u", EncryptionFeaturesEnabled);
err |= addAttributeString(&optionHead, "x-ss-general.encryptionEnabled", payloadStr);
}