OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2017 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 "webrtc/tools/network_tester/test_controller.h" | 11 #include "webrtc/tools/network_tester/test_controller.h" |
12 | 12 |
13 namespace webrtc { | 13 namespace webrtc { |
14 | 14 |
15 TestController::TestController(int min_port, | 15 TestController::TestController(int min_port, |
16 int max_port, | 16 int max_port, |
17 const std::string& config_file_path, | 17 const std::string& config_file_path, |
18 const std::string& log_file_path) | 18 const std::string& log_file_path) |
19 : config_file_path_(config_file_path), | 19 : socket_factory_(rtc::ThreadManager::Instance()->WrapCurrentThread()), |
| 20 config_file_path_(config_file_path), |
20 packet_logger_(log_file_path), | 21 packet_logger_(log_file_path), |
21 local_test_done_(false), | 22 local_test_done_(false), |
22 remote_test_done_(false) { | 23 remote_test_done_(false) { |
23 RTC_DCHECK_RUN_ON(&test_controller_thread_checker_); | 24 RTC_DCHECK_RUN_ON(&test_controller_thread_checker_); |
24 packet_sender_checker_.Detach(); | 25 packet_sender_checker_.Detach(); |
25 auto socket = | 26 auto socket = |
26 std::unique_ptr<rtc::AsyncPacketSocket>(socket_factory_.CreateUdpSocket( | 27 std::unique_ptr<rtc::AsyncPacketSocket>(socket_factory_.CreateUdpSocket( |
27 rtc::SocketAddress(rtc::GetAnyIP(AF_INET), 0), min_port, max_port)); | 28 rtc::SocketAddress(rtc::GetAnyIP(AF_INET), 0), min_port, max_port)); |
28 socket->SignalReadPacket.connect(this, &TestController::OnReadPacket); | 29 socket->SignalReadPacket.connect(this, &TestController::OnReadPacket); |
29 udp_transport_.reset( | 30 udp_transport_.reset( |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 udp_transport_->SetRemoteAddress(remote_addr); | 65 udp_transport_->SetRemoteAddress(remote_addr); |
65 SendData(packet, rtc::Optional<size_t>()); | 66 SendData(packet, rtc::Optional<size_t>()); |
66 packet_sender_.reset(new PacketSender(this, config_file_path_)); | 67 packet_sender_.reset(new PacketSender(this, config_file_path_)); |
67 packet_sender_->StartSending(); | 68 packet_sender_->StartSending(); |
68 rtc::CritScope scoped_lock(&local_test_done_lock_); | 69 rtc::CritScope scoped_lock(&local_test_done_lock_); |
69 local_test_done_ = false; | 70 local_test_done_ = false; |
70 remote_test_done_ = false; | 71 remote_test_done_ = false; |
71 break; | 72 break; |
72 } | 73 } |
73 case NetworkTesterPacket::TEST_START: { | 74 case NetworkTesterPacket::TEST_START: { |
| 75 local_test_done_ = false; |
| 76 remote_test_done_ = false; |
74 packet_sender_.reset(new PacketSender(this, config_file_path_)); | 77 packet_sender_.reset(new PacketSender(this, config_file_path_)); |
75 packet_sender_->StartSending(); | 78 packet_sender_->StartSending(); |
76 break; | 79 break; |
77 } | 80 } |
78 case NetworkTesterPacket::TEST_DATA: { | 81 case NetworkTesterPacket::TEST_DATA: { |
79 packet.set_arrival_timestamp(packet_time.timestamp); | 82 packet.set_arrival_timestamp(packet_time.timestamp); |
80 packet.set_packet_size(len); | 83 packet.set_packet_size(len); |
81 packet_logger_.LogPacket(packet); | 84 packet_logger_.LogPacket(packet); |
82 break; | 85 break; |
83 } | 86 } |
(...skipping 20 matching lines...) Expand all Loading... |
104 void TestController::OnTestDone() { | 107 void TestController::OnTestDone() { |
105 RTC_DCHECK_CALLED_SEQUENTIALLY(&packet_sender_checker_); | 108 RTC_DCHECK_CALLED_SEQUENTIALLY(&packet_sender_checker_); |
106 NetworkTesterPacket packet; | 109 NetworkTesterPacket packet; |
107 packet.set_type(NetworkTesterPacket::TEST_DONE); | 110 packet.set_type(NetworkTesterPacket::TEST_DONE); |
108 SendData(packet, rtc::Optional<size_t>()); | 111 SendData(packet, rtc::Optional<size_t>()); |
109 rtc::CritScope scoped_lock(&local_test_done_lock_); | 112 rtc::CritScope scoped_lock(&local_test_done_lock_); |
110 local_test_done_ = true; | 113 local_test_done_ = true; |
111 } | 114 } |
112 | 115 |
113 } // namespace webrtc | 116 } // namespace webrtc |
OLD | NEW |