Chromium Code Reviews| 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 22 matching lines...) Expand all Loading... | |
| 33 #include "bindings/core/v8/ArrayValue.h" | 33 #include "bindings/core/v8/ArrayValue.h" |
| 34 #include "bindings/core/v8/ExceptionMessages.h" | 34 #include "bindings/core/v8/ExceptionMessages.h" |
| 35 #include "bindings/core/v8/ExceptionState.h" | 35 #include "bindings/core/v8/ExceptionState.h" |
| 36 #include "bindings/core/v8/Microtask.h" | 36 #include "bindings/core/v8/Microtask.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/core/v8/ScriptState.h" | 39 #include "bindings/core/v8/ScriptState.h" |
| 40 #include "bindings/core/v8/ScriptValue.h" | 40 #include "bindings/core/v8/ScriptValue.h" |
| 41 #include "bindings/core/v8/V8ThrowException.h" | 41 #include "bindings/core/v8/V8ThrowException.h" |
| 42 #include "bindings/modules/v8/RTCIceCandidateInitOrRTCIceCandidate.h" | 42 #include "bindings/modules/v8/RTCIceCandidateInitOrRTCIceCandidate.h" |
| 43 #include "bindings/modules/v8/V8MediaStreamTrack.h" | |
| 43 #include "bindings/modules/v8/V8RTCCertificate.h" | 44 #include "bindings/modules/v8/V8RTCCertificate.h" |
| 45 #include "bindings/modules/v8/V8RTCStatsCallback.h" | |
| 44 #include "core/dom/DOMException.h" | 46 #include "core/dom/DOMException.h" |
| 45 #include "core/dom/DOMTimeStamp.h" | 47 #include "core/dom/DOMTimeStamp.h" |
| 46 #include "core/dom/Document.h" | 48 #include "core/dom/Document.h" |
| 47 #include "core/dom/ExceptionCode.h" | 49 #include "core/dom/ExceptionCode.h" |
| 48 #include "core/dom/ExecutionContext.h" | 50 #include "core/dom/ExecutionContext.h" |
| 49 #include "core/frame/HostsUsingFeatures.h" | 51 #include "core/frame/HostsUsingFeatures.h" |
| 50 #include "core/frame/LocalFrame.h" | 52 #include "core/frame/LocalFrame.h" |
| 51 #include "core/frame/UseCounter.h" | 53 #include "core/frame/UseCounter.h" |
| 52 #include "core/html/VoidCallback.h" | 54 #include "core/html/VoidCallback.h" |
| 53 #include "core/loader/FrameLoader.h" | 55 #include "core/loader/FrameLoader.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 64 #include "modules/peerconnection/RTCPeerConnectionErrorCallback.h" | 66 #include "modules/peerconnection/RTCPeerConnectionErrorCallback.h" |
| 65 #include "modules/peerconnection/RTCSessionDescription.h" | 67 #include "modules/peerconnection/RTCSessionDescription.h" |
| 66 #include "modules/peerconnection/RTCSessionDescriptionCallback.h" | 68 #include "modules/peerconnection/RTCSessionDescriptionCallback.h" |
| 67 #include "modules/peerconnection/RTCSessionDescriptionInit.h" | 69 #include "modules/peerconnection/RTCSessionDescriptionInit.h" |
| 68 #include "modules/peerconnection/RTCSessionDescriptionRequestImpl.h" | 70 #include "modules/peerconnection/RTCSessionDescriptionRequestImpl.h" |
| 69 #include "modules/peerconnection/RTCSessionDescriptionRequestPromiseImpl.h" | 71 #include "modules/peerconnection/RTCSessionDescriptionRequestPromiseImpl.h" |
| 70 #include "modules/peerconnection/RTCStatsCallback.h" | 72 #include "modules/peerconnection/RTCStatsCallback.h" |
| 71 #include "modules/peerconnection/RTCStatsRequestImpl.h" | 73 #include "modules/peerconnection/RTCStatsRequestImpl.h" |
| 72 #include "modules/peerconnection/RTCVoidRequestImpl.h" | 74 #include "modules/peerconnection/RTCVoidRequestImpl.h" |
| 73 #include "modules/peerconnection/RTCVoidRequestPromiseImpl.h" | 75 #include "modules/peerconnection/RTCVoidRequestPromiseImpl.h" |
| 76 #include "platform/RuntimeEnabledFeatures.h" | |
| 74 #include "platform/peerconnection/RTCAnswerOptionsPlatform.h" | 77 #include "platform/peerconnection/RTCAnswerOptionsPlatform.h" |
| 75 #include "platform/peerconnection/RTCConfiguration.h" | 78 #include "platform/peerconnection/RTCConfiguration.h" |
| 76 #include "platform/peerconnection/RTCOfferOptionsPlatform.h" | 79 #include "platform/peerconnection/RTCOfferOptionsPlatform.h" |
| 77 #include "public/platform/Platform.h" | 80 #include "public/platform/Platform.h" |
| 78 #include "public/platform/WebCryptoAlgorithmParams.h" | 81 #include "public/platform/WebCryptoAlgorithmParams.h" |
| 79 #include "public/platform/WebMediaStream.h" | 82 #include "public/platform/WebMediaStream.h" |
| 80 #include "public/platform/WebRTCAnswerOptions.h" | 83 #include "public/platform/WebRTCAnswerOptions.h" |
| 81 #include "public/platform/WebRTCCertificate.h" | 84 #include "public/platform/WebRTCCertificate.h" |
| 82 #include "public/platform/WebRTCCertificateGenerator.h" | 85 #include "public/platform/WebRTCCertificateGenerator.h" |
| 83 #include "public/platform/WebRTCConfiguration.h" | 86 #include "public/platform/WebRTCConfiguration.h" |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 364 offerToReceiveVideo = 0; | 367 offerToReceiveVideo = 0; |
| 365 if (DictionaryHelper::get(options, "offerToReceiveAudio", offerToReceiveAudi o) && offerToReceiveAudio < 0) | 368 if (DictionaryHelper::get(options, "offerToReceiveAudio", offerToReceiveAudi o) && offerToReceiveAudio < 0) |
| 366 offerToReceiveAudio = 0; | 369 offerToReceiveAudio = 0; |
| 367 DictionaryHelper::get(options, "voiceActivityDetection", voiceActivityDetect ion); | 370 DictionaryHelper::get(options, "voiceActivityDetection", voiceActivityDetect ion); |
| 368 DictionaryHelper::get(options, "iceRestart", iceRestart); | 371 DictionaryHelper::get(options, "iceRestart", iceRestart); |
| 369 | 372 |
| 370 RTCOfferOptionsPlatform* rtcOfferOptions = RTCOfferOptionsPlatform::create(o fferToReceiveVideo, offerToReceiveAudio, voiceActivityDetection, iceRestart); | 373 RTCOfferOptionsPlatform* rtcOfferOptions = RTCOfferOptionsPlatform::create(o fferToReceiveVideo, offerToReceiveAudio, voiceActivityDetection, iceRestart); |
| 371 return rtcOfferOptions; | 374 return rtcOfferOptions; |
| 372 } | 375 } |
| 373 | 376 |
| 377 RTCStatsCallback* ValueToRTCStatsCallback(ScriptState* scriptState, const v8::Lo cal<v8::Value>& value) | |
| 378 { | |
| 379 if (!value->IsObject()) | |
| 380 return nullptr; | |
| 381 v8::Local<v8::Object> object = value->ToObject(); | |
| 382 if (!object->IsCallable()) | |
| 383 return nullptr; | |
| 384 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(object); | |
| 385 // |function| should have one argument. If called and it doesn't have one it | |
| 386 // is still invoked but without the |RTCLegacyStatsReport|. If it has more | |
| 387 // than one argument it is invoked with the subsequent arguments undefined. | |
|
hta - Chromium
2016/07/19 09:56:48
Is this just a description of how v8::Function wor
hbos_chromium
2016/07/19 13:59:35
Done.
| |
| 388 return V8RTCStatsCallback::create(function, scriptState); | |
| 389 } | |
| 390 | |
| 374 } // namespace | 391 } // namespace |
| 375 | 392 |
| 376 RTCPeerConnection::EventWrapper::EventWrapper( | 393 RTCPeerConnection::EventWrapper::EventWrapper( |
| 377 Event* event, | 394 Event* event, |
| 378 std::unique_ptr<BoolFunction> function) | 395 std::unique_ptr<BoolFunction> function) |
| 379 : m_event(event) | 396 : m_event(event) |
| 380 , m_setupFunction(std::move(function)) | 397 , m_setupFunction(std::move(function)) |
| 381 { | 398 { |
| 382 } | 399 } |
| 383 | 400 |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 941 } | 958 } |
| 942 | 959 |
| 943 for (MediaStreamVector::iterator iter = m_remoteStreams.begin(); iter != m_r emoteStreams.end(); ++iter) { | 960 for (MediaStreamVector::iterator iter = m_remoteStreams.begin(); iter != m_r emoteStreams.end(); ++iter) { |
| 944 if ((*iter)->id() == streamId) | 961 if ((*iter)->id() == streamId) |
| 945 return iter->get(); | 962 return iter->get(); |
| 946 } | 963 } |
| 947 | 964 |
| 948 return 0; | 965 return 0; |
| 949 } | 966 } |
| 950 | 967 |
| 951 void RTCPeerConnection::getStats(ExecutionContext* context, RTCStatsCallback* su ccessCallback, MediaStreamTrack* selector) | 968 ScriptPromise RTCPeerConnection::getStats(ScriptState* scriptState, ScriptValue value) |
| 952 { | 969 { |
| 970 v8::Local<v8::Value> v8Value = value.v8Value(); | |
| 971 if (v8Value->IsUndefined() || v8Value->IsNull()) { | |
| 972 // Dispatch to "getStats(optional MediaStreamTrack?)". | |
| 973 return getStats(scriptState, static_cast<MediaStreamTrack*>(nullptr)); | |
| 974 } | |
| 975 if (v8Value->IsObject()) { | |
| 976 // Is |v8Value| a |MediaStreamTrack|? | |
| 977 MediaStreamTrack* selector = V8MediaStreamTrack::toImplWithTypeCheck(scr iptState->isolate(), v8Value); | |
| 978 if (selector) { | |
| 979 // Dispatch to "getStats(optional MediaStreamTrack?)". | |
| 980 return getStats(scriptState, selector); | |
| 981 } | |
| 982 | |
| 983 // [RTCStatsCallback| is either a function or an object that contains a |handleEvent| function. | |
| 984 // Is |v8Value| a valid callback function? | |
| 985 RTCStatsCallback* callback = ValueToRTCStatsCallback(scriptState, v8Valu e); | |
| 986 if (!callback) { | |
| 987 // Is "value.handleEvent" a valid callback function? | |
| 988 v8::Local<v8::Object> object = v8Value->ToObject(scriptState->contex t()).ToLocalChecked(); | |
| 989 v8::MaybeLocal<v8::Value> handleEvent = object->Get( | |
| 990 scriptState->context(), | |
| 991 v8::String::NewFromUtf8(scriptState->isolate(), "handleEvent")); | |
| 992 if (!handleEvent.IsEmpty()) | |
| 993 callback = ValueToRTCStatsCallback(scriptState, handleEvent.ToLo calChecked()); | |
| 994 } | |
| 995 if (callback) { | |
| 996 // Dispatch to "getStats(RTCStatsCallback, MediaStreamTrack?)". | |
| 997 return getStats(scriptState, callback, nullptr); | |
| 998 } | |
| 999 } | |
| 1000 | |
| 1001 // Invalid parameter, |value| is not compatible with |MediaStreamTrack| or | RTCStatsCallback|. | |
| 1002 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; | |
| 1003 ScriptPromise promise = resolver->promise(); | |
| 1004 resolver->reject(); | |
|
hta - Chromium
2016/07/19 09:56:48
Where do we set the error to be returned in this c
hbos_chromium
2016/07/19 13:59:35
This error was undefined. I added an error and upd
| |
| 1005 return promise; | |
| 1006 } | |
| 1007 | |
| 1008 ScriptPromise RTCPeerConnection::getStats(ScriptState* scriptState, RTCStatsCall back* successCallback, MediaStreamTrack* selector) | |
| 1009 { | |
| 1010 ExecutionContext* context = scriptState->getExecutionContext(); | |
| 1011 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; | |
| 1012 ScriptPromise promise = resolver->promise(); | |
| 1013 | |
| 953 UseCounter::count(context, UseCounter::RTCPeerConnectionGetStatsLegacyNonCom pliant); | 1014 UseCounter::count(context, UseCounter::RTCPeerConnectionGetStatsLegacyNonCom pliant); |
| 954 RTCStatsRequest* statsRequest = RTCStatsRequestImpl::create(getExecutionCont ext(), this, successCallback, selector); | 1015 RTCStatsRequest* statsRequest = RTCStatsRequestImpl::create(getExecutionCont ext(), this, successCallback, selector); |
| 955 // FIXME: Add passing selector as part of the statsRequest. | 1016 // FIXME: Add passing selector as part of the statsRequest. |
| 956 m_peerHandler->getStats(statsRequest); | 1017 m_peerHandler->getStats(statsRequest); |
| 1018 | |
| 1019 resolver->resolve(); | |
| 1020 return promise; | |
| 1021 } | |
| 1022 | |
| 1023 ScriptPromise RTCPeerConnection::getStats(ScriptState* scriptState, MediaStreamT rack* selector) | |
| 1024 { | |
| 1025 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; | |
| 1026 ScriptPromise promise = resolver->promise(); | |
| 1027 if (!RuntimeEnabledFeatures::rTCPeerConnectionNewGetStatsEnabled()) { | |
| 1028 resolver->reject(ExceptionMessages::argumentNullOrIncorrectType(1, "succ essCallback")); | |
| 1029 return promise; | |
| 1030 } | |
| 1031 | |
| 1032 // TODO(hbos): Implement new |getStats| function. | |
| 1033 resolver->reject(DOMException::create(NotSupportedError, "getStats(optional MediaStreamTrack?) has not been implemented yet.")); | |
| 1034 return promise; | |
| 957 } | 1035 } |
| 958 | 1036 |
| 959 RTCDataChannel* RTCPeerConnection::createDataChannel(String label, const Diction ary& options, ExceptionState& exceptionState) | 1037 RTCDataChannel* RTCPeerConnection::createDataChannel(String label, const Diction ary& options, ExceptionState& exceptionState) |
| 960 { | 1038 { |
| 961 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 1039 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
| 962 return nullptr; | 1040 return nullptr; |
| 963 | 1041 |
| 964 WebRTCDataChannelInit init; | 1042 WebRTCDataChannelInit init; |
| 965 DictionaryHelper::get(options, "ordered", init.ordered); | 1043 DictionaryHelper::get(options, "ordered", init.ordered); |
| 966 DictionaryHelper::get(options, "negotiated", init.negotiated); | 1044 DictionaryHelper::get(options, "negotiated", init.negotiated); |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1258 { | 1336 { |
| 1259 visitor->trace(m_localStreams); | 1337 visitor->trace(m_localStreams); |
| 1260 visitor->trace(m_remoteStreams); | 1338 visitor->trace(m_remoteStreams); |
| 1261 visitor->trace(m_dispatchScheduledEventRunner); | 1339 visitor->trace(m_dispatchScheduledEventRunner); |
| 1262 visitor->trace(m_scheduledEvents); | 1340 visitor->trace(m_scheduledEvents); |
| 1263 EventTargetWithInlineData::trace(visitor); | 1341 EventTargetWithInlineData::trace(visitor); |
| 1264 ActiveDOMObject::trace(visitor); | 1342 ActiveDOMObject::trace(visitor); |
| 1265 } | 1343 } |
| 1266 | 1344 |
| 1267 } // namespace blink | 1345 } // namespace blink |
| OLD | NEW |