From e9513029278f0ce9e7b32d3523afaadbac379399 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 6 Oct 2022 20:01:40 -0500 Subject: [PATCH] Disable RFI when streaming from a server that doesn't support it --- src/Connection.c | 1 + src/Limelight-internal.h | 1 + src/Misc.c | 6 ++++++ src/RtspConnection.c | 6 ++++++ 4 files changed, 14 insertions(+) diff --git a/src/Connection.c b/src/Connection.c index fb08ab8..1998641 100644 --- a/src/Connection.c +++ b/src/Connection.c @@ -24,6 +24,7 @@ OPUS_MULTISTREAM_CONFIGURATION HighQualityOpusConfig; int OriginalVideoBitrate; int AudioPacketDuration; bool AudioEncryptionEnabled; +bool ReferenceFrameInvalidationSupported; uint16_t RtspPortNumber; uint16_t ControlPortNumber; uint16_t AudioPortNumber; diff --git a/src/Limelight-internal.h b/src/Limelight-internal.h index 0fc6181..6770689 100644 --- a/src/Limelight-internal.h +++ b/src/Limelight-internal.h @@ -31,6 +31,7 @@ extern OPUS_MULTISTREAM_CONFIGURATION HighQualityOpusConfig; extern int OriginalVideoBitrate; extern int AudioPacketDuration; extern bool AudioEncryptionEnabled; +extern bool ReferenceFrameInvalidationSupported; extern uint16_t RtspPortNumber; extern uint16_t ControlPortNumber; diff --git a/src/Misc.c b/src/Misc.c index 4c43af0..5749219 100644 --- a/src/Misc.c +++ b/src/Misc.c @@ -121,6 +121,12 @@ void* extendBuffer(void* ptr, size_t newSize) { bool isReferenceFrameInvalidationEnabled(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)); } diff --git a/src/RtspConnection.c b/src/RtspConnection.c index 71f2517..cceaa12 100644 --- a/src/RtspConnection.c +++ b/src/RtspConnection.c @@ -806,6 +806,12 @@ int performRtspHandshake(void) { } } + // Look for the SDP attribute that indicates we're dealing with a server that supports RFI + ReferenceFrameInvalidationSupported = strstr(response.payload, "x-nv-video[0].refPicInvalidation") != NULL; + if (!ReferenceFrameInvalidationSupported) { + Limelog("Reference frame invalidation is not supported by this host\n"); + } + // Parse the Opus surround parameters out of the RTSP DESCRIBE response. ret = parseOpusConfigurations(&response); if (ret != 0) {