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"