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

Side by Side Diff: webrtc/p2p/base/faketransportcontroller.h

Issue 2099563004: Start ICE connectivity checks as soon as the first pair is pingable. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Removing debug log message, adding missing UpdateState. Created 4 years, 5 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/dtlstransportchannel.cc ('k') | webrtc/p2p/base/p2ptransportchannel.h » ('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 2009 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2009 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 } 104 }
105 bool SetSslRole(rtc::SSLRole role) override { 105 bool SetSslRole(rtc::SSLRole role) override {
106 ssl_role_ = role; 106 ssl_role_ = role;
107 return true; 107 return true;
108 } 108 }
109 bool GetSslRole(rtc::SSLRole* role) const override { 109 bool GetSslRole(rtc::SSLRole* role) const override {
110 *role = ssl_role_; 110 *role = ssl_role_;
111 return true; 111 return true;
112 } 112 }
113 113
114 void Connect() override {
115 if (state_ == STATE_INIT) {
116 state_ = STATE_CONNECTING;
117 }
118 }
119
120 void MaybeStartGathering() override { 114 void MaybeStartGathering() override {
121 if (gathering_state_ == kIceGatheringNew) { 115 if (gathering_state_ == kIceGatheringNew) {
122 gathering_state_ = kIceGatheringGathering; 116 gathering_state_ = kIceGatheringGathering;
123 SignalGatheringState(this); 117 SignalGatheringState(this);
124 } 118 }
125 } 119 }
126 120
127 IceGatheringState gathering_state() const override { 121 IceGatheringState gathering_state() const override {
128 return gathering_state_; 122 return gathering_state_;
129 } 123 }
130 124
131 void Reset() { 125 void Reset() {
132 if (state_ != STATE_INIT) { 126 if (state_ != STATE_INIT) {
133 state_ = STATE_INIT; 127 state_ = STATE_INIT;
134 if (dest_) { 128 if (dest_) {
135 dest_->state_ = STATE_INIT; 129 dest_->state_ = STATE_INIT;
136 dest_->dest_ = nullptr; 130 dest_->dest_ = nullptr;
137 dest_ = nullptr; 131 dest_ = nullptr;
138 } 132 }
139 } 133 }
140 } 134 }
141 135
142 void SetWritable(bool writable) { set_writable(writable); } 136 void SetWritable(bool writable) { set_writable(writable); }
143 137
144 // Simulates the two transport channels connecting to each other. 138 // Simulates the two transport channels connecting to each other.
145 // If |asymmetric| is true this method only affects this FakeTransportChannel. 139 // If |asymmetric| is true this method only affects this FakeTransportChannel.
146 // If false, it affects |dest| as well. 140 // If false, it affects |dest| as well.
147 void SetDestination(FakeTransportChannel* dest, bool asymmetric = false) { 141 void SetDestination(FakeTransportChannel* dest, bool asymmetric = false) {
148 if (state_ == STATE_CONNECTING && dest) { 142 if (state_ == STATE_INIT && dest) {
149 // This simulates the delivery of candidates. 143 // This simulates the delivery of candidates.
150 dest_ = dest; 144 dest_ = dest;
151 if (local_cert_ && dest_->local_cert_) { 145 if (local_cert_ && dest_->local_cert_) {
152 do_dtls_ = true; 146 do_dtls_ = true;
153 NegotiateSrtpCiphers(); 147 NegotiateSrtpCiphers();
154 } 148 }
155 state_ = STATE_CONNECTED; 149 state_ = STATE_CONNECTED;
156 set_writable(true); 150 set_writable(true);
157 if (!asymmetric) { 151 if (!asymmetric) {
158 dest->SetDestination(this, true); 152 dest->SetDestination(this, true);
159 } 153 }
160 } else if (state_ == STATE_CONNECTED && !dest) { 154 } else if (state_ == STATE_CONNECTED && !dest) {
161 // Simulates loss of connectivity, by asymmetrically forgetting dest_. 155 // Simulates loss of connectivity, by asymmetrically forgetting dest_.
162 dest_ = nullptr; 156 dest_ = nullptr;
163 state_ = STATE_CONNECTING; 157 state_ = STATE_INIT;
164 set_writable(false); 158 set_writable(false);
165 } 159 }
166 } 160 }
167 161
168 void SetConnectionCount(size_t connection_count) { 162 void SetConnectionCount(size_t connection_count) {
169 size_t old_connection_count = connection_count_; 163 size_t old_connection_count = connection_count_;
170 connection_count_ = connection_count; 164 connection_count_ = connection_count;
171 if (connection_count) 165 if (connection_count)
172 had_connection_ = true; 166 had_connection_ = true;
173 // In this fake transport channel, |connection_count_| determines the 167 // In this fake transport channel, |connection_count_| determines the
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 for (std::vector<int>::const_iterator it2 = dest_->srtp_ciphers_.begin(); 301 for (std::vector<int>::const_iterator it2 = dest_->srtp_ciphers_.begin();
308 it2 != dest_->srtp_ciphers_.end(); ++it2) { 302 it2 != dest_->srtp_ciphers_.end(); ++it2) {
309 if (*it1 == *it2) { 303 if (*it1 == *it2) {
310 chosen_crypto_suite_ = *it1; 304 chosen_crypto_suite_ = *it1;
311 return; 305 return;
312 } 306 }
313 } 307 }
314 } 308 }
315 } 309 }
316 310
317 enum State { STATE_INIT, STATE_CONNECTING, STATE_CONNECTED }; 311 enum State { STATE_INIT, STATE_CONNECTED };
318 FakeTransportChannel* dest_ = nullptr; 312 FakeTransportChannel* dest_ = nullptr;
319 State state_ = STATE_INIT; 313 State state_ = STATE_INIT;
320 bool async_ = false; 314 bool async_ = false;
321 Candidates remote_candidates_; 315 Candidates remote_candidates_;
322 rtc::scoped_refptr<rtc::RTCCertificate> local_cert_; 316 rtc::scoped_refptr<rtc::RTCCertificate> local_cert_;
323 rtc::FakeSSLCertificate* remote_cert_ = nullptr; 317 rtc::FakeSSLCertificate* remote_cert_ = nullptr;
324 bool do_dtls_ = false; 318 bool do_dtls_ = false;
325 std::vector<int> srtp_ciphers_; 319 std::vector<int> srtp_ciphers_;
326 int chosen_crypto_suite_ = rtc::SRTP_INVALID_CRYPTO_SUITE; 320 int chosen_crypto_suite_ = rtc::SRTP_INVALID_CRYPTO_SUITE;
327 int receiving_timeout_ = -1; 321 int receiving_timeout_ = -1;
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 rtc::CreateRandomString(cricket::ICE_PWD_LENGTH), cricket::ICEMODE_FULL, 565 rtc::CreateRandomString(cricket::ICE_PWD_LENGTH), cricket::ICEMODE_FULL,
572 cricket::CONNECTIONROLE_NONE, nullptr); 566 cricket::CONNECTIONROLE_NONE, nullptr);
573 for (auto& kv : transports()) { 567 for (auto& kv : transports()) {
574 FakeTransport* transport = static_cast<FakeTransport*>(kv.second); 568 FakeTransport* transport = static_cast<FakeTransport*>(kv.second);
575 // Set local transport description for FakeTransport before connecting. 569 // Set local transport description for FakeTransport before connecting.
576 // Otherwise, the RTC_CHECK in Transport.ConnectChannel will fail. 570 // Otherwise, the RTC_CHECK in Transport.ConnectChannel will fail.
577 if (!transport->local_description()) { 571 if (!transport->local_description()) {
578 transport->SetLocalTransportDescription(faketransport_desc, 572 transport->SetLocalTransportDescription(faketransport_desc,
579 cricket::CA_OFFER, nullptr); 573 cricket::CA_OFFER, nullptr);
580 } 574 }
581 transport->ConnectChannels();
582 transport->MaybeStartGathering(); 575 transport->MaybeStartGathering();
583 } 576 }
584 } 577 }
585 578
586 private: 579 private:
587 bool fail_create_channel_; 580 bool fail_create_channel_;
588 }; 581 };
589 582
590 } // namespace cricket 583 } // namespace cricket
591 584
592 #endif // WEBRTC_P2P_BASE_FAKETRANSPORTCONTROLLER_H_ 585 #endif // WEBRTC_P2P_BASE_FAKETRANSPORTCONTROLLER_H_
OLDNEW
« no previous file with comments | « webrtc/p2p/base/dtlstransportchannel.cc ('k') | webrtc/p2p/base/p2ptransportchannel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698