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