Revert "Convert P2PTransportChannel Candidate Pair Change to CallbackList"
This reverts commit dc43cb24bd8ee85d6a8224c5928ceaf90de729b6.
Reason for revert: Converted the wrong signal, should have been GatheringState.
Original change's description:
> Convert P2PTransportChannel Candidate Pair Change to CallbackList
>
> Earlier attempts have shown that this signal is multiply listened to.
>
> Bug: webrtc:11943
> Change-Id: If9130a7f4c70714b5afda5aca0469b66c8e2612f
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/347981
> Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
> Commit-Queue: Harald Alvestrand <hta@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#42124}
Bug: webrtc:11943
Change-Id: I73d5d815ced8d7aef4df765c9cf54d7637c6769d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/348220
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#42129}
diff --git a/p2p/base/ice_transport_internal.h b/p2p/base/ice_transport_internal.h
index fecae48..38b6bfe 100644
--- a/p2p/base/ice_transport_internal.h
+++ b/p2p/base/ice_transport_internal.h
@@ -338,15 +338,11 @@
// SignalNetworkRouteChanged.
sigslot::signal2<IceTransportInternal*, const Candidate&> SignalRouteChange;
- void AddCandidatePairChangeCallback(
- const void* removal_tag,
+ void SetCandidatePairChangeCallback(
absl::AnyInvocable<void(const cricket::CandidatePairChangeEvent&)>
callback) {
- candidate_pair_change_callback_list_.AddReceiver(removal_tag,
- std::move(callback));
- }
- void RemoveCandidatePairChangeCallback(const void* removal_tag) {
- candidate_pair_change_callback_list_.RemoveReceivers(removal_tag);
+ RTC_DCHECK(!candidate_pair_change_callback_);
+ candidate_pair_change_callback_ = std::move(callback);
}
// Invoked when there is conflict in the ICE role between local and remote
@@ -389,8 +385,7 @@
protected:
void SendGatheringStateEvent() { SignalGatheringState(this); }
- webrtc::CallbackList<const cricket::CandidatePairChangeEvent&>
- candidate_pair_change_callback_list_;
+
webrtc::CallbackList<IceTransportInternal*,
const StunDictionaryView&,
rtc::ArrayView<uint16_t>>
@@ -406,6 +401,9 @@
absl::AnyInvocable<void(IceTransportInternal*, const Candidates&)>
candidates_removed_callback_;
+ absl::AnyInvocable<void(const cricket::CandidatePairChangeEvent&)>
+ candidate_pair_change_callback_;
+
private:
// TODO(bugs.webrtc.org/11943): remove when removing Signal
void SignalGatheringStateFired(IceTransportInternal* transport) {
diff --git a/p2p/base/p2p_transport_channel.cc b/p2p/base/p2p_transport_channel.cc
index 068e0f3..241b423 100644
--- a/p2p/base/p2p_transport_channel.cc
+++ b/p2p/base/p2p_transport_channel.cc
@@ -1838,7 +1838,9 @@
} else {
pair_change.estimated_disconnected_time_ms = 0;
}
- candidate_pair_change_callback_list_.Send(pair_change);
+ if (candidate_pair_change_callback_) {
+ candidate_pair_change_callback_(pair_change);
+ }
}
++selected_candidate_pair_changes_;
diff --git a/p2p/base/p2p_transport_channel_unittest.cc b/p2p/base/p2p_transport_channel_unittest.cc
index ad4b43b..79ca2a5 100644
--- a/p2p/base/p2p_transport_channel_unittest.cc
+++ b/p2p/base/p2p_transport_channel_unittest.cc
@@ -3326,8 +3326,8 @@
&P2PTransportChannelPingTest::OnReadyToSend);
ch->SignalStateChanged.connect(
this, &P2PTransportChannelPingTest::OnChannelStateChanged);
- ch->AddCandidatePairChangeCallback(
- this, [this](const cricket::CandidatePairChangeEvent& event) {
+ ch->SetCandidatePairChangeCallback(
+ [this](const cricket::CandidatePairChangeEvent& event) {
OnCandidatePairChanged(event);
});
}
diff --git a/pc/jsep_transport_controller.cc b/pc/jsep_transport_controller.cc
index 268f5ff..dae7060 100644
--- a/pc/jsep_transport_controller.cc
+++ b/pc/jsep_transport_controller.cc
@@ -464,8 +464,8 @@
this, &JsepTransportController::OnTransportStateChanged_n);
dtls->ice_transport()->SignalIceTransportStateChanged.connect(
this, &JsepTransportController::OnTransportStateChanged_n);
- dtls->ice_transport()->AddCandidatePairChangeCallback(
- this, [this](const cricket::CandidatePairChangeEvent& event) {
+ dtls->ice_transport()->SetCandidatePairChangeCallback(
+ [this](const cricket::CandidatePairChangeEvent& event) {
RTC_DCHECK_RUN_ON(network_thread_);
OnTransportCandidatePairChanged_n(event);
});