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

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

Issue 1785613011: Revert of Remove candidates when doing continual gathering (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 4 years, 9 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/transportchannelimpl.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 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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 *error = "candidate has port below 1024, but not 80 or 443"; 287 *error = "candidate has port below 1024, but not 80 or 443";
288 return false; 288 return false;
289 } 289 }
290 290
291 if (cand.address().IsPrivateIP()) { 291 if (cand.address().IsPrivateIP()) {
292 *error = "candidate has port of 80 or 443 with private IP address"; 292 *error = "candidate has port of 80 or 443 with private IP address";
293 return false; 293 return false;
294 } 294 }
295 } 295 }
296 296
297 if (!HasChannel(cand.component())) {
298 *error = "Candidate has an unknown component: " + cand.ToString() +
299 " for content: " + name();
300 return false;
301 }
302
303 return true; 297 return true;
304 } 298 }
305 299
306 bool Transport::VerifyCandidates(const Candidates& candidates,
307 std::string* error) {
308 for (const Candidate& candidate : candidates) {
309 if (!VerifyCandidate(candidate, error)) {
310 return false;
311 }
312 }
313 return true;
314 }
315
316 300
317 bool Transport::GetStats(TransportStats* stats) { 301 bool Transport::GetStats(TransportStats* stats) {
318 stats->transport_name = name(); 302 stats->transport_name = name();
319 stats->channel_stats.clear(); 303 stats->channel_stats.clear();
320 for (auto kv : channels_) { 304 for (auto kv : channels_) {
321 TransportChannelImpl* channel = kv.second; 305 TransportChannelImpl* channel = kv.second;
322 TransportChannelStats substats; 306 TransportChannelStats substats;
323 substats.component = channel->component(); 307 substats.component = channel->component();
324 channel->GetSrtpCryptoSuite(&substats.srtp_crypto_suite); 308 channel->GetSrtpCryptoSuite(&substats.srtp_crypto_suite);
325 channel->GetSslCipherSuite(&substats.ssl_cipher_suite); 309 channel->GetSslCipherSuite(&substats.ssl_cipher_suite);
326 if (!channel->GetStats(&substats.connection_infos)) { 310 if (!channel->GetStats(&substats.connection_infos)) {
327 return false; 311 return false;
328 } 312 }
329 stats->channel_stats.push_back(substats); 313 stats->channel_stats.push_back(substats);
330 } 314 }
331 return true; 315 return true;
332 } 316 }
333 317
334 bool Transport::AddRemoteCandidates(const std::vector<Candidate>& candidates, 318 bool Transport::AddRemoteCandidates(const std::vector<Candidate>& candidates,
335 std::string* error) { 319 std::string* error) {
336 ASSERT(!channels_destroyed_); 320 ASSERT(!channels_destroyed_);
337 // Verify each candidate before passing down to the transport layer. 321 // Verify each candidate before passing down to transport layer.
338 if (!VerifyCandidates(candidates, error)) { 322 for (const Candidate& cand : candidates) {
339 return false; 323 if (!VerifyCandidate(cand, error)) {
324 return false;
325 }
326 if (!HasChannel(cand.component())) {
327 *error = "Candidate has unknown component: " + cand.ToString() +
328 " for content: " + name();
329 return false;
330 }
340 } 331 }
341 332
342 for (const Candidate& candidate : candidates) { 333 for (const Candidate& candidate : candidates) {
343 TransportChannelImpl* channel = GetChannel(candidate.component()); 334 TransportChannelImpl* channel = GetChannel(candidate.component());
344 if (channel != nullptr) { 335 if (channel != nullptr) {
345 channel->AddRemoteCandidate(candidate); 336 channel->AddRemoteCandidate(candidate);
346 } 337 }
347 } 338 }
348 return true; 339 return true;
349 }
350
351 bool Transport::RemoveRemoteCandidates(const std::vector<Candidate>& candidates,
352 std::string* error) {
353 ASSERT(!channels_destroyed_);
354 // Verify each candidate before passing down to the transport layer.
355 if (!VerifyCandidates(candidates, error)) {
356 return false;
357 }
358
359 for (const Candidate& candidate : candidates) {
360 TransportChannelImpl* channel = GetChannel(candidate.component());
361 if (channel != nullptr) {
362 channel->RemoveRemoteCandidate(candidate);
363 }
364 }
365 return true;
366 } 340 }
367 341
368 bool Transport::ApplyLocalTransportDescription(TransportChannelImpl* ch, 342 bool Transport::ApplyLocalTransportDescription(TransportChannelImpl* ch,
369 std::string* error_desc) { 343 std::string* error_desc) {
370 ch->SetIceCredentials(local_description_->ice_ufrag, 344 ch->SetIceCredentials(local_description_->ice_ufrag,
371 local_description_->ice_pwd); 345 local_description_->ice_pwd);
372 return true; 346 return true;
373 } 347 }
374 348
375 bool Transport::ApplyRemoteTransportDescription(TransportChannelImpl* ch, 349 bool Transport::ApplyRemoteTransportDescription(TransportChannelImpl* ch,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 // negotiation happens. 382 // negotiation happens.
409 for (const auto& kv : channels_) { 383 for (const auto& kv : channels_) {
410 if (!ApplyNegotiatedTransportDescription(kv.second, error_desc)) { 384 if (!ApplyNegotiatedTransportDescription(kv.second, error_desc)) {
411 return false; 385 return false;
412 } 386 }
413 } 387 }
414 return true; 388 return true;
415 } 389 }
416 390
417 } // namespace cricket 391 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/base/transport.h ('k') | webrtc/p2p/base/transportchannelimpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698