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

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

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/transport.h ('k') | webrtc/p2p/base/transport_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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 if (!ret) { 107 if (!ret) {
108 return false; 108 return false;
109 } 109 }
110 110
111 // If PRANSWER/ANSWER is set, we should decide transport protocol type. 111 // If PRANSWER/ANSWER is set, we should decide transport protocol type.
112 if (action == CA_PRANSWER || action == CA_ANSWER) { 112 if (action == CA_PRANSWER || action == CA_ANSWER) {
113 ret &= NegotiateTransportDescription(action, error_desc); 113 ret &= NegotiateTransportDescription(action, error_desc);
114 } 114 }
115 if (ret) { 115 if (ret) {
116 local_description_set_ = true; 116 local_description_set_ = true;
117 ConnectChannels();
118 } 117 }
119 118
120 return ret; 119 return ret;
121 } 120 }
122 121
123 bool Transport::SetRemoteTransportDescription( 122 bool Transport::SetRemoteTransportDescription(
124 const TransportDescription& description, 123 const TransportDescription& description,
125 ContentAction action, 124 ContentAction action,
126 std::string* error_desc) { 125 std::string* error_desc) {
127 bool ret = true; 126 bool ret = true;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 channel->SetIceConfig(ice_config_); 173 channel->SetIceConfig(ice_config_);
175 // TODO(ronghuawu): Change CreateChannel to be able to return error since 174 // TODO(ronghuawu): Change CreateChannel to be able to return error since
176 // below Apply**Description calls can fail. 175 // below Apply**Description calls can fail.
177 if (local_description_) 176 if (local_description_)
178 ApplyLocalTransportDescription(channel, nullptr); 177 ApplyLocalTransportDescription(channel, nullptr);
179 if (remote_description_) 178 if (remote_description_)
180 ApplyRemoteTransportDescription(channel, nullptr); 179 ApplyRemoteTransportDescription(channel, nullptr);
181 if (local_description_ && remote_description_) 180 if (local_description_ && remote_description_)
182 ApplyNegotiatedTransportDescription(channel, nullptr); 181 ApplyNegotiatedTransportDescription(channel, nullptr);
183 182
184 if (connect_requested_) {
185 channel->Connect();
186 }
187 return channel; 183 return channel;
188 } 184 }
189 185
190 TransportChannelImpl* Transport::GetChannel(int component) { 186 TransportChannelImpl* Transport::GetChannel(int component) {
191 auto iter = channels_.find(component); 187 auto iter = channels_.find(component);
192 return (iter != channels_.end()) ? iter->second : nullptr; 188 return (iter != channels_.end()) ? iter->second : nullptr;
193 } 189 }
194 190
195 bool Transport::HasChannels() { 191 bool Transport::HasChannels() {
196 return !channels_.empty(); 192 return !channels_.empty();
197 } 193 }
198 194
199 void Transport::DestroyChannel(int component) { 195 void Transport::DestroyChannel(int component) {
200 auto iter = channels_.find(component); 196 auto iter = channels_.find(component);
201 if (iter == channels_.end()) 197 if (iter == channels_.end())
202 return; 198 return;
203 199
204 TransportChannelImpl* channel = iter->second; 200 TransportChannelImpl* channel = iter->second;
205 channels_.erase(iter); 201 channels_.erase(iter);
206 DestroyTransportChannel(channel); 202 DestroyTransportChannel(channel);
207 } 203 }
208 204
209 void Transport::ConnectChannels() {
210 if (connect_requested_ || channels_.empty())
211 return;
212
213 connect_requested_ = true;
214
215 RTC_DCHECK(local_description_);
216
217 CallChannels(&TransportChannelImpl::Connect);
218 }
219
220 void Transport::MaybeStartGathering() { 205 void Transport::MaybeStartGathering() {
221 if (connect_requested_) { 206 CallChannels(&TransportChannelImpl::MaybeStartGathering);
222 CallChannels(&TransportChannelImpl::MaybeStartGathering);
223 }
224 } 207 }
225 208
226 void Transport::DestroyAllChannels() { 209 void Transport::DestroyAllChannels() {
227 for (const auto& kv : channels_) { 210 for (const auto& kv : channels_) {
228 DestroyTransportChannel(kv.second); 211 DestroyTransportChannel(kv.second);
229 } 212 }
230 channels_.clear(); 213 channels_.clear();
231 channels_destroyed_ = true; 214 channels_destroyed_ = true;
232 } 215 }
233 216
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 } 465 }
483 466
484 // If local is passive, local will act as server. 467 // If local is passive, local will act as server.
485 } 468 }
486 469
487 *ssl_role = is_remote_server ? rtc::SSL_CLIENT : rtc::SSL_SERVER; 470 *ssl_role = is_remote_server ? rtc::SSL_CLIENT : rtc::SSL_SERVER;
488 return true; 471 return true;
489 } 472 }
490 473
491 } // namespace cricket 474 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/base/transport.h ('k') | webrtc/p2p/base/transport_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698