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

Side by Side Diff: content/renderer/media/rtc_peer_connection_handler.cc

Issue 2511633002: Rename "updateICE" to "setConfiguration", everywhere except in Blink. (Closed)
Patch Set: Making sure updateIce doesn't change behavior in this CL. Created 4 years, 1 month 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 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/rtc_peer_connection_handler.h" 5 #include "content/renderer/media/rtc_peer_connection_handler.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 const webrtc::SessionDescriptionInterface* description = 182 const webrtc::SessionDescriptionInterface* description =
183 description_callback.Run(); 183 description_callback.Run();
184 if (description) { 184 if (description) {
185 description->ToString(sdp); 185 description->ToString(sdp);
186 *type = description->type(); 186 *type = description->type();
187 } 187 }
188 } 188 }
189 189
190 // Converter functions from Blink types to WebRTC types. 190 // Converter functions from Blink types to WebRTC types.
191 191
192 // This function doesn't assume |webrtc_config| is empty. Any fields in
193 // |blink_config| replace the corresponding fields in |webrtc_config|, but
194 // fields that only exist in |webrtc_config| are left alone.
192 void GetNativeRtcConfiguration( 195 void GetNativeRtcConfiguration(
193 const blink::WebRTCConfiguration& blink_config, 196 const blink::WebRTCConfiguration& blink_config,
194 webrtc::PeerConnectionInterface::RTCConfiguration* webrtc_config) { 197 webrtc::PeerConnectionInterface::RTCConfiguration* webrtc_config) {
195 DCHECK(webrtc_config); 198 DCHECK(webrtc_config);
196 199
200 webrtc_config->servers.clear();
197 for (const blink::WebRTCIceServer& blink_server : blink_config.iceServers) { 201 for (const blink::WebRTCIceServer& blink_server : blink_config.iceServers) {
198 webrtc::PeerConnectionInterface::IceServer server; 202 webrtc::PeerConnectionInterface::IceServer server;
199 server.username = 203 server.username =
200 base::UTF16ToUTF8(base::StringPiece16(blink_server.username)); 204 base::UTF16ToUTF8(base::StringPiece16(blink_server.username));
201 server.password = 205 server.password =
202 base::UTF16ToUTF8(base::StringPiece16(blink_server.credential)); 206 base::UTF16ToUTF8(base::StringPiece16(blink_server.credential));
203 server.uri = blink_server.url.string().utf8(); 207 server.uri = blink_server.url.string().utf8();
204 webrtc_config->servers.push_back(server); 208 webrtc_config->servers.push_back(server);
205 } 209 }
206 210
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate; 245 webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate;
242 break; 246 break;
243 case blink::WebRTCRtcpMuxPolicy::kRequire: 247 case blink::WebRTCRtcpMuxPolicy::kRequire:
244 webrtc_config->rtcp_mux_policy = 248 webrtc_config->rtcp_mux_policy =
245 webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire; 249 webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire;
246 break; 250 break;
247 default: 251 default:
248 NOTREACHED(); 252 NOTREACHED();
249 } 253 }
250 254
255 webrtc_config->certificates.clear();
251 for (const std::unique_ptr<blink::WebRTCCertificate>& blink_certificate : 256 for (const std::unique_ptr<blink::WebRTCCertificate>& blink_certificate :
252 blink_config.certificates) { 257 blink_config.certificates) {
253 webrtc_config->certificates.push_back( 258 webrtc_config->certificates.push_back(
254 static_cast<RTCCertificate*>(blink_certificate.get()) 259 static_cast<RTCCertificate*>(blink_certificate.get())
255 ->rtcCertificate()); 260 ->rtcCertificate());
256 } 261 }
257 } 262 }
258 263
259 void CopyConstraintsIntoRtcConfiguration( 264 void CopyConstraintsIntoRtcConfiguration(
260 const blink::WebMediaConstraints constraints, 265 const blink::WebMediaConstraints constraints,
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 1091
1087 bool RTCPeerConnectionHandler::initialize( 1092 bool RTCPeerConnectionHandler::initialize(
1088 const blink::WebRTCConfiguration& server_configuration, 1093 const blink::WebRTCConfiguration& server_configuration,
1089 const blink::WebMediaConstraints& options) { 1094 const blink::WebMediaConstraints& options) {
1090 DCHECK(thread_checker_.CalledOnValidThread()); 1095 DCHECK(thread_checker_.CalledOnValidThread());
1091 DCHECK(frame_); 1096 DCHECK(frame_);
1092 1097
1093 peer_connection_tracker_ = 1098 peer_connection_tracker_ =
1094 RenderThreadImpl::current()->peer_connection_tracker()->AsWeakPtr(); 1099 RenderThreadImpl::current()->peer_connection_tracker()->AsWeakPtr();
1095 1100
1096 webrtc::PeerConnectionInterface::RTCConfiguration config; 1101 GetNativeRtcConfiguration(server_configuration, &configuration_);
1097 GetNativeRtcConfiguration(server_configuration, &config);
1098 1102
1099 // Choose between RTC smoothness algorithm and prerenderer smoothing. 1103 // Choose between RTC smoothness algorithm and prerenderer smoothing.
1100 // Prerenderer smoothing is turned on if RTC smoothness is turned off. 1104 // Prerenderer smoothing is turned on if RTC smoothness is turned off.
1101 config.set_prerenderer_smoothing( 1105 configuration_.set_prerenderer_smoothing(
1102 base::CommandLine::ForCurrentProcess()->HasSwitch( 1106 base::CommandLine::ForCurrentProcess()->HasSwitch(
1103 switches::kDisableRTCSmoothnessAlgorithm)); 1107 switches::kDisableRTCSmoothnessAlgorithm));
1104 1108
1105 // Copy all the relevant constraints into |config|. 1109 // Copy all the relevant constraints into |config|.
1106 CopyConstraintsIntoRtcConfiguration(options, &config); 1110 CopyConstraintsIntoRtcConfiguration(options, &configuration_);
1107 1111
1108 peer_connection_observer_ = new Observer(weak_factory_.GetWeakPtr()); 1112 peer_connection_observer_ = new Observer(weak_factory_.GetWeakPtr());
1109 native_peer_connection_ = dependency_factory_->CreatePeerConnection( 1113 native_peer_connection_ = dependency_factory_->CreatePeerConnection(
1110 config, frame_, peer_connection_observer_.get()); 1114 configuration_, frame_, peer_connection_observer_.get());
1111 1115
1112 if (!native_peer_connection_.get()) { 1116 if (!native_peer_connection_.get()) {
1113 LOG(ERROR) << "Failed to initialize native PeerConnection."; 1117 LOG(ERROR) << "Failed to initialize native PeerConnection.";
1114 return false; 1118 return false;
1115 } 1119 }
1116 1120
1117 if (peer_connection_tracker_) { 1121 if (peer_connection_tracker_) {
1118 peer_connection_tracker_->RegisterPeerConnection(this, config, options, 1122 peer_connection_tracker_->RegisterPeerConnection(this, configuration_,
1119 frame_); 1123 options, frame_);
1120 } 1124 }
1121 1125
1122 uma_observer_ = new rtc::RefCountedObject<PeerConnectionUMAObserver>(); 1126 uma_observer_ = new rtc::RefCountedObject<PeerConnectionUMAObserver>();
1123 native_peer_connection_->RegisterUMAObserver(uma_observer_.get()); 1127 native_peer_connection_->RegisterUMAObserver(uma_observer_.get());
1124 return true; 1128 return true;
1125 } 1129 }
1126 1130
1127 bool RTCPeerConnectionHandler::InitializeForTest( 1131 bool RTCPeerConnectionHandler::InitializeForTest(
1128 const blink::WebRTCConfiguration& server_configuration, 1132 const blink::WebRTCConfiguration& server_configuration,
1129 const blink::WebMediaConstraints& options, 1133 const blink::WebMediaConstraints& options,
1130 const base::WeakPtr<PeerConnectionTracker>& peer_connection_tracker) { 1134 const base::WeakPtr<PeerConnectionTracker>& peer_connection_tracker) {
1131 DCHECK(thread_checker_.CalledOnValidThread()); 1135 DCHECK(thread_checker_.CalledOnValidThread());
1132 webrtc::PeerConnectionInterface::RTCConfiguration config; 1136 GetNativeRtcConfiguration(server_configuration, &configuration_);
1133 GetNativeRtcConfiguration(server_configuration, &config);
1134 1137
1135 peer_connection_observer_ = new Observer(weak_factory_.GetWeakPtr()); 1138 peer_connection_observer_ = new Observer(weak_factory_.GetWeakPtr());
1136 CopyConstraintsIntoRtcConfiguration(options, &config); 1139 CopyConstraintsIntoRtcConfiguration(options, &configuration_);
1137 1140
1138 native_peer_connection_ = dependency_factory_->CreatePeerConnection( 1141 native_peer_connection_ = dependency_factory_->CreatePeerConnection(
1139 config, nullptr, peer_connection_observer_.get()); 1142 configuration_, nullptr, peer_connection_observer_.get());
1140 if (!native_peer_connection_.get()) { 1143 if (!native_peer_connection_.get()) {
1141 LOG(ERROR) << "Failed to initialize native PeerConnection."; 1144 LOG(ERROR) << "Failed to initialize native PeerConnection.";
1142 return false; 1145 return false;
1143 } 1146 }
1144 peer_connection_tracker_ = peer_connection_tracker; 1147 peer_connection_tracker_ = peer_connection_tracker;
1145 return true; 1148 return true;
1146 } 1149 }
1147 1150
1148 void RTCPeerConnectionHandler::createOffer( 1151 void RTCPeerConnectionHandler::createOffer(
1149 const blink::WebRTCSessionDescriptionRequest& request, 1152 const blink::WebRTCSessionDescriptionRequest& request,
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1376 base::Bind(&webrtc::PeerConnectionInterface::remote_description, 1379 base::Bind(&webrtc::PeerConnectionInterface::remote_description,
1377 native_peer_connection_); 1380 native_peer_connection_);
1378 RunSynchronousClosureOnSignalingThread( 1381 RunSynchronousClosureOnSignalingThread(
1379 base::Bind(&GetSdpAndTypeFromSessionDescription, description_cb, 1382 base::Bind(&GetSdpAndTypeFromSessionDescription, description_cb,
1380 base::Unretained(&sdp), base::Unretained(&type)), 1383 base::Unretained(&sdp), base::Unretained(&type)),
1381 "remoteDescription"); 1384 "remoteDescription");
1382 1385
1383 return CreateWebKitSessionDescription(sdp, type); 1386 return CreateWebKitSessionDescription(sdp, type);
1384 } 1387 }
1385 1388
1386 bool RTCPeerConnectionHandler::updateICE( 1389 bool RTCPeerConnectionHandler::setConfiguration(
1387 const blink::WebRTCConfiguration& server_configuration) { 1390 const blink::WebRTCConfiguration& blink_config) {
1388 DCHECK(thread_checker_.CalledOnValidThread()); 1391 DCHECK(thread_checker_.CalledOnValidThread());
1389 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::updateICE"); 1392 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::setConfiguration");
1390 webrtc::PeerConnectionInterface::RTCConfiguration config; 1393 GetNativeRtcConfiguration(blink_config, &configuration_);
1391 GetNativeRtcConfiguration(server_configuration, &config);
1392 1394
1393 if (peer_connection_tracker_) 1395 if (peer_connection_tracker_)
1394 peer_connection_tracker_->TrackUpdateIce(this, config); 1396 peer_connection_tracker_->TrackSetConfiguration(this, configuration_);
1395 1397
1396 return native_peer_connection_->UpdateIce(config.servers); 1398 return native_peer_connection_->SetConfiguration(configuration_);
1397 } 1399 }
1398 1400
1399 void RTCPeerConnectionHandler::logSelectedRtcpMuxPolicy( 1401 void RTCPeerConnectionHandler::logSelectedRtcpMuxPolicy(
1400 blink::RtcpMuxPolicy selectedRtcpMuxPolicy) { 1402 blink::RtcpMuxPolicy selectedRtcpMuxPolicy) {
1401 UMA_HISTOGRAM_ENUMERATION("WebRTC.PeerConnection.SelectedRtcpMuxPolicy", 1403 UMA_HISTOGRAM_ENUMERATION("WebRTC.PeerConnection.SelectedRtcpMuxPolicy",
1402 selectedRtcpMuxPolicy, blink::RtcpMuxPolicyMax); 1404 selectedRtcpMuxPolicy, blink::RtcpMuxPolicyMax);
1403 } 1405 }
1404 1406
1405 bool RTCPeerConnectionHandler::addICECandidate( 1407 bool RTCPeerConnectionHandler::addICECandidate(
1406 const blink::WebRTCVoidRequest& request, 1408 const blink::WebRTCVoidRequest& request,
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
1955 } 1957 }
1956 1958
1957 void RTCPeerConnectionHandler::ResetUMAStats() { 1959 void RTCPeerConnectionHandler::ResetUMAStats() {
1958 DCHECK(thread_checker_.CalledOnValidThread()); 1960 DCHECK(thread_checker_.CalledOnValidThread());
1959 num_local_candidates_ipv6_ = 0; 1961 num_local_candidates_ipv6_ = 0;
1960 num_local_candidates_ipv4_ = 0; 1962 num_local_candidates_ipv4_ = 0;
1961 ice_connection_checking_start_ = base::TimeTicks(); 1963 ice_connection_checking_start_ = base::TimeTicks();
1962 memset(ice_state_seen_, 0, sizeof(ice_state_seen_)); 1964 memset(ice_state_seen_, 0, sizeof(ice_state_seen_));
1963 } 1965 }
1964 } // namespace content 1966 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698