Use CallbackList for DtlsState in dtls_transport.

- This contains a CallbackList disconnect and handled it
  by taking the given subscription tag to subscribe and unsubscribe.
- Left the original sigslot variable until downstream is update after
  this change.

Bug: webrtc:11943
No-Try: True
Change-Id: Ie96d74b9594eae11beaa552f61e40f451242bfab
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/203780
Commit-Queue: Lahiru Ginnaliya Gamathige <glahiru@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33285}
This commit is contained in:
Lahiru Ginnaliya Gamathige
2021-02-16 07:29:08 -08:00
committed by Commit Bot
parent 46e5a2f3f4
commit 60c0b442ee
6 changed files with 40 additions and 7 deletions

View File

@ -817,6 +817,7 @@ void DtlsTransport::set_dtls_state(DtlsTransportState state) {
<< " to " << state;
dtls_state_ = state;
SignalDtlsState(this, state);
SendDtlsState(this, state);
}
void DtlsTransport::OnDtlsHandshakeError(rtc::SSLHandshakeError error) {

View File

@ -115,6 +115,25 @@ class DtlsTransportInternal : public rtc::PacketTransportInternal {
virtual IceTransportInternal* ice_transport() = 0;
sigslot::signal2<DtlsTransportInternal*, DtlsTransportState> SignalDtlsState;
// F: void(DtlsTransportInternal*, const DtlsTransportState)
template <typename F>
void SubscribeDtlsState(F&& callback) {
dtls_state_callback_list_.AddReceiver(std::forward<F>(callback));
}
template <typename F>
void SubscribeDtlsState(const void* id, F&& callback) {
dtls_state_callback_list_.AddReceiver(id, std::forward<F>(callback));
}
// Unsubscribe the subscription with given id.
void UnsubscribeDtlsState(const void* id) {
dtls_state_callback_list_.RemoveReceivers(id);
}
void SendDtlsState(DtlsTransportInternal* transport,
DtlsTransportState state) {
dtls_state_callback_list_.Send(transport, state);
}
// Emitted whenever the Dtls handshake failed on some transport channel.
// F: void(rtc::SSLHandshakeError)
@ -134,6 +153,8 @@ class DtlsTransportInternal : public rtc::PacketTransportInternal {
RTC_DISALLOW_COPY_AND_ASSIGN(DtlsTransportInternal);
webrtc::CallbackList<const rtc::SSLHandshakeError>
dtls_handshake_error_callback_list_;
webrtc::CallbackList<DtlsTransportInternal*, const DtlsTransportState>
dtls_state_callback_list_;
};
} // namespace cricket

View File

@ -86,6 +86,7 @@ class FakeDtlsTransport : public DtlsTransportInternal {
void SetDtlsState(DtlsTransportState state) {
dtls_state_ = state;
SignalDtlsState(this, dtls_state_);
SendDtlsState(this, dtls_state_);
}
// Simulates the two DTLS transports connecting to each other.