OLD | NEW |
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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 std::unique_ptr<PortAllocatorSession> CreateSession( | 232 std::unique_ptr<PortAllocatorSession> CreateSession( |
233 const std::string& sid, | 233 const std::string& sid, |
234 const std::string& content_name, | 234 const std::string& content_name, |
235 int component, | 235 int component, |
236 const std::string& ice_ufrag, | 236 const std::string& ice_ufrag, |
237 const std::string& ice_pwd) { | 237 const std::string& ice_pwd) { |
238 std::unique_ptr<PortAllocatorSession> session = allocator_->CreateSession( | 238 std::unique_ptr<PortAllocatorSession> session = allocator_->CreateSession( |
239 sid, content_name, component, ice_ufrag, ice_pwd); | 239 sid, content_name, component, ice_ufrag, ice_pwd); |
240 session->SignalPortReady.connect(this, | 240 session->SignalPortReady.connect(this, |
241 &BasicPortAllocatorTest::OnPortReady); | 241 &BasicPortAllocatorTest::OnPortReady); |
242 session->SignalPortPruned.connect(this, | 242 session->SignalPortsRemoved.connect( |
243 &BasicPortAllocatorTest::OnPortPruned); | 243 this, &BasicPortAllocatorTest::OnPortsRemoved); |
244 session->SignalCandidatesReady.connect( | 244 session->SignalCandidatesReady.connect( |
245 this, &BasicPortAllocatorTest::OnCandidatesReady); | 245 this, &BasicPortAllocatorTest::OnCandidatesReady); |
246 session->SignalCandidatesAllocationDone.connect( | 246 session->SignalCandidatesAllocationDone.connect( |
247 this, &BasicPortAllocatorTest::OnCandidatesAllocationDone); | 247 this, &BasicPortAllocatorTest::OnCandidatesAllocationDone); |
248 return session; | 248 return session; |
249 } | 249 } |
250 | 250 |
251 // Return true if the addresses are the same, or the port is 0 in |pattern| | 251 // Return true if the addresses are the same, or the port is 0 in |pattern| |
252 // (acting as a wildcard) and the IPs are the same. | 252 // (acting as a wildcard) and the IPs are the same. |
253 // Even with a wildcard port, the port of the address should be nonzero if | 253 // Even with a wildcard port, the port of the address should be nonzero if |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 BasicPortAllocator& allocator() { return *allocator_; } | 408 BasicPortAllocator& allocator() { return *allocator_; } |
409 | 409 |
410 void OnPortReady(PortAllocatorSession* ses, PortInterface* port) { | 410 void OnPortReady(PortAllocatorSession* ses, PortInterface* port) { |
411 LOG(LS_INFO) << "OnPortReady: " << port->ToString(); | 411 LOG(LS_INFO) << "OnPortReady: " << port->ToString(); |
412 ports_.push_back(port); | 412 ports_.push_back(port); |
413 // Make sure the new port is added to ReadyPorts. | 413 // Make sure the new port is added to ReadyPorts. |
414 auto ready_ports = ses->ReadyPorts(); | 414 auto ready_ports = ses->ReadyPorts(); |
415 EXPECT_NE(ready_ports.end(), | 415 EXPECT_NE(ready_ports.end(), |
416 std::find(ready_ports.begin(), ready_ports.end(), port)); | 416 std::find(ready_ports.begin(), ready_ports.end(), port)); |
417 } | 417 } |
418 void OnPortPruned(PortAllocatorSession* ses, PortInterface* port) { | 418 void OnPortsRemoved(PortAllocatorSession* ses, |
419 LOG(LS_INFO) << "OnPortPruned: " << port->ToString(); | 419 const std::vector<PortInterface*>& ports_removed) { |
420 ports_.erase(std::remove(ports_.begin(), ports_.end(), port), ports_.end()); | 420 LOG(LS_INFO) << "Number of ports removed: " << ports_removed.size(); |
421 // Make sure the pruned port is not in ReadyPorts. | |
422 auto ready_ports = ses->ReadyPorts(); | 421 auto ready_ports = ses->ReadyPorts(); |
423 EXPECT_EQ(ready_ports.end(), | 422 auto new_end = ports_.end(); |
424 std::find(ready_ports.begin(), ready_ports.end(), port)); | 423 for (PortInterface* port : ports_removed) { |
| 424 new_end = std::remove(ports_.begin(), new_end, port); |
| 425 // Make sure the pruned port is not in ReadyPorts. |
| 426 EXPECT_EQ(ready_ports.end(), |
| 427 std::find(ready_ports.begin(), ready_ports.end(), port)); |
| 428 } |
| 429 ports_.erase(new_end, ports_.end()); |
425 } | 430 } |
426 | 431 |
427 void OnCandidatesReady(PortAllocatorSession* ses, | 432 void OnCandidatesReady(PortAllocatorSession* ses, |
428 const std::vector<Candidate>& candidates) { | 433 const std::vector<Candidate>& candidates) { |
429 for (const Candidate& candidate : candidates) { | 434 for (const Candidate& candidate : candidates) { |
430 LOG(LS_INFO) << "OnCandidatesReady: " << candidate.ToString(); | 435 LOG(LS_INFO) << "OnCandidatesReady: " << candidate.ToString(); |
431 // Sanity check that the ICE component is set. | 436 // Sanity check that the ICE component is set. |
432 EXPECT_EQ(ICE_CANDIDATE_COMPONENT_RTP, candidate.component()); | 437 EXPECT_EQ(ICE_CANDIDATE_COMPONENT_RTP, candidate.component()); |
433 candidates_.push_back(candidate); | 438 candidates_.push_back(candidate); |
434 } | 439 } |
(...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1708 for (const Candidate& candidate : candidates) { | 1713 for (const Candidate& candidate : candidates) { |
1709 // Expect only relay candidates now that the filter is applied. | 1714 // Expect only relay candidates now that the filter is applied. |
1710 EXPECT_EQ(std::string(RELAY_PORT_TYPE), candidate.type()); | 1715 EXPECT_EQ(std::string(RELAY_PORT_TYPE), candidate.type()); |
1711 // Expect that the raddr is emptied due to the CF_RELAY filter. | 1716 // Expect that the raddr is emptied due to the CF_RELAY filter. |
1712 EXPECT_EQ(candidate.related_address(), | 1717 EXPECT_EQ(candidate.related_address(), |
1713 rtc::EmptySocketAddressWithFamily(candidate.address().family())); | 1718 rtc::EmptySocketAddressWithFamily(candidate.address().family())); |
1714 } | 1719 } |
1715 } | 1720 } |
1716 | 1721 |
1717 } // namespace cricket | 1722 } // namespace cricket |
OLD | NEW |