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:

committed by
Commit Bot

parent
46e5a2f3f4
commit
60c0b442ee
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -277,14 +277,17 @@ void DtlsSrtpTransport::SetDtlsTransport(
|
||||
}
|
||||
|
||||
if (*old_dtls_transport) {
|
||||
(*old_dtls_transport)->SignalDtlsState.disconnect(this);
|
||||
(*old_dtls_transport)->UnsubscribeDtlsState(this);
|
||||
}
|
||||
|
||||
*old_dtls_transport = new_dtls_transport;
|
||||
|
||||
if (new_dtls_transport) {
|
||||
new_dtls_transport->SignalDtlsState.connect(
|
||||
this, &DtlsSrtpTransport::OnDtlsState);
|
||||
new_dtls_transport->SubscribeDtlsState(
|
||||
this, [this](cricket::DtlsTransportInternal* transport,
|
||||
cricket::DtlsTransportState state) {
|
||||
OnDtlsState(transport, state);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,8 +51,11 @@ DtlsTransport::DtlsTransport(
|
||||
ice_transport_(new rtc::RefCountedObject<IceTransportWithPointer>(
|
||||
internal_dtls_transport_->ice_transport())) {
|
||||
RTC_DCHECK(internal_dtls_transport_.get());
|
||||
internal_dtls_transport_->SignalDtlsState.connect(
|
||||
this, &DtlsTransport::OnInternalDtlsState);
|
||||
internal_dtls_transport_->SubscribeDtlsState(
|
||||
[this](cricket::DtlsTransportInternal* transport,
|
||||
cricket::DtlsTransportState state) {
|
||||
OnInternalDtlsState(transport, state);
|
||||
});
|
||||
UpdateInformation();
|
||||
}
|
||||
|
||||
|
@ -94,8 +94,12 @@ void SctpTransport::SetDtlsTransport(
|
||||
if (internal_sctp_transport_) {
|
||||
if (transport) {
|
||||
internal_sctp_transport_->SetDtlsTransport(transport->internal());
|
||||
transport->internal()->SignalDtlsState.connect(
|
||||
this, &SctpTransport::OnDtlsStateChange);
|
||||
|
||||
transport->internal()->SubscribeDtlsState(
|
||||
[this](cricket::DtlsTransportInternal* transport,
|
||||
cricket::DtlsTransportState state) {
|
||||
OnDtlsStateChange(transport, state);
|
||||
});
|
||||
if (info_.state() == SctpTransportState::kNew) {
|
||||
next_state = SctpTransportState::kConnecting;
|
||||
}
|
||||
|
Reference in New Issue
Block a user