Added missing nullable annotations to iOS SDK.

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 <yura.yaroshevich@gmail.com>
Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33384}
This commit is contained in:
Yura Yaroshevich 2021-03-02 23:25:10 +03:00 committed by Commit Bot
parent 854d59f750
commit d140c8f43b
8 changed files with 43 additions and 42 deletions

View File

@ -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<RTC_OBJC_TYPE(RTCPeerConnectionDelegate)>)delegate;
- (nullable instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory
configuration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration
constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints
delegate:
(nullable id<RTC_OBJC_TYPE(RTCPeerConnectionDelegate)>)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<webrtc::PeerConnectionDependencies>)dependencies
delegate:(nullable id<RTC_OBJC_TYPE(RTCPeerConnectionDelegate)>)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<webrtc::PeerConnectionDependencies>)dependencies
delegate:(nullable id<RTC_OBJC_TYPE(RTCPeerConnectionDelegate)>)delegate
NS_DESIGNATED_INITIALIZER;
+ (webrtc::PeerConnectionInterface::SignalingState)nativeSignalingStateForState:

View File

@ -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<NSString *> *)streamIds;
- (nullable RTC_OBJC_TYPE(RTCRtpSender) *)addTrack:(RTC_OBJC_TYPE(RTCMediaStreamTrack) *)track
streamIds:(NSArray<NSString *> *)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

View File

@ -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<RTC_OBJC_TYPE(RTCPeerConnectionDelegate)>)delegate {
- (nullable instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory
configuration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration
constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints
delegate:(id<RTC_OBJC_TYPE(RTCPeerConnectionDelegate)>)delegate {
NSParameterAssert(factory);
std::unique_ptr<webrtc::PeerConnectionDependencies> dependencies =
std::make_unique<webrtc::PeerConnectionDependencies>(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<webrtc::PeerConnectionDependencies>)dependencies
delegate:(id<RTC_OBJC_TYPE(RTCPeerConnectionDelegate)>)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<webrtc::PeerConnectionDependencies>)dependencies
delegate:(id<RTC_OBJC_TYPE(RTCPeerConnectionDelegate)>)delegate {
NSParameterAssert(factory);
NSParameterAssert(dependencies.get());
std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration> config(
@ -456,8 +456,8 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack(
[_localStreams removeObject:stream];
}
- (RTC_OBJC_TYPE(RTCRtpSender) *)addTrack:(RTC_OBJC_TYPE(RTCMediaStreamTrack) *)track
streamIds:(NSArray<NSString *> *)streamIds {
- (nullable RTC_OBJC_TYPE(RTCRtpSender) *)addTrack:(RTC_OBJC_TYPE(RTCMediaStreamTrack) *)track
streamIds:(NSArray<NSString *> *)streamIds {
std::vector<std::string> 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<rtc::scoped_refptr<webrtc::RtpTransceiverInterface>> 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<rtc::scoped_refptr<webrtc::RtpTransceiverInterface>> nativeTransceiverOrError =
_peerConnection->AddTransceiver(
[RTC_OBJC_TYPE(RTCRtpReceiver) nativeMediaTypeForMediaType:mediaType], init.nativeInit);

View File

@ -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<webrtc::PeerConnectionDependencies>)dependencies

View File

@ -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<RTC_OBJC_TYPE(RTCPeerConnectionDelegate)>)delegate;

View File

@ -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<webrtc::PeerConnectionDependencies>)dependencies

View File

@ -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;

View File

@ -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