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

Side by Side Diff: webrtc/p2p/base/p2ptransportchannel.cc

Issue 2224563004: Add signaling to support ICE renomination. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Merge Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel.h ('k') | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 LOG_J(LS_VERBOSE, this) << "Ice not completed yet for this channel as " 301 LOG_J(LS_VERBOSE, this) << "Ice not completed yet for this channel as "
302 << network->ToString() 302 << network->ToString()
303 << " has more than 1 connection."; 303 << " has more than 1 connection.";
304 return TransportChannelState::STATE_CONNECTING; 304 return TransportChannelState::STATE_CONNECTING;
305 } 305 }
306 } 306 }
307 307
308 return TransportChannelState::STATE_COMPLETED; 308 return TransportChannelState::STATE_COMPLETED;
309 } 309 }
310 310
311 void P2PTransportChannel::SetIceCredentials(const std::string& ice_ufrag, 311 void P2PTransportChannel::SetIceParameters(const IceParameters& ice_params) {
312 const std::string& ice_pwd) {
313 ASSERT(worker_thread_ == rtc::Thread::Current()); 312 ASSERT(worker_thread_ == rtc::Thread::Current());
314 ice_ufrag_ = ice_ufrag; 313 ice_parameters_ = ice_params;
315 ice_pwd_ = ice_pwd;
316 // Note: Candidate gathering will restart when MaybeStartGathering is next 314 // Note: Candidate gathering will restart when MaybeStartGathering is next
317 // called. 315 // called.
318 } 316 }
319 317
320 void P2PTransportChannel::SetRemoteIceCredentials(const std::string& ice_ufrag, 318 void P2PTransportChannel::SetRemoteIceParameters(
321 const std::string& ice_pwd) { 319 const IceParameters& ice_params) {
322 ASSERT(worker_thread_ == rtc::Thread::Current()); 320 ASSERT(worker_thread_ == rtc::Thread::Current());
321 LOG(LS_INFO) << "Remote supports ICE renomination ? "
322 << ice_params.renomination;
323 IceParameters* current_ice = remote_ice(); 323 IceParameters* current_ice = remote_ice();
324 IceParameters new_ice(ice_ufrag, ice_pwd); 324 if (!current_ice || *current_ice != ice_params) {
325 if (!current_ice || *current_ice != new_ice) {
326 // Keep the ICE credentials so that newer connections 325 // Keep the ICE credentials so that newer connections
327 // are prioritized over the older ones. 326 // are prioritized over the older ones.
328 remote_ice_parameters_.push_back(new_ice); 327 remote_ice_parameters_.push_back(ice_params);
329 } 328 }
330 329
331 // Update the pwd of remote candidate if needed. 330 // Update the pwd of remote candidate if needed.
332 for (RemoteCandidate& candidate : remote_candidates_) { 331 for (RemoteCandidate& candidate : remote_candidates_) {
333 if (candidate.username() == ice_ufrag && candidate.password().empty()) { 332 if (candidate.username() == ice_params.ufrag &&
334 candidate.set_password(ice_pwd); 333 candidate.password().empty()) {
334 candidate.set_password(ice_params.pwd);
335 } 335 }
336 } 336 }
337 // We need to update the credentials and generation for any peer reflexive 337 // We need to update the credentials and generation for any peer reflexive
338 // candidates. 338 // candidates.
339 for (Connection* conn : connections_) { 339 for (Connection* conn : connections_) {
340 conn->MaybeSetRemoteIceCredentialsAndGeneration( 340 conn->MaybeSetRemoteIceParametersAndGeneration(
341 ice_ufrag, ice_pwd, 341 ice_params, static_cast<int>(remote_ice_parameters_.size() - 1));
342 static_cast<int>(remote_ice_parameters_.size() - 1));
343 } 342 }
344 // Updating the remote ICE candidate generation could change the sort order. 343 // Updating the remote ICE candidate generation could change the sort order.
345 RequestSortAndStateUpdate(); 344 RequestSortAndStateUpdate();
346 } 345 }
347 346
348 void P2PTransportChannel::SetRemoteIceMode(IceMode mode) { 347 void P2PTransportChannel::SetRemoteIceMode(IceMode mode) {
349 remote_ice_mode_ = mode; 348 remote_ice_mode_ = mode;
350 } 349 }
351 350
352 void P2PTransportChannel::SetIceConfig(const IceConfig& config) { 351 void P2PTransportChannel::SetIceConfig(const IceConfig& config) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 LOG(LS_INFO) << "Set default nomination mode to " 426 LOG(LS_INFO) << "Set default nomination mode to "
428 << static_cast<int>(config_.default_nomination_mode); 427 << static_cast<int>(config_.default_nomination_mode);
429 } 428 }
430 } 429 }
431 430
432 const IceConfig& P2PTransportChannel::config() const { 431 const IceConfig& P2PTransportChannel::config() const {
433 return config_; 432 return config_;
434 } 433 }
435 434
436 void P2PTransportChannel::MaybeStartGathering() { 435 void P2PTransportChannel::MaybeStartGathering() {
437 if (ice_ufrag_.empty() || ice_pwd_.empty()) { 436 if (ice_parameters_.ufrag.empty() || ice_parameters_.pwd.empty()) {
438 return; 437 return;
439 } 438 }
440 // Start gathering if we never started before, or if an ICE restart occurred. 439 // Start gathering if we never started before, or if an ICE restart occurred.
441 if (allocator_sessions_.empty() || 440 if (allocator_sessions_.empty() ||
442 IceCredentialsChanged(allocator_sessions_.back()->ice_ufrag(), 441 IceCredentialsChanged(allocator_sessions_.back()->ice_ufrag(),
443 allocator_sessions_.back()->ice_pwd(), ice_ufrag_, 442 allocator_sessions_.back()->ice_pwd(),
444 ice_pwd_)) { 443 ice_parameters_.ufrag, ice_parameters_.pwd)) {
445 if (gathering_state_ != kIceGatheringGathering) { 444 if (gathering_state_ != kIceGatheringGathering) {
446 gathering_state_ = kIceGatheringGathering; 445 gathering_state_ = kIceGatheringGathering;
447 SignalGatheringState(this); 446 SignalGatheringState(this);
448 } 447 }
449 // Time for a new allocator. 448 // Time for a new allocator.
450 std::unique_ptr<PortAllocatorSession> pooled_session = 449 std::unique_ptr<PortAllocatorSession> pooled_session =
451 allocator_->TakePooledSession(transport_name(), component(), ice_ufrag_, 450 allocator_->TakePooledSession(transport_name(), component(),
452 ice_pwd_); 451 ice_parameters_.ufrag,
452 ice_parameters_.pwd);
453 if (pooled_session) { 453 if (pooled_session) {
454 AddAllocatorSession(std::move(pooled_session)); 454 AddAllocatorSession(std::move(pooled_session));
455 PortAllocatorSession* raw_pooled_session = 455 PortAllocatorSession* raw_pooled_session =
456 allocator_sessions_.back().get(); 456 allocator_sessions_.back().get();
457 // Process the pooled session's existing candidates/ports, if they exist. 457 // Process the pooled session's existing candidates/ports, if they exist.
458 OnCandidatesReady(raw_pooled_session, 458 OnCandidatesReady(raw_pooled_session,
459 raw_pooled_session->ReadyCandidates()); 459 raw_pooled_session->ReadyCandidates());
460 for (PortInterface* port : allocator_sessions_.back()->ReadyPorts()) { 460 for (PortInterface* port : allocator_sessions_.back()->ReadyPorts()) {
461 OnPortReady(raw_pooled_session, port); 461 OnPortReady(raw_pooled_session, port);
462 } 462 }
463 if (allocator_sessions_.back()->CandidatesAllocationDone()) { 463 if (allocator_sessions_.back()->CandidatesAllocationDone()) {
464 OnCandidatesAllocationDone(raw_pooled_session); 464 OnCandidatesAllocationDone(raw_pooled_session);
465 } 465 }
466 } else { 466 } else {
467 AddAllocatorSession(allocator_->CreateSession( 467 AddAllocatorSession(allocator_->CreateSession(
468 transport_name(), component(), ice_ufrag_, ice_pwd_)); 468 transport_name(), component(), ice_parameters_.ufrag,
469 ice_parameters_.pwd));
469 LOG(LS_INFO) << "Start getting ports"; 470 LOG(LS_INFO) << "Start getting ports";
470 allocator_sessions_.back()->StartGettingPorts(); 471 allocator_sessions_.back()->StartGettingPorts();
471 } 472 }
472 } 473 }
473 } 474 }
474 475
475 // A new port is available, attempt to make connections for it 476 // A new port is available, attempt to make connections for it
476 void P2PTransportChannel::OnPortReady(PortAllocatorSession *session, 477 void P2PTransportChannel::OnPortReady(PortAllocatorSession *session,
477 PortInterface* port) { 478 PortInterface* port) {
478 ASSERT(worker_thread_ == rtc::Thread::Current()); 479 ASSERT(worker_thread_ == rtc::Thread::Current());
(...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1618 } 1619 }
1619 } 1620 }
1620 1621
1621 // Apart from sending ping from |conn| this method also updates 1622 // Apart from sending ping from |conn| this method also updates
1622 // |use_candidate_attr| and |nomination| flags. One of the flags is set to 1623 // |use_candidate_attr| and |nomination| flags. One of the flags is set to
1623 // nominate |conn| if this channel is in CONTROLLING. 1624 // nominate |conn| if this channel is in CONTROLLING.
1624 void P2PTransportChannel::PingConnection(Connection* conn) { 1625 void P2PTransportChannel::PingConnection(Connection* conn) {
1625 bool use_candidate_attr = false; 1626 bool use_candidate_attr = false;
1626 uint32_t nomination = 0; 1627 uint32_t nomination = 0;
1627 if (ice_role_ == ICEROLE_CONTROLLING) { 1628 if (ice_role_ == ICEROLE_CONTROLLING) {
1628 if (remote_supports_renomination_) { 1629 bool renomination_supported = ice_parameters_.renomination &&
1630 !remote_ice_parameters_.empty() &&
1631 remote_ice_parameters_.back().renomination;
1632 if (renomination_supported) {
1629 nomination = GetNominationAttr(conn); 1633 nomination = GetNominationAttr(conn);
1630 } else { 1634 } else {
1631 use_candidate_attr = 1635 use_candidate_attr =
1632 GetUseCandidateAttr(conn, config_.default_nomination_mode); 1636 GetUseCandidateAttr(conn, config_.default_nomination_mode);
1633 } 1637 }
1634 } 1638 }
1635 conn->set_nomination(nomination); 1639 conn->set_nomination(nomination);
1636 conn->set_use_candidate_attr(use_candidate_attr); 1640 conn->set_use_candidate_attr(use_candidate_attr);
1637 last_ping_sent_ms_ = rtc::TimeMillis(); 1641 last_ping_sent_ms_ = rtc::TimeMillis();
1638 conn->Ping(last_ping_sent_ms_); 1642 conn->Ping(last_ping_sent_ms_);
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
1956 1960
1957 // During the initial state when nothing has been pinged yet, return the first 1961 // During the initial state when nothing has been pinged yet, return the first
1958 // one in the ordered |connections_|. 1962 // one in the ordered |connections_|.
1959 return *(std::find_if(connections_.begin(), connections_.end(), 1963 return *(std::find_if(connections_.begin(), connections_.end(),
1960 [conn1, conn2](Connection* conn) { 1964 [conn1, conn2](Connection* conn) {
1961 return conn == conn1 || conn == conn2; 1965 return conn == conn1 || conn == conn2;
1962 })); 1966 }));
1963 } 1967 }
1964 1968
1965 } // namespace cricket 1969 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel.h ('k') | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698