| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #import <Foundation/Foundation.h> | 11 #import <Foundation/Foundation.h> |
| 12 | 12 |
| 13 @class RTCConfiguration; | 13 @class RTCConfiguration; |
| 14 @class RTCDataChannel; | 14 @class RTCDataChannel; |
| 15 @class RTCDataChannelConfiguration; | 15 @class RTCDataChannelConfiguration; |
| 16 @class RTCIceCandidate; | 16 @class RTCIceCandidate; |
| 17 @class RTCMediaConstraints; | 17 @class RTCMediaConstraints; |
| 18 @class RTCMediaStream; | 18 @class RTCMediaStream; |
| 19 @class RTCMediaStreamTrack; | 19 @class RTCMediaStreamTrack; |
| 20 @class RTCPeerConnectionFactory; | 20 @class RTCPeerConnectionFactory; |
| 21 @class RTCSessionDescription; | 21 @class RTCSessionDescription; |
| 22 @class RTCStatsReport; | 22 @class RTCStatsReport; |
| 23 | 23 |
| 24 NS_ASSUME_NONNULL_BEGIN | 24 NS_ASSUME_NONNULL_BEGIN |
| 25 // TODO(hjon): Update nullability types. See http://crbug/webrtc/5592 |
| 25 | 26 |
| 26 extern NSString * const kRTCPeerConnectionErrorDomain; | 27 extern NSString * _Nonnull const kRTCPeerConnectionErrorDomain; |
| 27 extern int const kRTCSessionDescriptionErrorCode; | 28 extern int const kRTCSessionDescriptionErrorCode; |
| 28 | 29 |
| 29 /** Represents the signaling state of the peer connection. */ | 30 /** Represents the signaling state of the peer connection. */ |
| 30 typedef NS_ENUM(NSInteger, RTCSignalingState) { | 31 typedef NS_ENUM(NSInteger, RTCSignalingState) { |
| 31 RTCSignalingStateStable, | 32 RTCSignalingStateStable, |
| 32 RTCSignalingStateHaveLocalOffer, | 33 RTCSignalingStateHaveLocalOffer, |
| 33 RTCSignalingStateHaveLocalPrAnswer, | 34 RTCSignalingStateHaveLocalPrAnswer, |
| 34 RTCSignalingStateHaveRemoteOffer, | 35 RTCSignalingStateHaveRemoteOffer, |
| 35 RTCSignalingStateHaveRemotePrAnswer, | 36 RTCSignalingStateHaveRemotePrAnswer, |
| 36 RTCSignalingStateClosed, | 37 RTCSignalingStateClosed, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 59 typedef NS_ENUM(NSInteger, RTCStatsOutputLevel) { | 60 typedef NS_ENUM(NSInteger, RTCStatsOutputLevel) { |
| 60 RTCStatsOutputLevelStandard, | 61 RTCStatsOutputLevelStandard, |
| 61 RTCStatsOutputLevelDebug, | 62 RTCStatsOutputLevelDebug, |
| 62 }; | 63 }; |
| 63 | 64 |
| 64 @class RTCPeerConnection; | 65 @class RTCPeerConnection; |
| 65 | 66 |
| 66 @protocol RTCPeerConnectionDelegate <NSObject> | 67 @protocol RTCPeerConnectionDelegate <NSObject> |
| 67 | 68 |
| 68 /** Called when the SignalingState changed. */ | 69 /** Called when the SignalingState changed. */ |
| 69 - (void)peerConnection:(RTCPeerConnection *)peerConnection | 70 - (void)peerConnection:(nonnull RTCPeerConnection *)peerConnection |
| 70 didChangeSignalingState:(RTCSignalingState)stateChanged; | 71 didChangeSignalingState:(RTCSignalingState)stateChanged; |
| 71 | 72 |
| 72 /** Called when media is received on a new stream from remote peer. */ | 73 /** Called when media is received on a new stream from remote peer. */ |
| 73 - (void)peerConnection:(RTCPeerConnection *)peerConnection | 74 - (void)peerConnection:(nonnull RTCPeerConnection *)peerConnection |
| 74 didAddStream:(RTCMediaStream *)stream; | 75 didAddStream:(nonnull RTCMediaStream *)stream; |
| 75 | 76 |
| 76 /** Called when a remote peer closes a stream. */ | 77 /** Called when a remote peer closes a stream. */ |
| 77 - (void)peerConnection:(RTCPeerConnection *)peerConnection | 78 - (void)peerConnection:(nonnull RTCPeerConnection *)peerConnection |
| 78 didRemoveStream:(RTCMediaStream *)stream; | 79 didRemoveStream:(nonnull RTCMediaStream *)stream; |
| 79 | 80 |
| 80 /** Called when negotiation is needed, for example ICE has restarted. */ | 81 /** Called when negotiation is needed, for example ICE has restarted. */ |
| 81 - (void)peerConnectionShouldNegotiate:(RTCPeerConnection *)peerConnection; | 82 - (void)peerConnectionShouldNegotiate: |
| 83 (nonnull RTCPeerConnection *)peerConnection; |
| 82 | 84 |
| 83 /** Called any time the IceConnectionState changes. */ | 85 /** Called any time the IceConnectionState changes. */ |
| 84 - (void)peerConnection:(RTCPeerConnection *)peerConnection | 86 - (void)peerConnection:(nonnull RTCPeerConnection *)peerConnection |
| 85 didChangeIceConnectionState:(RTCIceConnectionState)newState; | 87 didChangeIceConnectionState:(RTCIceConnectionState)newState; |
| 86 | 88 |
| 87 /** Called any time the IceGatheringState changes. */ | 89 /** Called any time the IceGatheringState changes. */ |
| 88 - (void)peerConnection:(RTCPeerConnection *)peerConnection | 90 - (void)peerConnection:(nonnull RTCPeerConnection *)peerConnection |
| 89 didChangeIceGatheringState:(RTCIceGatheringState)newState; | 91 didChangeIceGatheringState:(RTCIceGatheringState)newState; |
| 90 | 92 |
| 91 /** New ice candidate has been found. */ | 93 /** New ice candidate has been found. */ |
| 92 - (void)peerConnection:(RTCPeerConnection *)peerConnection | 94 - (void)peerConnection:(nonnull RTCPeerConnection *)peerConnection |
| 93 didGenerateIceCandidate:(RTCIceCandidate *)candidate; | 95 didGenerateIceCandidate:(nonnull RTCIceCandidate *)candidate; |
| 94 | 96 |
| 95 /** New data channel has been opened. */ | 97 /** New data channel has been opened. */ |
| 96 - (void)peerConnection:(RTCPeerConnection *)peerConnection | 98 - (void)peerConnection:(nonnull RTCPeerConnection *)peerConnection |
| 97 didOpenDataChannel:(RTCDataChannel *)dataChannel; | 99 didOpenDataChannel:(nonnull RTCDataChannel *)dataChannel; |
| 98 | 100 |
| 99 @end | 101 @end |
| 100 | 102 |
| 101 | 103 |
| 102 @interface RTCPeerConnection : NSObject | 104 @interface RTCPeerConnection : NSObject |
| 103 | 105 |
| 104 /** The object that will be notifed about events such as state changes and | 106 /** The object that will be notifed about events such as state changes and |
| 105 * streams being added or removed. | 107 * streams being added or removed. |
| 106 */ | 108 */ |
| 107 @property(nonatomic, weak) id<RTCPeerConnectionDelegate> delegate; | 109 @property(nonatomic, weak, nullable) id<RTCPeerConnectionDelegate> delegate; |
| 108 @property(nonatomic, readonly) NSArray *localStreams; | 110 @property(nonatomic, readonly, nonnull) NSArray *localStreams; |
| 109 @property(nonatomic, readonly, nullable) | 111 @property(nonatomic, readonly, nullable) |
| 110 RTCSessionDescription *localDescription; | 112 RTCSessionDescription *localDescription; |
| 111 @property(nonatomic, readonly, nullable) | 113 @property(nonatomic, readonly, nullable) |
| 112 RTCSessionDescription *remoteDescription; | 114 RTCSessionDescription *remoteDescription; |
| 113 @property(nonatomic, readonly) RTCSignalingState signalingState; | 115 @property(nonatomic, readonly) RTCSignalingState signalingState; |
| 114 @property(nonatomic, readonly) RTCIceConnectionState iceConnectionState; | 116 @property(nonatomic, readonly) RTCIceConnectionState iceConnectionState; |
| 115 @property(nonatomic, readonly) RTCIceGatheringState iceGatheringState; | 117 @property(nonatomic, readonly) RTCIceGatheringState iceGatheringState; |
| 116 | 118 |
| 117 - (instancetype)init NS_UNAVAILABLE; | 119 - (nonnull instancetype)init NS_UNAVAILABLE; |
| 118 | 120 |
| 119 /** Initialize an RTCPeerConnection with a configuration, constraints, and | 121 /** Initialize an RTCPeerConnection with a configuration, constraints, and |
| 120 * delegate. | 122 * delegate. |
| 121 */ | 123 */ |
| 122 - (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory | 124 - (nonnull instancetype)initWithFactory: |
| 123 configuration:(RTCConfiguration *)configuration | 125 (nonnull RTCPeerConnectionFactory *)factory |
| 124 constraints:(RTCMediaConstraints *)constraints | 126 configuration: |
| 125 delegate:(id<RTCPeerConnectionDelegate>)delegate | 127 (nonnull RTCConfiguration *)configuration |
| 128 constraints: |
| 129 (nonnull RTCMediaConstraints *)constraints |
| 130 delegate: |
| 131 (nullable id<RTCPeerConnectionDelegate>)delegate |
| 126 NS_DESIGNATED_INITIALIZER; | 132 NS_DESIGNATED_INITIALIZER; |
| 127 | 133 |
| 128 /** Terminate all media and close the transport. */ | 134 /** Terminate all media and close the transport. */ |
| 129 - (void)close; | 135 - (void)close; |
| 130 | 136 |
| 131 /** Provide a remote candidate to the ICE Agent. */ | 137 /** Provide a remote candidate to the ICE Agent. */ |
| 132 - (void)addIceCandidate:(RTCIceCandidate *)candidate; | 138 - (void)addIceCandidate:(nonnull RTCIceCandidate *)candidate; |
| 133 | 139 |
| 134 /** Add a new media stream to be sent on this peer connection. */ | 140 /** Add a new media stream to be sent on this peer connection. */ |
| 135 - (void)addStream:(RTCMediaStream *)stream; | 141 - (void)addStream:(nonnull RTCMediaStream *)stream; |
| 136 | 142 |
| 137 /** Remove the given media stream from this peer connection. */ | 143 /** Remove the given media stream from this peer connection. */ |
| 138 - (void)removeStream:(RTCMediaStream *)stream; | 144 - (void)removeStream:(nonnull RTCMediaStream *)stream; |
| 139 | 145 |
| 140 /** Generate an SDP offer. */ | 146 /** Generate an SDP offer. */ |
| 141 - (void)offerForConstraints:(RTCMediaConstraints *)constraints | 147 - (void)offerForConstraints:(nonnull RTCMediaConstraints *)constraints |
| 142 completionHandler:(void (^)(RTCSessionDescription *sdp, | 148 completionHandler:(nullable void (^) |
| 143 NSError *error))completionHandler; | 149 (RTCSessionDescription * _Nullable sdp, |
| 150 NSError * _Nullable error))completionHandler; |
| 144 | 151 |
| 145 /** Generate an SDP answer. */ | 152 /** Generate an SDP answer. */ |
| 146 - (void)answerForConstraints:(RTCMediaConstraints *)constraints | 153 - (void)answerForConstraints:(nonnull RTCMediaConstraints *)constraints |
| 147 completionHandler:(void (^)(RTCSessionDescription *sdp, | 154 completionHandler:(nullable void (^) |
| 148 NSError *error))completionHandler; | 155 (RTCSessionDescription * _Nullable sdp, |
| 156 NSError * _Nullable error))completionHandler; |
| 149 | 157 |
| 150 /** Apply the supplied RTCSessionDescription as the local description. */ | 158 /** Apply the supplied RTCSessionDescription as the local description. */ |
| 151 - (void)setLocalDescription:(RTCSessionDescription *)sdp | 159 - (void)setLocalDescription:(nonnull RTCSessionDescription *)sdp |
| 152 completionHandler:(void (^)(NSError *error))completionHandler; | 160 completionHandler: |
| 161 (nullable void (^)(NSError * _Nullable error))completionHandler; |
| 153 | 162 |
| 154 /** Apply the supplied RTCSessionDescription as the remote description. */ | 163 /** Apply the supplied RTCSessionDescription as the remote description. */ |
| 155 - (void)setRemoteDescription:(RTCSessionDescription *)sdp | 164 - (void)setRemoteDescription:(nonnull RTCSessionDescription *)sdp |
| 156 completionHandler:(void (^)(NSError *error))completionHandler; | 165 completionHandler: |
| 166 (nullable void (^)(NSError * _Nullable error))completionHandler; |
| 157 | 167 |
| 158 @end | 168 @end |
| 159 | 169 |
| 160 @interface RTCPeerConnection (DataChannel) | 170 @interface RTCPeerConnection (DataChannel) |
| 161 | 171 |
| 162 /** Create a new data channel with the given label and configuration. */ | 172 /** Create a new data channel with the given label and configuration. */ |
| 163 - (RTCDataChannel *)dataChannelForLabel:(NSString *)label | 173 - (nonnull RTCDataChannel *)dataChannelForLabel:(nonnull NSString *)label |
| 164 configuration:(RTCDataChannelConfiguration *)configuration; | 174 configuration:(nonnull RTCDataChannelConfiguration *)configuration; |
| 165 | 175 |
| 166 @end | 176 @end |
| 167 | 177 |
| 168 @interface RTCPeerConnection (Stats) | 178 @interface RTCPeerConnection (Stats) |
| 169 | 179 |
| 170 /** Gather stats for the given RTCMediaStreamTrack. If |mediaStreamTrack| is nil | 180 /** Gather stats for the given RTCMediaStreamTrack. If |mediaStreamTrack| is nil |
| 171 * statistics are gathered for all tracks. | 181 * statistics are gathered for all tracks. |
| 172 */ | 182 */ |
| 173 - (void)statsForTrack: | 183 - (void)statsForTrack: |
| 174 (nullable RTCMediaStreamTrack *)mediaStreamTrack | 184 (nonnull RTCMediaStreamTrack *)mediaStreamTrack |
| 175 statsOutputLevel:(RTCStatsOutputLevel)statsOutputLevel | 185 statsOutputLevel:(RTCStatsOutputLevel)statsOutputLevel |
| 176 completionHandler: | 186 completionHandler: |
| 177 (void (^)(NSArray<RTCStatsReport *> *stats))completionHandler; | 187 (nullable void (^)(NSArray * _Nonnull stats))completionHandler; |
| 188 // (nullable void (^)(NSArray<RTCStatsReport *> *stats))completionHandler; |
| 178 | 189 |
| 179 @end | 190 @end |
| 180 | 191 |
| 181 NS_ASSUME_NONNULL_END | 192 NS_ASSUME_NONNULL_END |
| OLD | NEW |