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 send_data_.fill(42); | 25 send_data_.fill(42); |
25 packet_sender_checker_.Detach(); | 26 packet_sender_checker_.Detach(); |
26 auto socket = | 27 auto socket = |
27 std::unique_ptr<rtc::AsyncPacketSocket>(socket_factory_.CreateUdpSocket( | 28 std::unique_ptr<rtc::AsyncPacketSocket>(socket_factory_.CreateUdpSocket( |
28 rtc::SocketAddress(rtc::GetAnyIP(AF_INET), 0), min_port, max_port)); | 29 rtc::SocketAddress(rtc::GetAnyIP(AF_INET), 0), min_port, max_port)); |
29 socket->SignalReadPacket.connect(this, &TestController::OnReadPacket); | 30 socket->SignalReadPacket.connect(this, &TestController::OnReadPacket); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 packet_sender_.reset(new PacketSender(this, config_file_path_)); | 95 packet_sender_.reset(new PacketSender(this, config_file_path_)); |
95 packet_sender_->StartSending(); | 96 packet_sender_->StartSending(); |
96 rtc::CritScope scoped_lock(&local_test_done_lock_); | 97 rtc::CritScope scoped_lock(&local_test_done_lock_); |
97 local_test_done_ = false; | 98 local_test_done_ = false; |
98 remote_test_done_ = false; | 99 remote_test_done_ = false; |
99 break; | 100 break; |
100 } | 101 } |
101 case NetworkTesterPacket::TEST_START: { | 102 case NetworkTesterPacket::TEST_START: { |
102 packet_sender_.reset(new PacketSender(this, config_file_path_)); | 103 packet_sender_.reset(new PacketSender(this, config_file_path_)); |
103 packet_sender_->StartSending(); | 104 packet_sender_->StartSending(); |
| 105 rtc::CritScope scoped_lock(&local_test_done_lock_); |
| 106 local_test_done_ = false; |
| 107 remote_test_done_ = false; |
104 break; | 108 break; |
105 } | 109 } |
106 case NetworkTesterPacket::TEST_DATA: { | 110 case NetworkTesterPacket::TEST_DATA: { |
107 packet.set_arrival_timestamp(packet_time.timestamp); | 111 packet.set_arrival_timestamp(packet_time.timestamp); |
108 packet.set_packet_size(len); | 112 packet.set_packet_size(len); |
109 packet_logger_.LogPacket(packet); | 113 packet_logger_.LogPacket(packet); |
110 break; | 114 break; |
111 } | 115 } |
112 case NetworkTesterPacket::TEST_DONE: { | 116 case NetworkTesterPacket::TEST_DONE: { |
113 remote_test_done_ = true; | 117 remote_test_done_ = true; |
114 break; | 118 break; |
115 } | 119 } |
116 default: { RTC_NOTREACHED(); } | 120 default: { RTC_NOTREACHED(); } |
117 } | 121 } |
118 } | 122 } |
119 | 123 |
120 } // namespace webrtc | 124 } // namespace webrtc |
OLD | NEW |