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 NS_ASSUME_NONNULL_BEGIN | |
25 | |
26 extern NSString * const kRTCPeerConnectionErrorDomain; | |
27 extern int const kRTCSessionDescriptionErrorCode; | |
28 | |
29 /** Represents the signaling state of the peer connection. */ | |
30 typedef NS_ENUM(NSInteger, RTCSignalingState) { | |
31 RTCSignalingStateStable, | |
32 RTCSignalingStateHaveLocalOffer, | |
33 RTCSignalingStateHaveLocalPrAnswer, | |
34 RTCSignalingStateHaveRemoteOffer, | |
35 RTCSignalingStateHaveRemotePrAnswer, | |
36 RTCSignalingStateClosed, | |
37 }; | |
38 | |
39 /** Represents the ice connection state of the peer connection. */ | |
40 typedef NS_ENUM(NSInteger, RTCIceConnectionState) { | |
41 RTCIceConnectionStateNew, | |
42 RTCIceConnectionStateChecking, | |
43 RTCIceConnectionStateConnected, | |
44 RTCIceConnectionStateCompleted, | |
45 RTCIceConnectionStateFailed, | |
46 RTCIceConnectionStateDisconnected, | |
47 RTCIceConnectionStateClosed, | |
48 RTCIceConnectionStateMax, | |
49 }; | |
50 | |
51 /** Represents the ice gathering state of the peer connection. */ | |
52 typedef NS_ENUM(NSInteger, RTCIceGatheringState) { | |
53 RTCIceGatheringStateNew, | |
54 RTCIceGatheringStateGathering, | |
55 RTCIceGatheringStateComplete, | |
56 }; | |
57 | |
58 /** Represents the stats output level. */ | |
59 typedef NS_ENUM(NSInteger, RTCStatsOutputLevel) { | |
60 RTCStatsOutputLevelStandard, | |
61 RTCStatsOutputLevelDebug, | |
62 }; | |
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 didAddStream:(RTCMediaStream *)stream; | |
75 | |
76 /** Called when a remote peer closes a stream. */ | |
77 - (void)peerConnection:(RTCPeerConnection *)peerConnection | |
78 didRemoveStream:(RTCMediaStream *)stream; | |
79 | |
80 /** Called when negotiation is needed, for example ICE has restarted. */ | |
81 - (void)peerConnectionShouldNegotiate:(RTCPeerConnection *)peerConnection; | |
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 /** | |
tkchin_webrtc
2016/02/11 18:19:42
nit: move comment to first line
/** <foo>
* <bar
| |
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 @property(nonatomic, readonly) NSArray *localStreams; | |
110 @property(nonatomic, readonly, nullable) | |
111 RTCSessionDescription *localDescription; | |
112 @property(nonatomic, readonly, nullable) | |
113 RTCSessionDescription *remoteDescription; | |
114 @property(nonatomic, readonly) RTCSignalingState signalingState; | |
115 @property(nonatomic, readonly) RTCIceConnectionState iceConnectionState; | |
116 @property(nonatomic, readonly) RTCIceGatheringState iceGatheringState; | |
117 | |
118 - (instancetype)init NS_UNAVAILABLE; | |
119 | |
120 /** | |
121 * Initialize an RTCPeerConnection with a configuration, constraints, and | |
122 * delegate. | |
123 */ | |
124 - (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory | |
125 configuration:(RTCConfiguration *)configuration | |
126 constraints:(RTCMediaConstraints *)constraints | |
127 delegate:(id<RTCPeerConnectionDelegate>)delegate | |
128 NS_DESIGNATED_INITIALIZER; | |
129 | |
130 /** Terminate all media and close the transport. */ | |
131 - (void)close; | |
132 | |
133 /** Provide a remote candidate to the ICE Agent. */ | |
134 - (void)addIceCandidate:(RTCIceCandidate *)candidate; | |
135 | |
136 /** Add a new media stream to be sent on this peer connection. */ | |
137 - (void)addStream:(RTCMediaStream *)stream; | |
138 | |
139 /** Remove the given media stream from this peer connection. */ | |
140 - (void)removeStream:(RTCMediaStream *)stream; | |
141 | |
142 /** Generate an SDP offer. */ | |
143 - (void)offerForConstraints:(RTCMediaConstraints *)constraints | |
144 completionHandler:(void (^)(RTCSessionDescription *sessionDescription, | |
145 NSError *error))completionHandler; | |
146 | |
147 /** Generate an SDP answer. */ | |
148 - (void)answerForConstraints:(RTCMediaConstraints *)constraints | |
149 completionHandler:(void (^)(RTCSessionDescription *sessionDescription , | |
hjon_webrtc
2016/02/11 17:29:48
Looks like this is actually 81 characters. I'm thi
tkchin_webrtc
2016/02/11 18:19:42
call it sdp like you have below? haha
| |
150 NSError *error))completionHandler; | |
151 | |
152 /** Apply the supplied RTCSessionDescription as the local description. */ | |
153 - (void)setLocalDescription:(RTCSessionDescription *)sdp | |
154 completionHandler:(void (^)(NSError *error))completionHandler; | |
155 | |
156 /** Apply the supplied RTCSessionDescription as the remote description. */ | |
157 - (void)setRemoteDescription:(RTCSessionDescription *)sdp | |
158 completionHandler:(void (^)(NSError *error))completionHandler; | |
159 | |
160 @end | |
161 | |
162 @interface RTCPeerConnection (DataChannel) | |
163 | |
164 /** Create a new data channel with the given label and configuration. */ | |
165 - (RTCDataChannel *)dataChannelForLabel:(NSString *)label | |
166 configuration:(RTCDataChannelConfiguration *)configuration; | |
167 | |
168 @end | |
169 | |
170 @interface RTCPeerConnection (Stats) | |
171 | |
172 /** | |
173 * Gather stats for the given RTCMediaStreamTrack. If |mediaStreamTrack| is nil | |
174 * statistics are gathered for all tracks. | |
175 */ | |
176 - (void)statsForTrack: | |
177 (nullable RTCMediaStreamTrack *)mediaStreamTrack | |
178 statsOutputLevel:(RTCStatsOutputLevel)statsOutputLevel | |
179 completionHandler: | |
180 (void (^)(NSArray<RTCStatsReport *> *stats))completionHandler; | |
181 | |
182 @end | |
183 | |
184 NS_ASSUME_NONNULL_END | |
OLD | NEW |