From 09cd060889c27f51d43e1e2dc127c2a13595234d Mon Sep 17 00:00:00 2001 From: Marvin W Date: Sat, 18 Dec 2021 21:39:19 +0100 Subject: [PATCH] ICE: Use non-blocking send --- plugins/ice/src/transport_parameters.vala | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/plugins/ice/src/transport_parameters.vala b/plugins/ice/src/transport_parameters.vala index f42fad64..9aa3dda1 100644 --- a/plugins/ice/src/transport_parameters.vala +++ b/plugins/ice/src/transport_parameters.vala @@ -39,17 +39,23 @@ public class Dino.Plugins.Ice.TransportParameters : JingleIceUdp.IceUdpTransport public override void send_datagram(Bytes datagram) { if (this.agent != null && is_component_ready(agent, stream_id, component_id)) { - uint8[] encrypted_data = null; - if (dtls_srtp_handler != null) { - try { - encrypted_data = dtls_srtp_handler.process_outgoing_data(component_id, datagram.get_data()); + try { + if (dtls_srtp_handler != null) { + uint8[] encrypted_data = dtls_srtp_handler.process_outgoing_data(component_id, datagram.get_data()); if (encrypted_data == null) return; - } catch (Crypto.Error e) { - warning("%s while send_datagram stream %u component %u", e.message, stream_id, component_id); + // TODO: Nonblocking might require certain libnice versions? + GLib.OutputVector[] vectors = {{ encrypted_data, encrypted_data.length }}; + Nice.OutputMessage[] messages = {{ vectors }}; + agent.send_messages_nonblocking(stream_id, component_id, messages); + } else { + GLib.OutputVector[] vectors = {{ datagram.get_data(), datagram.get_size() }}; + Nice.OutputMessage[] messages = {{ vectors }}; + agent.send_messages_nonblocking(stream_id, component_id, messages); } + bytes_sent += datagram.length; + } catch (GLib.Error e) { + warning("%s while send_datagram stream %u component %u", e.message, stream_id, component_id); } - agent.send(stream_id, component_id, encrypted_data ?? datagram.get_data()); - bytes_sent += datagram.length; } } }