diff options
Diffstat (limited to 'third_party/libwebrtc/rtc_tools/network_tester/test_controller.cc')
-rw-r--r-- | third_party/libwebrtc/rtc_tools/network_tester/test_controller.cc | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/third_party/libwebrtc/rtc_tools/network_tester/test_controller.cc b/third_party/libwebrtc/rtc_tools/network_tester/test_controller.cc index 3d9af380f1..f8641aacb6 100644 --- a/third_party/libwebrtc/rtc_tools/network_tester/test_controller.cc +++ b/third_party/libwebrtc/rtc_tools/network_tester/test_controller.cc @@ -13,10 +13,12 @@ #include <limits> #include "absl/types/optional.h" +#include "api/units/timestamp.h" #include "rtc_base/checks.h" #include "rtc_base/internal/default_socket_server.h" #include "rtc_base/ip_address.h" #include "rtc_base/logging.h" +#include "rtc_base/network/received_packet.h" #include "rtc_base/thread.h" namespace webrtc { @@ -44,7 +46,10 @@ TestController::TestController(int min_port, std::unique_ptr<rtc::AsyncPacketSocket>(socket_factory_.CreateUdpSocket( rtc::SocketAddress(rtc::GetAnyIP(AF_INET), 0), min_port, max_port)); RTC_CHECK(udp_socket_ != nullptr); - udp_socket_->SignalReadPacket.connect(this, &TestController::OnReadPacket); + udp_socket_->RegisterReceivedPacketCallback( + [&](rtc::AsyncPacketSocket* socket, const rtc::ReceivedPacket& packet) { + OnReadPacket(socket, packet); + }); }); } @@ -103,14 +108,13 @@ bool TestController::IsTestDone() { } void TestController::OnReadPacket(rtc::AsyncPacketSocket* socket, - const char* data, - size_t len, - const rtc::SocketAddress& remote_addr, - const int64_t& packet_time_us) { + const rtc::ReceivedPacket& received_packet) { RTC_DCHECK_RUN_ON(packet_sender_thread_.get()); RTC_LOG(LS_VERBOSE) << "OnReadPacket"; - size_t packet_size = data[0]; - std::string receive_data(&data[1], packet_size); + size_t packet_size = received_packet.payload()[0]; + std::string receive_data( + reinterpret_cast<const char*>(&received_packet.payload()[1]), + packet_size); NetworkTesterPacket packet; packet.ParseFromString(receive_data); RTC_CHECK(packet.has_type()); @@ -118,7 +122,7 @@ void TestController::OnReadPacket(rtc::AsyncPacketSocket* socket, case NetworkTesterPacket::HAND_SHAKING: { NetworkTesterPacket packet; packet.set_type(NetworkTesterPacket::TEST_START); - remote_address_ = remote_addr; + remote_address_ = received_packet.source_address(); SendData(packet, absl::nullopt); packet_sender_.reset(new PacketSender(this, packet_sender_thread_.get(), task_safety_flag_, @@ -140,8 +144,9 @@ void TestController::OnReadPacket(rtc::AsyncPacketSocket* socket, break; } case NetworkTesterPacket::TEST_DATA: { - packet.set_arrival_timestamp(packet_time_us); - packet.set_packet_size(len); + packet.set_arrival_timestamp( + received_packet.arrival_time().value_or(Timestamp::Zero()).us()); + packet.set_packet_size(received_packet.payload().size()); packet_logger_.LogPacket(packet); break; } |