OLD | NEW |
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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 m_peerHandler->createAnswer(request.release(), constraints); | 241 m_peerHandler->createAnswer(request.release(), constraints); |
242 } | 242 } |
243 | 243 |
244 void RTCPeerConnection::setLocalDescription(PassRefPtr<RTCSessionDescription> pr
pSessionDescription, PassOwnPtr<VoidCallback> successCallback, PassOwnPtr<RTCErr
orCallback> errorCallback, ExceptionState& exceptionState) | 244 void RTCPeerConnection::setLocalDescription(PassRefPtr<RTCSessionDescription> pr
pSessionDescription, PassOwnPtr<VoidCallback> successCallback, PassOwnPtr<RTCErr
orCallback> errorCallback, ExceptionState& exceptionState) |
245 { | 245 { |
246 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 246 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
247 return; | 247 return; |
248 | 248 |
249 RefPtr<RTCSessionDescription> sessionDescription = prpSessionDescription; | 249 RefPtr<RTCSessionDescription> sessionDescription = prpSessionDescription; |
250 if (!sessionDescription) { | 250 if (!sessionDescription) { |
251 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a
rgumentNullOrIncorrectType(1, "RTCSessionDescription")); | 251 exceptionState.throwDOMException(TypeError, ExceptionMessages::argumentN
ullOrIncorrectType(1, "RTCSessionDescription")); |
252 return; | 252 return; |
253 } | 253 } |
254 | 254 |
255 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext
(), successCallback, errorCallback); | 255 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext
(), successCallback, errorCallback); |
256 m_peerHandler->setLocalDescription(request.release(), sessionDescription->we
bSessionDescription()); | 256 m_peerHandler->setLocalDescription(request.release(), sessionDescription->we
bSessionDescription()); |
257 } | 257 } |
258 | 258 |
259 PassRefPtr<RTCSessionDescription> RTCPeerConnection::localDescription(ExceptionS
tate& exceptionState) | 259 PassRefPtr<RTCSessionDescription> RTCPeerConnection::localDescription(ExceptionS
tate& exceptionState) |
260 { | 260 { |
261 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->local
Description(); | 261 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->local
Description(); |
262 if (webSessionDescription.isNull()) | 262 if (webSessionDescription.isNull()) |
263 return nullptr; | 263 return nullptr; |
264 | 264 |
265 RefPtr<RTCSessionDescription> sessionDescription = RTCSessionDescription::cr
eate(webSessionDescription); | 265 RefPtr<RTCSessionDescription> sessionDescription = RTCSessionDescription::cr
eate(webSessionDescription); |
266 return sessionDescription.release(); | 266 return sessionDescription.release(); |
267 } | 267 } |
268 | 268 |
269 void RTCPeerConnection::setRemoteDescription(PassRefPtr<RTCSessionDescription> p
rpSessionDescription, PassOwnPtr<VoidCallback> successCallback, PassOwnPtr<RTCEr
rorCallback> errorCallback, ExceptionState& exceptionState) | 269 void RTCPeerConnection::setRemoteDescription(PassRefPtr<RTCSessionDescription> p
rpSessionDescription, PassOwnPtr<VoidCallback> successCallback, PassOwnPtr<RTCEr
rorCallback> errorCallback, ExceptionState& exceptionState) |
270 { | 270 { |
271 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 271 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
272 return; | 272 return; |
273 | 273 |
274 RefPtr<RTCSessionDescription> sessionDescription = prpSessionDescription; | 274 RefPtr<RTCSessionDescription> sessionDescription = prpSessionDescription; |
275 if (!sessionDescription) { | 275 if (!sessionDescription) { |
276 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a
rgumentNullOrIncorrectType(1, "RTCSessionDescription")); | 276 exceptionState.throwDOMException(TypeError, ExceptionMessages::argumentN
ullOrIncorrectType(1, "RTCSessionDescription")); |
277 return; | 277 return; |
278 } | 278 } |
279 | 279 |
280 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext
(), successCallback, errorCallback); | 280 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext
(), successCallback, errorCallback); |
281 m_peerHandler->setRemoteDescription(request.release(), sessionDescription->w
ebSessionDescription()); | 281 m_peerHandler->setRemoteDescription(request.release(), sessionDescription->w
ebSessionDescription()); |
282 } | 282 } |
283 | 283 |
284 PassRefPtr<RTCSessionDescription> RTCPeerConnection::remoteDescription(Exception
State& exceptionState) | 284 PassRefPtr<RTCSessionDescription> RTCPeerConnection::remoteDescription(Exception
State& exceptionState) |
285 { | 285 { |
286 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->remot
eDescription(); | 286 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->remot
eDescription(); |
(...skipping 21 matching lines...) Expand all Loading... |
308 if (!valid) | 308 if (!valid) |
309 exceptionState.throwDOMException(SyntaxError, "Could not update the ICE
Agent with the given configuration."); | 309 exceptionState.throwDOMException(SyntaxError, "Could not update the ICE
Agent with the given configuration."); |
310 } | 310 } |
311 | 311 |
312 void RTCPeerConnection::addIceCandidate(RTCIceCandidate* iceCandidate, Exception
State& exceptionState) | 312 void RTCPeerConnection::addIceCandidate(RTCIceCandidate* iceCandidate, Exception
State& exceptionState) |
313 { | 313 { |
314 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 314 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
315 return; | 315 return; |
316 | 316 |
317 if (!iceCandidate) { | 317 if (!iceCandidate) { |
318 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a
rgumentNullOrIncorrectType(1, "RTCIceCandidate")); | 318 exceptionState.throwDOMException(TypeError, ExceptionMessages::argumentN
ullOrIncorrectType(1, "RTCIceCandidate")); |
319 return; | 319 return; |
320 } | 320 } |
321 | 321 |
322 bool valid = m_peerHandler->addICECandidate(iceCandidate->webCandidate()); | 322 bool valid = m_peerHandler->addICECandidate(iceCandidate->webCandidate()); |
323 if (!valid) | 323 if (!valid) |
324 exceptionState.throwDOMException(SyntaxError, "The ICE candidate could n
ot be added."); | 324 exceptionState.throwDOMException(SyntaxError, "The ICE candidate could n
ot be added."); |
325 } | 325 } |
326 | 326 |
327 void RTCPeerConnection::addIceCandidate(RTCIceCandidate* iceCandidate, PassOwnPt
r<VoidCallback> successCallback, PassOwnPtr<RTCErrorCallback> errorCallback, Exc
eptionState& exceptionState) | 327 void RTCPeerConnection::addIceCandidate(RTCIceCandidate* iceCandidate, PassOwnPt
r<VoidCallback> successCallback, PassOwnPtr<RTCErrorCallback> errorCallback, Exc
eptionState& exceptionState) |
328 { | 328 { |
329 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 329 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
330 return; | 330 return; |
331 | 331 |
332 if (!iceCandidate) { | 332 if (!iceCandidate) { |
333 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a
rgumentNullOrIncorrectType(1, "RTCIceCandidate")); | 333 exceptionState.throwDOMException(TypeError, ExceptionMessages::argumentN
ullOrIncorrectType(1, "RTCIceCandidate")); |
334 return; | 334 return; |
335 } | 335 } |
336 ASSERT(successCallback); | 336 ASSERT(successCallback); |
337 ASSERT(errorCallback); | 337 ASSERT(errorCallback); |
338 | 338 |
339 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext
(), successCallback, errorCallback); | 339 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext
(), successCallback, errorCallback); |
340 | 340 |
341 bool implemented = m_peerHandler->addICECandidate(request.release(), iceCand
idate->webCandidate()); | 341 bool implemented = m_peerHandler->addICECandidate(request.release(), iceCand
idate->webCandidate()); |
342 if (!implemented) | 342 if (!implemented) |
343 exceptionState.throwDOMException(NotSupportedError, "This method is not
yet implemented."); | 343 exceptionState.throwDOMException(NotSupportedError, "This method is not
yet implemented."); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 return String(); | 402 return String(); |
403 } | 403 } |
404 | 404 |
405 void RTCPeerConnection::addStream(PassRefPtr<MediaStream> prpStream, const Dicti
onary& mediaConstraints, ExceptionState& exceptionState) | 405 void RTCPeerConnection::addStream(PassRefPtr<MediaStream> prpStream, const Dicti
onary& mediaConstraints, ExceptionState& exceptionState) |
406 { | 406 { |
407 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 407 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
408 return; | 408 return; |
409 | 409 |
410 RefPtr<MediaStream> stream = prpStream; | 410 RefPtr<MediaStream> stream = prpStream; |
411 if (!stream) { | 411 if (!stream) { |
412 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a
rgumentNullOrIncorrectType(1, "MediaStream")); | 412 exceptionState.throwDOMException(TypeError, ExceptionMessages::argumentN
ullOrIncorrectType(1, "MediaStream")); |
413 return; | 413 return; |
414 } | 414 } |
415 | 415 |
416 if (m_localStreams.contains(stream)) | 416 if (m_localStreams.contains(stream)) |
417 return; | 417 return; |
418 | 418 |
419 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC
onstraints, exceptionState); | 419 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC
onstraints, exceptionState); |
420 if (exceptionState.hadException()) | 420 if (exceptionState.hadException()) |
421 return; | 421 return; |
422 | 422 |
423 m_localStreams.append(stream); | 423 m_localStreams.append(stream); |
424 | 424 |
425 bool valid = m_peerHandler->addStream(stream->descriptor(), constraints); | 425 bool valid = m_peerHandler->addStream(stream->descriptor(), constraints); |
426 if (!valid) | 426 if (!valid) |
427 exceptionState.throwDOMException(SyntaxError, "Unable to add the provide
d stream."); | 427 exceptionState.throwDOMException(SyntaxError, "Unable to add the provide
d stream."); |
428 } | 428 } |
429 | 429 |
430 void RTCPeerConnection::removeStream(PassRefPtr<MediaStream> prpStream, Exceptio
nState& exceptionState) | 430 void RTCPeerConnection::removeStream(PassRefPtr<MediaStream> prpStream, Exceptio
nState& exceptionState) |
431 { | 431 { |
432 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 432 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
433 return; | 433 return; |
434 | 434 |
435 if (!prpStream) { | 435 if (!prpStream) { |
436 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a
rgumentNullOrIncorrectType(1, "MediaStream")); | 436 exceptionState.throwDOMException(TypeError, ExceptionMessages::argumentN
ullOrIncorrectType(1, "MediaStream")); |
437 return; | 437 return; |
438 } | 438 } |
439 | 439 |
440 RefPtr<MediaStream> stream = prpStream; | 440 RefPtr<MediaStream> stream = prpStream; |
441 | 441 |
442 size_t pos = m_localStreams.find(stream); | 442 size_t pos = m_localStreams.find(stream); |
443 if (pos == kNotFound) | 443 if (pos == kNotFound) |
444 return; | 444 return; |
445 | 445 |
446 m_localStreams.remove(pos); | 446 m_localStreams.remove(pos); |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 events.swap(m_scheduledEvents); | 705 events.swap(m_scheduledEvents); |
706 | 706 |
707 WillBeHeapVector<RefPtrWillBeMember<Event> >::iterator it = events.begin(); | 707 WillBeHeapVector<RefPtrWillBeMember<Event> >::iterator it = events.begin(); |
708 for (; it != events.end(); ++it) | 708 for (; it != events.end(); ++it) |
709 dispatchEvent((*it).release()); | 709 dispatchEvent((*it).release()); |
710 | 710 |
711 events.clear(); | 711 events.clear(); |
712 } | 712 } |
713 | 713 |
714 } // namespace WebCore | 714 } // namespace WebCore |
OLD | NEW |