| 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 12 matching lines...) Expand all Loading... |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "modules/peerconnection/RTCPeerConnection.h" | 31 #include "modules/peerconnection/RTCPeerConnection.h" |
| 32 | 32 |
| 33 #include "bindings/core/v8/ArrayValue.h" | |
| 34 #include "bindings/core/v8/ExceptionMessages.h" | 33 #include "bindings/core/v8/ExceptionMessages.h" |
| 35 #include "bindings/core/v8/ExceptionState.h" | 34 #include "bindings/core/v8/ExceptionState.h" |
| 36 #include "bindings/core/v8/Microtask.h" | 35 #include "bindings/core/v8/Microtask.h" |
| 37 #include "bindings/core/v8/Nullable.h" | 36 #include "bindings/core/v8/Nullable.h" |
| 38 #include "bindings/core/v8/ScriptPromiseResolver.h" | 37 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 39 #include "bindings/core/v8/ScriptState.h" | 38 #include "bindings/core/v8/ScriptState.h" |
| 40 #include "bindings/core/v8/ScriptValue.h" | 39 #include "bindings/core/v8/ScriptValue.h" |
| 41 #include "bindings/core/v8/V8ThrowException.h" | 40 #include "bindings/core/v8/V8ThrowException.h" |
| 42 #include "bindings/modules/v8/RTCIceCandidateInitOrRTCIceCandidate.h" | 41 #include "bindings/modules/v8/RTCIceCandidateInitOrRTCIceCandidate.h" |
| 43 #include "bindings/modules/v8/V8MediaStreamTrack.h" | 42 #include "bindings/modules/v8/V8MediaStreamTrack.h" |
| 44 #include "bindings/modules/v8/V8RTCCertificate.h" | 43 #include "bindings/modules/v8/V8RTCCertificate.h" |
| 45 #include "core/dom/DOMException.h" | 44 #include "core/dom/DOMException.h" |
| 46 #include "core/dom/DOMTimeStamp.h" | 45 #include "core/dom/DOMTimeStamp.h" |
| 47 #include "core/dom/Document.h" | 46 #include "core/dom/Document.h" |
| 48 #include "core/dom/ExceptionCode.h" | 47 #include "core/dom/ExceptionCode.h" |
| 49 #include "core/dom/ExecutionContext.h" | 48 #include "core/dom/ExecutionContext.h" |
| 50 #include "core/frame/HostsUsingFeatures.h" | 49 #include "core/frame/HostsUsingFeatures.h" |
| 51 #include "core/frame/LocalFrame.h" | 50 #include "core/frame/LocalFrame.h" |
| 52 #include "core/frame/UseCounter.h" | 51 #include "core/frame/UseCounter.h" |
| 53 #include "core/html/VoidCallback.h" | 52 #include "core/html/VoidCallback.h" |
| 54 #include "core/loader/FrameLoader.h" | 53 #include "core/loader/FrameLoader.h" |
| 55 #include "core/loader/FrameLoaderClient.h" | 54 #include "core/loader/FrameLoaderClient.h" |
| 56 #include "modules/crypto/CryptoResultImpl.h" | 55 #include "modules/crypto/CryptoResultImpl.h" |
| 57 #include "modules/mediastream/MediaConstraintsImpl.h" | 56 #include "modules/mediastream/MediaConstraintsImpl.h" |
| 58 #include "modules/mediastream/MediaStreamEvent.h" | 57 #include "modules/mediastream/MediaStreamEvent.h" |
| 59 #include "modules/peerconnection/RTCAnswerOptions.h" | 58 #include "modules/peerconnection/RTCAnswerOptions.h" |
| 59 #include "modules/peerconnection/RTCConfiguration.h" |
| 60 #include "modules/peerconnection/RTCDTMFSender.h" | 60 #include "modules/peerconnection/RTCDTMFSender.h" |
| 61 #include "modules/peerconnection/RTCDataChannel.h" | 61 #include "modules/peerconnection/RTCDataChannel.h" |
| 62 #include "modules/peerconnection/RTCDataChannelEvent.h" | 62 #include "modules/peerconnection/RTCDataChannelEvent.h" |
| 63 #include "modules/peerconnection/RTCIceCandidateEvent.h" | 63 #include "modules/peerconnection/RTCIceCandidateEvent.h" |
| 64 #include "modules/peerconnection/RTCIceServer.h" |
| 64 #include "modules/peerconnection/RTCOfferOptions.h" | 65 #include "modules/peerconnection/RTCOfferOptions.h" |
| 65 #include "modules/peerconnection/RTCPeerConnectionErrorCallback.h" | 66 #include "modules/peerconnection/RTCPeerConnectionErrorCallback.h" |
| 66 #include "modules/peerconnection/RTCSessionDescription.h" | 67 #include "modules/peerconnection/RTCSessionDescription.h" |
| 67 #include "modules/peerconnection/RTCSessionDescriptionCallback.h" | 68 #include "modules/peerconnection/RTCSessionDescriptionCallback.h" |
| 68 #include "modules/peerconnection/RTCSessionDescriptionInit.h" | 69 #include "modules/peerconnection/RTCSessionDescriptionInit.h" |
| 69 #include "modules/peerconnection/RTCSessionDescriptionRequestImpl.h" | 70 #include "modules/peerconnection/RTCSessionDescriptionRequestImpl.h" |
| 70 #include "modules/peerconnection/RTCSessionDescriptionRequestPromiseImpl.h" | 71 #include "modules/peerconnection/RTCSessionDescriptionRequestPromiseImpl.h" |
| 71 #include "modules/peerconnection/RTCStatsCallback.h" | 72 #include "modules/peerconnection/RTCStatsCallback.h" |
| 72 #include "modules/peerconnection/RTCStatsReport.h" | 73 #include "modules/peerconnection/RTCStatsReport.h" |
| 73 #include "modules/peerconnection/RTCStatsRequestImpl.h" | 74 #include "modules/peerconnection/RTCStatsRequestImpl.h" |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 | 211 |
| 211 void onSuccess(std::unique_ptr<WebRTCCertificate> certificate) override { | 212 void onSuccess(std::unique_ptr<WebRTCCertificate> certificate) override { |
| 212 m_resolver->resolve(new RTCCertificate(std::move(certificate))); | 213 m_resolver->resolve(new RTCCertificate(std::move(certificate))); |
| 213 } | 214 } |
| 214 | 215 |
| 215 void onError() override { m_resolver->reject(); } | 216 void onError() override { m_resolver->reject(); } |
| 216 | 217 |
| 217 Persistent<ScriptPromiseResolver> m_resolver; | 218 Persistent<ScriptPromiseResolver> m_resolver; |
| 218 }; | 219 }; |
| 219 | 220 |
| 220 WebRTCConfiguration parseConfiguration(const Dictionary& configuration, | 221 WebRTCConfiguration parseConfiguration(ExecutionContext* context, |
| 221 ExceptionState& exceptionState, | 222 const RTCConfiguration& configuration, |
| 222 RtcpMuxPolicy* selectedRtcpMuxPolicy) { | 223 ExceptionState& exceptionState) { |
| 223 WebRTCConfiguration rtcConfiguration; | |
| 224 if (configuration.isUndefinedOrNull()) | |
| 225 return WebRTCConfiguration(); | |
| 226 | |
| 227 WebRTCIceTransports iceTransports = WebRTCIceTransports::All; | 224 WebRTCIceTransports iceTransports = WebRTCIceTransports::All; |
| 228 String iceTransportsString; | 225 String iceTransportsString = configuration.iceTransports(); |
| 229 if (DictionaryHelper::get(configuration, "iceTransports", | 226 if (iceTransportsString == "none") { |
| 230 iceTransportsString)) { | 227 UseCounter::count(context, UseCounter::RTCConfigurationIceTransportsNone); |
| 231 if (iceTransportsString == "none") { | 228 iceTransports = WebRTCIceTransports::None; |
| 232 iceTransports = WebRTCIceTransports::None; | 229 } else if (iceTransportsString == "relay") { |
| 233 } else if (iceTransportsString == "relay") { | 230 iceTransports = WebRTCIceTransports::Relay; |
| 234 iceTransports = WebRTCIceTransports::Relay; | 231 } else { |
| 235 } else if (iceTransportsString != "all") { | 232 DCHECK_EQ(iceTransportsString, "all"); |
| 236 exceptionState.throwTypeError("Malformed RTCIceTransports"); | |
| 237 return WebRTCConfiguration(); | |
| 238 } | |
| 239 } | |
| 240 | |
| 241 ArrayValue iceServers; | |
| 242 bool ok = DictionaryHelper::get(configuration, "iceServers", iceServers); | |
| 243 if (!ok || iceServers.isUndefinedOrNull()) { | |
| 244 exceptionState.throwTypeError("Malformed RTCConfiguration"); | |
| 245 return WebRTCConfiguration(); | |
| 246 } | |
| 247 | |
| 248 size_t numberOfServers; | |
| 249 ok = iceServers.length(numberOfServers); | |
| 250 if (!ok) { | |
| 251 exceptionState.throwTypeError("Malformed RTCConfiguration"); | |
| 252 return WebRTCConfiguration(); | |
| 253 } | 233 } |
| 254 | 234 |
| 255 WebRTCBundlePolicy bundlePolicy = WebRTCBundlePolicy::Balanced; | 235 WebRTCBundlePolicy bundlePolicy = WebRTCBundlePolicy::Balanced; |
| 256 String bundlePolicyString; | 236 String bundlePolicyString = configuration.bundlePolicy(); |
| 257 if (DictionaryHelper::get(configuration, "bundlePolicy", | 237 if (bundlePolicyString == "max-compat") { |
| 258 bundlePolicyString)) { | 238 bundlePolicy = WebRTCBundlePolicy::MaxCompat; |
| 259 if (bundlePolicyString == "max-compat") { | 239 } else if (bundlePolicyString == "max-bundle") { |
| 260 bundlePolicy = WebRTCBundlePolicy::MaxCompat; | 240 bundlePolicy = WebRTCBundlePolicy::MaxBundle; |
| 261 } else if (bundlePolicyString == "max-bundle") { | 241 } else { |
| 262 bundlePolicy = WebRTCBundlePolicy::MaxBundle; | 242 DCHECK_EQ(bundlePolicyString, "balanced"); |
| 263 } else if (bundlePolicyString != "balanced") { | |
| 264 exceptionState.throwTypeError("Malformed RTCBundlePolicy"); | |
| 265 return WebRTCConfiguration(); | |
| 266 } | |
| 267 } | 243 } |
| 268 | 244 |
| 269 // For the histogram value of "WebRTC.PeerConnection.SelectedRtcpMuxPolicy". | |
| 270 *selectedRtcpMuxPolicy = RtcpMuxPolicyDefault; | |
| 271 WebRTCRtcpMuxPolicy rtcpMuxPolicy = WebRTCRtcpMuxPolicy::Negotiate; | 245 WebRTCRtcpMuxPolicy rtcpMuxPolicy = WebRTCRtcpMuxPolicy::Negotiate; |
| 272 String rtcpMuxPolicyString; | 246 String rtcpMuxPolicyString = configuration.rtcpMuxPolicy(); |
| 273 if (DictionaryHelper::get(configuration, "rtcpMuxPolicy", | 247 if (rtcpMuxPolicyString == "require") { |
| 274 rtcpMuxPolicyString)) { | 248 rtcpMuxPolicy = WebRTCRtcpMuxPolicy::Require; |
| 275 if (rtcpMuxPolicyString == "require") { | 249 } else { |
| 276 *selectedRtcpMuxPolicy = RtcpMuxPolicyRequire; | 250 DCHECK_EQ(rtcpMuxPolicyString, "negotiate"); |
| 277 rtcpMuxPolicy = WebRTCRtcpMuxPolicy::Require; | |
| 278 } else if (rtcpMuxPolicyString == "negotiate") { | |
| 279 *selectedRtcpMuxPolicy = RtcpMuxPolicyNegotiate; | |
| 280 rtcpMuxPolicy = WebRTCRtcpMuxPolicy::Negotiate; | |
| 281 } else { | |
| 282 exceptionState.throwTypeError("Malformed RTCRtcpMuxPolicy"); | |
| 283 return WebRTCConfiguration(); | |
| 284 } | |
| 285 } | 251 } |
| 286 | 252 |
| 287 rtcConfiguration.iceTransports = iceTransports; | 253 WebRTCConfiguration webConfiguration; |
| 288 rtcConfiguration.bundlePolicy = bundlePolicy; | 254 webConfiguration.iceTransports = iceTransports; |
| 289 rtcConfiguration.rtcpMuxPolicy = rtcpMuxPolicy; | 255 webConfiguration.bundlePolicy = bundlePolicy; |
| 256 webConfiguration.rtcpMuxPolicy = rtcpMuxPolicy; |
| 290 | 257 |
| 291 for (size_t i = 0; i < numberOfServers; ++i) { | 258 if (configuration.hasIceServers()) { |
| 292 Dictionary iceServer; | 259 Vector<WebRTCIceServer> iceServers; |
| 293 ok = iceServers.get(i, iceServer); | 260 for (const RTCIceServer& iceServer : configuration.iceServers()) { |
| 294 if (!ok) { | 261 Vector<String> urlStrings; |
| 295 exceptionState.throwTypeError("Malformed RTCIceServer"); | 262 if (iceServer.hasURLs()) { |
| 296 return WebRTCConfiguration(); | 263 const StringOrStringSequence& urls = iceServer.urls(); |
| 297 } | 264 if (urls.isString()) { |
| 298 | 265 urlStrings.append(urls.getAsString()); |
| 299 Vector<String> names; | |
| 300 iceServer.getPropertyNames(names); | |
| 301 | |
| 302 Vector<String> urlStrings; | |
| 303 if (names.contains("urls")) { | |
| 304 if (!DictionaryHelper::get(iceServer, "urls", urlStrings) || | |
| 305 !urlStrings.size()) { | |
| 306 String urlString; | |
| 307 if (DictionaryHelper::get(iceServer, "urls", urlString)) { | |
| 308 urlStrings.append(urlString); | |
| 309 } else { | 266 } else { |
| 310 exceptionState.throwTypeError("Malformed RTCIceServer"); | 267 DCHECK(urls.isStringSequence()); |
| 311 return WebRTCConfiguration(); | 268 urlStrings = urls.getAsStringSequence(); |
| 312 } | 269 } |
| 313 } | 270 } else if (iceServer.hasURL()) { |
| 314 } else if (names.contains("url")) { | 271 UseCounter::count(context, UseCounter::RTCIceServerURL); |
| 315 String urlString; | 272 urlStrings.append(iceServer.url()); |
| 316 if (DictionaryHelper::get(iceServer, "url", urlString)) { | |
| 317 urlStrings.append(urlString); | |
| 318 } else { | 273 } else { |
| 319 exceptionState.throwTypeError("Malformed RTCIceServer"); | 274 exceptionState.throwTypeError("Malformed RTCIceServer"); |
| 320 return WebRTCConfiguration(); | 275 return WebRTCConfiguration(); |
| 321 } | 276 } |
| 322 } else { | 277 |
| 323 exceptionState.throwTypeError("Malformed RTCIceServer"); | 278 String username = iceServer.username(); |
| 324 return WebRTCConfiguration(); | 279 String credential = iceServer.credential(); |
| 280 |
| 281 for (const String& urlString : urlStrings) { |
| 282 KURL url(KURL(), urlString); |
| 283 if (!url.isValid() || |
| 284 !(url.protocolIs("turn") || url.protocolIs("turns") || |
| 285 url.protocolIs("stun"))) { |
| 286 exceptionState.throwTypeError("Malformed URL"); |
| 287 return WebRTCConfiguration(); |
| 288 } |
| 289 iceServers.append(WebRTCIceServer{url, username, credential}); |
| 290 } |
| 325 } | 291 } |
| 326 | 292 webConfiguration.iceServers = iceServers; |
| 327 String username, credential; | |
| 328 DictionaryHelper::get(iceServer, "username", username); | |
| 329 DictionaryHelper::get(iceServer, "credential", credential); | |
| 330 | |
| 331 Vector<WebRTCIceServer> iceServers; | |
| 332 for (Vector<String>::iterator iter = urlStrings.begin(); | |
| 333 iter != urlStrings.end(); ++iter) { | |
| 334 KURL url(KURL(), *iter); | |
| 335 if (!url.isValid() || | |
| 336 !(url.protocolIs("turn") || url.protocolIs("turns") || | |
| 337 url.protocolIs("stun"))) { | |
| 338 exceptionState.throwTypeError("Malformed URL"); | |
| 339 return WebRTCConfiguration(); | |
| 340 } | |
| 341 iceServers.append(WebRTCIceServer{url, username, credential}); | |
| 342 } | |
| 343 rtcConfiguration.iceServers = iceServers; | |
| 344 } | 293 } |
| 345 | 294 |
| 346 ArrayValue certificates; | 295 if (configuration.hasCertificates()) { |
| 347 if (DictionaryHelper::get(configuration, "certificates", certificates) && | 296 const HeapVector<Member<RTCCertificate>>& certificates = |
| 348 !certificates.isUndefinedOrNull()) { | 297 configuration.certificates(); |
| 349 size_t numberOfCertificates; | 298 size_t numberOfCertificates = certificates.size(); |
| 350 certificates.length(numberOfCertificates); | |
| 351 WebVector<std::unique_ptr<WebRTCCertificate>> certificatesCopy( | 299 WebVector<std::unique_ptr<WebRTCCertificate>> certificatesCopy( |
| 352 numberOfCertificates); | 300 numberOfCertificates); |
| 353 for (size_t i = 0; i < numberOfCertificates; ++i) { | 301 for (size_t i = 0; i < numberOfCertificates; ++i) { |
| 354 RTCCertificate* certificate = nullptr; | 302 certificatesCopy[i] = certificates[i]->certificateShallowCopy(); |
| 303 } |
| 304 webConfiguration.certificates.swap(certificatesCopy); |
| 305 } |
| 355 | 306 |
| 356 Dictionary dictCert; | 307 return webConfiguration; |
| 357 certificates.get(i, dictCert); | |
| 358 v8::Local<v8::Value> valCert = dictCert.v8Value(); | |
| 359 if (!valCert.IsEmpty()) { | |
| 360 certificate = V8RTCCertificate::toImplWithTypeCheck( | |
| 361 configuration.isolate(), valCert); | |
| 362 } | |
| 363 if (!certificate) { | |
| 364 exceptionState.throwTypeError("Malformed sequence<RTCCertificate>"); | |
| 365 return WebRTCConfiguration(); | |
| 366 } | |
| 367 | |
| 368 certificatesCopy[i] = certificate->certificateShallowCopy(); | |
| 369 } | |
| 370 rtcConfiguration.certificates.swap(certificatesCopy); | |
| 371 } | |
| 372 return rtcConfiguration; | |
| 373 } | 308 } |
| 374 | 309 |
| 375 RTCOfferOptionsPlatform* parseOfferOptions(const Dictionary& options) { | 310 RTCOfferOptionsPlatform* parseOfferOptions(const Dictionary& options) { |
| 376 if (options.isUndefinedOrNull()) | 311 if (options.isUndefinedOrNull()) |
| 377 return 0; | 312 return 0; |
| 378 | 313 |
| 379 Vector<String> propertyNames; | 314 Vector<String> propertyNames; |
| 380 options.getPropertyNames(propertyNames); | 315 options.getPropertyNames(propertyNames); |
| 381 | 316 |
| 382 // Treat |options| as MediaConstraints if it is empty or has "optional" or | 317 // Treat |options| as MediaConstraints if it is empty or has "optional" or |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 if (m_setupFunction) { | 380 if (m_setupFunction) { |
| 446 return (*m_setupFunction)(); | 381 return (*m_setupFunction)(); |
| 447 } | 382 } |
| 448 return true; | 383 return true; |
| 449 } | 384 } |
| 450 | 385 |
| 451 DEFINE_TRACE(RTCPeerConnection::EventWrapper) { | 386 DEFINE_TRACE(RTCPeerConnection::EventWrapper) { |
| 452 visitor->trace(m_event); | 387 visitor->trace(m_event); |
| 453 } | 388 } |
| 454 | 389 |
| 455 RTCPeerConnection* RTCPeerConnection::create(ExecutionContext* context, | 390 RTCPeerConnection* RTCPeerConnection::create( |
| 456 const Dictionary& rtcConfiguration, | 391 ExecutionContext* context, |
| 457 const Dictionary& mediaConstraints, | 392 const RTCConfiguration& rtcConfiguration, |
| 458 ExceptionState& exceptionState) { | 393 const Dictionary& mediaConstraints, |
| 394 ExceptionState& exceptionState) { |
| 459 if (mediaConstraints.isObject()) | 395 if (mediaConstraints.isObject()) |
| 460 UseCounter::count(context, | 396 UseCounter::count(context, |
| 461 UseCounter::RTCPeerConnectionConstructorConstraints); | 397 UseCounter::RTCPeerConnectionConstructorConstraints); |
| 462 else | 398 else |
| 463 UseCounter::count(context, | 399 UseCounter::count(context, |
| 464 UseCounter::RTCPeerConnectionConstructorCompliant); | 400 UseCounter::RTCPeerConnectionConstructorCompliant); |
| 465 | 401 |
| 466 // Record the RtcpMuxPolicy for histogram | 402 WebRTCConfiguration configuration = |
| 467 // "WebRTC.PeerConnection.SelectedRtcpMuxPolicy". | 403 parseConfiguration(context, rtcConfiguration, exceptionState); |
| 468 RtcpMuxPolicy selectedRtcpMuxPolicy = RtcpMuxPolicyDefault; | |
| 469 WebRTCConfiguration configuration = parseConfiguration( | |
| 470 rtcConfiguration, exceptionState, &selectedRtcpMuxPolicy); | |
| 471 if (exceptionState.hadException()) | 404 if (exceptionState.hadException()) |
| 472 return 0; | 405 return 0; |
| 473 | 406 |
| 474 // Make sure no certificates have expired. | 407 // Make sure no certificates have expired. |
| 408 // TODO(hbos): Should this be part of parseConfiguration and thus apply to |
| 409 // updateIce as well? |
| 475 if (configuration.certificates.size() > 0) { | 410 if (configuration.certificates.size() > 0) { |
| 476 DOMTimeStamp now = convertSecondsToDOMTimeStamp(currentTime()); | 411 DOMTimeStamp now = convertSecondsToDOMTimeStamp(currentTime()); |
| 477 for (const std::unique_ptr<WebRTCCertificate>& certificate : | 412 for (const std::unique_ptr<WebRTCCertificate>& certificate : |
| 478 configuration.certificates) { | 413 configuration.certificates) { |
| 479 DOMTimeStamp expires = certificate->expires(); | 414 DOMTimeStamp expires = certificate->expires(); |
| 480 if (expires <= now) { | 415 if (expires <= now) { |
| 481 // TODO(hbos): Per https://w3c.github.io/webrtc-pc/#operation this | 416 // TODO(hbos): Per https://w3c.github.io/webrtc-pc/#operation this |
| 482 // should throw InvalidAccessError, not InvalidStateError. | 417 // should throw InvalidAccessError, not InvalidStateError. |
| 483 exceptionState.throwDOMException(InvalidStateError, | 418 exceptionState.throwDOMException(InvalidStateError, |
| 484 "Expired certificate(s)."); | 419 "Expired certificate(s)."); |
| 485 return 0; | 420 return 0; |
| 486 } | 421 } |
| 487 } | 422 } |
| 488 } | 423 } |
| 489 | 424 |
| 490 MediaErrorState mediaErrorState; | 425 MediaErrorState mediaErrorState; |
| 491 WebMediaConstraints constraints = | 426 WebMediaConstraints constraints = |
| 492 MediaConstraintsImpl::create(context, mediaConstraints, mediaErrorState); | 427 MediaConstraintsImpl::create(context, mediaConstraints, mediaErrorState); |
| 493 if (mediaErrorState.hadException()) { | 428 if (mediaErrorState.hadException()) { |
| 494 mediaErrorState.raiseException(exceptionState); | 429 mediaErrorState.raiseException(exceptionState); |
| 495 return 0; | 430 return 0; |
| 496 } | 431 } |
| 497 | 432 |
| 498 RTCPeerConnection* peerConnection = new RTCPeerConnection( | 433 RTCPeerConnection* peerConnection = new RTCPeerConnection( |
| 499 context, configuration, constraints, exceptionState); | 434 context, configuration, constraints, exceptionState); |
| 500 peerConnection->suspendIfNeeded(); | 435 peerConnection->suspendIfNeeded(); |
| 501 if (exceptionState.hadException()) | 436 if (exceptionState.hadException()) |
| 502 return 0; | 437 return 0; |
| 503 | 438 |
| 439 // Record the RtcpMuxPolicy for histogram |
| 440 // "WebRTC.PeerConnection.SelectedRtcpMuxPolicy". |
| 504 peerConnection->m_peerHandler->logSelectedRtcpMuxPolicy( | 441 peerConnection->m_peerHandler->logSelectedRtcpMuxPolicy( |
| 505 selectedRtcpMuxPolicy); | 442 configuration.rtcpMuxPolicy == WebRTCRtcpMuxPolicy::Negotiate |
| 443 ? RtcpMuxPolicyNegotiate |
| 444 : RtcpMuxPolicyRequire); |
| 506 | 445 |
| 507 return peerConnection; | 446 return peerConnection; |
| 508 } | 447 } |
| 509 | 448 |
| 510 RTCPeerConnection::RTCPeerConnection(ExecutionContext* context, | 449 RTCPeerConnection::RTCPeerConnection(ExecutionContext* context, |
| 511 const WebRTCConfiguration& configuration, | 450 const WebRTCConfiguration& configuration, |
| 512 WebMediaConstraints constraints, | 451 WebMediaConstraints constraints, |
| 513 ExceptionState& exceptionState) | 452 ExceptionState& exceptionState) |
| 514 : ActiveScriptWrappable(this), | 453 : ActiveScriptWrappable(this), |
| 515 ActiveDOMObject(context), | 454 ActiveDOMObject(context), |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 | 757 |
| 819 RTCSessionDescription* RTCPeerConnection::remoteDescription() { | 758 RTCSessionDescription* RTCPeerConnection::remoteDescription() { |
| 820 WebRTCSessionDescription webSessionDescription = | 759 WebRTCSessionDescription webSessionDescription = |
| 821 m_peerHandler->remoteDescription(); | 760 m_peerHandler->remoteDescription(); |
| 822 if (webSessionDescription.isNull()) | 761 if (webSessionDescription.isNull()) |
| 823 return nullptr; | 762 return nullptr; |
| 824 | 763 |
| 825 return RTCSessionDescription::create(webSessionDescription); | 764 return RTCSessionDescription::create(webSessionDescription); |
| 826 } | 765 } |
| 827 | 766 |
| 828 void RTCPeerConnection::updateIce(const Dictionary& rtcConfiguration, | 767 void RTCPeerConnection::updateIce(ExecutionContext* context, |
| 768 const RTCConfiguration& rtcConfiguration, |
| 829 const Dictionary& mediaConstraints, | 769 const Dictionary& mediaConstraints, |
| 830 ExceptionState& exceptionState) { | 770 ExceptionState& exceptionState) { |
| 831 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 771 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
| 832 return; | 772 return; |
| 833 | 773 |
| 834 RtcpMuxPolicy selectedRtcpMuxPolicy = RtcpMuxPolicyDefault; | 774 WebRTCConfiguration configuration = |
| 835 WebRTCConfiguration configuration = parseConfiguration( | 775 parseConfiguration(context, rtcConfiguration, exceptionState); |
| 836 rtcConfiguration, exceptionState, &selectedRtcpMuxPolicy); | |
| 837 | 776 |
| 838 if (exceptionState.hadException()) | 777 if (exceptionState.hadException()) |
| 839 return; | 778 return; |
| 840 | 779 |
| 841 MediaErrorState mediaErrorState; | 780 MediaErrorState mediaErrorState; |
| 842 if (mediaErrorState.hadException()) { | 781 if (mediaErrorState.hadException()) { |
| 843 mediaErrorState.raiseException(exceptionState); | 782 mediaErrorState.raiseException(exceptionState); |
| 844 return; | 783 return; |
| 845 } | 784 } |
| 846 | 785 |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1505 DEFINE_TRACE(RTCPeerConnection) { | 1444 DEFINE_TRACE(RTCPeerConnection) { |
| 1506 visitor->trace(m_localStreams); | 1445 visitor->trace(m_localStreams); |
| 1507 visitor->trace(m_remoteStreams); | 1446 visitor->trace(m_remoteStreams); |
| 1508 visitor->trace(m_dispatchScheduledEventRunner); | 1447 visitor->trace(m_dispatchScheduledEventRunner); |
| 1509 visitor->trace(m_scheduledEvents); | 1448 visitor->trace(m_scheduledEvents); |
| 1510 EventTargetWithInlineData::trace(visitor); | 1449 EventTargetWithInlineData::trace(visitor); |
| 1511 ActiveDOMObject::trace(visitor); | 1450 ActiveDOMObject::trace(visitor); |
| 1512 } | 1451 } |
| 1513 | 1452 |
| 1514 } // namespace blink | 1453 } // namespace blink |
| OLD | NEW |