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 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 | 395 |
396 RTCPeerConnection::RTCPeerConnection(ExecutionContext* context, RTCConfiguration
* configuration, WebMediaConstraints constraints, ExceptionState& exceptionState
) | 396 RTCPeerConnection::RTCPeerConnection(ExecutionContext* context, RTCConfiguration
* configuration, WebMediaConstraints constraints, ExceptionState& exceptionState
) |
397 : ActiveDOMObject(context) | 397 : ActiveDOMObject(context) |
398 , m_signalingState(SignalingStateStable) | 398 , m_signalingState(SignalingStateStable) |
399 , m_iceGatheringState(ICEGatheringStateNew) | 399 , m_iceGatheringState(ICEGatheringStateNew) |
400 , m_iceConnectionState(ICEConnectionStateNew) | 400 , m_iceConnectionState(ICEConnectionStateNew) |
401 , m_dispatchScheduledEventRunner(AsyncMethodRunner<RTCPeerConnection>::creat
e(this, &RTCPeerConnection::dispatchScheduledEvent)) | 401 , m_dispatchScheduledEventRunner(AsyncMethodRunner<RTCPeerConnection>::creat
e(this, &RTCPeerConnection::dispatchScheduledEvent)) |
402 , m_stopped(false) | 402 , m_stopped(false) |
403 , m_closed(false) | 403 , m_closed(false) |
404 { | 404 { |
405 Document* document = toDocument(executionContext()); | 405 Document* document = toDocument(getExecutionContext()); |
406 | 406 |
407 // If we fail, set |m_closed| and |m_stopped| to true, to avoid hitting the
assert in the destructor. | 407 // If we fail, set |m_closed| and |m_stopped| to true, to avoid hitting the
assert in the destructor. |
408 | 408 |
409 if (!document->frame()) { | 409 if (!document->frame()) { |
410 m_closed = true; | 410 m_closed = true; |
411 m_stopped = true; | 411 m_stopped = true; |
412 exceptionState.throwDOMException(NotSupportedError, "PeerConnections may
not be created in detached documents."); | 412 exceptionState.throwDOMException(NotSupportedError, "PeerConnections may
not be created in detached documents."); |
413 return; | 413 return; |
414 } | 414 } |
415 | 415 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 | 447 |
448 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 448 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
449 return; | 449 return; |
450 | 450 |
451 ASSERT(successCallback); | 451 ASSERT(successCallback); |
452 | 452 |
453 RTCOfferOptions* offerOptions = parseOfferOptions(rtcOfferOptions, exception
State); | 453 RTCOfferOptions* offerOptions = parseOfferOptions(rtcOfferOptions, exception
State); |
454 if (exceptionState.hadException()) | 454 if (exceptionState.hadException()) |
455 return; | 455 return; |
456 | 456 |
457 RTCSessionDescriptionRequest* request = RTCSessionDescriptionRequestImpl::cr
eate(executionContext(), this, successCallback, errorCallback); | 457 RTCSessionDescriptionRequest* request = RTCSessionDescriptionRequestImpl::cr
eate(getExecutionContext(), this, successCallback, errorCallback); |
458 | 458 |
459 if (offerOptions) { | 459 if (offerOptions) { |
460 if (offerOptions->offerToReceiveAudio() != -1 || offerOptions->offerToRe
ceiveVideo() != -1) | 460 if (offerOptions->offerToReceiveAudio() != -1 || offerOptions->offerToRe
ceiveVideo() != -1) |
461 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferL
egacyOfferOptions); | 461 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferL
egacyOfferOptions); |
462 else if (errorCallback) | 462 else if (errorCallback) |
463 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferL
egacyCompliant); | 463 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferL
egacyCompliant); |
464 | 464 |
465 m_peerHandler->createOffer(request, offerOptions); | 465 m_peerHandler->createOffer(request, offerOptions); |
466 } else { | 466 } else { |
467 MediaErrorState mediaErrorState; | 467 MediaErrorState mediaErrorState; |
(...skipping 29 matching lines...) Expand all Loading... |
497 | 497 |
498 ASSERT(successCallback); | 498 ASSERT(successCallback); |
499 | 499 |
500 MediaErrorState mediaErrorState; | 500 MediaErrorState mediaErrorState; |
501 WebMediaConstraints constraints = MediaConstraintsImpl::create(context, medi
aConstraints, mediaErrorState); | 501 WebMediaConstraints constraints = MediaConstraintsImpl::create(context, medi
aConstraints, mediaErrorState); |
502 if (mediaErrorState.hadException()) { | 502 if (mediaErrorState.hadException()) { |
503 mediaErrorState.raiseException(exceptionState); | 503 mediaErrorState.raiseException(exceptionState); |
504 return; | 504 return; |
505 } | 505 } |
506 | 506 |
507 RTCSessionDescriptionRequest* request = RTCSessionDescriptionRequestImpl::cr
eate(executionContext(), this, successCallback, errorCallback); | 507 RTCSessionDescriptionRequest* request = RTCSessionDescriptionRequestImpl::cr
eate(getExecutionContext(), this, successCallback, errorCallback); |
508 m_peerHandler->createAnswer(request, constraints); | 508 m_peerHandler->createAnswer(request, constraints); |
509 } | 509 } |
510 | 510 |
511 ScriptPromise RTCPeerConnection::setLocalDescription(ScriptState* scriptState, c
onst RTCSessionDescriptionInit& sessionDescriptionInit) | 511 ScriptPromise RTCPeerConnection::setLocalDescription(ScriptState* scriptState, c
onst RTCSessionDescriptionInit& sessionDescriptionInit) |
512 { | 512 { |
513 if (m_signalingState == SignalingStateClosed) | 513 if (m_signalingState == SignalingStateClosed) |
514 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, kSignalingStateClosedMessage)); | 514 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, kSignalingStateClosedMessage)); |
515 | 515 |
516 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 516 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
517 ScriptPromise promise = resolver->promise(); | 517 ScriptPromise promise = resolver->promise(); |
518 RTCVoidRequest* request = RTCVoidRequestPromiseImpl::create(this, resolver); | 518 RTCVoidRequest* request = RTCVoidRequestPromiseImpl::create(this, resolver); |
519 m_peerHandler->setLocalDescription(request, WebRTCSessionDescription(session
DescriptionInit.type(), sessionDescriptionInit.sdp())); | 519 m_peerHandler->setLocalDescription(request, WebRTCSessionDescription(session
DescriptionInit.type(), sessionDescriptionInit.sdp())); |
520 return promise; | 520 return promise; |
521 } | 521 } |
522 | 522 |
523 ScriptPromise RTCPeerConnection::setLocalDescription(ScriptState* scriptState, R
TCSessionDescription* sessionDescription, VoidCallback* successCallback, RTCPeer
ConnectionErrorCallback* errorCallback) | 523 ScriptPromise RTCPeerConnection::setLocalDescription(ScriptState* scriptState, R
TCSessionDescription* sessionDescription, VoidCallback* successCallback, RTCPeer
ConnectionErrorCallback* errorCallback) |
524 { | 524 { |
525 ExecutionContext* context = scriptState->executionContext(); | 525 ExecutionContext* context = scriptState->getExecutionContext(); |
526 if (successCallback && errorCallback) { | 526 if (successCallback && errorCallback) { |
527 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDescript
ionLegacyCompliant); | 527 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDescript
ionLegacyCompliant); |
528 } else { | 528 } else { |
529 if (!successCallback) | 529 if (!successCallback) |
530 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDesc
riptionLegacyNoSuccessCallback); | 530 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDesc
riptionLegacyNoSuccessCallback); |
531 if (!errorCallback) | 531 if (!errorCallback) |
532 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDesc
riptionLegacyNoFailureCallback); | 532 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDesc
riptionLegacyNoFailureCallback); |
533 } | 533 } |
534 | 534 |
535 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback)
) | 535 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback)
) |
536 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isola
te())); | 536 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isola
te())); |
537 | 537 |
538 ASSERT(sessionDescription); | 538 ASSERT(sessionDescription); |
539 | 539 |
540 RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), thi
s, successCallback, errorCallback); | 540 RTCVoidRequest* request = RTCVoidRequestImpl::create(getExecutionContext(),
this, successCallback, errorCallback); |
541 m_peerHandler->setLocalDescription(request, sessionDescription->webSessionDe
scription()); | 541 m_peerHandler->setLocalDescription(request, sessionDescription->webSessionDe
scription()); |
542 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isolate()
)); | 542 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isolate()
)); |
543 } | 543 } |
544 | 544 |
545 RTCSessionDescription* RTCPeerConnection::localDescription() | 545 RTCSessionDescription* RTCPeerConnection::localDescription() |
546 { | 546 { |
547 WebRTCSessionDescription webSessionDescription = m_peerHandler->localDescrip
tion(); | 547 WebRTCSessionDescription webSessionDescription = m_peerHandler->localDescrip
tion(); |
548 if (webSessionDescription.isNull()) | 548 if (webSessionDescription.isNull()) |
549 return nullptr; | 549 return nullptr; |
550 | 550 |
551 return RTCSessionDescription::create(webSessionDescription); | 551 return RTCSessionDescription::create(webSessionDescription); |
552 } | 552 } |
553 | 553 |
554 ScriptPromise RTCPeerConnection::setRemoteDescription(ScriptState* scriptState,
const RTCSessionDescriptionInit& sessionDescriptionInit) | 554 ScriptPromise RTCPeerConnection::setRemoteDescription(ScriptState* scriptState,
const RTCSessionDescriptionInit& sessionDescriptionInit) |
555 { | 555 { |
556 if (m_signalingState == SignalingStateClosed) | 556 if (m_signalingState == SignalingStateClosed) |
557 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, kSignalingStateClosedMessage)); | 557 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, kSignalingStateClosedMessage)); |
558 | 558 |
559 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 559 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
560 ScriptPromise promise = resolver->promise(); | 560 ScriptPromise promise = resolver->promise(); |
561 RTCVoidRequest* request = RTCVoidRequestPromiseImpl::create(this, resolver); | 561 RTCVoidRequest* request = RTCVoidRequestPromiseImpl::create(this, resolver); |
562 m_peerHandler->setRemoteDescription(request, WebRTCSessionDescription(sessio
nDescriptionInit.type(), sessionDescriptionInit.sdp())); | 562 m_peerHandler->setRemoteDescription(request, WebRTCSessionDescription(sessio
nDescriptionInit.type(), sessionDescriptionInit.sdp())); |
563 return promise; | 563 return promise; |
564 } | 564 } |
565 | 565 |
566 ScriptPromise RTCPeerConnection::setRemoteDescription(ScriptState* scriptState,
RTCSessionDescription* sessionDescription, VoidCallback* successCallback, RTCPee
rConnectionErrorCallback* errorCallback) | 566 ScriptPromise RTCPeerConnection::setRemoteDescription(ScriptState* scriptState,
RTCSessionDescription* sessionDescription, VoidCallback* successCallback, RTCPee
rConnectionErrorCallback* errorCallback) |
567 { | 567 { |
568 ExecutionContext* context = scriptState->executionContext(); | 568 ExecutionContext* context = scriptState->getExecutionContext(); |
569 if (successCallback && errorCallback) { | 569 if (successCallback && errorCallback) { |
570 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDescrip
tionLegacyCompliant); | 570 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDescrip
tionLegacyCompliant); |
571 } else { | 571 } else { |
572 if (!successCallback) | 572 if (!successCallback) |
573 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDes
criptionLegacyNoSuccessCallback); | 573 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDes
criptionLegacyNoSuccessCallback); |
574 if (!errorCallback) | 574 if (!errorCallback) |
575 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDes
criptionLegacyNoFailureCallback); | 575 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDes
criptionLegacyNoFailureCallback); |
576 } | 576 } |
577 | 577 |
578 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback)
) | 578 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback)
) |
579 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isola
te())); | 579 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isola
te())); |
580 | 580 |
581 ASSERT(sessionDescription); | 581 ASSERT(sessionDescription); |
582 | 582 |
583 RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), thi
s, successCallback, errorCallback); | 583 RTCVoidRequest* request = RTCVoidRequestImpl::create(getExecutionContext(),
this, successCallback, errorCallback); |
584 m_peerHandler->setRemoteDescription(request, sessionDescription->webSessionD
escription()); | 584 m_peerHandler->setRemoteDescription(request, sessionDescription->webSessionD
escription()); |
585 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isolate()
)); | 585 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isolate()
)); |
586 } | 586 } |
587 | 587 |
588 RTCSessionDescription* RTCPeerConnection::remoteDescription() | 588 RTCSessionDescription* RTCPeerConnection::remoteDescription() |
589 { | 589 { |
590 WebRTCSessionDescription webSessionDescription = m_peerHandler->remoteDescri
ption(); | 590 WebRTCSessionDescription webSessionDescription = m_peerHandler->remoteDescri
ption(); |
591 if (webSessionDescription.isNull()) | 591 if (webSessionDescription.isNull()) |
592 return nullptr; | 592 return nullptr; |
593 | 593 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 | 670 |
671 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 671 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
672 ScriptPromise promise = resolver->promise(); | 672 ScriptPromise promise = resolver->promise(); |
673 | 673 |
674 WebRTCCertificateObserver* certificateObserver = WebRTCCertificateObserver::
create(resolver); | 674 WebRTCCertificateObserver* certificateObserver = WebRTCCertificateObserver::
create(resolver); |
675 | 675 |
676 // Generate certificate. The |certificateObserver| will resolve the promise
asynchronously upon completion. | 676 // Generate certificate. The |certificateObserver| will resolve the promise
asynchronously upon completion. |
677 // The observer will manage its own destruction as well as the resolver's de
struction. | 677 // The observer will manage its own destruction as well as the resolver's de
struction. |
678 certificateGenerator->generateCertificate( | 678 certificateGenerator->generateCertificate( |
679 keyParams.get(), | 679 keyParams.get(), |
680 toDocument(scriptState->executionContext())->url(), | 680 toDocument(scriptState->getExecutionContext())->url(), |
681 toDocument(scriptState->executionContext())->firstPartyForCookies(), | 681 toDocument(scriptState->getExecutionContext())->firstPartyForCookies(), |
682 certificateObserver); | 682 certificateObserver); |
683 | 683 |
684 return promise; | 684 return promise; |
685 } | 685 } |
686 | 686 |
687 ScriptPromise RTCPeerConnection::addIceCandidate(ScriptState* scriptState, const
RTCIceCandidateInitOrRTCIceCandidate& candidate) | 687 ScriptPromise RTCPeerConnection::addIceCandidate(ScriptState* scriptState, const
RTCIceCandidateInitOrRTCIceCandidate& candidate) |
688 { | 688 { |
689 if (m_signalingState == SignalingStateClosed) | 689 if (m_signalingState == SignalingStateClosed) |
690 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, kSignalingStateClosedMessage)); | 690 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, kSignalingStateClosedMessage)); |
691 | 691 |
(...skipping 13 matching lines...) Expand all Loading... |
705 | 705 |
706 ScriptPromise RTCPeerConnection::addIceCandidate(ScriptState* scriptState, RTCIc
eCandidate* iceCandidate, VoidCallback* successCallback, RTCPeerConnectionErrorC
allback* errorCallback) | 706 ScriptPromise RTCPeerConnection::addIceCandidate(ScriptState* scriptState, RTCIc
eCandidate* iceCandidate, VoidCallback* successCallback, RTCPeerConnectionErrorC
allback* errorCallback) |
707 { | 707 { |
708 ASSERT(iceCandidate); | 708 ASSERT(iceCandidate); |
709 ASSERT(successCallback); | 709 ASSERT(successCallback); |
710 ASSERT(errorCallback); | 710 ASSERT(errorCallback); |
711 | 711 |
712 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback)
) | 712 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback)
) |
713 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isola
te())); | 713 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isola
te())); |
714 | 714 |
715 RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), thi
s, successCallback, errorCallback); | 715 RTCVoidRequest* request = RTCVoidRequestImpl::create(getExecutionContext(),
this, successCallback, errorCallback); |
716 bool implemented = m_peerHandler->addICECandidate(request, iceCandidate->web
Candidate()); | 716 bool implemented = m_peerHandler->addICECandidate(request, iceCandidate->web
Candidate()); |
717 if (!implemented) | 717 if (!implemented) |
718 asyncCallErrorCallback(errorCallback, DOMException::create(OperationErro
r, "This operation could not be completed.")); | 718 asyncCallErrorCallback(errorCallback, DOMException::create(OperationErro
r, "This operation could not be completed.")); |
719 | 719 |
720 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isolate()
)); | 720 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isolate()
)); |
721 } | 721 } |
722 | 722 |
723 String RTCPeerConnection::signalingState() const | 723 String RTCPeerConnection::signalingState() const |
724 { | 724 { |
725 switch (m_signalingState) { | 725 switch (m_signalingState) { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 if ((*iter)->id() == streamId) | 846 if ((*iter)->id() == streamId) |
847 return iter->get(); | 847 return iter->get(); |
848 } | 848 } |
849 | 849 |
850 return 0; | 850 return 0; |
851 } | 851 } |
852 | 852 |
853 void RTCPeerConnection::getStats(ExecutionContext* context, RTCStatsCallback* su
ccessCallback, MediaStreamTrack* selector) | 853 void RTCPeerConnection::getStats(ExecutionContext* context, RTCStatsCallback* su
ccessCallback, MediaStreamTrack* selector) |
854 { | 854 { |
855 UseCounter::count(context, UseCounter::RTCPeerConnectionGetStatsLegacyNonCom
pliant); | 855 UseCounter::count(context, UseCounter::RTCPeerConnectionGetStatsLegacyNonCom
pliant); |
856 RTCStatsRequest* statsRequest = RTCStatsRequestImpl::create(executionContext
(), this, successCallback, selector); | 856 RTCStatsRequest* statsRequest = RTCStatsRequestImpl::create(getExecutionCont
ext(), this, successCallback, selector); |
857 // FIXME: Add passing selector as part of the statsRequest. | 857 // FIXME: Add passing selector as part of the statsRequest. |
858 m_peerHandler->getStats(statsRequest); | 858 m_peerHandler->getStats(statsRequest); |
859 } | 859 } |
860 | 860 |
861 RTCDataChannel* RTCPeerConnection::createDataChannel(String label, const Diction
ary& options, ExceptionState& exceptionState) | 861 RTCDataChannel* RTCPeerConnection::createDataChannel(String label, const Diction
ary& options, ExceptionState& exceptionState) |
862 { | 862 { |
863 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 863 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
864 return nullptr; | 864 return nullptr; |
865 | 865 |
866 WebRTCDataChannelInit init; | 866 WebRTCDataChannelInit init; |
867 DictionaryHelper::get(options, "ordered", init.ordered); | 867 DictionaryHelper::get(options, "ordered", init.ordered); |
868 DictionaryHelper::get(options, "negotiated", init.negotiated); | 868 DictionaryHelper::get(options, "negotiated", init.negotiated); |
869 | 869 |
870 unsigned short value = 0; | 870 unsigned short value = 0; |
871 if (DictionaryHelper::get(options, "id", value)) | 871 if (DictionaryHelper::get(options, "id", value)) |
872 init.id = value; | 872 init.id = value; |
873 if (DictionaryHelper::get(options, "maxRetransmits", value)) | 873 if (DictionaryHelper::get(options, "maxRetransmits", value)) |
874 init.maxRetransmits = value; | 874 init.maxRetransmits = value; |
875 if (DictionaryHelper::get(options, "maxRetransmitTime", value)) | 875 if (DictionaryHelper::get(options, "maxRetransmitTime", value)) |
876 init.maxRetransmitTime = value; | 876 init.maxRetransmitTime = value; |
877 | 877 |
878 String protocolString; | 878 String protocolString; |
879 DictionaryHelper::get(options, "protocol", protocolString); | 879 DictionaryHelper::get(options, "protocol", protocolString); |
880 init.protocol = protocolString; | 880 init.protocol = protocolString; |
881 | 881 |
882 RTCDataChannel* channel = RTCDataChannel::create(executionContext(), m_peerH
andler.get(), label, init, exceptionState); | 882 RTCDataChannel* channel = RTCDataChannel::create(getExecutionContext(), m_pe
erHandler.get(), label, init, exceptionState); |
883 if (exceptionState.hadException()) | 883 if (exceptionState.hadException()) |
884 return nullptr; | 884 return nullptr; |
885 RTCDataChannel::ReadyState handlerState = channel->getHandlerState(); | 885 RTCDataChannel::ReadyState handlerState = channel->getHandlerState(); |
886 if (handlerState != RTCDataChannel::ReadyStateConnecting) { | 886 if (handlerState != RTCDataChannel::ReadyStateConnecting) { |
887 // There was an early state transition. Don't miss it! | 887 // There was an early state transition. Don't miss it! |
888 channel->didChangeReadyState(handlerState); | 888 channel->didChangeReadyState(handlerState); |
889 } | 889 } |
890 return channel; | 890 return channel; |
891 } | 891 } |
892 | 892 |
(...skipping 11 matching lines...) Expand all Loading... |
904 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 904 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
905 return nullptr; | 905 return nullptr; |
906 | 906 |
907 ASSERT(track); | 907 ASSERT(track); |
908 | 908 |
909 if (!hasLocalStreamWithTrackId(track->id())) { | 909 if (!hasLocalStreamWithTrackId(track->id())) { |
910 exceptionState.throwDOMException(SyntaxError, "No local stream is availa
ble for the track provided."); | 910 exceptionState.throwDOMException(SyntaxError, "No local stream is availa
ble for the track provided."); |
911 return nullptr; | 911 return nullptr; |
912 } | 912 } |
913 | 913 |
914 RTCDTMFSender* dtmfSender = RTCDTMFSender::create(executionContext(), m_peer
Handler.get(), track, exceptionState); | 914 RTCDTMFSender* dtmfSender = RTCDTMFSender::create(getExecutionContext(), m_p
eerHandler.get(), track, exceptionState); |
915 if (exceptionState.hadException()) | 915 if (exceptionState.hadException()) |
916 return nullptr; | 916 return nullptr; |
917 return dtmfSender; | 917 return dtmfSender; |
918 } | 918 } |
919 | 919 |
920 void RTCPeerConnection::close(ExceptionState& exceptionState) | 920 void RTCPeerConnection::close(ExceptionState& exceptionState) |
921 { | 921 { |
922 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 922 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
923 return; | 923 return; |
924 | 924 |
925 closeInternal(); | 925 closeInternal(); |
926 } | 926 } |
927 | 927 |
928 void RTCPeerConnection::negotiationNeeded() | 928 void RTCPeerConnection::negotiationNeeded() |
929 { | 929 { |
930 ASSERT(!m_closed); | 930 ASSERT(!m_closed); |
931 scheduleDispatchEvent(Event::create(EventTypeNames::negotiationneeded)); | 931 scheduleDispatchEvent(Event::create(EventTypeNames::negotiationneeded)); |
932 } | 932 } |
933 | 933 |
934 void RTCPeerConnection::didGenerateICECandidate(const WebRTCICECandidate& webCan
didate) | 934 void RTCPeerConnection::didGenerateICECandidate(const WebRTCICECandidate& webCan
didate) |
935 { | 935 { |
936 ASSERT(!m_closed); | 936 ASSERT(!m_closed); |
937 ASSERT(executionContext()->isContextThread()); | 937 ASSERT(getExecutionContext()->isContextThread()); |
938 if (webCandidate.isNull()) | 938 if (webCandidate.isNull()) |
939 scheduleDispatchEvent(RTCIceCandidateEvent::create(false, false, nullptr
)); | 939 scheduleDispatchEvent(RTCIceCandidateEvent::create(false, false, nullptr
)); |
940 else { | 940 else { |
941 RTCIceCandidate* iceCandidate = RTCIceCandidate::create(webCandidate); | 941 RTCIceCandidate* iceCandidate = RTCIceCandidate::create(webCandidate); |
942 scheduleDispatchEvent(RTCIceCandidateEvent::create(false, false, iceCand
idate)); | 942 scheduleDispatchEvent(RTCIceCandidateEvent::create(false, false, iceCand
idate)); |
943 } | 943 } |
944 } | 944 } |
945 | 945 |
946 void RTCPeerConnection::didChangeSignalingState(SignalingState newState) | 946 void RTCPeerConnection::didChangeSignalingState(SignalingState newState) |
947 { | 947 { |
948 ASSERT(!m_closed); | 948 ASSERT(!m_closed); |
949 ASSERT(executionContext()->isContextThread()); | 949 ASSERT(getExecutionContext()->isContextThread()); |
950 changeSignalingState(newState); | 950 changeSignalingState(newState); |
951 } | 951 } |
952 | 952 |
953 void RTCPeerConnection::didChangeICEGatheringState(ICEGatheringState newState) | 953 void RTCPeerConnection::didChangeICEGatheringState(ICEGatheringState newState) |
954 { | 954 { |
955 ASSERT(!m_closed); | 955 ASSERT(!m_closed); |
956 ASSERT(executionContext()->isContextThread()); | 956 ASSERT(getExecutionContext()->isContextThread()); |
957 changeIceGatheringState(newState); | 957 changeIceGatheringState(newState); |
958 } | 958 } |
959 | 959 |
960 void RTCPeerConnection::didChangeICEConnectionState(ICEConnectionState newState) | 960 void RTCPeerConnection::didChangeICEConnectionState(ICEConnectionState newState) |
961 { | 961 { |
962 ASSERT(!m_closed); | 962 ASSERT(!m_closed); |
963 ASSERT(executionContext()->isContextThread()); | 963 ASSERT(getExecutionContext()->isContextThread()); |
964 changeIceConnectionState(newState); | 964 changeIceConnectionState(newState); |
965 } | 965 } |
966 | 966 |
967 void RTCPeerConnection::didAddRemoteStream(const WebMediaStream& remoteStream) | 967 void RTCPeerConnection::didAddRemoteStream(const WebMediaStream& remoteStream) |
968 { | 968 { |
969 ASSERT(!m_closed); | 969 ASSERT(!m_closed); |
970 ASSERT(executionContext()->isContextThread()); | 970 ASSERT(getExecutionContext()->isContextThread()); |
971 | 971 |
972 if (m_signalingState == SignalingStateClosed) | 972 if (m_signalingState == SignalingStateClosed) |
973 return; | 973 return; |
974 | 974 |
975 MediaStream* stream = MediaStream::create(executionContext(), remoteStream); | 975 MediaStream* stream = MediaStream::create(getExecutionContext(), remoteStrea
m); |
976 m_remoteStreams.append(stream); | 976 m_remoteStreams.append(stream); |
977 | 977 |
978 scheduleDispatchEvent(MediaStreamEvent::create(EventTypeNames::addstream, fa
lse, false, stream)); | 978 scheduleDispatchEvent(MediaStreamEvent::create(EventTypeNames::addstream, fa
lse, false, stream)); |
979 } | 979 } |
980 | 980 |
981 void RTCPeerConnection::didRemoveRemoteStream(const WebMediaStream& remoteStream
) | 981 void RTCPeerConnection::didRemoveRemoteStream(const WebMediaStream& remoteStream
) |
982 { | 982 { |
983 ASSERT(!m_closed); | 983 ASSERT(!m_closed); |
984 ASSERT(executionContext()->isContextThread()); | 984 ASSERT(getExecutionContext()->isContextThread()); |
985 | 985 |
986 MediaStreamDescriptor* streamDescriptor = remoteStream; | 986 MediaStreamDescriptor* streamDescriptor = remoteStream; |
987 ASSERT(streamDescriptor->client()); | 987 ASSERT(streamDescriptor->client()); |
988 | 988 |
989 MediaStream* stream = static_cast<MediaStream*>(streamDescriptor->client()); | 989 MediaStream* stream = static_cast<MediaStream*>(streamDescriptor->client()); |
990 stream->streamEnded(); | 990 stream->streamEnded(); |
991 | 991 |
992 if (m_signalingState == SignalingStateClosed) | 992 if (m_signalingState == SignalingStateClosed) |
993 return; | 993 return; |
994 | 994 |
995 size_t pos = m_remoteStreams.find(stream); | 995 size_t pos = m_remoteStreams.find(stream); |
996 ASSERT(pos != kNotFound); | 996 ASSERT(pos != kNotFound); |
997 m_remoteStreams.remove(pos); | 997 m_remoteStreams.remove(pos); |
998 | 998 |
999 scheduleDispatchEvent(MediaStreamEvent::create(EventTypeNames::removestream,
false, false, stream)); | 999 scheduleDispatchEvent(MediaStreamEvent::create(EventTypeNames::removestream,
false, false, stream)); |
1000 } | 1000 } |
1001 | 1001 |
1002 void RTCPeerConnection::didAddRemoteDataChannel(WebRTCDataChannelHandler* handle
r) | 1002 void RTCPeerConnection::didAddRemoteDataChannel(WebRTCDataChannelHandler* handle
r) |
1003 { | 1003 { |
1004 ASSERT(!m_closed); | 1004 ASSERT(!m_closed); |
1005 ASSERT(executionContext()->isContextThread()); | 1005 ASSERT(getExecutionContext()->isContextThread()); |
1006 | 1006 |
1007 if (m_signalingState == SignalingStateClosed) | 1007 if (m_signalingState == SignalingStateClosed) |
1008 return; | 1008 return; |
1009 | 1009 |
1010 RTCDataChannel* channel = RTCDataChannel::create(executionContext(), adoptPt
r(handler)); | 1010 RTCDataChannel* channel = RTCDataChannel::create(getExecutionContext(), adop
tPtr(handler)); |
1011 scheduleDispatchEvent(RTCDataChannelEvent::create(EventTypeNames::datachanne
l, false, false, channel)); | 1011 scheduleDispatchEvent(RTCDataChannelEvent::create(EventTypeNames::datachanne
l, false, false, channel)); |
1012 } | 1012 } |
1013 | 1013 |
1014 void RTCPeerConnection::releasePeerConnectionHandler() | 1014 void RTCPeerConnection::releasePeerConnectionHandler() |
1015 { | 1015 { |
1016 stop(); | 1016 stop(); |
1017 } | 1017 } |
1018 | 1018 |
1019 void RTCPeerConnection::closePeerConnection() | 1019 void RTCPeerConnection::closePeerConnection() |
1020 { | 1020 { |
1021 ASSERT(m_signalingState != RTCPeerConnection::SignalingStateClosed); | 1021 ASSERT(m_signalingState != RTCPeerConnection::SignalingStateClosed); |
1022 closeInternal(); | 1022 closeInternal(); |
1023 } | 1023 } |
1024 | 1024 |
1025 const AtomicString& RTCPeerConnection::interfaceName() const | 1025 const AtomicString& RTCPeerConnection::interfaceName() const |
1026 { | 1026 { |
1027 return EventTargetNames::RTCPeerConnection; | 1027 return EventTargetNames::RTCPeerConnection; |
1028 } | 1028 } |
1029 | 1029 |
1030 ExecutionContext* RTCPeerConnection::executionContext() const | 1030 ExecutionContext* RTCPeerConnection::getExecutionContext() const |
1031 { | 1031 { |
1032 return ActiveDOMObject::executionContext(); | 1032 return ActiveDOMObject::getExecutionContext(); |
1033 } | 1033 } |
1034 | 1034 |
1035 void RTCPeerConnection::suspend() | 1035 void RTCPeerConnection::suspend() |
1036 { | 1036 { |
1037 m_dispatchScheduledEventRunner->suspend(); | 1037 m_dispatchScheduledEventRunner->suspend(); |
1038 } | 1038 } |
1039 | 1039 |
1040 void RTCPeerConnection::resume() | 1040 void RTCPeerConnection::resume() |
1041 { | 1041 { |
1042 m_dispatchScheduledEventRunner->resume(); | 1042 m_dispatchScheduledEventRunner->resume(); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 { | 1132 { |
1133 visitor->trace(m_localStreams); | 1133 visitor->trace(m_localStreams); |
1134 visitor->trace(m_remoteStreams); | 1134 visitor->trace(m_remoteStreams); |
1135 visitor->trace(m_dispatchScheduledEventRunner); | 1135 visitor->trace(m_dispatchScheduledEventRunner); |
1136 visitor->trace(m_scheduledEvents); | 1136 visitor->trace(m_scheduledEvents); |
1137 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac
e(visitor); | 1137 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac
e(visitor); |
1138 ActiveDOMObject::trace(visitor); | 1138 ActiveDOMObject::trace(visitor); |
1139 } | 1139 } |
1140 | 1140 |
1141 } // namespace blink | 1141 } // namespace blink |
OLD | NEW |