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

Unified Diff: content/renderer/media/rtc_peer_connection_handler.cc

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: content/renderer/media/rtc_peer_connection_handler.cc
diff --git a/content/renderer/media/rtc_peer_connection_handler.cc b/content/renderer/media/rtc_peer_connection_handler.cc
index 64ecb99391809009238d29967ba82bdb9e770d76..1c4c07989ecf2602b039c9cdc0a2a63a86625c14 100644
--- a/content/renderer/media/rtc_peer_connection_handler.cc
+++ b/content/renderer/media/rtc_peer_connection_handler.cc
@@ -243,7 +243,9 @@ void GetNativeRtcConfiguration(
webrtc::PeerConnectionInterface::IceServer server;
server.username = blink_server.username.utf8();
server.password = blink_server.credential.utf8();
- server.uri = blink_server.url.string().utf8();
+ for (const blink::WebURL& url : blink_server.urls) {
+ server.urls.push_back(url.string().utf8());
+ }
webrtc_config->servers.push_back(server);
}
@@ -257,8 +259,6 @@ void GetNativeRtcConfiguration(
case blink::WebRTCIceTransportPolicy::kAll:
webrtc_config->type = webrtc::PeerConnectionInterface::kAll;
break;
- default:
tommi (sloooow) - chröme 2017/03/09 19:37:07 just checking - will compilation catch it for us i
Taylor_Brandstetter 2017/03/09 22:54:29 Yes, from the "Wswitch" warning. That way it's a c
- NOTREACHED();
}
switch (blink_config.bundlePolicy) {
@@ -274,8 +274,6 @@ void GetNativeRtcConfiguration(
webrtc_config->bundle_policy =
webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat;
break;
- default:
- NOTREACHED();
}
switch (blink_config.rtcpMuxPolicy) {
@@ -287,8 +285,6 @@ void GetNativeRtcConfiguration(
webrtc_config->rtcp_mux_policy =
webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire;
break;
- default:
- NOTREACHED();
}
webrtc_config->certificates.clear();
@@ -300,6 +296,75 @@ void GetNativeRtcConfiguration(
}
}
+void GetBlinkRtcConfiguration(
dcheng 2017/03/09 21:36:54 Nit: might be more clearly named ToBlinkRtcConfigu
zhihuang1 2017/03/10 03:20:43 Done.
+ const webrtc::PeerConnectionInterface::RTCConfiguration& webrtc_config,
+ blink::WebRTCConfiguration* blink_config) {
+ blink::WebVector<blink::WebRTCIceServer> iceServers(
+ webrtc_config.servers.size());
+ for (size_t i = 0; i < webrtc_config.servers.size(); i++) {
tommi (sloooow) - chröme 2017/03/09 19:37:07 ++i
zhihuang1 2017/03/10 03:20:42 Done.
+ const webrtc::PeerConnectionInterface::IceServer& ice_server =
+ webrtc_config.servers[i];
+ blink::WebRTCIceServer blink_server;
+ blink::WebVector<blink::WebURL> blink_urls(ice_server.urls.size());
+ for (size_t j = 0; j < ice_server.urls.size(); j++) {
tommi (sloooow) - chröme 2017/03/09 19:37:07 ++j Also, this code tends to not use {} for singl
zhihuang1 2017/03/10 03:20:43 Done.
+ blink_urls[j] = (GURL(ice_server.urls[j]));
dcheng 2017/03/09 21:36:54 Nit: no () around GURL()
zhihuang1 2017/03/10 03:20:43 Done.
+ }
+ blink_server.urls = std::move(blink_urls);
+ blink_server.username = blink::WebString::fromUTF8(ice_server.username);
+ blink_server.credential = blink::WebString::fromUTF8(ice_server.password);
+ iceServers[i] = blink_server;
+ }
+ blink_config->iceServers = std::move(iceServers);
+
+ switch (webrtc_config.type) {
+ case webrtc::PeerConnectionInterface::kNone:
+ blink_config->iceTransportPolicy = blink::WebRTCIceTransportPolicy::kNone;
+ break;
+ case webrtc::PeerConnectionInterface::kRelay:
+ blink_config->iceTransportPolicy =
+ blink::WebRTCIceTransportPolicy::kRelay;
+ break;
+ case webrtc::PeerConnectionInterface::kAll:
+ blink_config->iceTransportPolicy = blink::WebRTCIceTransportPolicy::kAll;
+ break;
+ default:
tommi (sloooow) - chröme 2017/03/09 19:37:07 needed? (since similar cases were deleted above).
zhihuang1 2017/03/10 03:20:43 I'll remove these.
+ NOTREACHED();
+ }
+
+ switch (webrtc_config.bundle_policy) {
+ case webrtc::PeerConnectionInterface::kBundlePolicyBalanced:
+ blink_config->bundlePolicy = blink::WebRTCBundlePolicy::kBalanced;
+ break;
+ case webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle:
+ blink_config->bundlePolicy = blink::WebRTCBundlePolicy::kMaxBundle;
+ break;
+ case webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat:
+ blink_config->bundlePolicy = blink::WebRTCBundlePolicy::kMaxCompat;
+ break;
+ default:
+ NOTREACHED();
+ }
+
+ switch (webrtc_config.rtcp_mux_policy) {
+ case webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate:
+ blink_config->rtcpMuxPolicy = blink::WebRTCRtcpMuxPolicy::kNegotiate;
+ break;
+ case webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire:
+ blink_config->rtcpMuxPolicy = blink::WebRTCRtcpMuxPolicy::kRequire;
+ break;
+ default:
+ NOTREACHED();
+ }
+
+ blink::WebVector<std::unique_ptr<blink::WebRTCCertificate>> certificates(
+ webrtc_config.certificates.size());
+ for (size_t i = 0; i < webrtc_config.certificates.size(); i++) {
tommi (sloooow) - chröme 2017/03/09 19:37:07 ++i
zhihuang1 2017/03/10 03:20:43 Done.
+ certificates[i] = std::unique_ptr<blink::WebRTCCertificate>(
dcheng 2017/03/09 21:36:54 Nit: base::MakeUnique<WebRTCCertificate>(...)
zhihuang1 2017/03/10 03:20:43 Done.
+ new RTCCertificate(webrtc_config.certificates[i]));
+ }
+ blink_config->certificates = std::move(certificates);
+}
+
void CopyConstraintsIntoRtcConfiguration(
const blink::WebMediaConstraints constraints,
webrtc::PeerConnectionInterface::RTCConfiguration* configuration) {
@@ -1455,6 +1520,15 @@ blink::WebRTCErrorType RTCPeerConnectionHandler::setConfiguration(
return blink_error.type();
}
+blink::WebRTCConfiguration RTCPeerConnectionHandler::getConfiguration() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ webrtc::PeerConnectionInterface::RTCConfiguration webrtc_config =
+ native_peer_connection_->GetConfiguration();
+ blink::WebRTCConfiguration blink_config;
+ GetBlinkRtcConfiguration(webrtc_config, &blink_config);
+ return blink_config;
+}
+
bool RTCPeerConnectionHandler::addICECandidate(
const blink::WebRTCVoidRequest& request,
const blink::WebRTCICECandidate& candidate) {

Powered by Google App Engine
This is Rietveld 408576698