Fix nullability of completion handlers in iOS SDK.
Bug: None Change-Id: I74d3d976760fd620a8f749a3c187430dbe80ef57 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/210961 Commit-Queue: Yura Yaroshevich <yura.yaroshevich@gmail.com> Reviewed-by: Kári Helgason <kthelgason@webrtc.org> Cr-Commit-Position: refs/heads/master@{#33416}
This commit is contained in:

committed by
Commit Bot

parent
89127190ce
commit
8bfa2756a5
@ -81,6 +81,12 @@ typedef NS_ENUM(NSInteger, RTCStatsOutputLevel) {
|
|||||||
RTCStatsOutputLevelDebug,
|
RTCStatsOutputLevelDebug,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef void (^RTCCreateSessionDescriptionCompletionHandler)(RTC_OBJC_TYPE(RTCSessionDescription) *
|
||||||
|
_Nullable sdp,
|
||||||
|
NSError *_Nullable error);
|
||||||
|
|
||||||
|
typedef void (^RTCSetSessionDescriptionCompletionHandler)(NSError *_Nullable error);
|
||||||
|
|
||||||
@class RTC_OBJC_TYPE(RTCPeerConnection);
|
@class RTC_OBJC_TYPE(RTCPeerConnection);
|
||||||
|
|
||||||
RTC_OBJC_EXPORT
|
RTC_OBJC_EXPORT
|
||||||
@ -293,27 +299,24 @@ RTC_OBJC_EXPORT
|
|||||||
|
|
||||||
/** Generate an SDP offer. */
|
/** Generate an SDP offer. */
|
||||||
- (void)offerForConstraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints
|
- (void)offerForConstraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints
|
||||||
completionHandler:(nullable void (^)(RTC_OBJC_TYPE(RTCSessionDescription) * _Nullable sdp,
|
completionHandler:(RTCCreateSessionDescriptionCompletionHandler)completionHandler;
|
||||||
NSError *_Nullable error))completionHandler;
|
|
||||||
|
|
||||||
/** Generate an SDP answer. */
|
/** Generate an SDP answer. */
|
||||||
- (void)answerForConstraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints
|
- (void)answerForConstraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints
|
||||||
completionHandler:
|
completionHandler:(RTCCreateSessionDescriptionCompletionHandler)completionHandler;
|
||||||
(nullable void (^)(RTC_OBJC_TYPE(RTCSessionDescription) * _Nullable sdp,
|
|
||||||
NSError *_Nullable error))completionHandler;
|
|
||||||
|
|
||||||
/** Apply the supplied RTCSessionDescription as the local description. */
|
/** Apply the supplied RTCSessionDescription as the local description. */
|
||||||
- (void)setLocalDescription:(RTC_OBJC_TYPE(RTCSessionDescription) *)sdp
|
- (void)setLocalDescription:(RTC_OBJC_TYPE(RTCSessionDescription) *)sdp
|
||||||
completionHandler:(nullable void (^)(NSError *_Nullable error))completionHandler;
|
completionHandler:(RTCSetSessionDescriptionCompletionHandler)completionHandler;
|
||||||
|
|
||||||
/** Creates an offer or answer (depending on current signaling state) and sets
|
/** Creates an offer or answer (depending on current signaling state) and sets
|
||||||
* it as the local session description. */
|
* it as the local session description. */
|
||||||
- (void)setLocalDescriptionWithCompletionHandler:
|
- (void)setLocalDescriptionWithCompletionHandler:
|
||||||
(nullable void (^)(NSError *_Nullable error))completionHandler;
|
(RTCSetSessionDescriptionCompletionHandler)completionHandler;
|
||||||
|
|
||||||
/** Apply the supplied RTCSessionDescription as the remote description. */
|
/** Apply the supplied RTCSessionDescription as the remote description. */
|
||||||
- (void)setRemoteDescription:(RTC_OBJC_TYPE(RTCSessionDescription) *)sdp
|
- (void)setRemoteDescription:(RTC_OBJC_TYPE(RTCSessionDescription) *)sdp
|
||||||
completionHandler:(nullable void (^)(NSError *_Nullable error))completionHandler;
|
completionHandler:(RTCSetSessionDescriptionCompletionHandler)completionHandler;
|
||||||
|
|
||||||
/** Limits the bandwidth allocated for all RTP streams sent by this
|
/** Limits the bandwidth allocated for all RTP streams sent by this
|
||||||
* PeerConnection. Nil parameters will be unchanged. Setting
|
* PeerConnection. Nil parameters will be unchanged. Setting
|
||||||
|
@ -37,33 +37,26 @@
|
|||||||
NSString *const kRTCPeerConnectionErrorDomain = @"org.webrtc.RTC_OBJC_TYPE(RTCPeerConnection)";
|
NSString *const kRTCPeerConnectionErrorDomain = @"org.webrtc.RTC_OBJC_TYPE(RTCPeerConnection)";
|
||||||
int const kRTCPeerConnnectionSessionDescriptionError = -1;
|
int const kRTCPeerConnnectionSessionDescriptionError = -1;
|
||||||
|
|
||||||
typedef void (^RTCSetSessionDescriptionCompletionHandler)(NSError *_Nullable error);
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class SetSessionDescriptionObserver : public webrtc::SetLocalDescriptionObserverInterface,
|
class SetSessionDescriptionObserver : public webrtc::SetLocalDescriptionObserverInterface,
|
||||||
public webrtc::SetRemoteDescriptionObserverInterface {
|
public webrtc::SetRemoteDescriptionObserverInterface {
|
||||||
public:
|
public:
|
||||||
SetSessionDescriptionObserver(
|
SetSessionDescriptionObserver(RTCSetSessionDescriptionCompletionHandler completionHandler) {
|
||||||
RTCSetSessionDescriptionCompletionHandler _Nullable completionHandler) {
|
|
||||||
completion_handler_ = completionHandler;
|
completion_handler_ = completionHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnSetLocalDescriptionComplete(webrtc::RTCError error) override {
|
virtual void OnSetLocalDescriptionComplete(webrtc::RTCError error) override {
|
||||||
if (completion_handler_ != nil) {
|
OnCompelete(error);
|
||||||
OnCompelete(error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnSetRemoteDescriptionComplete(webrtc::RTCError error) override {
|
virtual void OnSetRemoteDescriptionComplete(webrtc::RTCError error) override {
|
||||||
if (completion_handler_ != nil) {
|
OnCompelete(error);
|
||||||
OnCompelete(error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void OnCompelete(webrtc::RTCError error) {
|
void OnCompelete(webrtc::RTCError error) {
|
||||||
RTC_DCHECK(completion_handler_);
|
RTC_DCHECK(completion_handler_ != nil);
|
||||||
if (error.ok()) {
|
if (error.ok()) {
|
||||||
completion_handler_(nil);
|
completion_handler_(nil);
|
||||||
} else {
|
} else {
|
||||||
@ -542,8 +535,8 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack(
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)offerForConstraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints
|
- (void)offerForConstraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints
|
||||||
completionHandler:(void (^)(RTC_OBJC_TYPE(RTCSessionDescription) * sessionDescription,
|
completionHandler:(RTCCreateSessionDescriptionCompletionHandler)completionHandler {
|
||||||
NSError *error))completionHandler {
|
RTC_DCHECK(completionHandler != nil);
|
||||||
rtc::scoped_refptr<webrtc::CreateSessionDescriptionObserverAdapter>
|
rtc::scoped_refptr<webrtc::CreateSessionDescriptionObserverAdapter>
|
||||||
observer(new rtc::RefCountedObject
|
observer(new rtc::RefCountedObject
|
||||||
<webrtc::CreateSessionDescriptionObserverAdapter>(completionHandler));
|
<webrtc::CreateSessionDescriptionObserverAdapter>(completionHandler));
|
||||||
@ -554,8 +547,8 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack(
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)answerForConstraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints
|
- (void)answerForConstraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints
|
||||||
completionHandler:(void (^)(RTC_OBJC_TYPE(RTCSessionDescription) * sessionDescription,
|
completionHandler:(RTCCreateSessionDescriptionCompletionHandler)completionHandler {
|
||||||
NSError *error))completionHandler {
|
RTC_DCHECK(completionHandler != nil);
|
||||||
rtc::scoped_refptr<webrtc::CreateSessionDescriptionObserverAdapter>
|
rtc::scoped_refptr<webrtc::CreateSessionDescriptionObserverAdapter>
|
||||||
observer(new rtc::RefCountedObject
|
observer(new rtc::RefCountedObject
|
||||||
<webrtc::CreateSessionDescriptionObserverAdapter>(completionHandler));
|
<webrtc::CreateSessionDescriptionObserverAdapter>(completionHandler));
|
||||||
@ -566,21 +559,24 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack(
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)setLocalDescription:(RTC_OBJC_TYPE(RTCSessionDescription) *)sdp
|
- (void)setLocalDescription:(RTC_OBJC_TYPE(RTCSessionDescription) *)sdp
|
||||||
completionHandler:(nullable void (^)(NSError *error))completionHandler {
|
completionHandler:(RTCSetSessionDescriptionCompletionHandler)completionHandler {
|
||||||
|
RTC_DCHECK(completionHandler != nil);
|
||||||
rtc::scoped_refptr<webrtc::SetLocalDescriptionObserverInterface> observer(
|
rtc::scoped_refptr<webrtc::SetLocalDescriptionObserverInterface> observer(
|
||||||
new rtc::RefCountedObject<::SetSessionDescriptionObserver>(completionHandler));
|
new rtc::RefCountedObject<::SetSessionDescriptionObserver>(completionHandler));
|
||||||
_peerConnection->SetLocalDescription(sdp.nativeDescription->Clone(), observer);
|
_peerConnection->SetLocalDescription(sdp.nativeDescription->Clone(), observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setLocalDescriptionWithCompletionHandler:
|
- (void)setLocalDescriptionWithCompletionHandler:
|
||||||
(nullable void (^)(NSError *error))completionHandler {
|
(RTCSetSessionDescriptionCompletionHandler)completionHandler {
|
||||||
|
RTC_DCHECK(completionHandler != nil);
|
||||||
rtc::scoped_refptr<webrtc::SetLocalDescriptionObserverInterface> observer(
|
rtc::scoped_refptr<webrtc::SetLocalDescriptionObserverInterface> observer(
|
||||||
new rtc::RefCountedObject<::SetSessionDescriptionObserver>(completionHandler));
|
new rtc::RefCountedObject<::SetSessionDescriptionObserver>(completionHandler));
|
||||||
_peerConnection->SetLocalDescription(observer);
|
_peerConnection->SetLocalDescription(observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setRemoteDescription:(RTC_OBJC_TYPE(RTCSessionDescription) *)sdp
|
- (void)setRemoteDescription:(RTC_OBJC_TYPE(RTCSessionDescription) *)sdp
|
||||||
completionHandler:(nullable void (^)(NSError *error))completionHandler {
|
completionHandler:(RTCSetSessionDescriptionCompletionHandler)completionHandler {
|
||||||
|
RTC_DCHECK(completionHandler != nil);
|
||||||
rtc::scoped_refptr<webrtc::SetRemoteDescriptionObserverInterface> observer(
|
rtc::scoped_refptr<webrtc::SetRemoteDescriptionObserverInterface> observer(
|
||||||
new rtc::RefCountedObject<::SetSessionDescriptionObserver>(completionHandler));
|
new rtc::RefCountedObject<::SetSessionDescriptionObserver>(completionHandler));
|
||||||
_peerConnection->SetRemoteDescription(sdp.nativeDescription->Clone(), observer);
|
_peerConnection->SetRemoteDescription(sdp.nativeDescription->Clone(), observer);
|
||||||
|
Reference in New Issue
Block a user