From 96dca920468c2d8fbaa7b1bfde4958f26c7e05af Mon Sep 17 00:00:00 2001 From: Mirko Bonadei Date: Sat, 10 Jul 2021 22:37:40 +0200 Subject: [PATCH] [sigslot] - Remove sigslot from JsepTransport. Bug: webrtc:11943 Change-Id: I59231cf0d5b700d0ef2feb94d9619b8b4d30d655 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/225552 Reviewed-by: Harald Alvestrand Commit-Queue: Mirko Bonadei Cr-Commit-Position: refs/heads/master@{#34529} --- pc/jsep_transport.cc | 11 +++++++---- pc/jsep_transport.h | 19 ++++++++++--------- pc/jsep_transport_controller.cc | 7 ++++--- pc/jsep_transport_unittest.cc | 5 ++--- 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/pc/jsep_transport.cc b/pc/jsep_transport.cc index e72088885f..f0a062eaaa 100644 --- a/pc/jsep_transport.cc +++ b/pc/jsep_transport.cc @@ -13,8 +13,9 @@ #include #include +#include #include -#include // for std::pair +#include #include "api/array_view.h" #include "api/candidate.h" @@ -80,7 +81,8 @@ JsepTransport::JsepTransport( std::unique_ptr dtls_srtp_transport, std::unique_ptr rtp_dtls_transport, std::unique_ptr rtcp_dtls_transport, - std::unique_ptr sctp_transport) + std::unique_ptr sctp_transport, + std::function rtcp_mux_active_callback) : network_thread_(rtc::Thread::Current()), mid_(mid), local_certificate_(local_certificate), @@ -104,7 +106,8 @@ JsepTransport::JsepTransport( sctp_transport_(sctp_transport ? rtc::make_ref_counted( std::move(sctp_transport)) - : nullptr) { + : nullptr), + rtcp_mux_active_callback_(std::move(rtcp_mux_active_callback)) { TRACE_EVENT0("webrtc", "JsepTransport::JsepTransport"); RTC_DCHECK(ice_transport_); RTC_DCHECK(rtp_dtls_transport_); @@ -487,7 +490,7 @@ void JsepTransport::ActivateRtcpMux() { } rtcp_dtls_transport_ = nullptr; // Destroy this reference. // Notify the JsepTransportController to update the aggregate states. - SignalRtcpMuxActive(); + rtcp_mux_active_callback_(); } bool JsepTransport::SetSdes(const std::vector& cryptos, diff --git a/pc/jsep_transport.h b/pc/jsep_transport.h index 5e8cae0ecf..fe6f5829e1 100644 --- a/pc/jsep_transport.h +++ b/pc/jsep_transport.h @@ -11,6 +11,7 @@ #ifndef PC_JSEP_TRANSPORT_H_ #define PC_JSEP_TRANSPORT_H_ +#include #include #include #include @@ -47,7 +48,6 @@ #include "rtc_base/rtc_certificate.h" #include "rtc_base/ssl_fingerprint.h" #include "rtc_base/ssl_stream_adapter.h" -#include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/thread.h" #include "rtc_base/thread_annotations.h" @@ -86,7 +86,7 @@ struct JsepTransportDescription { // // On Threading: JsepTransport performs work solely on the network thread, and // so its methods should only be called on the network thread. -class JsepTransport : public sigslot::has_slots<> { +class JsepTransport { public: // |mid| is just used for log statements in order to identify the Transport. // Note that |local_certificate| is allowed to be null since a remote @@ -101,9 +101,10 @@ class JsepTransport : public sigslot::has_slots<> { std::unique_ptr dtls_srtp_transport, std::unique_ptr rtp_dtls_transport, std::unique_ptr rtcp_dtls_transport, - std::unique_ptr sctp_transport); + std::unique_ptr sctp_transport, + std::function rtcp_mux_active_callback); - ~JsepTransport() override; + ~JsepTransport(); // Returns the MID of this transport. This is only used for logging. const std::string& mid() const { return mid_; } @@ -226,11 +227,6 @@ class JsepTransport : public sigslot::has_slots<> { return nullptr; } - // This is signaled when RTCP-mux becomes active and - // |rtcp_dtls_transport_| is destroyed. The JsepTransportController will - // handle the signal and update the aggregate transport states. - sigslot::signal<> SignalRtcpMuxActive; - // TODO(deadbeef): The methods below are only public for testing. Should make // them utility functions or objects so they can be tested independently from // this class. @@ -326,6 +322,11 @@ class JsepTransport : public sigslot::has_slots<> { absl::optional> recv_extension_ids_ RTC_GUARDED_BY(network_thread_); + // This is invoked when RTCP-mux becomes active and + // |rtcp_dtls_transport_| is destroyed. The JsepTransportController will + // receive the callback and update the aggregate transport states. + std::function rtcp_mux_active_callback_; + RTC_DISALLOW_COPY_AND_ASSIGN(JsepTransport); }; diff --git a/pc/jsep_transport_controller.cc b/pc/jsep_transport_controller.cc index 95cf21587d..47fddd4e3e 100644 --- a/pc/jsep_transport_controller.cc +++ b/pc/jsep_transport_controller.cc @@ -1056,13 +1056,14 @@ RTCError JsepTransportController::MaybeCreateJsepTransport( content_info.name, certificate_, std::move(ice), std::move(rtcp_ice), std::move(unencrypted_rtp_transport), std::move(sdes_transport), std::move(dtls_srtp_transport), std::move(rtp_dtls_transport), - std::move(rtcp_dtls_transport), std::move(sctp_transport)); + std::move(rtcp_dtls_transport), std::move(sctp_transport), [&]() { + RTC_DCHECK_RUN_ON(network_thread_); + UpdateAggregateStates_n(); + }); jsep_transport->rtp_transport()->SignalRtcpPacketReceived.connect( this, &JsepTransportController::OnRtcpPacketReceived_n); - jsep_transport->SignalRtcpMuxActive.connect( - this, &JsepTransportController::UpdateAggregateStates_n); transports_.RegisterTransport(content_info.name, std::move(jsep_transport)); UpdateAggregateStates_n(); return RTCError::OK(); diff --git a/pc/jsep_transport_unittest.cc b/pc/jsep_transport_unittest.cc index 5f4334068a..ffca560cdd 100644 --- a/pc/jsep_transport_unittest.cc +++ b/pc/jsep_transport_unittest.cc @@ -118,11 +118,10 @@ class JsepTransport2Test : public ::testing::Test, public sigslot::has_slots<> { std::move(rtcp_ice), std::move(unencrypted_rtp_transport), std::move(sdes_transport), std::move(dtls_srtp_transport), std::move(rtp_dtls_transport), std::move(rtcp_dtls_transport), - /*sctp_transport=*/nullptr); + /*sctp_transport=*/nullptr, + /*rtcp_mux_active_callback=*/[&]() { OnRtcpMuxActive(); }); signal_rtcp_mux_active_received_ = false; - jsep_transport->SignalRtcpMuxActive.connect( - this, &JsepTransport2Test::OnRtcpMuxActive); return jsep_transport; }