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

Unified Diff: third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.cpp

Issue 2706563003: Create the API that returns the RTCConfiguration of the PeerConnection.
Patch Set: Response to the CR comments. 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.cpp
diff --git a/third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.cpp b/third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.cpp
index 256c5a61800a0b689dc2e7005590e89e9558989c..5c3ea99e1dd25a25081ad7f11088ad1ec6e330e7 100644
--- a/third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.cpp
+++ b/third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.cpp
@@ -298,6 +298,7 @@ WebRTCConfiguration parseConfiguration(ExecutionContext* context,
String username = iceServer.username();
String credential = iceServer.credential();
+ Vector<WebURL> urls;
for (const String& urlString : urlStrings) {
KURL url(KURL(), urlString);
if (!url.isValid()) {
@@ -320,8 +321,10 @@ WebRTCConfiguration parseConfiguration(ExecutionContext* context,
"required when the URL scheme is "
"\"turn\" or \"turns\".");
}
- iceServers.push_back(WebRTCIceServer{url, username, credential});
+ urls.push_back(url);
}
+ WebRTCIceServer webIceServer = {urls, username, credential};
+ iceServers.push_back(webIceServer);
}
webConfiguration.iceServers = iceServers;
}
@@ -795,6 +798,68 @@ RTCSessionDescription* RTCPeerConnection::remoteDescription() {
return RTCSessionDescription::create(webSessionDescription);
}
+void RTCPeerConnection::getConfiguration(RTCConfiguration& rtcConfig) {
+ blink::WebRTCConfiguration blinkConfig = m_peerHandler->getConfiguration();
+
+ switch (blinkConfig.iceTransportPolicy) {
+ case blink::WebRTCIceTransportPolicy::kNone:
+ rtcConfig.setIceTransportPolicy("none");
+ break;
+ case blink::WebRTCIceTransportPolicy::kRelay:
+ rtcConfig.setIceTransportPolicy("relay");
+ break;
+ case blink::WebRTCIceTransportPolicy::kAll:
+ rtcConfig.setIceTransportPolicy("all");
+ break;
+ }
+
+ switch (blinkConfig.bundlePolicy) {
+ case blink::WebRTCBundlePolicy::kBalanced:
+ rtcConfig.setBundlePolicy("balanced");
+ break;
+ case blink::WebRTCBundlePolicy::kMaxBundle:
+ rtcConfig.setBundlePolicy("max-bundle");
+ break;
+ case blink::WebRTCBundlePolicy::kMaxCompat:
+ rtcConfig.setBundlePolicy("max-compat");
+ break;
+ }
+
+ switch (blinkConfig.rtcpMuxPolicy) {
+ case blink::WebRTCRtcpMuxPolicy::kNegotiate:
+ rtcConfig.setRtcpMuxPolicy("negotiate");
+ break;
+ case blink::WebRTCRtcpMuxPolicy::kRequire:
+ rtcConfig.setRtcpMuxPolicy("require");
+ break;
+ }
+
+ HeapVector<RTCIceServer> servers;
+ for (const WebRTCIceServer& blink_server : blinkConfig.iceServers) {
+ RTCIceServer server;
+ Vector<String> urlStrings;
+ StringOrStringSequence urls;
+ for (const WebURL& blink_url : blink_server.urls) {
+ 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.
+ urlStrings.push_back(urlString);
+ }
+ urls.setStringSequence(urlStrings);
+ server.setURLs(urls);
+ 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.
+ server.setUsername(blink_server.username);
+ String credential(blink_server.credential.utf8().c_str());
+ server.setCredential(credential);
+ servers.push_back(server);
+ }
+ rtcConfig.setIceServers(servers);
+
+ HeapVector<Member<RTCCertificate>> certificates;
+ for (auto& blink_certificate : blinkConfig.certificates) {
+ certificates.push_back(new RTCCertificate(std::move(blink_certificate)));
+ }
+ rtcConfig.setCertificates(certificates);
+}
+
void RTCPeerConnection::setConfiguration(
ScriptState* scriptState,
const RTCConfiguration& rtcConfiguration,

Powered by Google App Engine
This is Rietveld 408576698