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 23 matching lines...) Expand all Loading... |
34 #include "bindings/core/v8/ArrayValue.h" | 34 #include "bindings/core/v8/ArrayValue.h" |
35 #include "bindings/core/v8/ExceptionMessages.h" | 35 #include "bindings/core/v8/ExceptionMessages.h" |
36 #include "bindings/core/v8/ExceptionState.h" | 36 #include "bindings/core/v8/ExceptionState.h" |
37 #include "bindings/core/v8/Nullable.h" | 37 #include "bindings/core/v8/Nullable.h" |
38 #include "bindings/core/v8/ScriptPromiseResolver.h" | 38 #include "bindings/core/v8/ScriptPromiseResolver.h" |
39 #include "bindings/modules/v8/V8RTCCertificate.h" | 39 #include "bindings/modules/v8/V8RTCCertificate.h" |
40 #include "core/dom/Document.h" | 40 #include "core/dom/Document.h" |
41 #include "core/dom/ExceptionCode.h" | 41 #include "core/dom/ExceptionCode.h" |
42 #include "core/dom/ExecutionContext.h" | 42 #include "core/dom/ExecutionContext.h" |
43 #include "core/frame/LocalFrame.h" | 43 #include "core/frame/LocalFrame.h" |
| 44 #include "core/frame/UseCounter.h" |
44 #include "core/html/VoidCallback.h" | 45 #include "core/html/VoidCallback.h" |
45 #include "core/loader/FrameLoader.h" | 46 #include "core/loader/FrameLoader.h" |
46 #include "core/loader/FrameLoaderClient.h" | 47 #include "core/loader/FrameLoaderClient.h" |
47 #include "modules/crypto/CryptoResultImpl.h" | 48 #include "modules/crypto/CryptoResultImpl.h" |
48 #include "modules/mediastream/MediaConstraintsImpl.h" | 49 #include "modules/mediastream/MediaConstraintsImpl.h" |
49 #include "modules/mediastream/MediaStreamEvent.h" | 50 #include "modules/mediastream/MediaStreamEvent.h" |
50 #include "modules/mediastream/RTCDTMFSender.h" | 51 #include "modules/mediastream/RTCDTMFSender.h" |
51 #include "modules/mediastream/RTCDataChannel.h" | 52 #include "modules/mediastream/RTCDataChannel.h" |
52 #include "modules/mediastream/RTCDataChannelEvent.h" | 53 #include "modules/mediastream/RTCDataChannelEvent.h" |
53 #include "modules/mediastream/RTCErrorCallback.h" | 54 #include "modules/mediastream/RTCErrorCallback.h" |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 | 294 |
294 DictionaryHelper::get(options, "voiceActivityDetection", voiceActivityDetect
ion); | 295 DictionaryHelper::get(options, "voiceActivityDetection", voiceActivityDetect
ion); |
295 DictionaryHelper::get(options, "iceRestart", iceRestart); | 296 DictionaryHelper::get(options, "iceRestart", iceRestart); |
296 | 297 |
297 RTCOfferOptions* rtcOfferOptions = RTCOfferOptions::create(offerToReceiveVid
eo, offerToReceiveAudio, voiceActivityDetection, iceRestart); | 298 RTCOfferOptions* rtcOfferOptions = RTCOfferOptions::create(offerToReceiveVid
eo, offerToReceiveAudio, voiceActivityDetection, iceRestart); |
298 return rtcOfferOptions; | 299 return rtcOfferOptions; |
299 } | 300 } |
300 | 301 |
301 RTCPeerConnection* RTCPeerConnection::create(ExecutionContext* context, const Di
ctionary& rtcConfiguration, const Dictionary& mediaConstraints, ExceptionState&
exceptionState) | 302 RTCPeerConnection* RTCPeerConnection::create(ExecutionContext* context, const Di
ctionary& rtcConfiguration, const Dictionary& mediaConstraints, ExceptionState&
exceptionState) |
302 { | 303 { |
| 304 if (mediaConstraints.isObject()) |
| 305 UseCounter::count(context, UseCounter::RTCPeerConnectionConstructorConst
raints); |
| 306 else |
| 307 UseCounter::count(context, UseCounter::RTCPeerConnectionConstructorCompl
iant); |
| 308 |
303 RTCConfiguration* configuration = parseConfiguration(rtcConfiguration, excep
tionState); | 309 RTCConfiguration* configuration = parseConfiguration(rtcConfiguration, excep
tionState); |
304 if (exceptionState.hadException()) | 310 if (exceptionState.hadException()) |
305 return 0; | 311 return 0; |
306 | 312 |
307 WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaConstrai
nts, exceptionState); | 313 WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaConstrai
nts, exceptionState); |
308 if (exceptionState.hadException()) | 314 if (exceptionState.hadException()) |
309 return 0; | 315 return 0; |
310 | 316 |
311 RTCPeerConnection* peerConnection = new RTCPeerConnection(context, configura
tion, constraints, exceptionState); | 317 RTCPeerConnection* peerConnection = new RTCPeerConnection(context, configura
tion, constraints, exceptionState); |
312 peerConnection->suspendIfNeeded(); | 318 peerConnection->suspendIfNeeded(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 } | 360 } |
355 } | 361 } |
356 | 362 |
357 RTCPeerConnection::~RTCPeerConnection() | 363 RTCPeerConnection::~RTCPeerConnection() |
358 { | 364 { |
359 // This checks that close() or stop() is called before the destructor. | 365 // This checks that close() or stop() is called before the destructor. |
360 // We are assuming that a wrapper is always created when RTCPeerConnection i
s created. | 366 // We are assuming that a wrapper is always created when RTCPeerConnection i
s created. |
361 ASSERT(m_closed || m_stopped); | 367 ASSERT(m_closed || m_stopped); |
362 } | 368 } |
363 | 369 |
364 void RTCPeerConnection::createOffer(RTCSessionDescriptionCallback* successCallba
ck, RTCErrorCallback* errorCallback, const Dictionary& rtcOfferOptions, Exceptio
nState& exceptionState) | 370 void RTCPeerConnection::createOffer(ExecutionContext* context, RTCSessionDescrip
tionCallback* successCallback, RTCErrorCallback* errorCallback, const Dictionary
& rtcOfferOptions, ExceptionState& exceptionState) |
365 { | 371 { |
| 372 if (errorCallback) |
| 373 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferLegac
yFailureCallback); |
| 374 else |
| 375 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferLegac
yNoFailureCallback); |
| 376 |
366 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 377 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
367 return; | 378 return; |
368 | 379 |
369 ASSERT(successCallback); | 380 ASSERT(successCallback); |
370 | 381 |
371 RTCOfferOptions* offerOptions = parseOfferOptions(rtcOfferOptions, exception
State); | 382 RTCOfferOptions* offerOptions = parseOfferOptions(rtcOfferOptions, exception
State); |
372 if (exceptionState.hadException()) | 383 if (exceptionState.hadException()) |
373 return; | 384 return; |
374 | 385 |
375 RTCSessionDescriptionRequest* request = RTCSessionDescriptionRequestImpl::cr
eate(executionContext(), this, successCallback, errorCallback); | 386 RTCSessionDescriptionRequest* request = RTCSessionDescriptionRequestImpl::cr
eate(executionContext(), this, successCallback, errorCallback); |
376 | 387 |
377 if (offerOptions) { | 388 if (offerOptions) { |
| 389 if (offerOptions->offerToReceiveAudio() != -1 || offerOptions->offerToRe
ceiveVideo() != -1) |
| 390 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferL
egacyOfferOptions); |
| 391 else if (errorCallback) |
| 392 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferL
egacyCompliant); |
| 393 |
378 m_peerHandler->createOffer(request, offerOptions); | 394 m_peerHandler->createOffer(request, offerOptions); |
379 } else { | 395 } else { |
380 WebMediaConstraints constraints = MediaConstraintsImpl::create(rtcOfferO
ptions, exceptionState); | 396 WebMediaConstraints constraints = MediaConstraintsImpl::create(rtcOfferO
ptions, exceptionState); |
381 if (exceptionState.hadException()) | 397 if (exceptionState.hadException()) |
382 return; | 398 return; |
383 | 399 |
| 400 if (!constraints.isEmpty()) |
| 401 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferL
egacyConstraints); |
| 402 else if (errorCallback) |
| 403 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferL
egacyCompliant); |
| 404 |
384 m_peerHandler->createOffer(request, constraints); | 405 m_peerHandler->createOffer(request, constraints); |
385 } | 406 } |
386 } | 407 } |
387 | 408 |
388 void RTCPeerConnection::createAnswer(RTCSessionDescriptionCallback* successCallb
ack, RTCErrorCallback* errorCallback, const Dictionary& mediaConstraints, Except
ionState& exceptionState) | 409 void RTCPeerConnection::createAnswer(ExecutionContext* context, RTCSessionDescri
ptionCallback* successCallback, RTCErrorCallback* errorCallback, const Dictionar
y& mediaConstraints, ExceptionState& exceptionState) |
389 { | 410 { |
| 411 if (errorCallback) |
| 412 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateAnswerLega
cyFailureCallback); |
| 413 else |
| 414 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateAnswerLega
cyNoFailureCallback); |
| 415 |
| 416 if (mediaConstraints.isObject()) |
| 417 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateAnswerLega
cyConstraints); |
| 418 else if (errorCallback) |
| 419 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateAnswerLega
cyCompliant); |
| 420 |
390 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 421 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
391 return; | 422 return; |
392 | 423 |
393 ASSERT(successCallback); | 424 ASSERT(successCallback); |
394 | 425 |
395 WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaConstrai
nts, exceptionState); | 426 WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaConstrai
nts, exceptionState); |
396 if (exceptionState.hadException()) | 427 if (exceptionState.hadException()) |
397 return; | 428 return; |
398 | 429 |
399 RTCSessionDescriptionRequest* request = RTCSessionDescriptionRequestImpl::cr
eate(executionContext(), this, successCallback, errorCallback); | 430 RTCSessionDescriptionRequest* request = RTCSessionDescriptionRequestImpl::cr
eate(executionContext(), this, successCallback, errorCallback); |
400 m_peerHandler->createAnswer(request, constraints); | 431 m_peerHandler->createAnswer(request, constraints); |
401 } | 432 } |
402 | 433 |
403 void RTCPeerConnection::setLocalDescription(RTCSessionDescription* sessionDescri
ption, VoidCallback* successCallback, RTCErrorCallback* errorCallback, Exception
State& exceptionState) | 434 void RTCPeerConnection::setLocalDescription(ExecutionContext* context, RTCSessio
nDescription* sessionDescription, VoidCallback* successCallback, RTCErrorCallbac
k* errorCallback, ExceptionState& exceptionState) |
404 { | 435 { |
| 436 if (successCallback && errorCallback) { |
| 437 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDescript
ionLegacyCompliant); |
| 438 } else { |
| 439 if (!successCallback) |
| 440 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDesc
riptionLegacyNoSuccessCallback); |
| 441 if (!errorCallback) |
| 442 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDesc
riptionLegacyNoFailureCallback); |
| 443 } |
| 444 |
405 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 445 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
406 return; | 446 return; |
407 | 447 |
408 ASSERT(sessionDescription); | 448 ASSERT(sessionDescription); |
409 | 449 |
410 RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), thi
s, successCallback, errorCallback); | 450 RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), thi
s, successCallback, errorCallback); |
411 m_peerHandler->setLocalDescription(request, sessionDescription->webSessionDe
scription()); | 451 m_peerHandler->setLocalDescription(request, sessionDescription->webSessionDe
scription()); |
412 } | 452 } |
413 | 453 |
414 RTCSessionDescription* RTCPeerConnection::localDescription() | 454 RTCSessionDescription* RTCPeerConnection::localDescription() |
415 { | 455 { |
416 WebRTCSessionDescription webSessionDescription = m_peerHandler->localDescrip
tion(); | 456 WebRTCSessionDescription webSessionDescription = m_peerHandler->localDescrip
tion(); |
417 if (webSessionDescription.isNull()) | 457 if (webSessionDescription.isNull()) |
418 return nullptr; | 458 return nullptr; |
419 | 459 |
420 return RTCSessionDescription::create(webSessionDescription); | 460 return RTCSessionDescription::create(webSessionDescription); |
421 } | 461 } |
422 | 462 |
423 void RTCPeerConnection::setRemoteDescription(RTCSessionDescription* sessionDescr
iption, VoidCallback* successCallback, RTCErrorCallback* errorCallback, Exceptio
nState& exceptionState) | 463 void RTCPeerConnection::setRemoteDescription(ExecutionContext* context, RTCSessi
onDescription* sessionDescription, VoidCallback* successCallback, RTCErrorCallba
ck* errorCallback, ExceptionState& exceptionState) |
424 { | 464 { |
| 465 if (successCallback && errorCallback) { |
| 466 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDescrip
tionLegacyCompliant); |
| 467 } else { |
| 468 if (!successCallback) |
| 469 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDes
criptionLegacyNoSuccessCallback); |
| 470 if (!errorCallback) |
| 471 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDes
criptionLegacyNoFailureCallback); |
| 472 } |
| 473 |
425 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 474 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
426 return; | 475 return; |
427 | 476 |
428 ASSERT(sessionDescription); | 477 ASSERT(sessionDescription); |
429 | 478 |
430 RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), thi
s, successCallback, errorCallback); | 479 RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), thi
s, successCallback, errorCallback); |
431 m_peerHandler->setRemoteDescription(request, sessionDescription->webSessionD
escription()); | 480 m_peerHandler->setRemoteDescription(request, sessionDescription->webSessionD
escription()); |
432 } | 481 } |
433 | 482 |
434 RTCSessionDescription* RTCPeerConnection::remoteDescription() | 483 RTCSessionDescription* RTCPeerConnection::remoteDescription() |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 } | 725 } |
677 | 726 |
678 for (MediaStreamVector::iterator iter = m_remoteStreams.begin(); iter != m_r
emoteStreams.end(); ++iter) { | 727 for (MediaStreamVector::iterator iter = m_remoteStreams.begin(); iter != m_r
emoteStreams.end(); ++iter) { |
679 if ((*iter)->id() == streamId) | 728 if ((*iter)->id() == streamId) |
680 return iter->get(); | 729 return iter->get(); |
681 } | 730 } |
682 | 731 |
683 return 0; | 732 return 0; |
684 } | 733 } |
685 | 734 |
686 void RTCPeerConnection::getStats(RTCStatsCallback* successCallback, MediaStreamT
rack* selector) | 735 void RTCPeerConnection::getStats(ExecutionContext* context, RTCStatsCallback* su
ccessCallback, MediaStreamTrack* selector) |
687 { | 736 { |
| 737 UseCounter::count(context, UseCounter::RTCPeerConnectionGetStatsLegacyNonCom
pliant); |
688 RTCStatsRequest* statsRequest = RTCStatsRequestImpl::create(executionContext
(), this, successCallback, selector); | 738 RTCStatsRequest* statsRequest = RTCStatsRequestImpl::create(executionContext
(), this, successCallback, selector); |
689 // FIXME: Add passing selector as part of the statsRequest. | 739 // FIXME: Add passing selector as part of the statsRequest. |
690 m_peerHandler->getStats(statsRequest); | 740 m_peerHandler->getStats(statsRequest); |
691 } | 741 } |
692 | 742 |
693 RTCDataChannel* RTCPeerConnection::createDataChannel(String label, const Diction
ary& options, ExceptionState& exceptionState) | 743 RTCDataChannel* RTCPeerConnection::createDataChannel(String label, const Diction
ary& options, ExceptionState& exceptionState) |
694 { | 744 { |
695 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 745 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
696 return nullptr; | 746 return nullptr; |
697 | 747 |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 { | 1004 { |
955 visitor->trace(m_localStreams); | 1005 visitor->trace(m_localStreams); |
956 visitor->trace(m_remoteStreams); | 1006 visitor->trace(m_remoteStreams); |
957 visitor->trace(m_dataChannels); | 1007 visitor->trace(m_dataChannels); |
958 visitor->trace(m_scheduledEvents); | 1008 visitor->trace(m_scheduledEvents); |
959 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac
e(visitor); | 1009 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac
e(visitor); |
960 ActiveDOMObject::trace(visitor); | 1010 ActiveDOMObject::trace(visitor); |
961 } | 1011 } |
962 | 1012 |
963 } // namespace blink | 1013 } // namespace blink |
OLD | NEW |