From 11b02e6dfae4506653f533c1595d5241c5bcdbfb Mon Sep 17 00:00:00 2001 From: Matthias Schicker Date: Tue, 28 May 2024 11:56:37 +0200 Subject: [PATCH] Feature/expose ice transport policy (#441) * #376: Added `_settings.session_timers_refresh_method` to UaSettings to expose this feature for users of SipUaHelper * Reformatted sip_ua_helper to get build pipeline to run * Updated some dependencies * More dependency updates * Exposed 'iceTransportPolicy' UaSettings to allow for restricting acceptable ice candidates * Removed inadvertently added empty lines --------- Co-authored-by: Matthias Schicker --- lib/src/sip_ua_helper.dart | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/lib/src/sip_ua_helper.dart b/lib/src/sip_ua_helper.dart index 9b2b9005..61fbe77c 100644 --- a/lib/src/sip_ua_helper.dart +++ b/lib/src/sip_ua_helper.dart @@ -2,11 +2,11 @@ import 'dart:async'; import 'package:flutter_webrtc/flutter_webrtc.dart'; import 'package:logger/logger.dart'; - import 'package:sip_ua/sip_ua.dart'; import 'package:sip_ua/src/map_helper.dart'; import 'package:sip_ua/src/transports/socket_interface.dart'; import 'package:sip_ua/src/transports/tcp_socket.dart'; + import 'config.dart'; import 'constants.dart' as DartSIP_C; import 'event_manager/event_manager.dart'; @@ -331,6 +331,9 @@ class SIPUAHelper extends EventManager { 'extraHeaders': [], 'pcConfig': { 'sdpSemantics': 'unified-plan', + 'iceTransportPolicy': + (_uaSettings?.iceTransportPolicy ?? IceTransportPolicy.ALL) + .toParameterString(), 'iceServers': _uaSettings?.iceServers }, 'mediaConstraints': { @@ -724,6 +727,31 @@ enum DtmfMode { RFC2833, } +/// Possible values for the transport policy to be used when selecting ICE +/// candidates. +/// +/// See: https://udn.realityripple.com/docs/Web/API/RTCConfiguration +enum IceTransportPolicy { + /// All ICE candidates will be considered. + /// This is the default if not specified explicitly. + ALL, + + /// Only ICE candidates whose IP addresses are being relayed, such as those + /// being passed through a TURN server, will be considered. + RELAY, +} + +extension _IceTransportPolicyEncoding on IceTransportPolicy { + String toParameterString() { + switch (this) { + case IceTransportPolicy.ALL: + return 'all'; + case IceTransportPolicy.RELAY: + return 'relay'; + } + } +} + class UaSettings { WebSocketSettings webSocketSettings = WebSocketSettings(); TcpSocketSettings tcpSocketSettings = TcpSocketSettings(); @@ -776,6 +804,11 @@ class UaSettings { // }, ]; + /// Defines the transport policy to be used for ICE. + /// See [IceTransportPolicy] for possible values. + /// Will default to [IceTransportPolicy.ALL] if not specified. + IceTransportPolicy? iceTransportPolicy; + /// Controls which kind of messages are to be sent to keep a SIP session /// alive. /// Defaults to "UPDATE"