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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 291 UseCounter::count(context, UseCounter::RTCIceServerURL); | 291 UseCounter::count(context, UseCounter::RTCIceServerURL); |
| 292 urlStrings.push_back(iceServer.url()); | 292 urlStrings.push_back(iceServer.url()); |
| 293 } else { | 293 } else { |
| 294 exceptionState.throwTypeError("Malformed RTCIceServer"); | 294 exceptionState.throwTypeError("Malformed RTCIceServer"); |
| 295 return WebRTCConfiguration(); | 295 return WebRTCConfiguration(); |
| 296 } | 296 } |
| 297 | 297 |
| 298 String username = iceServer.username(); | 298 String username = iceServer.username(); |
| 299 String credential = iceServer.credential(); | 299 String credential = iceServer.credential(); |
| 300 | 300 |
| 301 Vector<WebURL> urls; | |
| 301 for (const String& urlString : urlStrings) { | 302 for (const String& urlString : urlStrings) { |
| 302 KURL url(KURL(), urlString); | 303 KURL url(KURL(), urlString); |
| 303 if (!url.isValid()) { | 304 if (!url.isValid()) { |
| 304 exceptionState.throwDOMException( | 305 exceptionState.throwDOMException( |
| 305 SyntaxError, "'" + urlString + "' is not a valid URL."); | 306 SyntaxError, "'" + urlString + "' is not a valid URL."); |
| 306 return WebRTCConfiguration(); | 307 return WebRTCConfiguration(); |
| 307 } | 308 } |
| 308 if (!(url.protocolIs("turn") || url.protocolIs("turns") || | 309 if (!(url.protocolIs("turn") || url.protocolIs("turns") || |
| 309 url.protocolIs("stun"))) { | 310 url.protocolIs("stun"))) { |
| 310 exceptionState.throwDOMException( | 311 exceptionState.throwDOMException( |
| 311 SyntaxError, "'" + url.protocol() + | 312 SyntaxError, "'" + url.protocol() + |
| 312 "' is not one of the supported URL schemes " | 313 "' is not one of the supported URL schemes " |
| 313 "'stun', 'turn' or 'turns'."); | 314 "'stun', 'turn' or 'turns'."); |
| 314 return WebRTCConfiguration(); | 315 return WebRTCConfiguration(); |
| 315 } | 316 } |
| 316 if ((url.protocolIs("turn") || url.protocolIs("turns")) && | 317 if ((url.protocolIs("turn") || url.protocolIs("turns")) && |
| 317 (username.isNull() || credential.isNull())) { | 318 (username.isNull() || credential.isNull())) { |
| 318 exceptionState.throwDOMException(InvalidAccessError, | 319 exceptionState.throwDOMException(InvalidAccessError, |
| 319 "Both username and credential are " | 320 "Both username and credential are " |
| 320 "required when the URL scheme is " | 321 "required when the URL scheme is " |
| 321 "\"turn\" or \"turns\"."); | 322 "\"turn\" or \"turns\"."); |
| 322 } | 323 } |
| 323 iceServers.push_back(WebRTCIceServer{url, username, credential}); | 324 urls.push_back(url); |
| 324 } | 325 } |
| 326 WebRTCIceServer webIceServer = {urls, username, credential}; | |
| 327 iceServers.push_back(webIceServer); | |
| 325 } | 328 } |
| 326 webConfiguration.iceServers = iceServers; | 329 webConfiguration.iceServers = iceServers; |
| 327 } | 330 } |
| 328 | 331 |
| 329 if (configuration.hasCertificates()) { | 332 if (configuration.hasCertificates()) { |
| 330 const HeapVector<Member<RTCCertificate>>& certificates = | 333 const HeapVector<Member<RTCCertificate>>& certificates = |
| 331 configuration.certificates(); | 334 configuration.certificates(); |
| 332 WebVector<std::unique_ptr<WebRTCCertificate>> certificatesCopy( | 335 WebVector<std::unique_ptr<WebRTCCertificate>> certificatesCopy( |
| 333 certificates.size()); | 336 certificates.size()); |
| 334 for (size_t i = 0; i < certificates.size(); ++i) { | 337 for (size_t i = 0; i < certificates.size(); ++i) { |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 788 | 791 |
| 789 RTCSessionDescription* RTCPeerConnection::remoteDescription() { | 792 RTCSessionDescription* RTCPeerConnection::remoteDescription() { |
| 790 WebRTCSessionDescription webSessionDescription = | 793 WebRTCSessionDescription webSessionDescription = |
| 791 m_peerHandler->remoteDescription(); | 794 m_peerHandler->remoteDescription(); |
| 792 if (webSessionDescription.isNull()) | 795 if (webSessionDescription.isNull()) |
| 793 return nullptr; | 796 return nullptr; |
| 794 | 797 |
| 795 return RTCSessionDescription::create(webSessionDescription); | 798 return RTCSessionDescription::create(webSessionDescription); |
| 796 } | 799 } |
| 797 | 800 |
| 801 void RTCPeerConnection::getConfiguration(RTCConfiguration& rtcConfig) { | |
| 802 blink::WebRTCConfiguration blinkConfig = m_peerHandler->getConfiguration(); | |
| 803 | |
| 804 switch (blinkConfig.iceTransportPolicy) { | |
| 805 case blink::WebRTCIceTransportPolicy::kNone: | |
| 806 rtcConfig.setIceTransportPolicy("none"); | |
| 807 break; | |
| 808 case blink::WebRTCIceTransportPolicy::kRelay: | |
| 809 rtcConfig.setIceTransportPolicy("relay"); | |
| 810 break; | |
| 811 case blink::WebRTCIceTransportPolicy::kAll: | |
| 812 rtcConfig.setIceTransportPolicy("all"); | |
| 813 break; | |
| 814 } | |
| 815 | |
| 816 switch (blinkConfig.bundlePolicy) { | |
| 817 case blink::WebRTCBundlePolicy::kBalanced: | |
| 818 rtcConfig.setBundlePolicy("balanced"); | |
| 819 break; | |
| 820 case blink::WebRTCBundlePolicy::kMaxBundle: | |
| 821 rtcConfig.setBundlePolicy("max-bundle"); | |
| 822 break; | |
| 823 case blink::WebRTCBundlePolicy::kMaxCompat: | |
| 824 rtcConfig.setBundlePolicy("max-compat"); | |
| 825 break; | |
| 826 } | |
| 827 | |
| 828 switch (blinkConfig.rtcpMuxPolicy) { | |
| 829 case blink::WebRTCRtcpMuxPolicy::kNegotiate: | |
| 830 rtcConfig.setRtcpMuxPolicy("negotiate"); | |
| 831 break; | |
| 832 case blink::WebRTCRtcpMuxPolicy::kRequire: | |
| 833 rtcConfig.setRtcpMuxPolicy("require"); | |
| 834 break; | |
| 835 } | |
| 836 | |
| 837 HeapVector<RTCIceServer> servers; | |
| 838 for (const WebRTCIceServer& blink_server : blinkConfig.iceServers) { | |
| 839 RTCIceServer server; | |
| 840 Vector<String> urlStrings; | |
| 841 StringOrStringSequence urls; | |
| 842 for (const WebURL& blink_url : blink_server.urls) { | |
| 843 String urlString(blink_url.string().utf8().c_str()); | |
|
dcheng
2017/03/10 19:54:00
Nit: omit utf8().c_str(), otherwise this turns a r
zhihuang1
2017/03/11 00:40:33
Oh I see.
| |
| 844 urlStrings.push_back(urlString); | |
| 845 } | |
| 846 urls.setStringSequence(urlStrings); | |
| 847 server.setURLs(urls); | |
| 848 String username(blink_server.username.utf8().c_str()); | |
|
dcheng
2017/03/10 19:54:00
Same here and below: no local, and just pass the W
zhihuang1
2017/03/11 00:40:33
Done.
| |
| 849 server.setUsername(blink_server.username); | |
| 850 String credential(blink_server.credential.utf8().c_str()); | |
| 851 server.setCredential(credential); | |
| 852 servers.push_back(server); | |
| 853 } | |
| 854 rtcConfig.setIceServers(servers); | |
| 855 | |
| 856 HeapVector<Member<RTCCertificate>> certificates; | |
| 857 for (auto& blink_certificate : blinkConfig.certificates) { | |
| 858 certificates.push_back(new RTCCertificate(std::move(blink_certificate))); | |
| 859 } | |
| 860 rtcConfig.setCertificates(certificates); | |
| 861 } | |
| 862 | |
| 798 void RTCPeerConnection::setConfiguration( | 863 void RTCPeerConnection::setConfiguration( |
| 799 ScriptState* scriptState, | 864 ScriptState* scriptState, |
| 800 const RTCConfiguration& rtcConfiguration, | 865 const RTCConfiguration& rtcConfiguration, |
| 801 ExceptionState& exceptionState) { | 866 ExceptionState& exceptionState) { |
| 802 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 867 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
| 803 return; | 868 return; |
| 804 | 869 |
| 805 WebRTCConfiguration configuration = parseConfiguration( | 870 WebRTCConfiguration configuration = parseConfiguration( |
| 806 scriptState->getExecutionContext(), rtcConfiguration, exceptionState); | 871 scriptState->getExecutionContext(), rtcConfiguration, exceptionState); |
| 807 | 872 |
| (...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1499 DEFINE_TRACE(RTCPeerConnection) { | 1564 DEFINE_TRACE(RTCPeerConnection) { |
| 1500 visitor->trace(m_localStreams); | 1565 visitor->trace(m_localStreams); |
| 1501 visitor->trace(m_remoteStreams); | 1566 visitor->trace(m_remoteStreams); |
| 1502 visitor->trace(m_dispatchScheduledEventRunner); | 1567 visitor->trace(m_dispatchScheduledEventRunner); |
| 1503 visitor->trace(m_scheduledEvents); | 1568 visitor->trace(m_scheduledEvents); |
| 1504 EventTargetWithInlineData::trace(visitor); | 1569 EventTargetWithInlineData::trace(visitor); |
| 1505 SuspendableObject::trace(visitor); | 1570 SuspendableObject::trace(visitor); |
| 1506 } | 1571 } |
| 1507 | 1572 |
| 1508 } // namespace blink | 1573 } // namespace blink |
| OLD | NEW |