diff --git a/src/Limelight-internal.h b/src/Limelight-internal.h index 40443fc..cd3f63b 100644 --- a/src/Limelight-internal.h +++ b/src/Limelight-internal.h @@ -76,6 +76,7 @@ extern SS_PING VideoPingPayload; int serviceEnetHost(ENetHost* client, ENetEvent* event, enet_uint32 timeoutMs); int gracefullyDisconnectEnetPeer(ENetHost* host, ENetPeer* peer, enet_uint32 lingerTimeoutMs); int extractVersionQuadFromString(const char* string, int* quad); +bool isReferenceFrameInvalidationSupportedByDecoder(void); bool isReferenceFrameInvalidationEnabled(void); void* extendBuffer(void* ptr, size_t newSize); diff --git a/src/Misc.c b/src/Misc.c index 5749219..43c0f55 100644 --- a/src/Misc.c +++ b/src/Misc.c @@ -119,18 +119,18 @@ void* extendBuffer(void* ptr, size_t newSize) { return newBuf; } -bool isReferenceFrameInvalidationEnabled(void) { +bool isReferenceFrameInvalidationSupportedByDecoder(void) { LC_ASSERT(NegotiatedVideoFormat != 0); - // Even if the client wants it, we can't enable it without server support. - if (!ReferenceFrameInvalidationSupported) { - return false; - } - return ((NegotiatedVideoFormat & VIDEO_FORMAT_MASK_H264) && (VideoCallbacks.capabilities & CAPABILITY_REFERENCE_FRAME_INVALIDATION_AVC)) || ((NegotiatedVideoFormat & VIDEO_FORMAT_MASK_H265) && (VideoCallbacks.capabilities & CAPABILITY_REFERENCE_FRAME_INVALIDATION_HEVC)); } +bool isReferenceFrameInvalidationEnabled(void) { + // RFI must be supported by the server and the client decoder to be used + return ReferenceFrameInvalidationSupported && isReferenceFrameInvalidationSupportedByDecoder(); +} + void LiInitializeStreamConfiguration(PSTREAM_CONFIGURATION streamConfig) { memset(streamConfig, 0, sizeof(*streamConfig)); } diff --git a/src/SdpGenerator.c b/src/SdpGenerator.c index 4a848ed..5821581 100644 --- a/src/SdpGenerator.c +++ b/src/SdpGenerator.c @@ -386,7 +386,11 @@ static PSDP_OPTION getAttributesList(char*urlSafeAddr) { } if (AppVersionQuad[0] >= 7) { - if (isReferenceFrameInvalidationEnabled()) { + // If the decoder supports reference frame invalidation, that indicates it also supports + // the maximum number of reference frames allowed by the codec. Even if we can't use RFI + // due to lack of host support, we can still allow the host to pick a number of reference + // frames greater than 1 to improve encoding efficiency. + if (isReferenceFrameInvalidationSupportedByDecoder()) { err |= addAttributeString(&optionHead, "x-nv-video[0].maxNumReferenceFrames", "0"); } else {