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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 289 UseCounter::count(context, UseCounter::RTCIceServerURL); | 289 UseCounter::count(context, UseCounter::RTCIceServerURL); |
| 290 urlStrings.push_back(iceServer.url()); | 290 urlStrings.push_back(iceServer.url()); |
| 291 } else { | 291 } else { |
| 292 exceptionState.throwTypeError("Malformed RTCIceServer"); | 292 exceptionState.throwTypeError("Malformed RTCIceServer"); |
| 293 return WebRTCConfiguration(); | 293 return WebRTCConfiguration(); |
| 294 } | 294 } |
| 295 | 295 |
| 296 String username = iceServer.username(); | 296 String username = iceServer.username(); |
| 297 String credential = iceServer.credential(); | 297 String credential = iceServer.credential(); |
| 298 | 298 |
| 299 Vector<WebURL> urls; | |
| 299 for (const String& urlString : urlStrings) { | 300 for (const String& urlString : urlStrings) { |
| 300 KURL url(KURL(), urlString); | 301 KURL url(KURL(), urlString); |
| 301 if (!url.isValid()) { | 302 if (!url.isValid()) { |
| 302 exceptionState.throwDOMException( | 303 exceptionState.throwDOMException( |
| 303 SyntaxError, "'" + urlString + "' is not a valid URL."); | 304 SyntaxError, "'" + urlString + "' is not a valid URL."); |
| 304 return WebRTCConfiguration(); | 305 return WebRTCConfiguration(); |
| 305 } | 306 } |
| 306 if (!(url.protocolIs("turn") || url.protocolIs("turns") || | 307 if (!(url.protocolIs("turn") || url.protocolIs("turns") || |
| 307 url.protocolIs("stun"))) { | 308 url.protocolIs("stun"))) { |
| 308 exceptionState.throwDOMException( | 309 exceptionState.throwDOMException( |
| 309 SyntaxError, "'" + url.protocol() + | 310 SyntaxError, "'" + url.protocol() + |
| 310 "' is not one of the supported URL schemes " | 311 "' is not one of the supported URL schemes " |
| 311 "'stun', 'turn' or 'turns'."); | 312 "'stun', 'turn' or 'turns'."); |
| 312 return WebRTCConfiguration(); | 313 return WebRTCConfiguration(); |
| 313 } | 314 } |
| 314 if ((url.protocolIs("turn") || url.protocolIs("turns")) && | 315 if ((url.protocolIs("turn") || url.protocolIs("turns")) && |
| 315 (username.isNull() || credential.isNull())) { | 316 (username.isNull() || credential.isNull())) { |
| 316 exceptionState.throwDOMException(InvalidAccessError, | 317 exceptionState.throwDOMException(InvalidAccessError, |
| 317 "Both username and credential are " | 318 "Both username and credential are " |
| 318 "required when the URL scheme is " | 319 "required when the URL scheme is " |
| 319 "\"turn\" or \"turns\"."); | 320 "\"turn\" or \"turns\"."); |
| 320 } | 321 } |
| 321 iceServers.push_back(WebRTCIceServer{url, username, credential}); | 322 urls.push_back(url); |
| 322 } | 323 } |
| 324 iceServers.push_back(WebRTCIceServer{urls, username, credential}); | |
| 323 } | 325 } |
| 324 webConfiguration.iceServers = iceServers; | 326 webConfiguration.iceServers = iceServers; |
| 325 } | 327 } |
| 326 | 328 |
| 327 if (configuration.hasCertificates()) { | 329 if (configuration.hasCertificates()) { |
| 328 const HeapVector<Member<RTCCertificate>>& certificates = | 330 const HeapVector<Member<RTCCertificate>>& certificates = |
| 329 configuration.certificates(); | 331 configuration.certificates(); |
| 330 WebVector<std::unique_ptr<WebRTCCertificate>> certificatesCopy( | 332 WebVector<std::unique_ptr<WebRTCCertificate>> certificatesCopy( |
| 331 certificates.size()); | 333 certificates.size()); |
| 332 for (size_t i = 0; i < certificates.size(); ++i) { | 334 for (size_t i = 0; i < certificates.size(); ++i) { |
| 333 certificatesCopy[i] = certificates[i]->certificateShallowCopy(); | 335 certificatesCopy[i] = certificates[i]->certificateShallowCopy(); |
| 334 } | 336 } |
| 335 webConfiguration.certificates = std::move(certificatesCopy); | 337 webConfiguration.certificates = std::move(certificatesCopy); |
| 336 } | 338 } |
| 337 | 339 |
| 338 return webConfiguration; | 340 return webConfiguration; |
| 339 } | 341 } |
| 340 | 342 |
| 343 RTCConfiguration getWebKitRtcConfiguration(WebRTCConfiguration& blinkConfig) { | |
| 344 RTCConfiguration rtcConfig; | |
| 345 | |
| 346 switch (blinkConfig.iceTransportPolicy) { | |
| 347 case blink::WebRTCIceTransportPolicy::kNone: | |
| 348 rtcConfig.setIceTransportPolicy("none"); | |
| 349 break; | |
| 350 case blink::WebRTCIceTransportPolicy::kRelay: | |
| 351 rtcConfig.setIceTransportPolicy("relay"); | |
| 352 break; | |
| 353 case blink::WebRTCIceTransportPolicy::kAll: | |
| 354 rtcConfig.setIceTransportPolicy("all"); | |
| 355 break; | |
| 356 default: | |
|
Taylor_Brandstetter
2017/03/02 22:30:45
nit: Don't need any of the default cases in this f
| |
| 357 NOTREACHED(); | |
| 358 } | |
| 359 | |
| 360 switch (blinkConfig.bundlePolicy) { | |
| 361 case blink::WebRTCBundlePolicy::kBalanced: | |
| 362 rtcConfig.setBundlePolicy("balanced"); | |
| 363 break; | |
| 364 case blink::WebRTCBundlePolicy::kMaxBundle: | |
| 365 rtcConfig.setBundlePolicy("max-bundle"); | |
| 366 break; | |
| 367 case blink::WebRTCBundlePolicy::kMaxCompat: | |
| 368 rtcConfig.setBundlePolicy("max-compat"); | |
| 369 break; | |
| 370 default: | |
| 371 NOTREACHED(); | |
| 372 } | |
| 373 | |
| 374 switch (blinkConfig.rtcpMuxPolicy) { | |
| 375 case blink::WebRTCRtcpMuxPolicy::kNegotiate: | |
| 376 rtcConfig.setRtcpMuxPolicy("negotiate"); | |
| 377 break; | |
| 378 case blink::WebRTCRtcpMuxPolicy::kRequire: | |
| 379 rtcConfig.setRtcpMuxPolicy("require"); | |
| 380 break; | |
| 381 default: | |
| 382 NOTREACHED(); | |
| 383 } | |
| 384 | |
| 385 HeapVector<RTCIceServer> servers; | |
| 386 for (WebRTCIceServer blink_server : blinkConfig.iceServers) { | |
| 387 RTCIceServer server; | |
| 388 Vector<String> urlStrings; | |
| 389 StringOrStringSequence urls; | |
| 390 for (WebURL blink_url : blink_server.urls) { | |
| 391 String urlString(blink_url.string().utf8().c_str()); | |
| 392 urlStrings.push_back(urlString); | |
| 393 } | |
| 394 urls.setStringSequence(urlStrings); | |
| 395 server.setURLs(urls); | |
| 396 String username(blink_server.username.utf8().c_str()); | |
| 397 server.setUsername(blink_server.username); | |
| 398 String credential(blink_server.credential.utf8().c_str()); | |
| 399 server.setCredential(credential); | |
| 400 servers.push_back(server); | |
| 401 } | |
| 402 rtcConfig.setIceServers(servers); | |
| 403 | |
| 404 HeapVector<Member<RTCCertificate>> certificates; | |
| 405 for (std::unique_ptr<blink::WebRTCCertificate>& blink_certificate : | |
| 406 blinkConfig.certificates) { | |
| 407 certificates.push_back(new RTCCertificate(std::move(blink_certificate))); | |
| 408 } | |
| 409 rtcConfig.setCertificates(certificates); | |
| 410 | |
| 411 return rtcConfig; | |
| 412 } | |
| 413 | |
| 341 RTCOfferOptionsPlatform* parseOfferOptions(const Dictionary& options, | 414 RTCOfferOptionsPlatform* parseOfferOptions(const Dictionary& options, |
| 342 ExceptionState& exceptionState) { | 415 ExceptionState& exceptionState) { |
| 343 if (options.isUndefinedOrNull()) | 416 if (options.isUndefinedOrNull()) |
| 344 return nullptr; | 417 return nullptr; |
| 345 | 418 |
| 346 const Vector<String>& propertyNames = | 419 const Vector<String>& propertyNames = |
| 347 options.getPropertyNames(exceptionState); | 420 options.getPropertyNames(exceptionState); |
| 348 if (exceptionState.hadException()) | 421 if (exceptionState.hadException()) |
| 349 return nullptr; | 422 return nullptr; |
| 350 | 423 |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 786 | 859 |
| 787 RTCSessionDescription* RTCPeerConnection::remoteDescription() { | 860 RTCSessionDescription* RTCPeerConnection::remoteDescription() { |
| 788 WebRTCSessionDescription webSessionDescription = | 861 WebRTCSessionDescription webSessionDescription = |
| 789 m_peerHandler->remoteDescription(); | 862 m_peerHandler->remoteDescription(); |
| 790 if (webSessionDescription.isNull()) | 863 if (webSessionDescription.isNull()) |
| 791 return nullptr; | 864 return nullptr; |
| 792 | 865 |
| 793 return RTCSessionDescription::create(webSessionDescription); | 866 return RTCSessionDescription::create(webSessionDescription); |
| 794 } | 867 } |
| 795 | 868 |
| 869 void RTCPeerConnection::getConfiguration(RTCConfiguration& rtcConfig) { | |
| 870 blink::WebRTCConfiguration blinkConfig = m_peerHandler->getConfiguration(); | |
| 871 rtcConfig = getWebKitRtcConfiguration(blinkConfig); | |
| 872 } | |
| 873 | |
| 796 void RTCPeerConnection::setConfiguration( | 874 void RTCPeerConnection::setConfiguration( |
| 797 ScriptState* scriptState, | 875 ScriptState* scriptState, |
| 798 const RTCConfiguration& rtcConfiguration, | 876 const RTCConfiguration& rtcConfiguration, |
| 799 ExceptionState& exceptionState) { | 877 ExceptionState& exceptionState) { |
| 800 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 878 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
| 801 return; | 879 return; |
| 802 | 880 |
| 803 WebRTCConfiguration configuration = parseConfiguration( | 881 WebRTCConfiguration configuration = parseConfiguration( |
| 804 scriptState->getExecutionContext(), rtcConfiguration, exceptionState); | 882 scriptState->getExecutionContext(), rtcConfiguration, exceptionState); |
| 805 | 883 |
| (...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1493 DEFINE_TRACE(RTCPeerConnection) { | 1571 DEFINE_TRACE(RTCPeerConnection) { |
| 1494 visitor->trace(m_localStreams); | 1572 visitor->trace(m_localStreams); |
| 1495 visitor->trace(m_remoteStreams); | 1573 visitor->trace(m_remoteStreams); |
| 1496 visitor->trace(m_dispatchScheduledEventRunner); | 1574 visitor->trace(m_dispatchScheduledEventRunner); |
| 1497 visitor->trace(m_scheduledEvents); | 1575 visitor->trace(m_scheduledEvents); |
| 1498 EventTargetWithInlineData::trace(visitor); | 1576 EventTargetWithInlineData::trace(visitor); |
| 1499 SuspendableObject::trace(visitor); | 1577 SuspendableObject::trace(visitor); |
| 1500 } | 1578 } |
| 1501 | 1579 |
| 1502 } // namespace blink | 1580 } // namespace blink |
| OLD | NEW |