Remove DtlsHandShakeError and replace it with a Function Pointer.

- Remove the last sigslot from JsepTransportController.
- Tested the potential test failure on chromium blink test by importing
  this CL to chromium source.

Bug: webrtc:11943
Change-Id: I107d05606350aff655ca73a5cb640dff1a7036ee
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/202741
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33085}
This commit is contained in:
Lahiru Ginnaliya Gamathige
2021-01-27 23:32:46 -08:00
parent b70c9531ee
commit 70f9e249d5
5 changed files with 16 additions and 8 deletions

View File

@ -87,6 +87,7 @@ JsepTransportController::JsepTransportController(
RTC_DCHECK(config_.transport_observer);
RTC_DCHECK(config_.rtcp_handler);
RTC_DCHECK(config_.ice_transport_factory);
RTC_DCHECK(config_.on_dtls_handshake_error_);
}
JsepTransportController::~JsepTransportController() {
@ -1411,7 +1412,7 @@ void JsepTransportController::OnRtcpPacketReceived_n(
void JsepTransportController::OnDtlsHandshakeError(
rtc::SSLHandshakeError error) {
SignalDtlsHandshakeError(error);
config_.on_dtls_handshake_error_(error);
}
} // namespace webrtc

View File

@ -103,6 +103,7 @@ class JsepTransportController : public sigslot::has_slots<> {
// Factory for SCTP transports.
SctpTransportFactoryInterface* sctp_factory = nullptr;
std::function<void(const rtc::SSLHandshakeError)> on_dtls_handshake_error_;
};
// The ICE related events are signaled on the |signaling_thread|.
@ -192,8 +193,6 @@ class JsepTransportController : public sigslot::has_slots<> {
// and deletes unused transports, but doesn't consider anything more complex.
void RollbackTransports();
sigslot::signal1<rtc::SSLHandshakeError> SignalDtlsHandshakeError;
// F: void(const std::string&, const std::vector<cricket::Candidate>&)
template <typename F>
void SubscribeIceCandidateGathered(F&& callback) {

View File

@ -82,6 +82,7 @@ class JsepTransportControllerTest : public JsepTransportController::Observer,
int64_t packet_time_us) { RTC_NOTREACHED(); };
config.ice_transport_factory = fake_ice_transport_factory_.get();
config.dtls_transport_factory = fake_dtls_transport_factory_.get();
config.on_dtls_handshake_error_ = [](rtc::SSLHandshakeError s) {};
transport_controller_ = std::make_unique<JsepTransportController>(
signaling_thread, network_thread, port_allocator,
nullptr /* async_resolver_factory */, config);

View File

@ -453,7 +453,8 @@ PeerConnection::PeerConnection(
call_(std::move(call)),
call_ptr_(call_.get()),
data_channel_controller_(this),
message_handler_(signaling_thread()) {}
message_handler_(signaling_thread()),
weak_factory_(this) {}
PeerConnection::~PeerConnection() {
TRACE_EVENT0("webrtc", "PeerConnection::~PeerConnection");
@ -602,18 +603,22 @@ RTCError PeerConnection::Initialize(
}
config.ice_transport_factory = ice_transport_factory_.get();
config.on_dtls_handshake_error_ =
[weak_ptr = weak_factory_.GetWeakPtr()](rtc::SSLHandshakeError s) {
if (weak_ptr) {
weak_ptr->OnTransportControllerDtlsHandshakeError(s);
}
};
transport_controller_.reset(new JsepTransportController(
signaling_thread(), network_thread(), port_allocator_.get(),
async_resolver_factory_.get(), config));
transport_controller_->SignalDtlsHandshakeError.connect(
this, &PeerConnection::OnTransportControllerDtlsHandshakeError);
// Following RTC_DCHECKs are added by looking at the caller thread.
// The following RTC_DCHECKs are added by looking at the caller thread.
// If this is incorrect there might not be test failures
// due to lack of unit tests which trigger these scenarios.
// TODO(bugs.webrtc.org/12160): Remove above comments.
// callbacks for signaling_thread.
transport_controller_->SubscribeIceConnectionState(
[this](cricket::IceConnectionState s) {
RTC_DCHECK_RUN_ON(signaling_thread());

View File

@ -692,6 +692,8 @@ class PeerConnection : public PeerConnectionInternal,
// Administration of senders, receivers and transceivers
// Accessed on both signaling and network thread. Const after Initialize().
std::unique_ptr<RtpTransmissionManager> rtp_manager_;
rtc::WeakPtrFactory<PeerConnection> weak_factory_;
};
} // namespace webrtc