summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/rtc_base/async_packet_socket.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
commit40a355a42d4a9444dc753c04c6608dade2f06a23 (patch)
tree871fc667d2de662f171103ce5ec067014ef85e61 /third_party/libwebrtc/rtc_base/async_packet_socket.cc
parentAdding upstream version 124.0.1. (diff)
downloadfirefox-upstream/125.0.1.tar.xz
firefox-upstream/125.0.1.zip
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/libwebrtc/rtc_base/async_packet_socket.cc')
-rw-r--r--third_party/libwebrtc/rtc_base/async_packet_socket.cc37
1 files changed, 37 insertions, 0 deletions
diff --git a/third_party/libwebrtc/rtc_base/async_packet_socket.cc b/third_party/libwebrtc/rtc_base/async_packet_socket.cc
index f50138cb62..3721366099 100644
--- a/third_party/libwebrtc/rtc_base/async_packet_socket.cc
+++ b/third_party/libwebrtc/rtc_base/async_packet_socket.cc
@@ -10,6 +10,8 @@
#include "rtc_base/async_packet_socket.h"
+#include "rtc_base/checks.h"
+
namespace rtc {
PacketTimeUpdateParams::PacketTimeUpdateParams() = default;
@@ -38,6 +40,41 @@ void AsyncPacketSocket::UnsubscribeCloseEvent(const void* removal_tag) {
on_close_.RemoveReceivers(removal_tag);
}
+void AsyncPacketSocket::RegisterReceivedPacketCallback(
+ absl::AnyInvocable<void(AsyncPacketSocket*, const rtc::ReceivedPacket&)>
+ received_packet_callback) {
+ RTC_DCHECK_RUN_ON(&network_checker_);
+ RTC_CHECK(!received_packet_callback_);
+ SignalReadPacket.connect(this, &AsyncPacketSocket::NotifyPacketReceived);
+ received_packet_callback_ = std::move(received_packet_callback);
+}
+
+void AsyncPacketSocket::DeregisterReceivedPacketCallback() {
+ RTC_DCHECK_RUN_ON(&network_checker_);
+ SignalReadPacket.disconnect(this);
+ received_packet_callback_ = nullptr;
+}
+
+void AsyncPacketSocket::NotifyPacketReceived(
+ const rtc::ReceivedPacket& packet) {
+ RTC_DCHECK_RUN_ON(&network_checker_);
+ if (received_packet_callback_) {
+ received_packet_callback_(this, packet);
+ return;
+ }
+ if (SignalReadPacket.is_empty()) {
+ RTC_DCHECK_NOTREACHED() << " No listener registered";
+ return;
+ }
+ // TODO(bugs.webrtc.org:15368): Remove. This code path is only used if
+ // SignalReadyPacket is used by clients to get notification of received
+ // packets but actual socket implementation use NotifyPacketReceived to
+ // trigger the notification.
+ SignalReadPacket(this, reinterpret_cast<const char*>(packet.payload().data()),
+ packet.payload().size(), packet.source_address(),
+ packet.arrival_time() ? packet.arrival_time()->us() : -1);
+}
+
void CopySocketInformationToPacketInfo(size_t packet_size_bytes,
const AsyncPacketSocket& socket_from,
bool is_connectionless,