diff --git a/AUTHORS b/AUTHORS index e7592cf887..cfff3f50c8 100644 --- a/AUTHORS +++ b/AUTHORS @@ -186,6 +186,7 @@ The WebRTC Authors <*@webrtc.org> Threema GmbH <*@threema.ch> Tuple, LLC <*@tuple.app> Twilio, Inc. <*@twilio.com> +Twitch Interactive, Inc. <*@justin.tv> Vewd Software AS <*@vewd.com> Videona Socialmedia <*@videona.com> Videxio AS <*@videxio.com> diff --git a/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm b/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm index 2160d79ae5..6f5afb17ba 100644 --- a/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm +++ b/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm @@ -585,24 +585,26 @@ NSUInteger GetMaxSampleRate(const webrtc::H264ProfileLevelId &profile_level_id) CVPixelBufferPoolRef pixelBufferPool = VTCompressionSessionGetPixelBufferPool(_compressionSession); if (!pixelBufferPool) { - return NO; - } - - NSDictionary *poolAttributes = - (__bridge NSDictionary *)CVPixelBufferPoolGetPixelBufferAttributes(pixelBufferPool); - id pixelFormats = - [poolAttributes objectForKey:(__bridge NSString *)kCVPixelBufferPixelFormatTypeKey]; - NSArray *compressionSessionPixelFormats = nil; - if ([pixelFormats isKindOfClass:[NSArray class]]) { - compressionSessionPixelFormats = (NSArray *)pixelFormats; - } else if ([pixelFormats isKindOfClass:[NSNumber class]]) { - compressionSessionPixelFormats = @[ (NSNumber *)pixelFormats ]; - } - - if (![compressionSessionPixelFormats - containsObject:[NSNumber numberWithLong:framePixelFormat]]) { + // If we have a compression session but can't acquire the pixel buffer pool, we're in an + // invalid state and should reset. resetCompressionSession = YES; - RTC_LOG(LS_INFO) << "Resetting compression session due to non-matching pixel format."; + } else { + NSDictionary *poolAttributes = + (__bridge NSDictionary *)CVPixelBufferPoolGetPixelBufferAttributes(pixelBufferPool); + id pixelFormats = + [poolAttributes objectForKey:(__bridge NSString *)kCVPixelBufferPixelFormatTypeKey]; + NSArray *compressionSessionPixelFormats = nil; + if ([pixelFormats isKindOfClass:[NSArray class]]) { + compressionSessionPixelFormats = (NSArray *)pixelFormats; + } else if ([pixelFormats isKindOfClass:[NSNumber class]]) { + compressionSessionPixelFormats = @[ (NSNumber *)pixelFormats ]; + } + + if (![compressionSessionPixelFormats + containsObject:[NSNumber numberWithLong:framePixelFormat]]) { + resetCompressionSession = YES; + RTC_LOG(LS_INFO) << "Resetting compression session due to non-matching pixel format."; + } } } else { resetCompressionSession = YES;