commit b6ecc6301c439b8a542c92f76d8ffe9f5f0994ad
parent 811836188b9922f2edec6167756c508d880c9ea4
Author: Dan Baker <dbaker@mozilla.com>
Date: Mon, 1 Dec 2025 21:42:39 -0700
Bug 2000941 - Vendor libwebrtc from ffb3f04cf6
Upstream commit: https://webrtc.googlesource.com/src/+/ffb3f04cf67009c6d8def83688eaf343ed36758f
Reapply "use sigslot trampoline in PortInterface"
This reverts commit 113c64e969c4848779e3d5c7903e36bb8eac8835.
Reason for reland: Moved problematic functions to .cc file.
Bug: webrtc:42222066
Change-Id: I009ff6aea7209e90057048d5a6da56cf6a7652df
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/409547
Commit-Queue: Lena Kaplan <lenakaplan@meta.com>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45674}
Diffstat:
10 files changed, 141 insertions(+), 24 deletions(-)
diff --git a/third_party/libwebrtc/README.mozilla.last-vendor b/third_party/libwebrtc/README.mozilla.last-vendor
@@ -1,4 +1,4 @@
# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc
-libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-12-02T04:39:39.517365+00:00.
+libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-12-02T04:42:25.076032+00:00.
# base of lastest vendoring
-83b0eaa6ec
+ffb3f04cf6
diff --git a/third_party/libwebrtc/p2p/base/p2p_transport_channel.cc b/third_party/libwebrtc/p2p/base/p2p_transport_channel.cc
@@ -931,9 +931,15 @@ void P2PTransportChannel::OnPortReady(PortAllocatorSession* /* session */,
port->SetIceRole(ice_role_);
port->SetIceTiebreaker(allocator_->ice_tiebreaker());
ports_.push_back(port);
- port->SignalUnknownAddress.connect(this,
- &P2PTransportChannel::OnUnknownAddress);
- port->SignalSentPacket.connect(this, &P2PTransportChannel::OnSentPacket);
+ port->SubscribeUnknownAddress(
+ [this](PortInterface* port, const SocketAddress& address,
+ ProtocolType proto, IceMessage* stun_msg,
+ const std::string& remote_username, bool port_muxed) {
+ OnUnknownAddress(port, address, proto, stun_msg, remote_username,
+ port_muxed);
+ });
+ port->SubscribeSentPacket(
+ [this](const SentPacketInfo& sent_packet) { OnSentPacket(sent_packet); });
port->SubscribePortDestroyed(
[this](PortInterface* port) { OnPortDestroyed(port); });
diff --git a/third_party/libwebrtc/p2p/base/p2p_transport_channel_unittest.cc b/third_party/libwebrtc/p2p/base/p2p_transport_channel_unittest.cc
@@ -3988,7 +3988,7 @@ TEST_F(P2PTransportChannelPingTest, PingingStartedAsSoonAsPossible) {
prflx_priority));
Port* port = GetPort(&ch);
ASSERT_NE(nullptr, port);
- port->SignalUnknownAddress(port, SocketAddress("1.1.1.1", 1), PROTO_UDP,
+ port->NotifyUnknownAddress(port, SocketAddress("1.1.1.1", 1), PROTO_UDP,
&request, kIceUfrag[1], false);
Connection* conn = GetConnectionTo(&ch, "1.1.1.1", 1);
ASSERT_NE(nullptr, conn);
@@ -4178,14 +4178,14 @@ TEST_F(P2PTransportChannelPingTest, ConnectionResurrection) {
Port* port = GetPort(&ch);
// conn1 should be resurrected with original priority.
- port->SignalUnknownAddress(port, SocketAddress("1.1.1.1", 1), PROTO_UDP,
+ port->NotifyUnknownAddress(port, SocketAddress("1.1.1.1", 1), PROTO_UDP,
&request, kIceUfrag[1], false);
conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1);
ASSERT_TRUE(conn1 != nullptr);
EXPECT_EQ(conn1->remote_candidate().priority(), remote_priority);
// conn3, a real prflx connection, should have prflx priority.
- port->SignalUnknownAddress(port, SocketAddress("3.3.3.3", 1), PROTO_UDP,
+ port->NotifyUnknownAddress(port, SocketAddress("3.3.3.3", 1), PROTO_UDP,
&request, kIceUfrag[1], false);
Connection* conn3 = WaitForConnectionTo(&ch, "3.3.3.3", 1);
ASSERT_TRUE(conn3 != nullptr);
@@ -4463,7 +4463,7 @@ TEST_F(P2PTransportChannelPingTest, TestSelectConnectionFromUnknownAddress) {
request.AddAttribute(std::make_unique<StunUInt32Attribute>(STUN_ATTR_PRIORITY,
prflx_priority));
TestUDPPort* port = static_cast<TestUDPPort*>(GetPort(&ch));
- port->SignalUnknownAddress(port, SocketAddress("1.1.1.1", 1), PROTO_UDP,
+ port->NotifyUnknownAddress(port, SocketAddress("1.1.1.1", 1), PROTO_UDP,
&request, kIceUfrag[1], false);
Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1);
ASSERT_TRUE(conn1 != nullptr);
@@ -4490,7 +4490,7 @@ TEST_F(P2PTransportChannelPingTest, TestSelectConnectionFromUnknownAddress) {
// Another request with unknown address, it will not be set as the selected
// connection because the selected connection was nominated by the controlling
// side.
- port->SignalUnknownAddress(port, SocketAddress("3.3.3.3", 3), PROTO_UDP,
+ port->NotifyUnknownAddress(port, SocketAddress("3.3.3.3", 3), PROTO_UDP,
&request, kIceUfrag[1], false);
Connection* conn3 = WaitForConnectionTo(&ch, "3.3.3.3", 3);
ASSERT_TRUE(conn3 != nullptr);
@@ -4502,7 +4502,7 @@ TEST_F(P2PTransportChannelPingTest, TestSelectConnectionFromUnknownAddress) {
// selected as the selected connection.
request.AddAttribute(
std::make_unique<StunByteStringAttribute>(STUN_ATTR_USE_CANDIDATE));
- port->SignalUnknownAddress(port, SocketAddress("4.4.4.4", 4), PROTO_UDP,
+ port->NotifyUnknownAddress(port, SocketAddress("4.4.4.4", 4), PROTO_UDP,
&request, kIceUfrag[1], false);
Connection* conn4 = WaitForConnectionTo(&ch, "4.4.4.4", 4);
ASSERT_TRUE(conn4 != nullptr);
@@ -4519,7 +4519,7 @@ TEST_F(P2PTransportChannelPingTest, TestSelectConnectionFromUnknownAddress) {
// port->set_sent_binding_response(false);
ch.SetRemoteIceParameters(kIceParams[2]);
ch.SetRemoteIceParameters(kIceParams[3]);
- port->SignalUnknownAddress(port, SocketAddress("5.5.5.5", 5), PROTO_UDP,
+ port->NotifyUnknownAddress(port, SocketAddress("5.5.5.5", 5), PROTO_UDP,
&request, kIceUfrag[2], false);
Connection* conn5 = WaitForConnectionTo(&ch, "5.5.5.5", 5);
ASSERT_TRUE(conn5 != nullptr);
@@ -4571,7 +4571,7 @@ TEST_F(P2PTransportChannelPingTest, TestSelectConnectionBasedOnMediaReceived) {
request.AddAttribute(
std::make_unique<StunByteStringAttribute>(STUN_ATTR_USE_CANDIDATE));
Port* port = GetPort(&ch);
- port->SignalUnknownAddress(port, SocketAddress("3.3.3.3", 3), PROTO_UDP,
+ port->NotifyUnknownAddress(port, SocketAddress("3.3.3.3", 3), PROTO_UDP,
&request, kIceUfrag[1], false);
Connection* conn3 = WaitForConnectionTo(&ch, "3.3.3.3", 3);
ASSERT_TRUE(conn3 != nullptr);
diff --git a/third_party/libwebrtc/p2p/base/port.cc b/third_party/libwebrtc/p2p/base/port.cc
@@ -133,7 +133,10 @@ Port::Port(const PortParametersRef& args,
shared_socket_(shared_socket),
network_cost_(args.network->GetCost(env_.field_trials())),
role_conflict_callback_(nullptr),
- weak_factory_(this) {
+ weak_factory_(this),
+ unknown_address_trampoline_(this),
+ read_packet_trampoline_(this),
+ sent_packet_trampoline_(this) {
RTC_DCHECK_RUN_ON(thread_);
RTC_DCHECK(factory_ != nullptr);
// TODO(pthatcher): Remove this old behavior once we're sure no one
@@ -394,7 +397,7 @@ void Port::OnReadPacket(const ReceivedIpPacket& packet, ProtocolType proto) {
const SocketAddress& addr = packet.source_address();
// If the user has enabled port packets, just hand this over.
if (enable_port_packets_) {
- SignalReadPacket(this, data, size, addr);
+ NotifyReadPacket(this, data, size, addr);
return;
}
@@ -415,7 +418,7 @@ void Port::OnReadPacket(const ReceivedIpPacket& packet, ProtocolType proto) {
// We need to signal an unknown address before we handle any role conflict
// below. Otherwise there would be no candidate pair and TURN entry created
// to send the error response in case of a role conflict.
- SignalUnknownAddress(this, addr, proto, msg.get(), remote_username, false);
+ NotifyUnknownAddress(this, addr, proto, msg.get(), remote_username, false);
// Check for role conflicts.
if (!MaybeIceRoleConflict(addr, msg.get(), remote_username)) {
RTC_LOG(LS_INFO) << "Received conflicting role from the peer.";
@@ -1080,4 +1083,45 @@ void Port::NotifyRoleConflict() {
}
}
+void Port::SubscribeUnknownAddress(absl::AnyInvocable<void(PortInterface*,
+ const SocketAddress&,
+ ProtocolType,
+ IceMessage*,
+ const std::string&,
+ bool)> callback) {
+ unknown_address_trampoline_.Subscribe(std::move(callback));
+}
+
+void Port::NotifyUnknownAddress(PortInterface* port,
+ const SocketAddress& address,
+ ProtocolType proto,
+ IceMessage* msg,
+ const std::string& rf,
+ bool port_muxed) {
+ SignalUnknownAddress(port, address, proto, msg, rf, port_muxed);
+}
+
+void Port::SubscribeReadPacket(
+ absl::AnyInvocable<
+ void(PortInterface*, const char*, size_t, const SocketAddress&)>
+ callback) {
+ read_packet_trampoline_.Subscribe(std::move(callback));
+}
+
+void Port::NotifyReadPacket(PortInterface* port,
+ const char* data,
+ size_t size,
+ const SocketAddress& remote_address) {
+ SignalReadPacket(port, data, size, remote_address);
+}
+
+void Port::SubscribeSentPacket(
+ absl::AnyInvocable<void(const SentPacketInfo&)> callback) {
+ sent_packet_trampoline_.Subscribe(std::move(callback));
+}
+
+void Port::NotifySentPacket(const SentPacketInfo& packet) {
+ SignalSentPacket(packet);
+}
+
} // namespace webrtc
diff --git a/third_party/libwebrtc/p2p/base/port.h b/third_party/libwebrtc/p2p/base/port.h
@@ -399,6 +399,33 @@ class RTC_EXPORT Port : public PortInterface, public sigslot::has_slots<> {
void SubscribeRoleConflict(absl::AnyInvocable<void()> callback) override;
void NotifyRoleConflict() override;
+ void SubscribeUnknownAddress(
+ absl::AnyInvocable<void(PortInterface*,
+ const SocketAddress&,
+ ProtocolType,
+ IceMessage*,
+ const std::string&,
+ bool)> callback) override;
+ void NotifyUnknownAddress(PortInterface* port,
+ const SocketAddress& address,
+ ProtocolType proto,
+ IceMessage* msg,
+ const std::string& rf,
+ bool port_muxed) override;
+
+ void SubscribeReadPacket(
+ absl::AnyInvocable<
+ void(PortInterface*, const char*, size_t, const SocketAddress&)>
+ callback) override;
+ void NotifyReadPacket(PortInterface* prot,
+ const char* data,
+ size_t size,
+ const SocketAddress& remote_address) override;
+
+ void SubscribeSentPacket(
+ absl::AnyInvocable<void(const SentPacketInfo&)> callback) override;
+ void NotifySentPacket(const SentPacketInfo& packet) override;
+
protected:
void UpdateNetworkCost() override;
@@ -580,6 +607,13 @@ class RTC_EXPORT Port : public PortInterface, public sigslot::has_slots<> {
// Keep as the last member variable.
WeakPtrFactory<Port> weak_factory_ RTC_GUARDED_BY(thread_);
+
+ SignalTrampoline<PortInterface, &PortInterface::SignalUnknownAddress>
+ unknown_address_trampoline_;
+ SignalTrampoline<PortInterface, &PortInterface::SignalReadPacket>
+ read_packet_trampoline_;
+ SignalTrampoline<PortInterface, &PortInterface::SignalSentPacket>
+ sent_packet_trampoline_;
};
} // namespace webrtc
diff --git a/third_party/libwebrtc/p2p/base/port_interface.h b/third_party/libwebrtc/p2p/base/port_interface.h
@@ -17,6 +17,7 @@
#include <memory>
#include <optional>
#include <string>
+#include <utility>
#include <vector>
#include "absl/functional/any_invocable.h"
@@ -111,7 +112,20 @@ class PortInterface {
const std::string&,
bool>
SignalUnknownAddress;
-
+ virtual void SubscribeUnknownAddress(
+ absl::AnyInvocable<void(PortInterface*,
+ const SocketAddress&,
+ ProtocolType,
+ IceMessage*,
+ const std::string&,
+ bool)> callback) = 0;
+
+ virtual void NotifyUnknownAddress(PortInterface* port,
+ const SocketAddress& address,
+ ProtocolType proto,
+ IceMessage* msg,
+ const std::string& rf,
+ bool port_muxed) = 0;
// Sends a response message (normal or error) to the given request. One of
// these methods should be called as a response to SignalUnknownAddress.
virtual void SendBindingErrorResponse(StunMessage* message,
@@ -137,9 +151,20 @@ class PortInterface {
virtual void EnablePortPackets() = 0;
sigslot::signal4<PortInterface*, const char*, size_t, const SocketAddress&>
SignalReadPacket;
+ virtual void SubscribeReadPacket(
+ absl::AnyInvocable<
+ void(PortInterface*, const char*, size_t, const SocketAddress&)>
+ callback) = 0;
+ virtual void NotifyReadPacket(PortInterface* port_interface,
+ const char*,
+ size_t,
+ const SocketAddress&) = 0;
// Emitted each time a packet is sent on this port.
sigslot::signal1<const SentPacketInfo&> SignalSentPacket;
+ virtual void SubscribeSentPacket(
+ absl::AnyInvocable<void(const SentPacketInfo&)> callback) = 0;
+ virtual void NotifySentPacket(const SentPacketInfo& packet) = 0;
virtual std::string ToString() const = 0;
diff --git a/third_party/libwebrtc/p2p/base/port_unittest.cc b/third_party/libwebrtc/p2p/base/port_unittest.cc
@@ -238,7 +238,7 @@ class TestPort : public Port {
private:
void OnSentPacket(AsyncPacketSocket* socket,
const SentPacketInfo& sent_packet) override {
- PortInterface::SignalSentPacket(sent_packet);
+ NotifySentPacket(sent_packet);
}
std::unique_ptr<BufferT<uint8_t>> last_stun_buf_;
std::unique_ptr<IceMessage> last_stun_msg_;
@@ -282,7 +282,12 @@ class TestChannel : public sigslot::has_slots<> {
// Takes ownership of `p1` (but not `p2`).
explicit TestChannel(std::unique_ptr<Port> p1) : port_(std::move(p1)) {
port_->SubscribePortComplete([this](Port* port) { OnPortComplete(port); });
- port_->SignalUnknownAddress.connect(this, &TestChannel::OnUnknownAddress);
+ port_->SubscribeUnknownAddress(
+ [this](PortInterface* port, const SocketAddress& address,
+ ProtocolType proto, IceMessage* msg, const std::string& rf,
+ bool port_muxed) {
+ OnUnknownAddress(port, address, proto, msg, rf, port_muxed);
+ });
port_->SubscribePortDestroyed(
[this](PortInterface* port) { OnSrcPortDestroyed(port); });
}
diff --git a/third_party/libwebrtc/p2p/base/stun_port.cc b/third_party/libwebrtc/p2p/base/stun_port.cc
@@ -413,7 +413,7 @@ void UDPPort::OnReadPacket(AsyncPacketSocket* socket,
void UDPPort::OnSentPacket(AsyncPacketSocket* /* socket */,
const SentPacketInfo& sent_packet) {
- PortInterface::SignalSentPacket(sent_packet);
+ NotifySentPacket(sent_packet);
}
void UDPPort::OnReadyToSend(AsyncPacketSocket* /* socket */) {
diff --git a/third_party/libwebrtc/p2p/base/tcp_port.cc b/third_party/libwebrtc/p2p/base/tcp_port.cc
@@ -428,7 +428,7 @@ void TCPConnection::OnSentPacket(AsyncPacketSocket* socket,
const SentPacketInfo& sent_packet) {
RTC_DCHECK_RUN_ON(network_thread());
if (port()) {
- port()->SignalSentPacket(sent_packet);
+ port()->NotifySentPacket(sent_packet);
}
}
diff --git a/third_party/libwebrtc/p2p/base/turn_port_unittest.cc b/third_party/libwebrtc/p2p/base/turn_port_unittest.cc
@@ -372,9 +372,12 @@ class TurnPortTest : public ::testing::Test,
[this](Port* port, const IceCandidateErrorEvent& event) {
OnCandidateError(port, event);
});
-
- turn_port_->SignalUnknownAddress.connect(
- this, &TurnPortTest::OnTurnUnknownAddress);
+ turn_port_->SubscribeUnknownAddress(
+ [this](PortInterface* port, const SocketAddress& address,
+ ProtocolType proto, IceMessage* stun_msg, const std::string& rf,
+ bool port_muxed) {
+ OnTurnUnknownAddress(port, address, proto, stun_msg, rf, port_muxed);
+ });
turn_port_->SubscribePortDestroyed(
[this](PortInterface* port) { OnTurnPortDestroyed(port); });
turn_port_->SetCallbacksForTest(this);