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 : config_file_path_(config_file_path), | 19 : config_file_path_(config_file_path), |
| 20 packet_logger_(log_file_path), |
19 local_test_done_(false), | 21 local_test_done_(false), |
20 remote_test_done_(false) { | 22 remote_test_done_(false) { |
21 RTC_DCHECK_RUN_ON(&test_controller_thread_checker_); | 23 RTC_DCHECK_RUN_ON(&test_controller_thread_checker_); |
22 packet_sender_checker_.Detach(); | 24 packet_sender_checker_.Detach(); |
23 auto socket = | 25 auto socket = |
24 std::unique_ptr<rtc::AsyncPacketSocket>(socket_factory_.CreateUdpSocket( | 26 std::unique_ptr<rtc::AsyncPacketSocket>(socket_factory_.CreateUdpSocket( |
25 rtc::SocketAddress(rtc::GetAnyIP(AF_INET), 0), min_port, max_port)); | 27 rtc::SocketAddress(rtc::GetAnyIP(AF_INET), 0), min_port, max_port)); |
26 socket->SignalReadPacket.connect(this, &TestController::OnReadPacket); | 28 socket->SignalReadPacket.connect(this, &TestController::OnReadPacket); |
27 udp_transport_.reset( | 29 udp_transport_.reset( |
28 new cricket::UdpTransport("network tester transport", std::move(socket))); | 30 new cricket::UdpTransport("network tester transport", std::move(socket))); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 break; | 71 break; |
70 } | 72 } |
71 case NetworkTesterPacket::TEST_START: { | 73 case NetworkTesterPacket::TEST_START: { |
72 packet_sender_.reset(new PacketSender(this, config_file_path_)); | 74 packet_sender_.reset(new PacketSender(this, config_file_path_)); |
73 packet_sender_->StartSending(); | 75 packet_sender_->StartSending(); |
74 break; | 76 break; |
75 } | 77 } |
76 case NetworkTesterPacket::TEST_DATA: { | 78 case NetworkTesterPacket::TEST_DATA: { |
77 packet.set_arrival_timestamp(packet_time.timestamp); | 79 packet.set_arrival_timestamp(packet_time.timestamp); |
78 packet.set_packet_size(len); | 80 packet.set_packet_size(len); |
79 // log packet | 81 packet_logger_.LogPacket(packet); |
80 break; | 82 break; |
81 } | 83 } |
82 case NetworkTesterPacket::TEST_DONE: { | 84 case NetworkTesterPacket::TEST_DONE: { |
83 remote_test_done_ = true; | 85 remote_test_done_ = true; |
84 break; | 86 break; |
85 } | 87 } |
86 default: { RTC_NOTREACHED(); } | 88 default: { RTC_NOTREACHED(); } |
87 } | 89 } |
88 } | 90 } |
89 | 91 |
(...skipping 12 matching lines...) Expand all Loading... |
102 void TestController::OnTestDone() { | 104 void TestController::OnTestDone() { |
103 RTC_DCHECK_CALLED_SEQUENTIALLY(&packet_sender_checker_); | 105 RTC_DCHECK_CALLED_SEQUENTIALLY(&packet_sender_checker_); |
104 NetworkTesterPacket packet; | 106 NetworkTesterPacket packet; |
105 packet.set_type(NetworkTesterPacket::TEST_DONE); | 107 packet.set_type(NetworkTesterPacket::TEST_DONE); |
106 SendData(packet, rtc::Optional<size_t>()); | 108 SendData(packet, rtc::Optional<size_t>()); |
107 rtc::CritScope scoped_lock(&local_test_done_lock_); | 109 rtc::CritScope scoped_lock(&local_test_done_lock_); |
108 local_test_done_ = true; | 110 local_test_done_ = true; |
109 } | 111 } |
110 | 112 |
111 } // namespace webrtc | 113 } // namespace webrtc |
OLD | NEW |