commit d8fcd8cde7144390bacac601c4b3a805e9486c5f parent 805a2a3f4fbc940464128991bbfd7a36743c154a Author: Michael Froman <mfroman@mozilla.com> Date: Thu, 9 Oct 2025 23:20:19 -0500 Bug 1993083 - Vendor libwebrtc from efc58a5039 Upstream commit: https://webrtc.googlesource.com/src/+/efc58a50390e891f271e5abae6e3c6c086d7b07e Propagate transport name together with candidates This change further disconnects the use of mid and the transport_name() Candidate property and facilitates removing that property altogether. Bug: webrtc:406795492, webrtc:8395 Change-Id: Ia834b51e9d257127c0620bff489a93ca707bc528 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/394400 Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/main@{#45207} Diffstat:
18 files changed, 66 insertions(+), 59 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 /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc -libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-10T04:19:00.768982+00:00. +libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-10T04:20:10.029739+00:00. # base of lastest vendoring -5ff715d566 +efc58a5039 diff --git a/third_party/libwebrtc/api/BUILD.gn b/third_party/libwebrtc/api/BUILD.gn @@ -1428,6 +1428,7 @@ if (rtc_include_tests) { ":candidate", ":libjingle_peerconnection_api", "../test:test_support", + "//third_party/abseil-cpp/absl/strings:string_view", ] } diff --git a/third_party/libwebrtc/api/jsep.cc b/third_party/libwebrtc/api/jsep.cc @@ -15,11 +15,13 @@ #include <string> #include <vector> +#include "absl/strings/string_view.h" #include "api/candidate.h" namespace webrtc { size_t SessionDescriptionInterface::RemoveCandidates( + absl::string_view mid, const std::vector<Candidate>& /* candidates */) { return 0; } diff --git a/third_party/libwebrtc/api/jsep.h b/third_party/libwebrtc/api/jsep.h @@ -273,7 +273,8 @@ class RTC_EXPORT SessionDescriptionInterface { // Returns the number of candidates removed. // TODO: webrtc:42233526 - Deprecate and eventually remove this method in // favor of the IceCandidate version. - virtual size_t RemoveCandidates(const std::vector<Candidate>& candidates); + virtual size_t RemoveCandidates(absl::string_view mid, + const std::vector<Candidate>& candidates); // Returns the number of m= sections in the session description. virtual size_t number_of_mediasections() const = 0; diff --git a/third_party/libwebrtc/api/jsep_session_description.h b/third_party/libwebrtc/api/jsep_session_description.h @@ -62,7 +62,8 @@ class JsepSessionDescription : public SessionDescriptionInterface { virtual bool RemoveCandidate(const IceCandidate* candidate); // TODO: https://issues.webrtc.org/42233526 - Remove this method in favor of // the IceCandidate version. - virtual size_t RemoveCandidates(const std::vector<Candidate>& candidates); + virtual size_t RemoveCandidates(absl::string_view mid, + const std::vector<Candidate>& candidates); virtual size_t number_of_mediasections() const; virtual const IceCandidateCollection* candidates( size_t mediasection_index) const; diff --git a/third_party/libwebrtc/api/test/mock_session_description_interface.h b/third_party/libwebrtc/api/test/mock_session_description_interface.h @@ -17,6 +17,7 @@ #include <type_traits> #include <vector> +#include "absl/strings/string_view.h" #include "api/candidate.h" #include "api/jsep.h" #include "test/gmock.h" @@ -39,7 +40,7 @@ class MockSessionDescriptionInterface : public SessionDescriptionInterface { MOCK_METHOD(bool, RemoveCandidate, (const IceCandidate*), (override)); MOCK_METHOD(size_t, RemoveCandidates, - (const std::vector<Candidate>&), + (absl::string_view, const std::vector<Candidate>&), (override)); MOCK_METHOD(size_t, number_of_mediasections, (), (const, override)); MOCK_METHOD(const IceCandidateCollection*, diff --git a/third_party/libwebrtc/moz-patch-stack/s0027.patch b/third_party/libwebrtc/moz-patch-stack/s0027.patch @@ -204,7 +204,7 @@ index 3357c2dcdf..db3f2454bc 100644 } diff --git a/api/BUILD.gn b/api/BUILD.gn -index c5810b61a8..b6da9b6920 100644 +index d584d4591e..bf3dea8da6 100644 --- a/api/BUILD.gn +++ b/api/BUILD.gn @@ -44,6 +44,9 @@ rtc_library("enable_media") { diff --git a/third_party/libwebrtc/moz-patch-stack/s0103.patch b/third_party/libwebrtc/moz-patch-stack/s0103.patch @@ -126,7 +126,7 @@ index 9ebcd0de52..9a5730ab4c 100644 "Generated during 'gn gen' by //BUILD.gn.", "", diff --git a/api/BUILD.gn b/api/BUILD.gn -index b6da9b6920..eda94a3854 100644 +index bf3dea8da6..0693e12daa 100644 --- a/api/BUILD.gn +++ b/api/BUILD.gn @@ -8,8 +8,8 @@ diff --git a/third_party/libwebrtc/p2p/base/p2p_transport_channel.cc b/third_party/libwebrtc/p2p/base/p2p_transport_channel.cc @@ -2220,14 +2220,8 @@ void P2PTransportChannel::OnCandidatesRemoved( if (!config_.gather_continually() || session != allocator_session()) { return; } - - std::vector<Candidate> candidates_to_remove; - for (Candidate candidate : candidates) { - candidate.set_transport_name(transport_name()); - candidates_to_remove.push_back(candidate); - } if (candidates_removed_callback_) { - candidates_removed_callback_(this, candidates_to_remove); + candidates_removed_callback_(this, candidates); } } diff --git a/third_party/libwebrtc/pc/jsep_session_description.cc b/third_party/libwebrtc/pc/jsep_session_description.cc @@ -280,14 +280,15 @@ bool JsepSessionDescription::RemoveCandidate(const IceCandidate* candidate) { } size_t JsepSessionDescription::RemoveCandidates( + absl::string_view mid, const std::vector<Candidate>& candidates) { - size_t num_removed = 0; + int mediasection_index = GetMediasectionIndex(mid); + if (mediasection_index < 0) { + return 0u; + } + + size_t num_removed = 0u; for (auto& candidate : candidates) { - int mediasection_index = GetMediasectionIndex(candidate.transport_name()); - if (mediasection_index < 0) { - // Not found. - continue; - } num_removed += candidate_collection_[mediasection_index].remove(candidate); UpdateConnectionAddress( candidate_collection_[mediasection_index], diff --git a/third_party/libwebrtc/pc/jsep_session_description_unittest.cc b/third_party/libwebrtc/pc/jsep_session_description_unittest.cc @@ -498,20 +498,14 @@ TEST_F(JsepSessionDescriptionTest, RemoveCandidateAndSetConnectionAddress) { SocketAddress("::1", 1234), kCandidatePriority, "", "", IceCandidateType::kHost, kCandidateGeneration, kCandidateFoundation); - candidate1.set_transport_name("audio"); - Candidate candidate2(ICE_CANDIDATE_COMPONENT_RTP, "tcp", SocketAddress("::2", 1235), kCandidatePriority, "", "", IceCandidateType::kHost, kCandidateGeneration, kCandidateFoundation); - candidate2.set_transport_name("audio"); - Candidate candidate3(ICE_CANDIDATE_COMPONENT_RTP, "udp", SocketAddress("192.168.1.1", 1236), kCandidatePriority, "", "", IceCandidateType::kHost, kCandidateGeneration, kCandidateFoundation); - candidate3.set_transport_name("audio"); - IceCandidate jice1("audio", 0, candidate1); IceCandidate jice2("audio", 0, candidate2); IceCandidate jice3("audio", 0, candidate3); @@ -528,17 +522,17 @@ TEST_F(JsepSessionDescriptionTest, RemoveCandidateAndSetConnectionAddress) { EXPECT_EQ("192.168.1.1:1236", media_desc->connection_address().ToString()); candidates.push_back(candidate3); - ASSERT_TRUE(jsep_desc_->RemoveCandidates(candidates)); + ASSERT_TRUE(jsep_desc_->RemoveCandidates("audio", candidates)); EXPECT_EQ("[::1]:1234", media_desc->connection_address().ToString()); candidates.clear(); candidates.push_back(candidate2); - ASSERT_TRUE(jsep_desc_->RemoveCandidates(candidates)); + ASSERT_TRUE(jsep_desc_->RemoveCandidates("audio", candidates)); EXPECT_EQ("[::1]:1234", media_desc->connection_address().ToString()); candidates.clear(); candidates.push_back(candidate1); - ASSERT_TRUE(jsep_desc_->RemoveCandidates(candidates)); + ASSERT_TRUE(jsep_desc_->RemoveCandidates("audio", candidates)); EXPECT_EQ("0.0.0.0:9", media_desc->connection_address().ToString()); } diff --git a/third_party/libwebrtc/pc/jsep_transport_controller.cc b/third_party/libwebrtc/pc/jsep_transport_controller.cc @@ -1346,7 +1346,7 @@ void JsepTransportController::OnTransportCandidateError_n( void JsepTransportController::OnTransportCandidatesRemoved_n( IceTransportInternal* transport, const Candidates& candidates) { - signal_ice_candidates_removed_.Send(candidates); + signal_ice_candidates_removed_.Send(transport, candidates); } void JsepTransportController::OnTransportCandidatePairChanged_n( const CandidatePairChangeEvent& event) { diff --git a/third_party/libwebrtc/pc/jsep_transport_controller.h b/third_party/libwebrtc/pc/jsep_transport_controller.h @@ -335,8 +335,8 @@ class JsepTransportController : public PayloadTypeSuggester, CallbackList<const IceCandidateErrorEvent&> signal_ice_candidate_error_ RTC_GUARDED_BY(network_thread_); - CallbackList<const std::vector<Candidate>&> signal_ice_candidates_removed_ - RTC_GUARDED_BY(network_thread_); + CallbackList<IceTransportInternal*, const std::vector<Candidate>&> + signal_ice_candidates_removed_ RTC_GUARDED_BY(network_thread_); CallbackList<const CandidatePairChangeEvent&> signal_ice_candidate_pair_changed_ RTC_GUARDED_BY(network_thread_); diff --git a/third_party/libwebrtc/pc/peer_connection.cc b/third_party/libwebrtc/pc/peer_connection.cc @@ -778,12 +778,13 @@ JsepTransportController* PeerConnection::InitializeTransportController_n( })); }); transport_controller_->SubscribeIceCandidatesRemoved( - [this](const std::vector<Candidate>& c) { + [this](IceTransportInternal* transport, const std::vector<Candidate>& c) { RTC_DCHECK_RUN_ON(network_thread()); - signaling_thread()->PostTask( - SafeTask(signaling_thread_safety_.flag(), [this, c = c]() { + std::string mid = transport->transport_name(); + signaling_thread()->PostTask(SafeTask( + signaling_thread_safety_.flag(), [this, mid = mid, c = c]() { RTC_DCHECK_RUN_ON(signaling_thread()); - OnTransportControllerCandidatesRemoved(c); + OnTransportControllerCandidatesRemoved(mid, c); })); }); transport_controller_->SubscribeIceCandidatePairChanged( @@ -2076,12 +2077,24 @@ void PeerConnection::OnIceCandidateError(const std::string& address, } void PeerConnection::OnIceCandidatesRemoved( + absl::string_view mid, const std::vector<Candidate>& candidates) { if (IsClosed()) { return; } - RunWithObserver( - [&](auto observer) { observer->OnIceCandidatesRemoved(candidates); }); + // Since this callback is based on the Candidate type, and not IceCandidate, + // all candidate instances should have the transport_name() property set to + // `mid`. See BasicPortAllocatorSession::PrunePortsAndRemoveCandidates for + // where the list of candidates is initially gathered. + std::vector<Candidate> candidates_for_notification; + candidates_for_notification.reserve(candidates.size()); + for (Candidate candidate : candidates) { // Create a copy. + candidate.set_transport_name(mid); + candidates_for_notification.push_back(candidate); + } + RunWithObserver([&](auto observer) { + observer->OnIceCandidatesRemoved(candidates_for_notification); + }); } void PeerConnection::OnSelectedCandidatePairChanged( @@ -2455,18 +2468,11 @@ void PeerConnection::OnTransportControllerCandidateError( } void PeerConnection::OnTransportControllerCandidatesRemoved( + absl::string_view mid, const std::vector<Candidate>& candidates) { - // Sanity check. - for (const Candidate& candidate : candidates) { - if (candidate.transport_name().empty()) { - RTC_LOG(LS_ERROR) << "OnTransportControllerCandidatesRemoved: " - "empty content name in candidate " - << candidate.ToString(); - return; - } - } - sdp_handler_->RemoveLocalIceCandidates(candidates); - OnIceCandidatesRemoved(candidates); + RTC_DCHECK(!mid.empty()); + sdp_handler_->RemoveLocalIceCandidates(mid, candidates); + OnIceCandidatesRemoved(mid, candidates); } void PeerConnection::OnTransportControllerCandidateChanged( diff --git a/third_party/libwebrtc/pc/peer_connection.h b/third_party/libwebrtc/pc/peer_connection.h @@ -521,7 +521,8 @@ class PeerConnection : public PeerConnectionInternal, const std::string& error_text) RTC_RUN_ON(signaling_thread()); // Some local ICE candidates have been removed. - void OnIceCandidatesRemoved(const std::vector<Candidate>& candidates) + void OnIceCandidatesRemoved(absl::string_view mid, + const std::vector<Candidate>& candidates) RTC_RUN_ON(signaling_thread()); void OnSelectedCandidatePairChanged(const CandidatePairChangeEvent& event) @@ -582,6 +583,7 @@ class PeerConnection : public PeerConnectionInternal, void OnTransportControllerCandidateError(const IceCandidateErrorEvent& event) RTC_RUN_ON(signaling_thread()); void OnTransportControllerCandidatesRemoved( + absl::string_view mid, const std::vector<Candidate>& candidates) RTC_RUN_ON(signaling_thread()); void OnTransportControllerCandidateChanged( const CandidatePairChangeEvent& event) RTC_RUN_ON(signaling_thread()); diff --git a/third_party/libwebrtc/pc/sdp_offer_answer.cc b/third_party/libwebrtc/pc/sdp_offer_answer.cc @@ -3024,8 +3024,11 @@ bool SdpOfferAnswerHandler::RemoveIceCandidates( return false; } - const size_t number_removed = - mutable_remote_description()->RemoveCandidates(candidates); + size_t number_removed = 0u; + for (const auto& c : candidates) { + number_removed += + mutable_remote_description()->RemoveCandidates(c.transport_name(), {c}); + } if (number_removed != candidates.size()) { RTC_LOG(LS_ERROR) << "RemoveIceCandidates: Failed to remove candidates. Requested " @@ -3054,10 +3057,11 @@ void SdpOfferAnswerHandler::AddLocalIceCandidate( } void SdpOfferAnswerHandler::RemoveLocalIceCandidates( + absl::string_view mid, const std::vector<Candidate>& candidates) { RTC_DCHECK_RUN_ON(signaling_thread()); if (local_description()) { - mutable_local_description()->RemoveCandidates(candidates); + mutable_local_description()->RemoveCandidates(mid, candidates); } } diff --git a/third_party/libwebrtc/pc/sdp_offer_answer.h b/third_party/libwebrtc/pc/sdp_offer_answer.h @@ -22,6 +22,7 @@ #include <string> #include <vector> +#include "absl/strings/string_view.h" #include "api/audio_options.h" #include "api/candidate.h" #include "api/jsep.h" @@ -153,7 +154,8 @@ class SdpOfferAnswerHandler : public SdpStateProvider { bool RemoveIceCandidates(const std::vector<Candidate>& candidates); // Adds a locally generated candidate to the local description. void AddLocalIceCandidate(const IceCandidate* candidate); - void RemoveLocalIceCandidates(const std::vector<Candidate>& candidates); + void RemoveLocalIceCandidates(absl::string_view mid, + const std::vector<Candidate>& candidates); bool ShouldFireNegotiationNeededEvent(uint32_t event_id); bool AddStream(MediaStreamInterface* local_stream); diff --git a/third_party/libwebrtc/pc/webrtc_sdp_unittest.cc b/third_party/libwebrtc/pc/webrtc_sdp_unittest.cc @@ -1082,12 +1082,10 @@ class WebRtcSdpTest : public ::testing::Test { jdesc_.candidates(1); ASSERT_NE(nullptr, video_candidates_collection); std::vector<Candidate> video_candidates; - for (size_t i = 0; i < video_candidates_collection->count(); ++i) { - Candidate c = video_candidates_collection->at(i)->candidate(); - c.set_transport_name("video_content_name"); - video_candidates.push_back(c); + for (const auto& c : video_candidates_collection->candidates()) { + video_candidates.push_back(c->candidate()); } - jdesc_.RemoveCandidates(video_candidates); + jdesc_.RemoveCandidates("video_content_name", video_candidates); } // Turns the existing reference description into a description using