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 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 | 648 |
649 // We pass the candidates directly to the other side. | 649 // We pass the candidates directly to the other side. |
650 void OnCandidateGathered(cricket::TransportChannelImpl* ch, | 650 void OnCandidateGathered(cricket::TransportChannelImpl* ch, |
651 const cricket::Candidate& c) { | 651 const cricket::Candidate& c) { |
652 if (force_relay_ && c.type() != cricket::RELAY_PORT_TYPE) | 652 if (force_relay_ && c.type() != cricket::RELAY_PORT_TYPE) |
653 return; | 653 return; |
654 | 654 |
655 if (GetEndpoint(ch)->save_candidates_) { | 655 if (GetEndpoint(ch)->save_candidates_) { |
656 GetEndpoint(ch)->saved_candidates_.push_back(new CandidatesData(ch, c)); | 656 GetEndpoint(ch)->saved_candidates_.push_back(new CandidatesData(ch, c)); |
657 } else { | 657 } else { |
658 main_->Post(this, MSG_ADD_CANDIDATES, new CandidatesData(ch, c)); | 658 main_->Post(RTC_FROM_HERE, this, MSG_ADD_CANDIDATES, |
| 659 new CandidatesData(ch, c)); |
659 } | 660 } |
660 } | 661 } |
661 | 662 |
662 void PauseCandidates(int endpoint) { | 663 void PauseCandidates(int endpoint) { |
663 GetEndpoint(endpoint)->save_candidates_ = true; | 664 GetEndpoint(endpoint)->save_candidates_ = true; |
664 } | 665 } |
665 | 666 |
666 void OnCandidatesRemoved(cricket::TransportChannelImpl* ch, | 667 void OnCandidatesRemoved(cricket::TransportChannelImpl* ch, |
667 const std::vector<cricket::Candidate>& candidates) { | 668 const std::vector<cricket::Candidate>& candidates) { |
668 // Candidate removals are not paused. | 669 // Candidate removals are not paused. |
669 CandidatesData* candidates_data = new CandidatesData(ch, candidates); | 670 CandidatesData* candidates_data = new CandidatesData(ch, candidates); |
670 main_->Post(this, MSG_REMOVE_CANDIDATES, candidates_data); | 671 main_->Post(RTC_FROM_HERE, this, MSG_REMOVE_CANDIDATES, candidates_data); |
671 } | 672 } |
672 | 673 |
673 // Tcp candidate verification has to be done when they are generated. | 674 // Tcp candidate verification has to be done when they are generated. |
674 void VerifySavedTcpCandidates(int endpoint, const std::string& tcptype) { | 675 void VerifySavedTcpCandidates(int endpoint, const std::string& tcptype) { |
675 for (auto& data : GetEndpoint(endpoint)->saved_candidates_) { | 676 for (auto& data : GetEndpoint(endpoint)->saved_candidates_) { |
676 for (auto& candidate : data->candidates) { | 677 for (auto& candidate : data->candidates) { |
677 EXPECT_EQ(candidate.protocol(), cricket::TCP_PROTOCOL_NAME); | 678 EXPECT_EQ(candidate.protocol(), cricket::TCP_PROTOCOL_NAME); |
678 EXPECT_EQ(candidate.tcptype(), tcptype); | 679 EXPECT_EQ(candidate.tcptype(), tcptype); |
679 if (candidate.tcptype() == cricket::TCPTYPE_ACTIVE_STR) { | 680 if (candidate.tcptype() == cricket::TCPTYPE_ACTIVE_STR) { |
680 EXPECT_EQ(candidate.address().port(), cricket::DISCARD_PORT); | 681 EXPECT_EQ(candidate.address().port(), cricket::DISCARD_PORT); |
681 } else if (candidate.tcptype() == cricket::TCPTYPE_PASSIVE_STR) { | 682 } else if (candidate.tcptype() == cricket::TCPTYPE_PASSIVE_STR) { |
682 EXPECT_NE(candidate.address().port(), cricket::DISCARD_PORT); | 683 EXPECT_NE(candidate.address().port(), cricket::DISCARD_PORT); |
683 } else { | 684 } else { |
684 FAIL() << "Unknown tcptype: " << candidate.tcptype(); | 685 FAIL() << "Unknown tcptype: " << candidate.tcptype(); |
685 } | 686 } |
686 } | 687 } |
687 } | 688 } |
688 } | 689 } |
689 | 690 |
690 void ResumeCandidates(int endpoint) { | 691 void ResumeCandidates(int endpoint) { |
691 Endpoint* ed = GetEndpoint(endpoint); | 692 Endpoint* ed = GetEndpoint(endpoint); |
692 std::vector<CandidatesData*>::iterator it = ed->saved_candidates_.begin(); | 693 std::vector<CandidatesData*>::iterator it = ed->saved_candidates_.begin(); |
693 for (; it != ed->saved_candidates_.end(); ++it) { | 694 for (; it != ed->saved_candidates_.end(); ++it) { |
694 main_->Post(this, MSG_ADD_CANDIDATES, *it); | 695 main_->Post(RTC_FROM_HERE, this, MSG_ADD_CANDIDATES, *it); |
695 } | 696 } |
696 ed->saved_candidates_.clear(); | 697 ed->saved_candidates_.clear(); |
697 ed->save_candidates_ = false; | 698 ed->save_candidates_ = false; |
698 } | 699 } |
699 | 700 |
700 void OnMessage(rtc::Message* msg) { | 701 void OnMessage(rtc::Message* msg) { |
701 switch (msg->message_id) { | 702 switch (msg->message_id) { |
702 case MSG_ADD_CANDIDATES: { | 703 case MSG_ADD_CANDIDATES: { |
703 std::unique_ptr<CandidatesData> data( | 704 std::unique_ptr<CandidatesData> data( |
704 static_cast<CandidatesData*>(msg->pdata)); | 705 static_cast<CandidatesData*>(msg->pdata)); |
(...skipping 2210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2915 | 2916 |
2916 // TCP Relay/Relay is the next. | 2917 // TCP Relay/Relay is the next. |
2917 VerifyNextPingableConnection(cricket::RELAY_PORT_TYPE, | 2918 VerifyNextPingableConnection(cricket::RELAY_PORT_TYPE, |
2918 cricket::RELAY_PORT_TYPE, | 2919 cricket::RELAY_PORT_TYPE, |
2919 cricket::TCP_PROTOCOL_NAME); | 2920 cricket::TCP_PROTOCOL_NAME); |
2920 | 2921 |
2921 // Finally, Local/Relay will be pinged. | 2922 // Finally, Local/Relay will be pinged. |
2922 VerifyNextPingableConnection(cricket::LOCAL_PORT_TYPE, | 2923 VerifyNextPingableConnection(cricket::LOCAL_PORT_TYPE, |
2923 cricket::RELAY_PORT_TYPE); | 2924 cricket::RELAY_PORT_TYPE); |
2924 } | 2925 } |
OLD | NEW |