Fix cyclic reference in DTLS

This commit is contained in:
Marvin W 2021-03-29 13:14:10 +02:00
parent fc3263d49e
commit fd21eafe26
No known key found for this signature in database
GPG key ID: 072E9235DB996F2A

View file

@ -65,10 +65,7 @@ public class Dino.Plugins.Ice.TransportParameters : JingleIceUdp.IceUdpTransport
this.agent = agent;
if (this.peer_fingerprint != null || !incoming) {
dtls_srtp = DtlsSrtp.setup();
dtls_srtp.send_data.connect((data) => {
agent.send(stream_id, 1, data);
});
dtls_srtp = setup_dtls(this);
this.own_fingerprint = dtls_srtp.get_own_fingerprint(GnuTLS.DigestAlgorithm.SHA256);
if (incoming) {
dtls_srtp.set_peer_fingerprint(this.peer_fingerprint);
@ -105,6 +102,16 @@ public class Dino.Plugins.Ice.TransportParameters : JingleIceUdp.IceUdpTransport
agent.gather_candidates(stream_id);
}
private static DtlsSrtp setup_dtls(TransportParameters tp) {
var weak_self = new WeakRef(tp);
DtlsSrtp dtls_srtp = DtlsSrtp.setup();
dtls_srtp.send_data.connect((data) => {
TransportParameters self = (TransportParameters) weak_self.get();
if (self != null) self.agent.send(self.stream_id, 1, data);
});
return dtls_srtp;
}
private void on_candidate_gathering_done(uint stream_id) {
if (stream_id != this.stream_id) return;
debug("on_candidate_gathering_done in %u", stream_id);