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

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

Issue 2706563003: Create the API that returns the RTCConfiguration of the PeerConnection.
Patch Set: rebaselining again 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..f6559a66b3e421dd7992a2cbfe4323d548bb4633 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,9 @@ WebRTCConfiguration parseConfiguration(ExecutionContext* context,
"required when the URL scheme is "
"\"turn\" or \"turns\".");
}
- iceServers.push_back(WebRTCIceServer{url, username, credential});
+ urls.push_back(url);
}
+ iceServers.push_back(WebRTCIceServer{urls, username, credential});
dcheng 2017/03/09 21:36:54 Nit: () rather than {}. We only use uniform initia
zhihuang1 2017/03/10 03:20:43 Thanks for the link. Good to learn that.
dcheng 2017/03/10 19:54:00 Ah... I missed that this was a struct. It's OK to
Taylor_Brandstetter 2017/03/10 20:06:03 Actually, isn't emplace_back preferable then? ice
}
webConfiguration.iceServers = iceServers;
}
@@ -340,6 +342,71 @@ WebRTCConfiguration parseConfiguration(ExecutionContext* context,
return webConfiguration;
}
+RTCConfiguration getWebKitRtcConfiguration(WebRTCConfiguration& blinkConfig) {
dcheng 2017/03/09 21:36:54 Pass argument by const ref. The naming is also a
zhihuang1 2017/03/10 03:20:43 It is not const because the ownership of blinkConf
+ RTCConfiguration rtcConfig;
+
+ 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 (WebRTCIceServer blink_server : blinkConfig.iceServers) {
tommi (sloooow) - chröme 2017/03/09 19:37:08 nit: const WebRTCIceServer& as is, you're creating
zhihuang1 2017/03/10 03:20:43 Done.
+ RTCIceServer server;
+ Vector<String> urlStrings;
+ StringOrStringSequence urls;
+ for (WebURL blink_url : blink_server.urls) {
tommi (sloooow) - chröme 2017/03/09 19:37:08 const WebURL&
zhihuang1 2017/03/10 03:20:43 Done.
+ String urlString(blink_url.string().utf8().c_str());
+ urlStrings.push_back(urlString);
+ }
+ urls.setStringSequence(urlStrings);
+ server.setURLs(urls);
+ String username(blink_server.username.utf8().c_str());
+ 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 (std::unique_ptr<blink::WebRTCCertificate>& blink_certificate :
dcheng 2017/03/09 21:36:54 auto& for conciseness
zhihuang1 2017/03/10 03:20:43 Done.
+ blinkConfig.certificates) {
+ certificates.push_back(new RTCCertificate(std::move(blink_certificate)));
+ }
+ rtcConfig.setCertificates(certificates);
+
+ return rtcConfig;
+}
+
RTCOfferOptionsPlatform* parseOfferOptions(const Dictionary& options,
ExceptionState& exceptionState) {
if (options.isUndefinedOrNull())
@@ -795,6 +862,11 @@ RTCSessionDescription* RTCPeerConnection::remoteDescription() {
return RTCSessionDescription::create(webSessionDescription);
}
+void RTCPeerConnection::getConfiguration(RTCConfiguration& rtcConfig) {
+ blink::WebRTCConfiguration blinkConfig = m_peerHandler->getConfiguration();
+ rtcConfig = getWebKitRtcConfiguration(blinkConfig);
dcheng 2017/03/09 21:36:54 Nit: reads a bit more naturally to just return the
zhihuang1 2017/03/10 03:20:43 I agree that the direct return is more nature but
dcheng 2017/03/10 19:54:00 Acknowledged.
+}
+
void RTCPeerConnection::setConfiguration(
ScriptState* scriptState,
const RTCConfiguration& rtcConfiguration,

Powered by Google App Engine
This is Rietveld 408576698