Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.cpp

Issue 2706563003: Create the API that returns the RTCConfiguration of the PeerConnection.
Patch Set: rebaselining Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 iceServers.push_back(WebRTCIceServer{urls, username, credential});
325 } 327 }
326 webConfiguration.iceServers = iceServers; 328 webConfiguration.iceServers = iceServers;
327 } 329 }
328 330
329 if (configuration.hasCertificates()) { 331 if (configuration.hasCertificates()) {
330 const HeapVector<Member<RTCCertificate>>& certificates = 332 const HeapVector<Member<RTCCertificate>>& certificates =
331 configuration.certificates(); 333 configuration.certificates();
332 WebVector<std::unique_ptr<WebRTCCertificate>> certificatesCopy( 334 WebVector<std::unique_ptr<WebRTCCertificate>> certificatesCopy(
333 certificates.size()); 335 certificates.size());
334 for (size_t i = 0; i < certificates.size(); ++i) { 336 for (size_t i = 0; i < certificates.size(); ++i) {
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 791
790 RTCSessionDescription* RTCPeerConnection::remoteDescription() { 792 RTCSessionDescription* RTCPeerConnection::remoteDescription() {
791 WebRTCSessionDescription webSessionDescription = 793 WebRTCSessionDescription webSessionDescription =
792 m_peerHandler->remoteDescription(); 794 m_peerHandler->remoteDescription();
793 if (webSessionDescription.isNull()) 795 if (webSessionDescription.isNull())
794 return nullptr; 796 return nullptr;
795 797
796 return RTCSessionDescription::create(webSessionDescription); 798 return RTCSessionDescription::create(webSessionDescription);
797 } 799 }
798 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 urlStrings.push_back(blink_url.string());
844 urls.setStringSequence(urlStrings);
foolip 2017/03/21 08:37:14 There's some normalization here that isn't spelled
845 server.setURLs(urls);
846 server.setUsername(blink_server.username);
847 server.setCredential(blink_server.credential);
848 servers.push_back(server);
849 }
850 rtcConfig.setIceServers(servers);
851
852 HeapVector<Member<RTCCertificate>> certificates;
853 for (auto& blink_certificate : blinkConfig.certificates) {
854 certificates.push_back(new RTCCertificate(std::move(blink_certificate)));
855 }
856 rtcConfig.setCertificates(certificates);
857 }
858
799 void RTCPeerConnection::setConfiguration( 859 void RTCPeerConnection::setConfiguration(
800 ScriptState* scriptState, 860 ScriptState* scriptState,
801 const RTCConfiguration& rtcConfiguration, 861 const RTCConfiguration& rtcConfiguration,
802 ExceptionState& exceptionState) { 862 ExceptionState& exceptionState) {
803 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 863 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
804 return; 864 return;
805 865
806 WebRTCConfiguration configuration = parseConfiguration( 866 WebRTCConfiguration configuration = parseConfiguration(
807 scriptState->getExecutionContext(), rtcConfiguration, exceptionState); 867 scriptState->getExecutionContext(), rtcConfiguration, exceptionState);
808 868
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 DEFINE_TRACE(RTCPeerConnection) { 1560 DEFINE_TRACE(RTCPeerConnection) {
1501 visitor->trace(m_localStreams); 1561 visitor->trace(m_localStreams);
1502 visitor->trace(m_remoteStreams); 1562 visitor->trace(m_remoteStreams);
1503 visitor->trace(m_dispatchScheduledEventRunner); 1563 visitor->trace(m_dispatchScheduledEventRunner);
1504 visitor->trace(m_scheduledEvents); 1564 visitor->trace(m_scheduledEvents);
1505 EventTargetWithInlineData::trace(visitor); 1565 EventTargetWithInlineData::trace(visitor);
1506 SuspendableObject::trace(visitor); 1566 SuspendableObject::trace(visitor);
1507 } 1567 }
1508 1568
1509 } // namespace blink 1569 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698