diff --git a/examples/objc/AppRTCMobile/ARDAppEngineClient.m b/examples/objc/AppRTCMobile/ARDAppEngineClient.m index ad7a6c2bf2..dc883621e6 100644 --- a/examples/objc/AppRTCMobile/ARDAppEngineClient.m +++ b/examples/objc/AppRTCMobile/ARDAppEngineClient.m @@ -58,7 +58,6 @@ static NSInteger const kARDAppEngineClientErrorBadResponse = -1; __weak ARDAppEngineClient *weakSelf = self; [NSURLConnection sendAsyncRequest:request completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { - ARDAppEngineClient *strongSelf = weakSelf; if (error) { if (completionHandler) { completionHandler(nil, error); @@ -102,7 +101,6 @@ static NSInteger const kARDAppEngineClientErrorBadResponse = -1; completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { - ARDAppEngineClient *strongSelf = weakSelf; if (error) { if (completionHandler) { completionHandler(nil, error); diff --git a/examples/objc/AppRTCMobile/ARDCaptureController.m b/examples/objc/AppRTCMobile/ARDCaptureController.m index 6830e88c23..0145c17091 100644 --- a/examples/objc/AppRTCMobile/ARDCaptureController.m +++ b/examples/objc/AppRTCMobile/ARDCaptureController.m @@ -21,7 +21,7 @@ - (instancetype)initWithCapturer:(RTCCameraVideoCapturer *)capturer settings:(ARDSettingsModel *)settings { - if ([super init]) { + if (self = [super init]) { _capturer = capturer; _settings = settings; _usingFrontCamera = YES; diff --git a/examples/objc/AppRTCMobile/ARDSettingsModel.m b/examples/objc/AppRTCMobile/ARDSettingsModel.m index a4eea731d4..7d731fd4bf 100644 --- a/examples/objc/AppRTCMobile/ARDSettingsModel.m +++ b/examples/objc/AppRTCMobile/ARDSettingsModel.m @@ -168,8 +168,6 @@ NS_ASSUME_NONNULL_BEGIN } - (void)registerStoreDefaults { - NSString *defaultVideoResolutionSetting = [self defaultVideoResolutionSetting]; - NSData *codecData = [NSKeyedArchiver archivedDataWithRootObject:[self defaultVideoCodecSetting]]; [ARDSettingsStore setDefaultsForVideoResolution:[self defaultVideoResolutionSetting] videoCodec:codecData diff --git a/modules/video_capture/objc/rtc_video_capture_objc.mm b/modules/video_capture/objc/rtc_video_capture_objc.mm index bea9bb79ff..92bfd64fa3 100644 --- a/modules/video_capture/objc/rtc_video_capture_objc.mm +++ b/modules/video_capture/objc/rtc_video_capture_objc.mm @@ -42,7 +42,7 @@ using namespace webrtc::videocapturemodule; @synthesize frameRotation = _framRotation; - (id)initWithOwner:(VideoCaptureIos*)owner { - if (self == [super init]) { + if (self = [super init]) { _owner = owner; _captureSession = [[AVCaptureSession alloc] init]; #if defined(WEBRTC_IOS) diff --git a/sdk/objc/Framework/Classes/Common/RTCFileLogger.mm b/sdk/objc/Framework/Classes/Common/RTCFileLogger.mm index 15461f44fa..6acb942a3a 100644 --- a/sdk/objc/Framework/Classes/Common/RTCFileLogger.mm +++ b/sdk/objc/Framework/Classes/Common/RTCFileLogger.mm @@ -124,7 +124,7 @@ const char *kRTCFileLoggerRotatingLogPrefix = "rotating_log"; _logSink.reset(); } -- (NSData *)logData { +- (nullable NSData *)logData { if (_hasStarted) { return nil; } diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCAudioTrack.mm b/sdk/objc/Framework/Classes/PeerConnection/RTCAudioTrack.mm index fffbd7cfe5..e26088f59d 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCAudioTrack.mm +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCAudioTrack.mm @@ -31,7 +31,7 @@ std::string nativeId = [NSString stdStringForString:trackId]; rtc::scoped_refptr track = factory.nativeFactory->CreateAudioTrack(nativeId, source.nativeAudioSource); - if ([self initWithNativeTrack:track type:RTCMediaStreamTrackTypeAudio]) { + if (self = [self initWithNativeTrack:track type:RTCMediaStreamTrackTypeAudio]) { _source = source; } return self; diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCConfiguration+Private.h b/sdk/objc/Framework/Classes/PeerConnection/RTCConfiguration+Private.h index bf00d1870f..d9a991650b 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCConfiguration+Private.h +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCConfiguration+Private.h @@ -62,8 +62,7 @@ NS_ASSUME_NONNULL_BEGIN * RTCConfiguration struct representation of this RTCConfiguration. This is * needed to pass to the underlying C++ APIs. */ -- (webrtc::PeerConnectionInterface::RTCConfiguration *) - createNativeConfiguration; +- (nullable webrtc::PeerConnectionInterface::RTCConfiguration *)createNativeConfiguration; - (instancetype)initWithNativeConfiguration: (const webrtc::PeerConnectionInterface::RTCConfiguration &)config NS_DESIGNATED_INITIALIZER; diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCEncodedImage.mm b/sdk/objc/Framework/Classes/PeerConnection/RTCEncodedImage.mm index ef2840f157..467f225b58 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCEncodedImage.mm +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCEncodedImage.mm @@ -48,7 +48,7 @@ _frameType = static_cast(encodedImage._frameType); _rotation = static_cast(encodedImage.rotation_); _completeFrame = encodedImage._completeFrame; - _qp = encodedImage.qp_ == -1 ? nil : @(encodedImage.qp_); + _qp = @(encodedImage.qp_); _contentType = (encodedImage.content_type_ == webrtc::VideoContentType::SCREENSHARE) ? RTCVideoContentTypeScreenshare : RTCVideoContentTypeUnspecified; diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCFileVideoCapturer.m b/sdk/objc/Framework/Classes/PeerConnection/RTCFileVideoCapturer.m index 07cb2c6668..7e27bf2df3 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCFileVideoCapturer.m +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCFileVideoCapturer.m @@ -139,6 +139,7 @@ typedef NS_ENUM(NSInteger, RTCFileVideoCapturerStatus) { } if (CMSampleBufferGetNumSamples(sampleBuffer) != 1 || !CMSampleBufferIsValid(sampleBuffer) || !CMSampleBufferDataIsReady(sampleBuffer)) { + CFRelease(sampleBuffer); [self readNextBuffer]; return; } diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnection+DataChannel.mm b/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnection+DataChannel.mm index 80b510898c..d17d9ac2f4 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnection+DataChannel.mm +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnection+DataChannel.mm @@ -16,9 +16,8 @@ @implementation RTCPeerConnection (DataChannel) -- (RTCDataChannel *)dataChannelForLabel:(NSString *)label - configuration: - (RTCDataChannelConfiguration *)configuration { +- (nullable RTCDataChannel *)dataChannelForLabel:(NSString *)label + configuration:(RTCDataChannelConfiguration *)configuration { std::string labelString = [NSString stdStringForString:label]; const webrtc::DataChannelInit nativeInit = configuration.nativeDataChannelInit; diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCRtpReceiver.mm b/sdk/objc/Framework/Classes/PeerConnection/RTCRtpReceiver.mm index 0888f24b0a..cb2771a29c 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCRtpReceiver.mm +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCRtpReceiver.mm @@ -58,7 +58,7 @@ void RtpReceiverDelegateAdapter::OnFirstPacketReceived( } } -- (RTCMediaStreamTrack *)track { +- (nullable RTCMediaStreamTrack *)track { rtc::scoped_refptr nativeTrack( _nativeRtpReceiver->track()); if (nativeTrack) { diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCSessionDescription+Private.h b/sdk/objc/Framework/Classes/PeerConnection/RTCSessionDescription+Private.h index 5811a5abc5..4c58fa726a 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCSessionDescription+Private.h +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCSessionDescription+Private.h @@ -21,8 +21,7 @@ NS_ASSUME_NONNULL_BEGIN * RTCSessionDescription object. This is needed to pass to the underlying C++ * APIs. */ -@property(nonatomic, readonly) - webrtc::SessionDescriptionInterface *nativeDescription; +@property(nonatomic, readonly, nullable) webrtc::SessionDescriptionInterface *nativeDescription; /** * Initialize an RTCSessionDescription from a native diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCVideoTrack.mm b/sdk/objc/Framework/Classes/PeerConnection/RTCVideoTrack.mm index 9fa6111411..2f03110739 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCVideoTrack.mm +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCVideoTrack.mm @@ -32,7 +32,7 @@ rtc::scoped_refptr track = factory.nativeFactory->CreateVideoTrack(nativeId, source.nativeVideoSource); - if ([self initWithNativeTrack:track type:RTCMediaStreamTrackTypeVideo]) { + if (self = [self initWithNativeTrack:track type:RTCMediaStreamTrackTypeVideo]) { _source = source; } return self; diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCWrappedNativeVideoDecoder.mm b/sdk/objc/Framework/Classes/PeerConnection/RTCWrappedNativeVideoDecoder.mm index 7d82c5b8e3..7529ebf028 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCWrappedNativeVideoDecoder.mm +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCWrappedNativeVideoDecoder.mm @@ -49,7 +49,7 @@ - (NSInteger)decode:(RTCEncodedImage *)encodedImage missingFrames:(BOOL)missingFrames fragmentationHeader:(RTCRtpFragmentationHeader *)fragmentationHeader - codecSpecificInfo:(__nullable id)info + codecSpecificInfo:(nullable id)info renderTimeMs:(int64_t)renderTimeMs { RTC_NOTREACHED(); return 0; diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCWrappedNativeVideoEncoder.mm b/sdk/objc/Framework/Classes/PeerConnection/RTCWrappedNativeVideoEncoder.mm index 9d2f81b3cc..8988e6d76e 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCWrappedNativeVideoEncoder.mm +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCWrappedNativeVideoEncoder.mm @@ -47,7 +47,7 @@ } - (NSInteger)encode:(RTCVideoFrame *)frame - codecSpecificInfo:(id)info + codecSpecificInfo:(nullable id)info frameTypes:(NSArray *)frameTypes { RTC_NOTREACHED(); return 0; diff --git a/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoDecoderH264.mm b/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoDecoderH264.mm index debd504790..2f4b6bd72c 100644 --- a/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoDecoderH264.mm +++ b/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoDecoderH264.mm @@ -22,6 +22,7 @@ #import "WebRTC/RTCVideoFrame.h" #import "WebRTC/RTCVideoFrameBuffer.h" #import "helpers.h" +#import "scoped_cftyperef.h" #if defined(WEBRTC_IOS) #import "Common/RTCUIApplicationStatusObserver.h" @@ -99,7 +100,7 @@ void decompressionOutputCallback(void *decoderRef, - (NSInteger)decode:(RTCEncodedImage *)inputImage missingFrames:(BOOL)missingFrames fragmentationHeader:(RTCRtpFragmentationHeader *)fragmentationHeader - codecSpecificInfo:(__nullable id)info + codecSpecificInfo:(nullable id)info renderTimeMs:(int64_t)renderTimeMs { RTC_DCHECK(inputImage.buffer); @@ -119,19 +120,22 @@ void decompressionOutputCallback(void *decoderRef, return WEBRTC_VIDEO_CODEC_NO_OUTPUT; } #endif - CMVideoFormatDescriptionRef inputFormat = nullptr; if (webrtc::H264AnnexBBufferHasVideoFormatDescription((uint8_t *)inputImage.buffer.bytes, inputImage.buffer.length)) { - inputFormat = webrtc::CreateVideoFormatDescription((uint8_t *)inputImage.buffer.bytes, - inputImage.buffer.length); + rtc::ScopedCFTypeRef inputFormat = + rtc::ScopedCF(webrtc::CreateVideoFormatDescription((uint8_t *)inputImage.buffer.bytes, + inputImage.buffer.length)); if (inputFormat) { // Check if the video format has changed, and reinitialize decoder if // needed. - if (!CMFormatDescriptionEqual(inputFormat, _videoFormat)) { - [self setVideoFormat:inputFormat]; - [self resetDecompressionSession]; + if (!CMFormatDescriptionEqual(inputFormat.get(), _videoFormat)) { + [self setVideoFormat:inputFormat.get()]; + + int resetDecompressionSessionError = [self resetDecompressionSession]; + if (resetDecompressionSessionError != WEBRTC_VIDEO_CODEC_OK) { + return resetDecompressionSessionError; + } } - CFRelease(inputFormat); } } if (!_videoFormat) { diff --git a/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm b/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm index 86855a293c..a818c27d1e 100644 --- a/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm +++ b/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm @@ -340,7 +340,7 @@ CFStringRef ExtractProfile(webrtc::SdpVideoFormat videoFormat) { } - (NSInteger)encode:(RTCVideoFrame *)frame - codecSpecificInfo:(id)codecSpecificInfo + codecSpecificInfo:(nullable id)codecSpecificInfo frameTypes:(NSArray *)frameTypes { RTC_DCHECK_EQ(frame.width, _width); RTC_DCHECK_EQ(frame.height, _height); diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCFileLogger.h b/sdk/objc/Framework/Headers/WebRTC/RTCFileLogger.h index 5656b7bf43..1e8a591b73 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCFileLogger.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCFileLogger.h @@ -69,7 +69,7 @@ RTC_EXPORT // Returns the current contents of the logs, or nil if start has been called // without a stop. -- (NSData *)logData; +- (nullable NSData *)logData; @end diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCPeerConnection.h b/sdk/objc/Framework/Headers/WebRTC/RTCPeerConnection.h index 7b0c4492f4..a4c113b1d6 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCPeerConnection.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCPeerConnection.h @@ -212,8 +212,8 @@ RTC_EXPORT @interface RTCPeerConnection (DataChannel) /** Create a new data channel with the given label and configuration. */ -- (RTCDataChannel *)dataChannelForLabel:(NSString *)label - configuration:(RTCDataChannelConfiguration *)configuration; +- (nullable RTCDataChannel *)dataChannelForLabel:(NSString *)label + configuration:(RTCDataChannelConfiguration *)configuration; @end diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCRtpReceiver.h b/sdk/objc/Framework/Headers/WebRTC/RTCRtpReceiver.h index 6c39a25310..6156db9f93 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCRtpReceiver.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCRtpReceiver.h @@ -65,7 +65,7 @@ RTC_EXPORT * RTCMediaStreamTrack. Use isEqual: instead of == to compare * RTCMediaStreamTrack instances. */ -@property(nonatomic, readonly) RTCMediaStreamTrack *track; +@property(nonatomic, readonly, nullable) RTCMediaStreamTrack *track; /** The delegate for this RtpReceiver. */ @property(nonatomic, weak) id delegate; diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCVideoCodec.h b/sdk/objc/Framework/Headers/WebRTC/RTCVideoCodec.h index ab17ce4fc8..470eb02326 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCVideoCodec.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCVideoCodec.h @@ -148,7 +148,7 @@ RTC_EXPORT numberOfCores:(int)numberOfCores; - (NSInteger)releaseEncoder; - (NSInteger)encode:(RTCVideoFrame *)frame - codecSpecificInfo:(id)info + codecSpecificInfo:(nullable id)info frameTypes:(NSArray *)frameTypes; - (int)setBitrate:(uint32_t)bitrateKbit framerate:(uint32_t)framerate; - (NSString *)implementationName; @@ -171,7 +171,7 @@ RTC_EXPORT - (NSInteger)decode:(RTCEncodedImage *)encodedImage missingFrames:(BOOL)missingFrames fragmentationHeader:(RTCRtpFragmentationHeader *)fragmentationHeader - codecSpecificInfo:(__nullable id)info + codecSpecificInfo:(nullable id)info renderTimeMs:(int64_t)renderTimeMs; - (NSString *)implementationName; diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCVideoCodecFactory.h b/sdk/objc/Framework/Headers/WebRTC/RTCVideoCodecFactory.h index c77593ff97..0ef2c8a655 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCVideoCodecFactory.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCVideoCodecFactory.h @@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN RTC_EXPORT @protocol RTCVideoEncoderFactory -- (id)createEncoder:(RTCVideoCodecInfo *)info; +- (nullable id)createEncoder:(RTCVideoCodecInfo *)info; - (NSArray *)supportedCodecs; // TODO(andersc): "supportedFormats" instead? @end @@ -28,7 +28,7 @@ RTC_EXPORT RTC_EXPORT @protocol RTCVideoDecoderFactory -- (id)createDecoder:(RTCVideoCodecInfo *)info; +- (nullable id)createDecoder:(RTCVideoCodecInfo *)info; - (NSArray *)supportedCodecs; // TODO(andersc): "supportedFormats" instead? @end