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

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

Issue 1788703003: Reland the CL to 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
297 return true; 303 return true;
298 } 304 }
299 305
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
300 316
301 bool Transport::GetStats(TransportStats* stats) { 317 bool Transport::GetStats(TransportStats* stats) {
302 stats->transport_name = name(); 318 stats->transport_name = name();
303 stats->channel_stats.clear(); 319 stats->channel_stats.clear();
304 for (auto kv : channels_) { 320 for (auto kv : channels_) {
305 TransportChannelImpl* channel = kv.second; 321 TransportChannelImpl* channel = kv.second;
306 TransportChannelStats substats; 322 TransportChannelStats substats;
307 substats.component = channel->component(); 323 substats.component = channel->component();
308 channel->GetSrtpCryptoSuite(&substats.srtp_crypto_suite); 324 channel->GetSrtpCryptoSuite(&substats.srtp_crypto_suite);
309 channel->GetSslCipherSuite(&substats.ssl_cipher_suite); 325 channel->GetSslCipherSuite(&substats.ssl_cipher_suite);
310 if (!channel->GetStats(&substats.connection_infos)) { 326 if (!channel->GetStats(&substats.connection_infos)) {
311 return false; 327 return false;
312 } 328 }
313 stats->channel_stats.push_back(substats); 329 stats->channel_stats.push_back(substats);
314 } 330 }
315 return true; 331 return true;
316 } 332 }
317 333
318 bool Transport::AddRemoteCandidates(const std::vector<Candidate>& candidates, 334 bool Transport::AddRemoteCandidates(const std::vector<Candidate>& candidates,
319 std::string* error) { 335 std::string* error) {
320 ASSERT(!channels_destroyed_); 336 ASSERT(!channels_destroyed_);
321 // Verify each candidate before passing down to transport layer. 337 // Verify each candidate before passing down to the transport layer.
322 for (const Candidate& cand : candidates) { 338 if (!VerifyCandidates(candidates, error)) {
323 if (!VerifyCandidate(cand, error)) { 339 return false;
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 }
331 } 340 }
332 341
333 for (const Candidate& candidate : candidates) { 342 for (const Candidate& candidate : candidates) {
334 TransportChannelImpl* channel = GetChannel(candidate.component()); 343 TransportChannelImpl* channel = GetChannel(candidate.component());
335 if (channel != nullptr) { 344 if (channel != nullptr) {
336 channel->AddRemoteCandidate(candidate); 345 channel->AddRemoteCandidate(candidate);
337 } 346 }
338 } 347 }
339 return true; 348 return true;
340 } 349 }
341 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 }
367
342 bool Transport::ApplyLocalTransportDescription(TransportChannelImpl* ch, 368 bool Transport::ApplyLocalTransportDescription(TransportChannelImpl* ch,
343 std::string* error_desc) { 369 std::string* error_desc) {
344 ch->SetIceCredentials(local_description_->ice_ufrag, 370 ch->SetIceCredentials(local_description_->ice_ufrag,
345 local_description_->ice_pwd); 371 local_description_->ice_pwd);
346 return true; 372 return true;
347 } 373 }
348 374
349 bool Transport::ApplyRemoteTransportDescription(TransportChannelImpl* ch, 375 bool Transport::ApplyRemoteTransportDescription(TransportChannelImpl* ch,
350 std::string* error_desc) { 376 std::string* error_desc) {
351 ch->SetRemoteIceCredentials(remote_description_->ice_ufrag, 377 ch->SetRemoteIceCredentials(remote_description_->ice_ufrag,
(...skipping 30 matching lines...) Expand all
382 // negotiation happens. 408 // negotiation happens.
383 for (const auto& kv : channels_) { 409 for (const auto& kv : channels_) {
384 if (!ApplyNegotiatedTransportDescription(kv.second, error_desc)) { 410 if (!ApplyNegotiatedTransportDescription(kv.second, error_desc)) {
385 return false; 411 return false;
386 } 412 }
387 } 413 }
388 return true; 414 return true;
389 } 415 }
390 416
391 } // namespace cricket 417 } // 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