OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. | |
3 * | |
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 | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #ifndef WEBRTC_TOOLS_NETWORK_TESTER_TEST_CONTROLLER_H_ | |
12 #define WEBRTC_TOOLS_NETWORK_TESTER_TEST_CONTROLLER_H_ | |
13 | |
14 #include <array> | |
15 #include <limits> | |
16 #include <memory> | |
17 #include <string> | |
18 #include <utility> | |
19 | |
20 #include "webrtc/base/ignore_wundef.h" | |
21 #include "webrtc/p2p/base/basicpacketsocketfactory.h" | |
22 #include "webrtc/p2p/base/udptransport.h" | |
23 #include "webrtc/tools/network_tester/packet_sender.h" | |
24 | |
25 #ifdef WEBRTC_NETWORK_TESTER_PROTO | |
26 RTC_PUSH_IGNORING_WUNDEF() | |
27 #include "webrtc/tools/network_tester/network_tester_packet.pb.h" | |
28 RTC_POP_IGNORING_WUNDEF() | |
29 using webrtc::network_tester::packet::NetworkTesterPacket; | |
30 #else | |
31 class NetworkTesterPacket; | |
32 #endif // WEBRTC_NETWORK_TESTER_PROTO | |
33 | |
34 namespace webrtc { | |
35 | |
36 class TestController : public sigslot::has_slots<> { | |
minyue-webrtc
2017/04/03 08:09:51
I don't quite understand why sigslot::has_slots<>
michaelt
2017/04/03 13:05:39
TestController register itself in socket as a rece
| |
37 public: | |
38 TestController(int min_port, | |
39 int max_port, | |
40 const std::string& config_file_path); | |
41 | |
42 void Run(); | |
43 | |
44 void SendConnectTo(const std::string& hostname, int port); | |
45 | |
46 void OnReadPacket(rtc::AsyncPacketSocket* socket, | |
47 const char* data, | |
48 size_t len, | |
49 const rtc::SocketAddress& remote_addr, | |
50 const rtc::PacketTime& packet_time); | |
51 | |
52 void SendData(const NetworkTesterPacket& packet, | |
53 rtc::Optional<size_t> data_size); | |
54 | |
55 void OnTestDone(); | |
56 | |
57 bool IsTestDone() { return local_test_done_ && remote_test_done_; } | |
58 | |
59 private: | |
60 rtc::BasicPacketSocketFactory socket_factory_; | |
61 std::unique_ptr<cricket::UdpTransport> udp_transport_; | |
62 std::unique_ptr<PacketSender> packet_sender_; | |
63 const std::string config_file_path_; | |
64 bool local_test_done_; | |
65 bool remote_test_done_; | |
66 std::array<char, 15000> send_data_; | |
minyue-webrtc
2017/04/03 08:05:20
15000? Preferably not hard coded here
michaelt
2017/04/03 13:05:39
Done.
| |
67 }; | |
68 | |
69 } // namespace webrtc | |
70 | |
71 #endif // WEBRTC_TOOLS_NETWORK_TESTER_TEST_CONTROLLER_H_ | |
OLD | NEW |