OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | |
3 * | |
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 | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #import <Foundation/Foundation.h> | |
12 | |
13 @class RTCConfiguration; | |
14 @class RTCDataChannel; | |
15 @class RTCDataChannelConfiguration; | |
16 @class RTCIceCandidate; | |
17 @class RTCMediaConstraints; | |
18 @class RTCMediaStream; | |
19 @class RTCMediaStreamTrack; | |
20 @class RTCPeerConnectionFactory; | |
21 @class RTCSessionDescription; | |
22 @class RTCStatsReport; | |
23 | |
24 extern NSString * _Nonnull const kRTCPeerConnectionErrorDomain; | |
25 extern int const kRTCSessionDescriptionErrorCode; | |
26 | |
27 /** Represents the signaling state of the peer connection. */ | |
28 typedef NS_ENUM(NSInteger, RTCSignalingState) { | |
29 RTCSignalingStateStable, | |
30 RTCSignalingStateHaveLocalOffer, | |
31 RTCSignalingStateHaveLocalPrAnswer, | |
32 RTCSignalingStateHaveRemoteOffer, | |
33 RTCSignalingStateHaveRemotePrAnswer, | |
34 RTCSignalingStateClosed, | |
35 }; | |
36 | |
37 /** Represents the ice connection state of the peer connection. */ | |
38 typedef NS_ENUM(NSInteger, RTCIceConnectionState) { | |
39 RTCIceConnectionStateNew, | |
40 RTCIceConnectionStateChecking, | |
41 RTCIceConnectionStateConnected, | |
42 RTCIceConnectionStateCompleted, | |
43 RTCIceConnectionStateFailed, | |
44 RTCIceConnectionStateDisconnected, | |
45 RTCIceConnectionStateClosed, | |
46 RTCIceConnectionStateMax, | |
47 }; | |
48 | |
49 /** Represents the ice gathering state of the peer connection. */ | |
50 typedef NS_ENUM(NSInteger, RTCIceGatheringState) { | |
51 RTCIceGatheringStateNew, | |
52 RTCIceGatheringStateGathering, | |
53 RTCIceGatheringStateComplete, | |
54 }; | |
55 | |
56 /** Represents the stats output level. */ | |
57 typedef NS_ENUM(NSInteger, RTCStatsOutputLevel) { | |
58 RTCStatsOutputLevelStandard, | |
59 RTCStatsOutputLevelDebug, | |
60 }; | |
61 | |
62 NS_ASSUME_NONNULL_BEGIN | |
63 | |
64 @class RTCPeerConnection; | |
65 | |
66 @protocol RTCPeerConnectionDelegate <NSObject> | |
67 | |
68 /** Called when the SignalingState changed. */ | |
69 - (void)peerConnection:(RTCPeerConnection *)peerConnection | |
70 didChangeSignalingState:(RTCSignalingState)stateChanged; | |
71 | |
72 /** Called when media is received on a new stream from remote peer. */ | |
73 - (void)peerConnection:(RTCPeerConnection *)peerConnection | |
74 addedStream:(RTCMediaStream *)stream; | |
tkchin_webrtc
2016/02/10 18:54:40
didAddStream
hjon_webrtc
2016/02/11 00:25:08
Done.
| |
75 | |
76 /** Called when a remote peer closes a stream. */ | |
77 - (void)peerConnection:(RTCPeerConnection *)peerConnection | |
78 removedStream:(RTCMediaStream *)stream; | |
tkchin_webrtc
2016/02/10 18:54:40
didRemoveStream
hjon_webrtc
2016/02/11 00:25:08
Done.
| |
79 | |
80 /** Called when negotiation is needed, for example ICE has restarted. */ | |
81 - (void)peerConnectionNeedsNegotiation:(RTCPeerConnection *)peerConnection; | |
tkchin_webrtc
2016/02/10 18:54:40
peerConnectionShouldNegotiate
hjon_webrtc
2016/02/11 00:25:08
Done.
| |
82 | |
83 /** Called any time the IceConnectionState changes. */ | |
84 - (void)peerConnection:(RTCPeerConnection *)peerConnection | |
85 didChangeIceConnectionState:(RTCIceConnectionState)newState; | |
86 | |
87 /** Called any time the IceGatheringState changes. */ | |
88 - (void)peerConnection:(RTCPeerConnection *)peerConnection | |
89 didChangeIceGatheringState:(RTCIceGatheringState)newState; | |
90 | |
91 /** New ice candidate has been found. */ | |
92 - (void)peerConnection:(RTCPeerConnection *)peerConnection | |
93 didGenerateIceCandidate:(RTCIceCandidate *)candidate; | |
94 | |
95 /** New data channel has been opened. */ | |
96 - (void)peerConnection:(RTCPeerConnection *)peerConnection | |
97 didOpenDataChannel:(RTCDataChannel *)dataChannel; | |
98 | |
99 @end | |
100 | |
101 | |
102 @interface RTCPeerConnection : NSObject | |
103 | |
104 /** | |
105 * The object that will be notifed about events such as state changes and | |
106 * streams being added or removed. | |
107 */ | |
108 @property(nonatomic, weak) id<RTCPeerConnectionDelegate> delegate; | |
109 | |
110 /** The current remote description. */ | |
tkchin_webrtc
2016/02/10 18:54:40
? Comment does not match
hjon_webrtc
2016/02/11 00:25:08
Done.
| |
111 @property(nonatomic, readonly) NSArray *localStreams; | |
112 | |
113 /** The current local description. */ | |
114 @property(nonatomic, readonly, nullable) | |
115 RTCSessionDescription *localDescription; | |
116 | |
117 /** The pending or current remote description. */ | |
tkchin_webrtc
2016/02/10 18:54:40
What does it mean to be a pending description?
I
hjon_webrtc
2016/02/11 00:25:08
I removed most of the comments in this section, as
| |
118 @property(nonatomic, readonly, nullable) | |
119 RTCSessionDescription *remoteDescription; | |
120 | |
121 /** The signaling state of this RTCPeerConnection instance. */ | |
122 @property(nonatomic, readonly) RTCSignalingState signalingState; | |
123 | |
124 /** The ICE connection state of this RTCPeerConnection instance. */ | |
125 @property(nonatomic, readonly) RTCIceConnectionState iceConnectionState; | |
126 | |
127 /** The ICE gathering state of this RTCPeerConnection instance. */ | |
128 @property(nonatomic, readonly) RTCIceGatheringState iceGatheringState; | |
129 | |
130 - (instancetype)init NS_UNAVAILABLE; | |
131 | |
132 /** | |
133 * Initialize an RTCPeerConnection with a configuration, constraints, and | |
134 * delegate. | |
135 */ | |
136 - (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory | |
137 configuration:(RTCConfiguration *)configuration | |
138 constraints:(RTCMediaConstraints *)constraints | |
139 delegate:(id<RTCPeerConnectionDelegate>)delegate | |
140 NS_DESIGNATED_INITIALIZER; | |
141 | |
142 /** Terminate all media and close the transport. */ | |
143 - (void)close; | |
144 | |
145 /** Provide a remote candidate to the ICE Agent. */ | |
146 - (void)addIceCandidate:(RTCIceCandidate *)candidate; | |
147 | |
148 /** Add a new media stream to be sent on this peer connection. */ | |
149 - (void)addStream:(RTCMediaStream *)stream; | |
150 | |
151 /** Remove the given media stream from this peer connection. */ | |
152 - (void)removeStream:(RTCMediaStream *)stream; | |
153 | |
154 /** Generate an SDP offer. */ | |
155 - (void)offerForConstraints:(RTCMediaConstraints *)constraints | |
156 completionHandler:(void (^) | |
tkchin_webrtc
2016/02/10 18:54:40
formatting
(void (^)(RTCSessionDescription *,
hjon_webrtc
2016/02/11 00:25:08
Done.
| |
157 (RTCSessionDescription *sessionDescription, NSError *error))completionHandler; | |
158 | |
159 /** Generate an SDP answer. */ | |
160 - (void)answerForConstraints:(RTCMediaConstraints *)constraints | |
161 completionHandler:(void (^) | |
162 (RTCSessionDescription *sessionDescription, NSError *error))completionHandler; | |
tkchin_webrtc
2016/02/10 18:54:40
ditto
hjon_webrtc
2016/02/11 00:25:08
Done.
| |
163 | |
164 /** Apply the supplied RTCSessionDescription as the local description. */ | |
165 - (void)setLocalDescription:(RTCSessionDescription *)sdp | |
166 completionHandler:(void (^)(NSError *error))completionHandler; | |
167 | |
168 /** Apply the supplied RTCSessionDescription as the remote description. */ | |
169 - (void)setRemoteDescription:(RTCSessionDescription *)sdp | |
170 completionHandler:(void (^)(NSError *error))completionHandler; | |
171 | |
172 @end | |
173 | |
174 @interface RTCPeerConnection (DataChannel) | |
175 | |
176 /** Create a new data channel with the given label and configuration. */ | |
177 - (RTCDataChannel *)dataChannelWithLabel:(NSString *)label | |
tkchin_webrtc
2016/02/10 18:54:40
nit: dataChannelForLabel:configuration:
hjon_webrtc
2016/02/11 00:25:08
Done.
| |
178 configuration:(RTCDataChannelConfiguration *)configuration; | |
179 | |
180 @end | |
181 | |
182 @interface RTCPeerConnection (Stats) | |
183 | |
184 /** | |
185 * Gather stats for the given RTCMediaStreamTrack. If |mediaStreamTrack| is nil | |
186 * statistics are gathered for all tracks. | |
187 */ | |
188 - (void)statsForMediaStreamTrack: | |
tkchin_webrtc
2016/02/10 18:54:40
nit: unless this is explicitly in the spec, statsF
hjon_webrtc
2016/02/11 00:25:08
Done.
| |
189 (nullable RTCMediaStreamTrack *)mediaStreamTrack | |
190 statsOutputLevel:(RTCStatsOutputLevel)statsOutputLevel | |
191 completionHandler: | |
192 (void (^)(NSArray<RTCStatsReport *> *stats))completionHandler; | |
tkchin_webrtc
2016/02/10 18:54:40
no error?
hjon_webrtc
2016/02/11 00:25:08
Feels a little surprising, but there's not an erro
| |
193 | |
194 @end | |
195 | |
196 NS_ASSUME_NONNULL_END | |
OLD | NEW |