diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
commit | d8bbc7858622b6d9c278469aab701ca0b609cddf (patch) | |
tree | eff41dc61d9f714852212739e6b3738b82a2af87 /third_party/libwebrtc/rtc_base/async_udp_socket.cc | |
parent | Releasing progress-linux version 125.0.3-1~progress7.99u1. (diff) | |
download | firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip |
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | third_party/libwebrtc/rtc_base/async_udp_socket.cc | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/third_party/libwebrtc/rtc_base/async_udp_socket.cc b/third_party/libwebrtc/rtc_base/async_udp_socket.cc index 358420a5de..3d258bcb26 100644 --- a/third_party/libwebrtc/rtc_base/async_udp_socket.cc +++ b/third_party/libwebrtc/rtc_base/async_udp_socket.cc @@ -10,9 +10,11 @@ #include "rtc_base/async_udp_socket.h" - +#include "absl/types/optional.h" +#include "api/units/time_delta.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" +#include "rtc_base/network/received_packet.h" #include "rtc_base/network/sent_packet.h" #include "rtc_base/time_utils.h" #include "system_wrappers/include/field_trial.h" @@ -109,10 +111,8 @@ void AsyncUDPSocket::OnReadEvent(Socket* socket) { RTC_DCHECK(socket_.get() == socket); RTC_DCHECK_RUN_ON(&sequence_checker_); - SocketAddress remote_addr; - int64_t timestamp = -1; - int len = socket_->RecvFrom(buf_, BUF_SIZE, &remote_addr, ×tamp); - + Socket::ReceiveBuffer receive_buffer(buffer_); + int len = socket_->RecvFrom(receive_buffer); if (len < 0) { // An error here typically means we got an ICMP error in response to our // send datagram, indicating the remote address was unreachable. @@ -123,21 +123,31 @@ void AsyncUDPSocket::OnReadEvent(Socket* socket) { << "] receive failed with error " << socket_->GetError(); return; } - if (timestamp == -1) { + if (len == 0) { + // Spurios wakeup. + return; + } + + if (!receive_buffer.arrival_time) { // Timestamp from socket is not available. - timestamp = TimeMicros(); + receive_buffer.arrival_time = webrtc::Timestamp::Micros(rtc::TimeMicros()); } else { if (!socket_time_offset_) { - socket_time_offset_ = - !IsScmTimeStampExperimentDisabled() ? TimeMicros() - timestamp : 0; + // Estimate timestamp offset from first packet arrival time unless + // disabled + bool estimate_time_offset = !IsScmTimeStampExperimentDisabled(); + if (estimate_time_offset) { + socket_time_offset_ = webrtc::Timestamp::Micros(rtc::TimeMicros()) - + *receive_buffer.arrival_time; + } else { + socket_time_offset_ = webrtc::TimeDelta::Micros(0); + } } - timestamp += *socket_time_offset_; + *receive_buffer.arrival_time += *socket_time_offset_; } - - // TODO: Make sure that we got all of the packet. - // If we did not, then we should resize our buffer to be large enough. - NotifyPacketReceived( - rtc::ReceivedPacket::CreateFromLegacy(buf_, len, timestamp, remote_addr)); + NotifyPacketReceived(ReceivedPacket(receive_buffer.payload, + receive_buffer.source_address, + receive_buffer.arrival_time)); } void AsyncUDPSocket::OnWriteEvent(Socket* socket) { |