diff --git a/src/Limelight-internal.h b/src/Limelight-internal.h index cee74cd..dfd4758 100644 --- a/src/Limelight-internal.h +++ b/src/Limelight-internal.h @@ -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; diff --git a/src/SdpGenerator.c b/src/SdpGenerator.c index db3262d..831856c 100644 --- a/src/SdpGenerator.c +++ b/src/SdpGenerator.c @@ -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); }