diff --git a/src/ControlStream.c b/src/ControlStream.c index b11119b..5ad111b 100644 --- a/src/ControlStream.c +++ b/src/ControlStream.c @@ -203,7 +203,8 @@ int getNextFrameInvalidationTuple(PQUEUED_FRAME_INVALIDATION_TUPLE* qfit) { } void queueFrameInvalidationTuple(int startFrame, int endFrame) { - if (VideoCallbacks.capabilities & CAPABILITY_REFERENCE_FRAME_INVALIDATION) { + if ((NegotiatedVideoFormat == VIDEO_FORMAT_H264 && (VideoCallbacks.capabilities & CAPABILITY_REFERENCE_FRAME_INVALIDATION_AVC)) || + ((NegotiatedVideoFormat == VIDEO_FORMAT_H265 && (VideoCallbacks.capabilities & CAPABILITY_REFERENCE_FRAME_INVALIDATION_HEVC)))) { PQUEUED_FRAME_INVALIDATION_TUPLE qfit; qfit = malloc(sizeof(*qfit)); if (qfit != NULL) { diff --git a/src/Limelight.h b/src/Limelight.h index 6f6eba7..609c808 100644 --- a/src/Limelight.h +++ b/src/Limelight.h @@ -86,10 +86,15 @@ typedef struct _DECODE_UNIT { // renderer is non-blocking. This flag is valid on both audio and video renderers. #define CAPABILITY_DIRECT_SUBMIT 0x1 -// !!! HIGHLY EXPERIMENTAL - DO NOT SET IN PRODUCTION CODE !!! // If set in the video renderer capabilities field, this flag specifies that the renderer -// supports reference frame invalidation. This flag is only valid on video renderers. -#define CAPABILITY_REFERENCE_FRAME_INVALIDATION 0x2 +// supports reference frame invalidation for AVC/H.264 streams. This flag is only valid on video renderers. +// If using this feature, the bitstream may not be patched (changing num_ref_frames or max_dec_frame_buffering) +// to avoid video corruption on packet loss. +#define CAPABILITY_REFERENCE_FRAME_INVALIDATION_AVC 0x2 + +// If set in the video renderer capabilities field, this flag specifies that the renderer +// supports reference frame invalidation for HEVC/H.265 streams. This flag is only valid on video renderers. +#define CAPABILITY_REFERENCE_FRAME_INVALIDATION_HEVC 0x4 // If set in the video renderer capabilities field, this macro specifies that the renderer // supports slicing to increase decoding performance. The parameter specifies the desired diff --git a/src/VideoDepacketizer.c b/src/VideoDepacketizer.c index ca5905c..b337330 100644 --- a/src/VideoDepacketizer.c +++ b/src/VideoDepacketizer.c @@ -43,7 +43,11 @@ void initializeVideoDepacketizer(int pktSize) { gotNextFrameStart = 0; lastPacketInStream = -1; decodingFrame = 0; - strictIdrFrameWait = !(VideoCallbacks.capabilities & CAPABILITY_REFERENCE_FRAME_INVALIDATION); + + LC_ASSERT(NegotiatedVideoFormat != 0); + strictIdrFrameWait = + !((NegotiatedVideoFormat == VIDEO_FORMAT_H264 && (VideoCallbacks.capabilities & CAPABILITY_REFERENCE_FRAME_INVALIDATION_AVC)) || + ((NegotiatedVideoFormat == VIDEO_FORMAT_H265 && (VideoCallbacks.capabilities & CAPABILITY_REFERENCE_FRAME_INVALIDATION_HEVC)))); } // Free the NAL chain