From d140c8f43bc43257b534281c1dcaee26f7e26ecb Mon Sep 17 00:00:00 2001 From: Yura Yaroshevich Date: Tue, 2 Mar 2021 23:25:10 +0300 Subject: [PATCH] Added missing nullable annotations to iOS SDK. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some of the PCF and PC methods are actually return nil, but was by default annotated as nonnull via NS_ASSUME_NONNULL_BEGIN. Bug: None No-Presubmit: True Change-Id: Ib8b9263452a61241c9e7a16c1807d87bd597c093 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/209180 Commit-Queue: Yura Yaroshevich Reviewed-by: Kári Helgason Cr-Commit-Position: refs/heads/master@{#33384} --- .../RTCPeerConnection+Private.h | 21 +++++------ .../api/peerconnection/RTCPeerConnection.h | 16 ++++----- .../api/peerconnection/RTCPeerConnection.mm | 36 +++++++++---------- .../RTCPeerConnectionFactory+Native.h | 2 +- .../peerconnection/RTCPeerConnectionFactory.h | 2 +- .../RTCPeerConnectionFactory.mm | 4 +-- .../capturer/RTCCameraVideoCapturer.h | 2 +- .../capturer/RTCCameraVideoCapturer.m | 2 +- 8 files changed, 43 insertions(+), 42 deletions(-) diff --git a/sdk/objc/api/peerconnection/RTCPeerConnection+Private.h b/sdk/objc/api/peerconnection/RTCPeerConnection+Private.h index 735881025a..558cf07dce 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnection+Private.h +++ b/sdk/objc/api/peerconnection/RTCPeerConnection+Private.h @@ -77,20 +77,21 @@ class PeerConnectionDelegateAdapter : public PeerConnectionObserver { /** Initialize an RTCPeerConnection with a configuration, constraints, and * delegate. */ -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory - configuration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration - constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints - delegate:(nullable id)delegate; +- (nullable instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory + configuration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration + constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints + delegate: + (nullable id)delegate; /** Initialize an RTCPeerConnection with a configuration, constraints, * delegate and PeerConnectionDependencies. */ -- (instancetype)initWithDependencies:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory - configuration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration - constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints - dependencies: - (std::unique_ptr)dependencies - delegate:(nullable id)delegate +- (nullable instancetype) + initWithDependencies:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory + configuration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration + constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints + dependencies:(std::unique_ptr)dependencies + delegate:(nullable id)delegate NS_DESIGNATED_INITIALIZER; + (webrtc::PeerConnectionInterface::SignalingState)nativeSignalingStateForState: diff --git a/sdk/objc/api/peerconnection/RTCPeerConnection.h b/sdk/objc/api/peerconnection/RTCPeerConnection.h index bb8d87bc2d..a332b2e1d5 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnection.h +++ b/sdk/objc/api/peerconnection/RTCPeerConnection.h @@ -238,8 +238,8 @@ RTC_OBJC_EXPORT * - A sender already exists for the track. * - The peer connection is closed. */ -- (RTC_OBJC_TYPE(RTCRtpSender) *)addTrack:(RTC_OBJC_TYPE(RTCMediaStreamTrack) *)track - streamIds:(NSArray *)streamIds; +- (nullable RTC_OBJC_TYPE(RTCRtpSender) *)addTrack:(RTC_OBJC_TYPE(RTCMediaStreamTrack) *)track + streamIds:(NSArray *)streamIds; /** With PlanB semantics, removes an RTCRtpSender from this peer connection. * @@ -271,19 +271,19 @@ RTC_OBJC_EXPORT * of the transceiver (and sender/receiver) will be derived from the kind of * the track. */ -- (RTC_OBJC_TYPE(RTCRtpTransceiver) *)addTransceiverWithTrack: +- (nullable RTC_OBJC_TYPE(RTCRtpTransceiver) *)addTransceiverWithTrack: (RTC_OBJC_TYPE(RTCMediaStreamTrack) *)track; -- (RTC_OBJC_TYPE(RTCRtpTransceiver) *) +- (nullable RTC_OBJC_TYPE(RTCRtpTransceiver) *) addTransceiverWithTrack:(RTC_OBJC_TYPE(RTCMediaStreamTrack) *)track init:(RTC_OBJC_TYPE(RTCRtpTransceiverInit) *)init; /** Adds a transceiver with the given kind. Can either be RTCRtpMediaTypeAudio * or RTCRtpMediaTypeVideo. */ -- (RTC_OBJC_TYPE(RTCRtpTransceiver) *)addTransceiverOfType:(RTCRtpMediaType)mediaType; -- (RTC_OBJC_TYPE(RTCRtpTransceiver) *)addTransceiverOfType:(RTCRtpMediaType)mediaType - init:(RTC_OBJC_TYPE(RTCRtpTransceiverInit) *) - init; +- (nullable RTC_OBJC_TYPE(RTCRtpTransceiver) *)addTransceiverOfType:(RTCRtpMediaType)mediaType; +- (nullable RTC_OBJC_TYPE(RTCRtpTransceiver) *) + addTransceiverOfType:(RTCRtpMediaType)mediaType + init:(RTC_OBJC_TYPE(RTCRtpTransceiverInit) *)init; /** Generate an SDP offer. */ - (void)offerForConstraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints diff --git a/sdk/objc/api/peerconnection/RTCPeerConnection.mm b/sdk/objc/api/peerconnection/RTCPeerConnection.mm index 9288a13745..766b61f6af 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnection.mm +++ b/sdk/objc/api/peerconnection/RTCPeerConnection.mm @@ -307,10 +307,10 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack( @synthesize delegate = _delegate; @synthesize factory = _factory; -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory - configuration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration - constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints - delegate:(id)delegate { +- (nullable instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory + configuration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration + constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints + delegate:(id)delegate { NSParameterAssert(factory); std::unique_ptr dependencies = std::make_unique(nullptr); @@ -321,12 +321,12 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack( delegate:delegate]; } -- (instancetype)initWithDependencies:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory - configuration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration - constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints - dependencies: - (std::unique_ptr)dependencies - delegate:(id)delegate { +- (nullable instancetype) + initWithDependencies:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory + configuration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration + constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints + dependencies:(std::unique_ptr)dependencies + delegate:(id)delegate { NSParameterAssert(factory); NSParameterAssert(dependencies.get()); std::unique_ptr config( @@ -456,8 +456,8 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack( [_localStreams removeObject:stream]; } -- (RTC_OBJC_TYPE(RTCRtpSender) *)addTrack:(RTC_OBJC_TYPE(RTCMediaStreamTrack) *)track - streamIds:(NSArray *)streamIds { +- (nullable RTC_OBJC_TYPE(RTCRtpSender) *)addTrack:(RTC_OBJC_TYPE(RTCMediaStreamTrack) *)track + streamIds:(NSArray *)streamIds { std::vector nativeStreamIds; for (NSString *streamId in streamIds) { nativeStreamIds.push_back([streamId UTF8String]); @@ -480,13 +480,13 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack( return result; } -- (RTC_OBJC_TYPE(RTCRtpTransceiver) *)addTransceiverWithTrack: +- (nullable RTC_OBJC_TYPE(RTCRtpTransceiver) *)addTransceiverWithTrack: (RTC_OBJC_TYPE(RTCMediaStreamTrack) *)track { return [self addTransceiverWithTrack:track init:[[RTC_OBJC_TYPE(RTCRtpTransceiverInit) alloc] init]]; } -- (RTC_OBJC_TYPE(RTCRtpTransceiver) *) +- (nullable RTC_OBJC_TYPE(RTCRtpTransceiver) *) addTransceiverWithTrack:(RTC_OBJC_TYPE(RTCMediaStreamTrack) *)track init:(RTC_OBJC_TYPE(RTCRtpTransceiverInit) *)init { webrtc::RTCErrorOr> nativeTransceiverOrError = @@ -501,14 +501,14 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack( nativeRtpTransceiver:nativeTransceiverOrError.MoveValue()]; } -- (RTC_OBJC_TYPE(RTCRtpTransceiver) *)addTransceiverOfType:(RTCRtpMediaType)mediaType { +- (nullable RTC_OBJC_TYPE(RTCRtpTransceiver) *)addTransceiverOfType:(RTCRtpMediaType)mediaType { return [self addTransceiverOfType:mediaType init:[[RTC_OBJC_TYPE(RTCRtpTransceiverInit) alloc] init]]; } -- (RTC_OBJC_TYPE(RTCRtpTransceiver) *)addTransceiverOfType:(RTCRtpMediaType)mediaType - init:(RTC_OBJC_TYPE(RTCRtpTransceiverInit) *) - init { +- (nullable RTC_OBJC_TYPE(RTCRtpTransceiver) *) + addTransceiverOfType:(RTCRtpMediaType)mediaType + init:(RTC_OBJC_TYPE(RTCRtpTransceiverInit) *)init { webrtc::RTCErrorOr> nativeTransceiverOrError = _peerConnection->AddTransceiver( [RTC_OBJC_TYPE(RTCRtpReceiver) nativeMediaTypeForMediaType:mediaType], init.nativeInit); diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Native.h b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Native.h index 1d3b82550a..f361b9f0ea 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Native.h +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Native.h @@ -74,7 +74,7 @@ NS_ASSUME_NONNULL_BEGIN /** Initialize an RTCPeerConnection with a configuration, constraints, and * dependencies. */ -- (RTC_OBJC_TYPE(RTCPeerConnection) *) +- (nullable RTC_OBJC_TYPE(RTCPeerConnection) *) peerConnectionWithDependencies:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints dependencies:(std::unique_ptr)dependencies diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h index 3dcd3b6495..2b0489885f 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h @@ -70,7 +70,7 @@ RTC_OBJC_EXPORT /** Initialize an RTCPeerConnection with a configuration, constraints, and * delegate. */ -- (RTC_OBJC_TYPE(RTCPeerConnection) *) +- (nullable RTC_OBJC_TYPE(RTCPeerConnection) *) peerConnectionWithConfiguration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints delegate:(nullable id)delegate; diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm index e466f99b99..2f324f7289 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm @@ -256,7 +256,7 @@ return [[RTC_OBJC_TYPE(RTCMediaStream) alloc] initWithFactory:self streamId:streamId]; } -- (RTC_OBJC_TYPE(RTCPeerConnection) *) +- (nullable RTC_OBJC_TYPE(RTCPeerConnection) *) peerConnectionWithConfiguration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints delegate: @@ -267,7 +267,7 @@ delegate:delegate]; } -- (RTC_OBJC_TYPE(RTCPeerConnection) *) +- (nullable RTC_OBJC_TYPE(RTCPeerConnection) *) peerConnectionWithDependencies:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints dependencies:(std::unique_ptr)dependencies diff --git a/sdk/objc/components/capturer/RTCCameraVideoCapturer.h b/sdk/objc/components/capturer/RTCCameraVideoCapturer.h index fed5a37827..370bfa70f0 100644 --- a/sdk/objc/components/capturer/RTCCameraVideoCapturer.h +++ b/sdk/objc/components/capturer/RTCCameraVideoCapturer.h @@ -40,7 +40,7 @@ NS_EXTENSION_UNAVAILABLE_IOS("Camera not available in app extensions.") - (void)startCaptureWithDevice:(AVCaptureDevice *)device format:(AVCaptureDeviceFormat *)format fps:(NSInteger)fps - completionHandler:(nullable void (^)(NSError *))completionHandler; + completionHandler:(nullable void (^)(NSError *_Nullable))completionHandler; // Stops the capture session asynchronously and notifies callback on completion. - (void)stopCaptureWithCompletionHandler:(nullable void (^)(void))completionHandler; diff --git a/sdk/objc/components/capturer/RTCCameraVideoCapturer.m b/sdk/objc/components/capturer/RTCCameraVideoCapturer.m index 6edcec88e9..e0e9e41254 100644 --- a/sdk/objc/components/capturer/RTCCameraVideoCapturer.m +++ b/sdk/objc/components/capturer/RTCCameraVideoCapturer.m @@ -153,7 +153,7 @@ const int64_t kNanosecondsPerSecond = 1000000000; - (void)startCaptureWithDevice:(AVCaptureDevice *)device format:(AVCaptureDeviceFormat *)format fps:(NSInteger)fps - completionHandler:(nullable void (^)(NSError *))completionHandler { + completionHandler:(nullable void (^)(NSError *_Nullable error))completionHandler { _willBeRunning = YES; [RTC_OBJC_TYPE(RTCDispatcher) dispatchAsyncOnType:RTCDispatcherTypeCaptureSession