diff --git a/sdk/objc/Framework/Classes/Common/UIDevice+RTCDevice.mm b/sdk/objc/Framework/Classes/Common/UIDevice+RTCDevice.mm index 94faf53506..01905d99eb 100644 --- a/sdk/objc/Framework/Classes/Common/UIDevice+RTCDevice.mm +++ b/sdk/objc/Framework/Classes/Common/UIDevice+RTCDevice.mm @@ -173,4 +173,8 @@ return [self currentDeviceSystemVersion] >= 9.0; } ++ (BOOL)isIOS11OrLater { + return [self currentDeviceSystemVersion] >= 11.0; +} + @end diff --git a/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoDecoderH264.mm b/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoDecoderH264.mm index 6e000ab747..4cf48bd9c4 100644 --- a/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoDecoderH264.mm +++ b/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoDecoderH264.mm @@ -25,6 +25,7 @@ #if defined(WEBRTC_IOS) #import "Common/RTCUIApplicationStatusObserver.h" +#import "WebRTC/UIDevice+RTCDevice.h" #endif // Struct that we pass to the decoder per frame to decode. We receive it again @@ -236,6 +237,11 @@ void decompressionOutputCallback(void *decoder, - (void)destroyDecompressionSession { if (_decompressionSession) { +#if defined(WEBRTC_IOS) + if ([UIDevice isIOS11OrLater]) { + VTDecompressionSessionWaitForAsynchronousFrames(_decompressionSession); + } +#endif VTDecompressionSessionInvalidate(_decompressionSession); CFRelease(_decompressionSession); _decompressionSession = nullptr; diff --git a/sdk/objc/Framework/Headers/WebRTC/UIDevice+RTCDevice.h b/sdk/objc/Framework/Headers/WebRTC/UIDevice+RTCDevice.h index 29e4801b2e..7e01c47f39 100644 --- a/sdk/objc/Framework/Headers/WebRTC/UIDevice+RTCDevice.h +++ b/sdk/objc/Framework/Headers/WebRTC/UIDevice+RTCDevice.h @@ -60,5 +60,6 @@ typedef NS_ENUM(NSInteger, RTCDeviceType) { + (RTCDeviceType)deviceType; + (NSString *)stringForDeviceType:(RTCDeviceType)deviceType; + (BOOL)isIOS9OrLater; ++ (BOOL)isIOS11OrLater; @end