Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(449)

Side by Side Diff: Source/modules/mediastream/RTCPeerConnection.cpp

Issue 72363002: Rename es => exceptionState in other than bindings/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Retry Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 #include "modules/mediastream/RTCStatsCallback.h" 56 #include "modules/mediastream/RTCStatsCallback.h"
57 #include "modules/mediastream/RTCStatsRequestImpl.h" 57 #include "modules/mediastream/RTCStatsRequestImpl.h"
58 #include "modules/mediastream/RTCVoidRequestImpl.h" 58 #include "modules/mediastream/RTCVoidRequestImpl.h"
59 #include "platform/mediastream/RTCConfiguration.h" 59 #include "platform/mediastream/RTCConfiguration.h"
60 #include "public/platform/WebRTCDataChannelInit.h" 60 #include "public/platform/WebRTCDataChannelInit.h"
61 #include "public/platform/WebRTCICECandidate.h" 61 #include "public/platform/WebRTCICECandidate.h"
62 #include "public/platform/WebRTCSessionDescription.h" 62 #include "public/platform/WebRTCSessionDescription.h"
63 63
64 namespace WebCore { 64 namespace WebCore {
65 65
66 PassRefPtr<RTCConfiguration> RTCPeerConnection::parseConfiguration(const Diction ary& configuration, ExceptionState& es) 66 PassRefPtr<RTCConfiguration> RTCPeerConnection::parseConfiguration(const Diction ary& configuration, ExceptionState& exceptionState)
67 { 67 {
68 if (configuration.isUndefinedOrNull()) 68 if (configuration.isUndefinedOrNull())
69 return 0; 69 return 0;
70 70
71 ArrayValue iceServers; 71 ArrayValue iceServers;
72 bool ok = configuration.get("iceServers", iceServers); 72 bool ok = configuration.get("iceServers", iceServers);
73 if (!ok || iceServers.isUndefinedOrNull()) { 73 if (!ok || iceServers.isUndefinedOrNull()) {
74 es.throwUninformativeAndGenericDOMException(TypeMismatchError); 74 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatchErro r);
75 return 0; 75 return 0;
76 } 76 }
77 77
78 size_t numberOfServers; 78 size_t numberOfServers;
79 ok = iceServers.length(numberOfServers); 79 ok = iceServers.length(numberOfServers);
80 if (!ok) { 80 if (!ok) {
81 es.throwUninformativeAndGenericDOMException(TypeMismatchError); 81 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatchErro r);
82 return 0; 82 return 0;
83 } 83 }
84 84
85 RefPtr<RTCConfiguration> rtcConfiguration = RTCConfiguration::create(); 85 RefPtr<RTCConfiguration> rtcConfiguration = RTCConfiguration::create();
86 86
87 for (size_t i = 0; i < numberOfServers; ++i) { 87 for (size_t i = 0; i < numberOfServers; ++i) {
88 Dictionary iceServer; 88 Dictionary iceServer;
89 ok = iceServers.get(i, iceServer); 89 ok = iceServers.get(i, iceServer);
90 if (!ok) { 90 if (!ok) {
91 es.throwUninformativeAndGenericDOMException(TypeMismatchError); 91 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatch Error);
92 return 0; 92 return 0;
93 } 93 }
94 94
95 String urlString, username, credential; 95 String urlString, username, credential;
96 ok = iceServer.get("url", urlString); 96 ok = iceServer.get("url", urlString);
97 if (!ok) { 97 if (!ok) {
98 es.throwUninformativeAndGenericDOMException(TypeMismatchError); 98 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatch Error);
99 return 0; 99 return 0;
100 } 100 }
101 KURL url(KURL(), urlString); 101 KURL url(KURL(), urlString);
102 if (!url.isValid() || !(url.protocolIs("turn") || url.protocolIs("turns" ) || url.protocolIs("stun"))) { 102 if (!url.isValid() || !(url.protocolIs("turn") || url.protocolIs("turns" ) || url.protocolIs("stun"))) {
103 es.throwUninformativeAndGenericDOMException(TypeMismatchError); 103 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatch Error);
104 return 0; 104 return 0;
105 } 105 }
106 106
107 iceServer.get("username", username); 107 iceServer.get("username", username);
108 iceServer.get("credential", credential); 108 iceServer.get("credential", credential);
109 109
110 rtcConfiguration->appendServer(RTCIceServer::create(url, username, crede ntial)); 110 rtcConfiguration->appendServer(RTCIceServer::create(url, username, crede ntial));
111 } 111 }
112 112
113 return rtcConfiguration.release(); 113 return rtcConfiguration.release();
114 } 114 }
115 115
116 PassRefPtr<RTCPeerConnection> RTCPeerConnection::create(ExecutionContext* contex t, const Dictionary& rtcConfiguration, const Dictionary& mediaConstraints, Excep tionState& es) 116 PassRefPtr<RTCPeerConnection> RTCPeerConnection::create(ExecutionContext* contex t, const Dictionary& rtcConfiguration, const Dictionary& mediaConstraints, Excep tionState& exceptionState)
117 { 117 {
118 RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration , es); 118 RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration , exceptionState);
119 if (es.hadException()) 119 if (exceptionState.hadException())
120 return 0; 120 return 0;
121 121
122 RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaCon straints, es); 122 RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaCon straints, exceptionState);
123 if (es.hadException()) 123 if (exceptionState.hadException())
124 return 0; 124 return 0;
125 125
126 RefPtr<RTCPeerConnection> peerConnection = adoptRef(new RTCPeerConnection(co ntext, configuration.release(), constraints.release(), es)); 126 RefPtr<RTCPeerConnection> peerConnection = adoptRef(new RTCPeerConnection(co ntext, configuration.release(), constraints.release(), exceptionState));
127 peerConnection->suspendIfNeeded(); 127 peerConnection->suspendIfNeeded();
128 if (es.hadException()) 128 if (exceptionState.hadException())
129 return 0; 129 return 0;
130 130
131 return peerConnection.release(); 131 return peerConnection.release();
132 } 132 }
133 133
134 RTCPeerConnection::RTCPeerConnection(ExecutionContext* context, PassRefPtr<RTCCo nfiguration> configuration, PassRefPtr<MediaConstraints> constraints, ExceptionS tate& es) 134 RTCPeerConnection::RTCPeerConnection(ExecutionContext* context, PassRefPtr<RTCCo nfiguration> configuration, PassRefPtr<MediaConstraints> constraints, ExceptionS tate& exceptionState)
135 : ActiveDOMObject(context) 135 : ActiveDOMObject(context)
136 , m_signalingState(SignalingStateStable) 136 , m_signalingState(SignalingStateStable)
137 , m_iceGatheringState(IceGatheringStateNew) 137 , m_iceGatheringState(IceGatheringStateNew)
138 , m_iceConnectionState(IceConnectionStateNew) 138 , m_iceConnectionState(IceConnectionStateNew)
139 , m_dispatchScheduledEventRunner(this, &RTCPeerConnection::dispatchScheduled Event) 139 , m_dispatchScheduledEventRunner(this, &RTCPeerConnection::dispatchScheduled Event)
140 , m_stopped(false) 140 , m_stopped(false)
141 { 141 {
142 ScriptWrappable::init(this); 142 ScriptWrappable::init(this);
143 Document* document = toDocument(executionContext()); 143 Document* document = toDocument(executionContext());
144 144
145 if (!document->frame()) { 145 if (!document->frame()) {
146 es.throwUninformativeAndGenericDOMException(NotSupportedError); 146 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedErro r);
147 return; 147 return;
148 } 148 }
149 149
150 m_peerHandler = RTCPeerConnectionHandler::create(this); 150 m_peerHandler = RTCPeerConnectionHandler::create(this);
151 if (!m_peerHandler) { 151 if (!m_peerHandler) {
152 es.throwUninformativeAndGenericDOMException(NotSupportedError); 152 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedErro r);
153 return; 153 return;
154 } 154 }
155 155
156 document->frame()->loader().client()->dispatchWillStartUsingPeerConnectionHa ndler(m_peerHandler.get()); 156 document->frame()->loader().client()->dispatchWillStartUsingPeerConnectionHa ndler(m_peerHandler.get());
157 157
158 if (!m_peerHandler->initialize(configuration, constraints)) { 158 if (!m_peerHandler->initialize(configuration, constraints)) {
159 es.throwUninformativeAndGenericDOMException(NotSupportedError); 159 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedErro r);
160 return; 160 return;
161 } 161 }
162 } 162 }
163 163
164 RTCPeerConnection::~RTCPeerConnection() 164 RTCPeerConnection::~RTCPeerConnection()
165 { 165 {
166 stop(); 166 stop();
167 } 167 }
168 168
169 void RTCPeerConnection::createOffer(PassRefPtr<RTCSessionDescriptionCallback> su ccessCallback, PassRefPtr<RTCErrorCallback> errorCallback, const Dictionary& med iaConstraints, ExceptionState& es) 169 void RTCPeerConnection::createOffer(PassRefPtr<RTCSessionDescriptionCallback> su ccessCallback, PassRefPtr<RTCErrorCallback> errorCallback, const Dictionary& med iaConstraints, ExceptionState& exceptionState)
170 { 170 {
171 if (m_signalingState == SignalingStateClosed) { 171 if (m_signalingState == SignalingStateClosed) {
172 es.throwUninformativeAndGenericDOMException(InvalidStateError); 172 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
173 return; 173 return;
174 } 174 }
175 175
176 if (!successCallback) { 176 if (!successCallback) {
177 es.throwUninformativeAndGenericDOMException(TypeMismatchError); 177 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatchErro r);
178 return; 178 return;
179 } 179 }
180 180
181 RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaCon straints, es); 181 RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaCon straints, exceptionState);
182 if (es.hadException()) 182 if (exceptionState.hadException())
183 return; 183 return;
184 184
185 RefPtr<RTCSessionDescriptionRequestImpl> request = RTCSessionDescriptionRequ estImpl::create(executionContext(), successCallback, errorCallback); 185 RefPtr<RTCSessionDescriptionRequestImpl> request = RTCSessionDescriptionRequ estImpl::create(executionContext(), successCallback, errorCallback);
186 m_peerHandler->createOffer(request.release(), constraints); 186 m_peerHandler->createOffer(request.release(), constraints);
187 } 187 }
188 188
189 void RTCPeerConnection::createAnswer(PassRefPtr<RTCSessionDescriptionCallback> s uccessCallback, PassRefPtr<RTCErrorCallback> errorCallback, const Dictionary& me diaConstraints, ExceptionState& es) 189 void RTCPeerConnection::createAnswer(PassRefPtr<RTCSessionDescriptionCallback> s uccessCallback, PassRefPtr<RTCErrorCallback> errorCallback, const Dictionary& me diaConstraints, ExceptionState& exceptionState)
190 { 190 {
191 if (m_signalingState == SignalingStateClosed) { 191 if (m_signalingState == SignalingStateClosed) {
192 es.throwUninformativeAndGenericDOMException(InvalidStateError); 192 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
193 return; 193 return;
194 } 194 }
195 195
196 if (!successCallback) { 196 if (!successCallback) {
197 es.throwUninformativeAndGenericDOMException(TypeMismatchError); 197 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatchErro r);
198 return; 198 return;
199 } 199 }
200 200
201 RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaCon straints, es); 201 RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaCon straints, exceptionState);
202 if (es.hadException()) 202 if (exceptionState.hadException())
203 return; 203 return;
204 204
205 RefPtr<RTCSessionDescriptionRequestImpl> request = RTCSessionDescriptionRequ estImpl::create(executionContext(), successCallback, errorCallback); 205 RefPtr<RTCSessionDescriptionRequestImpl> request = RTCSessionDescriptionRequ estImpl::create(executionContext(), successCallback, errorCallback);
206 m_peerHandler->createAnswer(request.release(), constraints.release()); 206 m_peerHandler->createAnswer(request.release(), constraints.release());
207 } 207 }
208 208
209 void RTCPeerConnection::setLocalDescription(PassRefPtr<RTCSessionDescription> pr pSessionDescription, PassRefPtr<VoidCallback> successCallback, PassRefPtr<RTCErr orCallback> errorCallback, ExceptionState& es) 209 void RTCPeerConnection::setLocalDescription(PassRefPtr<RTCSessionDescription> pr pSessionDescription, PassRefPtr<VoidCallback> successCallback, PassRefPtr<RTCErr orCallback> errorCallback, ExceptionState& exceptionState)
210 { 210 {
211 if (m_signalingState == SignalingStateClosed) { 211 if (m_signalingState == SignalingStateClosed) {
212 es.throwUninformativeAndGenericDOMException(InvalidStateError); 212 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
213 return; 213 return;
214 } 214 }
215 215
216 RefPtr<RTCSessionDescription> sessionDescription = prpSessionDescription; 216 RefPtr<RTCSessionDescription> sessionDescription = prpSessionDescription;
217 if (!sessionDescription) { 217 if (!sessionDescription) {
218 es.throwUninformativeAndGenericDOMException(TypeMismatchError); 218 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatchErro r);
219 return; 219 return;
220 } 220 }
221 221
222 RefPtr<RTCVoidRequestImpl> request = RTCVoidRequestImpl::create(executionCon text(), successCallback, errorCallback); 222 RefPtr<RTCVoidRequestImpl> request = RTCVoidRequestImpl::create(executionCon text(), successCallback, errorCallback);
223 m_peerHandler->setLocalDescription(request.release(), sessionDescription->we bSessionDescription()); 223 m_peerHandler->setLocalDescription(request.release(), sessionDescription->we bSessionDescription());
224 } 224 }
225 225
226 PassRefPtr<RTCSessionDescription> RTCPeerConnection::localDescription(ExceptionS tate& es) 226 PassRefPtr<RTCSessionDescription> RTCPeerConnection::localDescription(ExceptionS tate& exceptionState)
227 { 227 {
228 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->local Description(); 228 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->local Description();
229 if (webSessionDescription.isNull()) 229 if (webSessionDescription.isNull())
230 return 0; 230 return 0;
231 231
232 RefPtr<RTCSessionDescription> sessionDescription = RTCSessionDescription::cr eate(webSessionDescription); 232 RefPtr<RTCSessionDescription> sessionDescription = RTCSessionDescription::cr eate(webSessionDescription);
233 return sessionDescription.release(); 233 return sessionDescription.release();
234 } 234 }
235 235
236 void RTCPeerConnection::setRemoteDescription(PassRefPtr<RTCSessionDescription> p rpSessionDescription, PassRefPtr<VoidCallback> successCallback, PassRefPtr<RTCEr rorCallback> errorCallback, ExceptionState& es) 236 void RTCPeerConnection::setRemoteDescription(PassRefPtr<RTCSessionDescription> p rpSessionDescription, PassRefPtr<VoidCallback> successCallback, PassRefPtr<RTCEr rorCallback> errorCallback, ExceptionState& exceptionState)
237 { 237 {
238 if (m_signalingState == SignalingStateClosed) { 238 if (m_signalingState == SignalingStateClosed) {
239 es.throwUninformativeAndGenericDOMException(InvalidStateError); 239 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
240 return; 240 return;
241 } 241 }
242 242
243 RefPtr<RTCSessionDescription> sessionDescription = prpSessionDescription; 243 RefPtr<RTCSessionDescription> sessionDescription = prpSessionDescription;
244 if (!sessionDescription) { 244 if (!sessionDescription) {
245 es.throwUninformativeAndGenericDOMException(TypeMismatchError); 245 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatchErro r);
246 return; 246 return;
247 } 247 }
248 248
249 RefPtr<RTCVoidRequestImpl> request = RTCVoidRequestImpl::create(executionCon text(), successCallback, errorCallback); 249 RefPtr<RTCVoidRequestImpl> request = RTCVoidRequestImpl::create(executionCon text(), successCallback, errorCallback);
250 m_peerHandler->setRemoteDescription(request.release(), sessionDescription->w ebSessionDescription()); 250 m_peerHandler->setRemoteDescription(request.release(), sessionDescription->w ebSessionDescription());
251 } 251 }
252 252
253 PassRefPtr<RTCSessionDescription> RTCPeerConnection::remoteDescription(Exception State& es) 253 PassRefPtr<RTCSessionDescription> RTCPeerConnection::remoteDescription(Exception State& exceptionState)
254 { 254 {
255 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->remot eDescription(); 255 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->remot eDescription();
256 if (webSessionDescription.isNull()) 256 if (webSessionDescription.isNull())
257 return 0; 257 return 0;
258 258
259 RefPtr<RTCSessionDescription> desc = RTCSessionDescription::create(webSessio nDescription); 259 RefPtr<RTCSessionDescription> desc = RTCSessionDescription::create(webSessio nDescription);
260 return desc.release(); 260 return desc.release();
261 } 261 }
262 262
263 void RTCPeerConnection::updateIce(const Dictionary& rtcConfiguration, const Dict ionary& mediaConstraints, ExceptionState& es) 263 void RTCPeerConnection::updateIce(const Dictionary& rtcConfiguration, const Dict ionary& mediaConstraints, ExceptionState& exceptionState)
264 { 264 {
265 if (m_signalingState == SignalingStateClosed) { 265 if (m_signalingState == SignalingStateClosed) {
266 es.throwUninformativeAndGenericDOMException(InvalidStateError); 266 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
267 return; 267 return;
268 } 268 }
269 269
270 RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration , es); 270 RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration , exceptionState);
271 if (es.hadException()) 271 if (exceptionState.hadException())
272 return; 272 return;
273 273
274 RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaCon straints, es); 274 RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaCon straints, exceptionState);
275 if (es.hadException()) 275 if (exceptionState.hadException())
276 return; 276 return;
277 277
278 bool valid = m_peerHandler->updateIce(configuration, constraints); 278 bool valid = m_peerHandler->updateIce(configuration, constraints);
279 if (!valid) 279 if (!valid)
280 es.throwUninformativeAndGenericDOMException(SyntaxError); 280 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError);
281 } 281 }
282 282
283 void RTCPeerConnection::addIceCandidate(RTCIceCandidate* iceCandidate, Exception State& es) 283 void RTCPeerConnection::addIceCandidate(RTCIceCandidate* iceCandidate, Exception State& exceptionState)
284 { 284 {
285 if (m_signalingState == SignalingStateClosed) { 285 if (m_signalingState == SignalingStateClosed) {
286 es.throwUninformativeAndGenericDOMException(InvalidStateError); 286 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
287 return; 287 return;
288 } 288 }
289 289
290 if (!iceCandidate) { 290 if (!iceCandidate) {
291 es.throwUninformativeAndGenericDOMException(TypeMismatchError); 291 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatchErro r);
292 return; 292 return;
293 } 293 }
294 294
295 bool valid = m_peerHandler->addIceCandidate(iceCandidate->webCandidate()); 295 bool valid = m_peerHandler->addIceCandidate(iceCandidate->webCandidate());
296 if (!valid) 296 if (!valid)
297 es.throwUninformativeAndGenericDOMException(SyntaxError); 297 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError);
298 } 298 }
299 299
300 void RTCPeerConnection::addIceCandidate(RTCIceCandidate* iceCandidate, PassRefPt r<VoidCallback> successCallback, PassRefPtr<RTCErrorCallback> errorCallback, Exc eptionState& es) 300 void RTCPeerConnection::addIceCandidate(RTCIceCandidate* iceCandidate, PassRefPt r<VoidCallback> successCallback, PassRefPtr<RTCErrorCallback> errorCallback, Exc eptionState& exceptionState)
301 { 301 {
302 if (m_signalingState == SignalingStateClosed) { 302 if (m_signalingState == SignalingStateClosed) {
303 es.throwUninformativeAndGenericDOMException(InvalidStateError); 303 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
304 return; 304 return;
305 } 305 }
306 306
307 if (!iceCandidate || !successCallback || !errorCallback) { 307 if (!iceCandidate || !successCallback || !errorCallback) {
308 es.throwUninformativeAndGenericDOMException(TypeMismatchError); 308 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatchErro r);
309 return; 309 return;
310 } 310 }
311 311
312 RefPtr<RTCVoidRequestImpl> request = RTCVoidRequestImpl::create(executionCon text(), successCallback, errorCallback); 312 RefPtr<RTCVoidRequestImpl> request = RTCVoidRequestImpl::create(executionCon text(), successCallback, errorCallback);
313 313
314 bool implemented = m_peerHandler->addIceCandidate(request.release(), iceCand idate->webCandidate()); 314 bool implemented = m_peerHandler->addIceCandidate(request.release(), iceCand idate->webCandidate());
315 if (!implemented) 315 if (!implemented)
316 es.throwUninformativeAndGenericDOMException(NotSupportedError); 316 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedErro r);
317 } 317 }
318 318
319 String RTCPeerConnection::signalingState() const 319 String RTCPeerConnection::signalingState() const
320 { 320 {
321 switch (m_signalingState) { 321 switch (m_signalingState) {
322 case SignalingStateStable: 322 case SignalingStateStable:
323 return "stable"; 323 return "stable";
324 case SignalingStateHaveLocalOffer: 324 case SignalingStateHaveLocalOffer:
325 return "have-local-offer"; 325 return "have-local-offer";
326 case SignalingStateHaveRemoteOffer: 326 case SignalingStateHaveRemoteOffer:
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 case IceConnectionStateDisconnected: 368 case IceConnectionStateDisconnected:
369 return "disconnected"; 369 return "disconnected";
370 case IceConnectionStateClosed: 370 case IceConnectionStateClosed:
371 return "closed"; 371 return "closed";
372 } 372 }
373 373
374 ASSERT_NOT_REACHED(); 374 ASSERT_NOT_REACHED();
375 return String(); 375 return String();
376 } 376 }
377 377
378 void RTCPeerConnection::addStream(PassRefPtr<MediaStream> prpStream, const Dicti onary& mediaConstraints, ExceptionState& es) 378 void RTCPeerConnection::addStream(PassRefPtr<MediaStream> prpStream, const Dicti onary& mediaConstraints, ExceptionState& exceptionState)
379 { 379 {
380 if (m_signalingState == SignalingStateClosed) { 380 if (m_signalingState == SignalingStateClosed) {
381 es.throwUninformativeAndGenericDOMException(InvalidStateError); 381 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
382 return; 382 return;
383 } 383 }
384 384
385 RefPtr<MediaStream> stream = prpStream; 385 RefPtr<MediaStream> stream = prpStream;
386 if (!stream) { 386 if (!stream) {
387 es.throwUninformativeAndGenericDOMException(TypeMismatchError); 387 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatchErro r);
388 return; 388 return;
389 } 389 }
390 390
391 if (m_localStreams.contains(stream)) 391 if (m_localStreams.contains(stream))
392 return; 392 return;
393 393
394 RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaCon straints, es); 394 RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaCon straints, exceptionState);
395 if (es.hadException()) 395 if (exceptionState.hadException())
396 return; 396 return;
397 397
398 m_localStreams.append(stream); 398 m_localStreams.append(stream);
399 399
400 bool valid = m_peerHandler->addStream(stream->descriptor(), constraints); 400 bool valid = m_peerHandler->addStream(stream->descriptor(), constraints);
401 if (!valid) 401 if (!valid)
402 es.throwUninformativeAndGenericDOMException(SyntaxError); 402 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError);
403 } 403 }
404 404
405 void RTCPeerConnection::removeStream(PassRefPtr<MediaStream> prpStream, Exceptio nState& es) 405 void RTCPeerConnection::removeStream(PassRefPtr<MediaStream> prpStream, Exceptio nState& exceptionState)
406 { 406 {
407 if (m_signalingState == SignalingStateClosed) { 407 if (m_signalingState == SignalingStateClosed) {
408 es.throwUninformativeAndGenericDOMException(InvalidStateError); 408 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
409 return; 409 return;
410 } 410 }
411 411
412 if (!prpStream) { 412 if (!prpStream) {
413 es.throwUninformativeAndGenericDOMException(TypeMismatchError); 413 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatchErro r);
414 return; 414 return;
415 } 415 }
416 416
417 RefPtr<MediaStream> stream = prpStream; 417 RefPtr<MediaStream> stream = prpStream;
418 418
419 size_t pos = m_localStreams.find(stream); 419 size_t pos = m_localStreams.find(stream);
420 if (pos == kNotFound) 420 if (pos == kNotFound)
421 return; 421 return;
422 422
423 m_localStreams.remove(pos); 423 m_localStreams.remove(pos);
(...skipping 26 matching lines...) Expand all
450 return 0; 450 return 0;
451 } 451 }
452 452
453 void RTCPeerConnection::getStats(PassRefPtr<RTCStatsCallback> successCallback, P assRefPtr<MediaStreamTrack> selector) 453 void RTCPeerConnection::getStats(PassRefPtr<RTCStatsCallback> successCallback, P assRefPtr<MediaStreamTrack> selector)
454 { 454 {
455 RefPtr<RTCStatsRequestImpl> statsRequest = RTCStatsRequestImpl::create(execu tionContext(), successCallback, selector); 455 RefPtr<RTCStatsRequestImpl> statsRequest = RTCStatsRequestImpl::create(execu tionContext(), successCallback, selector);
456 // FIXME: Add passing selector as part of the statsRequest. 456 // FIXME: Add passing selector as part of the statsRequest.
457 m_peerHandler->getStats(statsRequest.release()); 457 m_peerHandler->getStats(statsRequest.release());
458 } 458 }
459 459
460 PassRefPtr<RTCDataChannel> RTCPeerConnection::createDataChannel(String label, co nst Dictionary& options, ExceptionState& es) 460 PassRefPtr<RTCDataChannel> RTCPeerConnection::createDataChannel(String label, co nst Dictionary& options, ExceptionState& exceptionState)
461 { 461 {
462 if (m_signalingState == SignalingStateClosed) { 462 if (m_signalingState == SignalingStateClosed) {
463 es.throwUninformativeAndGenericDOMException(InvalidStateError); 463 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
464 return 0; 464 return 0;
465 } 465 }
466 466
467 blink::WebRTCDataChannelInit init; 467 blink::WebRTCDataChannelInit init;
468 options.get("ordered", init.ordered); 468 options.get("ordered", init.ordered);
469 options.get("negotiated", init.negotiated); 469 options.get("negotiated", init.negotiated);
470 470
471 unsigned short value = 0; 471 unsigned short value = 0;
472 if (options.get("id", value)) 472 if (options.get("id", value))
473 init.id = value; 473 init.id = value;
474 if (options.get("maxRetransmits", value)) 474 if (options.get("maxRetransmits", value))
475 init.maxRetransmits = value; 475 init.maxRetransmits = value;
476 if (options.get("maxRetransmitTime", value)) 476 if (options.get("maxRetransmitTime", value))
477 init.maxRetransmitTime = value; 477 init.maxRetransmitTime = value;
478 478
479 String protocolString; 479 String protocolString;
480 options.get("protocol", protocolString); 480 options.get("protocol", protocolString);
481 init.protocol = protocolString; 481 init.protocol = protocolString;
482 482
483 RefPtr<RTCDataChannel> channel = RTCDataChannel::create(executionContext(), m_peerHandler.get(), label, init, es); 483 RefPtr<RTCDataChannel> channel = RTCDataChannel::create(executionContext(), m_peerHandler.get(), label, init, exceptionState);
484 if (es.hadException()) 484 if (exceptionState.hadException())
485 return 0; 485 return 0;
486 m_dataChannels.append(channel); 486 m_dataChannels.append(channel);
487 return channel.release(); 487 return channel.release();
488 } 488 }
489 489
490 bool RTCPeerConnection::hasLocalStreamWithTrackId(const String& trackId) 490 bool RTCPeerConnection::hasLocalStreamWithTrackId(const String& trackId)
491 { 491 {
492 for (MediaStreamVector::iterator iter = m_localStreams.begin(); iter != m_lo calStreams.end(); ++iter) { 492 for (MediaStreamVector::iterator iter = m_localStreams.begin(); iter != m_lo calStreams.end(); ++iter) {
493 if ((*iter)->getTrackById(trackId)) 493 if ((*iter)->getTrackById(trackId))
494 return true; 494 return true;
495 } 495 }
496 return false; 496 return false;
497 } 497 }
498 498
499 PassRefPtr<RTCDTMFSender> RTCPeerConnection::createDTMFSender(PassRefPtr<MediaSt reamTrack> prpTrack, ExceptionState& es) 499 PassRefPtr<RTCDTMFSender> RTCPeerConnection::createDTMFSender(PassRefPtr<MediaSt reamTrack> prpTrack, ExceptionState& exceptionState)
500 { 500 {
501 if (m_signalingState == SignalingStateClosed) { 501 if (m_signalingState == SignalingStateClosed) {
502 es.throwUninformativeAndGenericDOMException(InvalidStateError); 502 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
503 return 0; 503 return 0;
504 } 504 }
505 505
506 if (!prpTrack) { 506 if (!prpTrack) {
507 es.throwUninformativeAndGenericTypeError(); 507 exceptionState.throwUninformativeAndGenericTypeError();
508 return 0; 508 return 0;
509 } 509 }
510 510
511 RefPtr<MediaStreamTrack> track = prpTrack; 511 RefPtr<MediaStreamTrack> track = prpTrack;
512 512
513 if (!hasLocalStreamWithTrackId(track->id())) { 513 if (!hasLocalStreamWithTrackId(track->id())) {
514 es.throwUninformativeAndGenericDOMException(SyntaxError); 514 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError);
515 return 0; 515 return 0;
516 } 516 }
517 517
518 RefPtr<RTCDTMFSender> dtmfSender = RTCDTMFSender::create(executionContext(), m_peerHandler.get(), track.release(), es); 518 RefPtr<RTCDTMFSender> dtmfSender = RTCDTMFSender::create(executionContext(), m_peerHandler.get(), track.release(), exceptionState);
519 if (es.hadException()) 519 if (exceptionState.hadException())
520 return 0; 520 return 0;
521 return dtmfSender.release(); 521 return dtmfSender.release();
522 } 522 }
523 523
524 void RTCPeerConnection::close(ExceptionState& es) 524 void RTCPeerConnection::close(ExceptionState& exceptionState)
525 { 525 {
526 if (m_signalingState == SignalingStateClosed) { 526 if (m_signalingState == SignalingStateClosed) {
527 es.throwUninformativeAndGenericDOMException(InvalidStateError); 527 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
528 return; 528 return;
529 } 529 }
530 530
531 m_peerHandler->stop(); 531 m_peerHandler->stop();
532 532
533 changeIceConnectionState(IceConnectionStateClosed); 533 changeIceConnectionState(IceConnectionStateClosed);
534 changeIceGatheringState(IceGatheringStateComplete); 534 changeIceGatheringState(IceGatheringStateComplete);
535 changeSignalingState(SignalingStateClosed); 535 changeSignalingState(SignalingStateClosed);
536 } 536 }
537 537
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 events.swap(m_scheduledEvents); 686 events.swap(m_scheduledEvents);
687 687
688 Vector<RefPtr<Event> >::iterator it = events.begin(); 688 Vector<RefPtr<Event> >::iterator it = events.begin();
689 for (; it != events.end(); ++it) 689 for (; it != events.end(); ++it)
690 dispatchEvent((*it).release()); 690 dispatchEvent((*it).release());
691 691
692 events.clear(); 692 events.clear();
693 } 693 }
694 694
695 } // namespace WebCore 695 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/mediastream/RTCIceCandidate.cpp ('k') | Source/modules/mediastream/RTCSessionDescription.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698