Commit 08110857 authored by deadbeef's avatar deadbeef Committed by Commit bot

Rename "updateICE" to "setConfiguration", everywhere except in Blink.

This CL prepares for later renaming updateIce to setConfiguration in
Blink, once it has an Intent to Ship.

updateIce was never functional in the first place (in the native webrtc
library), always throwing the same exception. SetConfiguration is
functional, and will allow an application to change the set of ICE
servers and ICE candidate policy. Soon, also the ICE candidate pool
size.

updateIce will no longer be tracked after this CL, which should be ok
since it has always been nonfunctional and stats show zero use.

BUG=chromium:587453

Review-Url: https://codereview.chromium.org/2511633002
Cr-Commit-Position: refs/heads/master@{#438206}
parent 876fe79c
...@@ -454,7 +454,7 @@ WebRTCSessionDescription MockWebRTCPeerConnectionHandler::remoteDescription() { ...@@ -454,7 +454,7 @@ WebRTCSessionDescription MockWebRTCPeerConnectionHandler::remoteDescription() {
return remote_description_; return remote_description_;
} }
bool MockWebRTCPeerConnectionHandler::updateICE( bool MockWebRTCPeerConnectionHandler::setConfiguration(
const WebRTCConfiguration& configuration) { const WebRTCConfiguration& configuration) {
return true; return true;
} }
......
...@@ -50,7 +50,8 @@ class MockWebRTCPeerConnectionHandler ...@@ -50,7 +50,8 @@ class MockWebRTCPeerConnectionHandler
const blink::WebRTCSessionDescription& remote_description) override; const blink::WebRTCSessionDescription& remote_description) override;
blink::WebRTCSessionDescription localDescription() override; blink::WebRTCSessionDescription localDescription() override;
blink::WebRTCSessionDescription remoteDescription() override; blink::WebRTCSessionDescription remoteDescription() override;
bool updateICE(const blink::WebRTCConfiguration& configuration) override; bool setConfiguration(
const blink::WebRTCConfiguration& configuration) override;
void logSelectedRtcpMuxPolicy(blink::RtcpMuxPolicy) override; void logSelectedRtcpMuxPolicy(blink::RtcpMuxPolicy) override;
bool addICECandidate(const blink::WebRTCICECandidate& ice_candidate) override; bool addICECandidate(const blink::WebRTCICECandidate& ice_candidate) override;
bool addICECandidate(const blink::WebRTCVoidRequest& request, bool addICECandidate(const blink::WebRTCVoidRequest& request,
......
...@@ -266,7 +266,8 @@ void MockPeerConnectionImpl::SetRemoteDescriptionWorker( ...@@ -266,7 +266,8 @@ void MockPeerConnectionImpl::SetRemoteDescriptionWorker(
remote_desc_.reset(desc); remote_desc_.reset(desc);
} }
bool MockPeerConnectionImpl::UpdateIce(const IceServers& configuration) { bool MockPeerConnectionImpl::SetConfiguration(
const RTCConfiguration& configuration) {
return true; return true;
} }
......
...@@ -92,7 +92,7 @@ class MockPeerConnectionImpl : public webrtc::PeerConnectionInterface { ...@@ -92,7 +92,7 @@ class MockPeerConnectionImpl : public webrtc::PeerConnectionInterface {
void SetRemoteDescriptionWorker( void SetRemoteDescriptionWorker(
webrtc::SetSessionDescriptionObserver* observer, webrtc::SetSessionDescriptionObserver* observer,
webrtc::SessionDescriptionInterface* desc); webrtc::SessionDescriptionInterface* desc);
bool UpdateIce(const IceServers& configuration) override; bool SetConfiguration(const RTCConfiguration& configuration) override;
bool AddIceCandidate(const webrtc::IceCandidateInterface* candidate) override; bool AddIceCandidate(const webrtc::IceCandidateInterface* candidate) override;
void RegisterUMAObserver(webrtc::UMAObserver* observer) override; void RegisterUMAObserver(webrtc::UMAObserver* observer) override;
......
...@@ -524,7 +524,7 @@ void PeerConnectionTracker::TrackSetSessionDescription( ...@@ -524,7 +524,7 @@ void PeerConnectionTracker::TrackSetSessionDescription(
value); value);
} }
void PeerConnectionTracker::TrackUpdateIce( void PeerConnectionTracker::TrackSetConfiguration(
RTCPeerConnectionHandler* pc_handler, RTCPeerConnectionHandler* pc_handler,
const webrtc::PeerConnectionInterface::RTCConfiguration& config) { const webrtc::PeerConnectionInterface::RTCConfiguration& config) {
DCHECK(main_thread_.CalledOnValidThread()); DCHECK(main_thread_.CalledOnValidThread());
...@@ -539,10 +539,7 @@ void PeerConnectionTracker::TrackUpdateIce( ...@@ -539,10 +539,7 @@ void PeerConnectionTracker::TrackUpdateIce(
<< "rtcpMuxPolicy: " << SerializeRtcpMuxPolicy(config.rtcp_mux_policy) << "rtcpMuxPolicy: " << SerializeRtcpMuxPolicy(config.rtcp_mux_policy)
<< "}"; << "}";
SendPeerConnectionUpdate( SendPeerConnectionUpdate(id, "setConfiguration", result.str());
id,
"updateIce",
result.str());
} }
void PeerConnectionTracker::TrackAddIceCandidate( void PeerConnectionTracker::TrackAddIceCandidate(
......
...@@ -102,8 +102,8 @@ class CONTENT_EXPORT PeerConnectionTracker ...@@ -102,8 +102,8 @@ class CONTENT_EXPORT PeerConnectionTracker
RTCPeerConnectionHandler* pc_handler, RTCPeerConnectionHandler* pc_handler,
const std::string& sdp, const std::string& type, Source source); const std::string& sdp, const std::string& type, Source source);
// Sends an update when Ice candidates are updated. // Sends an update when setConfiguration is called.
virtual void TrackUpdateIce( virtual void TrackSetConfiguration(
RTCPeerConnectionHandler* pc_handler, RTCPeerConnectionHandler* pc_handler,
const webrtc::PeerConnectionInterface::RTCConfiguration& config); const webrtc::PeerConnectionInterface::RTCConfiguration& config);
......
...@@ -189,11 +189,15 @@ void GetSdpAndTypeFromSessionDescription( ...@@ -189,11 +189,15 @@ void GetSdpAndTypeFromSessionDescription(
// Converter functions from Blink types to WebRTC types. // Converter functions from Blink types to WebRTC types.
// This function doesn't assume |webrtc_config| is empty. Any fields in
// |blink_config| replace the corresponding fields in |webrtc_config|, but
// fields that only exist in |webrtc_config| are left alone.
void GetNativeRtcConfiguration( void GetNativeRtcConfiguration(
const blink::WebRTCConfiguration& blink_config, const blink::WebRTCConfiguration& blink_config,
webrtc::PeerConnectionInterface::RTCConfiguration* webrtc_config) { webrtc::PeerConnectionInterface::RTCConfiguration* webrtc_config) {
DCHECK(webrtc_config); DCHECK(webrtc_config);
webrtc_config->servers.clear();
for (const blink::WebRTCIceServer& blink_server : blink_config.iceServers) { for (const blink::WebRTCIceServer& blink_server : blink_config.iceServers) {
webrtc::PeerConnectionInterface::IceServer server; webrtc::PeerConnectionInterface::IceServer server;
server.username = server.username =
...@@ -248,6 +252,7 @@ void GetNativeRtcConfiguration( ...@@ -248,6 +252,7 @@ void GetNativeRtcConfiguration(
NOTREACHED(); NOTREACHED();
} }
webrtc_config->certificates.clear();
for (const std::unique_ptr<blink::WebRTCCertificate>& blink_certificate : for (const std::unique_ptr<blink::WebRTCCertificate>& blink_certificate :
blink_config.certificates) { blink_config.certificates) {
webrtc_config->certificates.push_back( webrtc_config->certificates.push_back(
...@@ -1093,21 +1098,20 @@ bool RTCPeerConnectionHandler::initialize( ...@@ -1093,21 +1098,20 @@ bool RTCPeerConnectionHandler::initialize(
peer_connection_tracker_ = peer_connection_tracker_ =
RenderThreadImpl::current()->peer_connection_tracker()->AsWeakPtr(); RenderThreadImpl::current()->peer_connection_tracker()->AsWeakPtr();
webrtc::PeerConnectionInterface::RTCConfiguration config; GetNativeRtcConfiguration(server_configuration, &configuration_);
GetNativeRtcConfiguration(server_configuration, &config);
// Choose between RTC smoothness algorithm and prerenderer smoothing. // Choose between RTC smoothness algorithm and prerenderer smoothing.
// Prerenderer smoothing is turned on if RTC smoothness is turned off. // Prerenderer smoothing is turned on if RTC smoothness is turned off.
config.set_prerenderer_smoothing( configuration_.set_prerenderer_smoothing(
base::CommandLine::ForCurrentProcess()->HasSwitch( base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableRTCSmoothnessAlgorithm)); switches::kDisableRTCSmoothnessAlgorithm));
// Copy all the relevant constraints into |config|. // Copy all the relevant constraints into |config|.
CopyConstraintsIntoRtcConfiguration(options, &config); CopyConstraintsIntoRtcConfiguration(options, &configuration_);
peer_connection_observer_ = new Observer(weak_factory_.GetWeakPtr()); peer_connection_observer_ = new Observer(weak_factory_.GetWeakPtr());
native_peer_connection_ = dependency_factory_->CreatePeerConnection( native_peer_connection_ = dependency_factory_->CreatePeerConnection(
config, frame_, peer_connection_observer_.get()); configuration_, frame_, peer_connection_observer_.get());
if (!native_peer_connection_.get()) { if (!native_peer_connection_.get()) {
LOG(ERROR) << "Failed to initialize native PeerConnection."; LOG(ERROR) << "Failed to initialize native PeerConnection.";
...@@ -1115,8 +1119,8 @@ bool RTCPeerConnectionHandler::initialize( ...@@ -1115,8 +1119,8 @@ bool RTCPeerConnectionHandler::initialize(
} }
if (peer_connection_tracker_) { if (peer_connection_tracker_) {
peer_connection_tracker_->RegisterPeerConnection(this, config, options, peer_connection_tracker_->RegisterPeerConnection(this, configuration_,
frame_); options, frame_);
} }
uma_observer_ = new rtc::RefCountedObject<PeerConnectionUMAObserver>(); uma_observer_ = new rtc::RefCountedObject<PeerConnectionUMAObserver>();
...@@ -1129,14 +1133,13 @@ bool RTCPeerConnectionHandler::InitializeForTest( ...@@ -1129,14 +1133,13 @@ bool RTCPeerConnectionHandler::InitializeForTest(
const blink::WebMediaConstraints& options, const blink::WebMediaConstraints& options,
const base::WeakPtr<PeerConnectionTracker>& peer_connection_tracker) { const base::WeakPtr<PeerConnectionTracker>& peer_connection_tracker) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
webrtc::PeerConnectionInterface::RTCConfiguration config; GetNativeRtcConfiguration(server_configuration, &configuration_);
GetNativeRtcConfiguration(server_configuration, &config);
peer_connection_observer_ = new Observer(weak_factory_.GetWeakPtr()); peer_connection_observer_ = new Observer(weak_factory_.GetWeakPtr());
CopyConstraintsIntoRtcConfiguration(options, &config); CopyConstraintsIntoRtcConfiguration(options, &configuration_);
native_peer_connection_ = dependency_factory_->CreatePeerConnection( native_peer_connection_ = dependency_factory_->CreatePeerConnection(
config, nullptr, peer_connection_observer_.get()); configuration_, nullptr, peer_connection_observer_.get());
if (!native_peer_connection_.get()) { if (!native_peer_connection_.get()) {
LOG(ERROR) << "Failed to initialize native PeerConnection."; LOG(ERROR) << "Failed to initialize native PeerConnection.";
return false; return false;
...@@ -1383,17 +1386,16 @@ RTCPeerConnectionHandler::remoteDescription() { ...@@ -1383,17 +1386,16 @@ RTCPeerConnectionHandler::remoteDescription() {
return CreateWebKitSessionDescription(sdp, type); return CreateWebKitSessionDescription(sdp, type);
} }
bool RTCPeerConnectionHandler::updateICE( bool RTCPeerConnectionHandler::setConfiguration(
const blink::WebRTCConfiguration& server_configuration) { const blink::WebRTCConfiguration& blink_config) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::updateICE"); TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::setConfiguration");
webrtc::PeerConnectionInterface::RTCConfiguration config; GetNativeRtcConfiguration(blink_config, &configuration_);
GetNativeRtcConfiguration(server_configuration, &config);
if (peer_connection_tracker_) if (peer_connection_tracker_)
peer_connection_tracker_->TrackUpdateIce(this, config); peer_connection_tracker_->TrackSetConfiguration(this, configuration_);
return native_peer_connection_->UpdateIce(config.servers); return native_peer_connection_->SetConfiguration(configuration_);
} }
void RTCPeerConnectionHandler::logSelectedRtcpMuxPolicy( void RTCPeerConnectionHandler::logSelectedRtcpMuxPolicy(
......
...@@ -132,8 +132,8 @@ class CONTENT_EXPORT RTCPeerConnectionHandler ...@@ -132,8 +132,8 @@ class CONTENT_EXPORT RTCPeerConnectionHandler
blink::WebRTCSessionDescription localDescription() override; blink::WebRTCSessionDescription localDescription() override;
blink::WebRTCSessionDescription remoteDescription() override; blink::WebRTCSessionDescription remoteDescription() override;
bool updateICE( bool setConfiguration(
const blink::WebRTCConfiguration& server_configuration) override; const blink::WebRTCConfiguration& configuration) override;
void logSelectedRtcpMuxPolicy( void logSelectedRtcpMuxPolicy(
blink::RtcpMuxPolicy selectedRtcpMuxPolicy) override; blink::RtcpMuxPolicy selectedRtcpMuxPolicy) override;
bool addICECandidate(const blink::WebRTCICECandidate& candidate) override; bool addICECandidate(const blink::WebRTCICECandidate& candidate) override;
...@@ -271,6 +271,11 @@ class CONTENT_EXPORT RTCPeerConnectionHandler ...@@ -271,6 +271,11 @@ class CONTENT_EXPORT RTCPeerConnectionHandler
// |native_peer_connection_| is the libjingle native PeerConnection object. // |native_peer_connection_| is the libjingle native PeerConnection object.
scoped_refptr<webrtc::PeerConnectionInterface> native_peer_connection_; scoped_refptr<webrtc::PeerConnectionInterface> native_peer_connection_;
// The last applied configuration. Used so that the constraints
// used when constructing the PeerConnection carry over when
// SetConfiguration is called.
webrtc::PeerConnectionInterface::RTCConfiguration configuration_;
// Record info about the first SessionDescription from the local and // Record info about the first SessionDescription from the local and
// remote side to record UMA stats once both are set. We only check // remote side to record UMA stats once both are set. We only check
// for the first offer or answer. "pranswer"s and "unknown"s (from // for the first offer or answer. "pranswer"s and "unknown"s (from
......
...@@ -150,7 +150,7 @@ class MockPeerConnectionTracker : public PeerConnectionTracker { ...@@ -150,7 +150,7 @@ class MockPeerConnectionTracker : public PeerConnectionTracker {
const std::string& sdp, const std::string& type, const std::string& sdp, const std::string& type,
Source source)); Source source));
MOCK_METHOD2( MOCK_METHOD2(
TrackUpdateIce, TrackSetConfiguration,
void(RTCPeerConnectionHandler* pc_handler, void(RTCPeerConnectionHandler* pc_handler,
const webrtc::PeerConnectionInterface::RTCConfiguration& config)); const webrtc::PeerConnectionInterface::RTCConfiguration& config));
MOCK_METHOD4(TrackAddIceCandidate, MOCK_METHOD4(TrackAddIceCandidate,
...@@ -507,14 +507,15 @@ TEST_F(RTCPeerConnectionHandlerTest, setRemoteDescription) { ...@@ -507,14 +507,15 @@ TEST_F(RTCPeerConnectionHandlerTest, setRemoteDescription) {
EXPECT_EQ(kDummySdp, sdp_string); EXPECT_EQ(kDummySdp, sdp_string);
} }
TEST_F(RTCPeerConnectionHandlerTest, updateICE) { TEST_F(RTCPeerConnectionHandlerTest, setConfiguration) {
blink::WebRTCConfiguration config; blink::WebRTCConfiguration config;
EXPECT_CALL(*mock_tracker_.get(), TrackUpdateIce(pc_handler_.get(), _)); EXPECT_CALL(*mock_tracker_.get(),
TrackSetConfiguration(pc_handler_.get(), _));
// TODO(perkj): Test that the parameters in |config| can be translated when a // TODO(perkj): Test that the parameters in |config| can be translated when a
// WebRTCConfiguration can be constructed. It's WebKit class and can't be // WebRTCConfiguration can be constructed. It's WebKit class and can't be
// initialized from a test. // initialized from a test.
EXPECT_TRUE(pc_handler_->updateICE(config)); EXPECT_TRUE(pc_handler_->setConfiguration(config));
} }
TEST_F(RTCPeerConnectionHandlerTest, addICECandidate) { TEST_F(RTCPeerConnectionHandlerTest, addICECandidate) {
......
...@@ -807,7 +807,7 @@ RTCSessionDescription* RTCPeerConnection::remoteDescription() { ...@@ -807,7 +807,7 @@ RTCSessionDescription* RTCPeerConnection::remoteDescription() {
void RTCPeerConnection::updateIce(ExecutionContext* context, void RTCPeerConnection::updateIce(ExecutionContext* context,
const RTCConfiguration& rtcConfiguration, const RTCConfiguration& rtcConfiguration,
const Dictionary& mediaConstraints, const Dictionary&,
ExceptionState& exceptionState) { ExceptionState& exceptionState) {
if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
return; return;
...@@ -825,9 +825,8 @@ void RTCPeerConnection::updateIce(ExecutionContext* context, ...@@ -825,9 +825,8 @@ void RTCPeerConnection::updateIce(ExecutionContext* context,
return; return;
} }
// Constraints are ignored. // TODO(deadbeef): When this changes to setConfiguration, call
bool valid = m_peerHandler->updateICE(configuration); // m_peerHandler->setConfiguration.
if (!valid)
exceptionState.throwDOMException( exceptionState.throwDOMException(
SyntaxError, SyntaxError,
"Could not update the ICE Agent with the given configuration."); "Could not update the ICE Agent with the given configuration.");
......
...@@ -110,7 +110,7 @@ class RTCPeerConnection final : public EventTargetWithInlineData, ...@@ -110,7 +110,7 @@ class RTCPeerConnection final : public EventTargetWithInlineData,
void updateIce(ExecutionContext*, void updateIce(ExecutionContext*,
const RTCConfiguration&, const RTCConfiguration&,
const Dictionary& mediaConstraints, const Dictionary&,
ExceptionState&); ExceptionState&);
// Certificate management // Certificate management
......
...@@ -81,7 +81,7 @@ class WebRTCPeerConnectionHandler { ...@@ -81,7 +81,7 @@ class WebRTCPeerConnectionHandler {
const WebRTCSessionDescription&) = 0; const WebRTCSessionDescription&) = 0;
virtual WebRTCSessionDescription localDescription() = 0; virtual WebRTCSessionDescription localDescription() = 0;
virtual WebRTCSessionDescription remoteDescription() = 0; virtual WebRTCSessionDescription remoteDescription() = 0;
virtual bool updateICE(const WebRTCConfiguration&) = 0; virtual bool setConfiguration(const WebRTCConfiguration&) = 0;
virtual void logSelectedRtcpMuxPolicy(RtcpMuxPolicy) = 0; virtual void logSelectedRtcpMuxPolicy(RtcpMuxPolicy) = 0;
// DEPRECATED // DEPRECATED
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment