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

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

Issue 2416023002: Introduce rtc::PacketTransportInterface and let cricket::TransportChannel inherit. (Closed)
Patch Set: Let BaseChannel::PacketIsRtcp() use PacketTransportInterface. Created 4 years, 2 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
OLDNEW
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
11 #include <algorithm> 11 #include <algorithm>
12 #include <memory> 12 #include <memory>
13 13
14 #include "webrtc/api/fakemetricsobserver.h" 14 #include "webrtc/api/fakemetricsobserver.h"
15 #include "webrtc/p2p/base/fakeportallocator.h" 15 #include "webrtc/p2p/base/fakeportallocator.h"
16 #include "webrtc/p2p/base/packettransportinterface.h"
16 #include "webrtc/p2p/base/p2ptransportchannel.h" 17 #include "webrtc/p2p/base/p2ptransportchannel.h"
17 #include "webrtc/p2p/base/testrelayserver.h" 18 #include "webrtc/p2p/base/testrelayserver.h"
18 #include "webrtc/p2p/base/teststunserver.h" 19 #include "webrtc/p2p/base/teststunserver.h"
19 #include "webrtc/p2p/base/testturnserver.h" 20 #include "webrtc/p2p/base/testturnserver.h"
20 #include "webrtc/p2p/client/basicportallocator.h" 21 #include "webrtc/p2p/client/basicportallocator.h"
21 #include "webrtc/base/dscp.h" 22 #include "webrtc/base/dscp.h"
22 #include "webrtc/base/fakeclock.h" 23 #include "webrtc/base/fakeclock.h"
23 #include "webrtc/base/fakenetwork.h" 24 #include "webrtc/base/fakenetwork.h"
24 #include "webrtc/base/firewallsocketserver.h" 25 #include "webrtc/base/firewallsocketserver.h"
25 #include "webrtc/base/gunit.h" 26 #include "webrtc/base/gunit.h"
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 ep2_ch1()->receiving() && 664 ep2_ch1()->receiving() &&
664 ep2_ch1()->writable(), 665 ep2_ch1()->writable(),
665 1000); 666 1000);
666 667
667 EXPECT_TRUE(ep1_ch1()->selected_connection() && 668 EXPECT_TRUE(ep1_ch1()->selected_connection() &&
668 ep2_ch1()->selected_connection()); 669 ep2_ch1()->selected_connection());
669 670
670 TestSendRecv(); 671 TestSendRecv();
671 } 672 }
672 673
673 void OnReadyToSend(TransportChannel* ch) { 674 void OnReadyToSend(rtc::PacketTransportInterface* transport) {
674 GetEndpoint(ch)->ready_to_send_ = true; 675 GetEndpoint(static_cast<TransportChannel*>(transport))->ready_to_send_ =
676 true;
675 } 677 }
676 678
677 // We pass the candidates directly to the other side. 679 // We pass the candidates directly to the other side.
678 void OnCandidateGathered(TransportChannelImpl* ch, const Candidate& c) { 680 void OnCandidateGathered(TransportChannelImpl* ch, const Candidate& c) {
679 if (force_relay_ && c.type() != RELAY_PORT_TYPE) 681 if (force_relay_ && c.type() != RELAY_PORT_TYPE)
680 return; 682 return;
681 683
682 if (GetEndpoint(ch)->save_candidates_) { 684 if (GetEndpoint(ch)->save_candidates_) {
683 GetEndpoint(ch)->saved_candidates_.push_back( 685 GetEndpoint(ch)->saved_candidates_.push_back(
684 std::unique_ptr<CandidatesData>(new CandidatesData(ch, c))); 686 std::unique_ptr<CandidatesData>(new CandidatesData(ch, c)));
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 return; 772 return;
771 } 773 }
772 for (Candidate& c : data->candidates) { 774 for (Candidate& c : data->candidates) {
773 LOG(LS_INFO) << "Removed remote candidate " << c.ToString(); 775 LOG(LS_INFO) << "Removed remote candidate " << c.ToString();
774 rch->RemoveRemoteCandidate(c); 776 rch->RemoveRemoteCandidate(c);
775 } 777 }
776 break; 778 break;
777 } 779 }
778 } 780 }
779 } 781 }
780 void OnReadPacket(TransportChannel* channel, 782
783 void OnReadPacket(rtc::PacketTransportInterface* transport,
781 const char* data, 784 const char* data,
782 size_t len, 785 size_t len,
783 const rtc::PacketTime& packet_time, 786 const rtc::PacketTime& packet_time,
784 int flags) { 787 int flags) {
785 std::list<std::string>& packets = GetPacketList(channel); 788 std::list<std::string>& packets =
789 GetPacketList(static_cast<TransportChannel*>(transport));
786 packets.push_front(std::string(data, len)); 790 packets.push_front(std::string(data, len));
787 } 791 }
792
788 void OnRoleConflict(TransportChannelImpl* channel) { 793 void OnRoleConflict(TransportChannelImpl* channel) {
789 GetEndpoint(channel)->OnRoleConflict(true); 794 GetEndpoint(channel)->OnRoleConflict(true);
790 IceRole new_role = GetEndpoint(channel)->ice_role() == ICEROLE_CONTROLLING 795 IceRole new_role = GetEndpoint(channel)->ice_role() == ICEROLE_CONTROLLING
791 ? ICEROLE_CONTROLLED 796 ? ICEROLE_CONTROLLED
792 : ICEROLE_CONTROLLING; 797 : ICEROLE_CONTROLLING;
793 channel->SetIceRole(new_role); 798 channel->SetIceRole(new_role);
794 } 799 }
795 800
796 int SendData(TransportChannel* channel, const char* data, size_t len) { 801 int SendData(TransportChannel* channel, const char* data, size_t len) {
797 rtc::PacketOptions options; 802 rtc::PacketOptions options;
(...skipping 2104 matching lines...) Expand 10 before | Expand all | Expand 10 after
2902 new StunUInt32Attribute(STUN_ATTR_NOMINATION, nomination)); 2907 new StunUInt32Attribute(STUN_ATTR_NOMINATION, nomination));
2903 } 2908 }
2904 msg.SetTransactionID(rtc::CreateRandomString(kStunTransactionIdLength)); 2909 msg.SetTransactionID(rtc::CreateRandomString(kStunTransactionIdLength));
2905 msg.AddMessageIntegrity(conn->local_candidate().password()); 2910 msg.AddMessageIntegrity(conn->local_candidate().password());
2906 msg.AddFingerprint(); 2911 msg.AddFingerprint();
2907 rtc::ByteBufferWriter buf; 2912 rtc::ByteBufferWriter buf;
2908 msg.Write(&buf); 2913 msg.Write(&buf);
2909 conn->OnReadPacket(buf.Data(), buf.Length(), rtc::CreatePacketTime(0)); 2914 conn->OnReadPacket(buf.Data(), buf.Length(), rtc::CreatePacketTime(0));
2910 } 2915 }
2911 2916
2912 void OnReadyToSend(TransportChannel* channel) { 2917 void OnReadyToSend(rtc::PacketTransportInterface* transport) {
2913 channel_ready_to_send_ = true; 2918 channel_ready_to_send_ = true;
2914 } 2919 }
2915 void OnChannelStateChanged(TransportChannelImpl* channel) { 2920 void OnChannelStateChanged(TransportChannelImpl* channel) {
2916 channel_state_ = channel->GetState(); 2921 channel_state_ = channel->GetState();
2917 } 2922 }
2918 2923
2919 CandidatePairInterface* last_selected_candidate_pair() { 2924 CandidatePairInterface* last_selected_candidate_pair() {
2920 return last_selected_candidate_pair_; 2925 return last_selected_candidate_pair_;
2921 } 2926 }
2922 int last_sent_packet_id() { return last_sent_packet_id_; } 2927 int last_sent_packet_id() { return last_sent_packet_id_; }
(...skipping 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after
4216 4221
4217 // TCP Relay/Relay is the next. 4222 // TCP Relay/Relay is the next.
4218 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE, 4223 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE,
4219 TCP_PROTOCOL_NAME); 4224 TCP_PROTOCOL_NAME);
4220 4225
4221 // Finally, Local/Relay will be pinged. 4226 // Finally, Local/Relay will be pinged.
4222 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE); 4227 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE);
4223 } 4228 }
4224 4229
4225 } // namespace cricket { 4230 } // namespace cricket {
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698