Skip to content

Commit

Permalink
Feature/expose ice transport policy (#441)
Browse files Browse the repository at this point in the history
* #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 <[email protected]>
  • Loading branch information
komaxx and Matthias Schicker authored May 28, 2024
1 parent f0f6751 commit 11b02e6
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion lib/src/sip_ua_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -331,6 +331,9 @@ class SIPUAHelper extends EventManager {
'extraHeaders': <dynamic>[],
'pcConfig': <String, dynamic>{
'sdpSemantics': 'unified-plan',
'iceTransportPolicy':
(_uaSettings?.iceTransportPolicy ?? IceTransportPolicy.ALL)
.toParameterString(),
'iceServers': _uaSettings?.iceServers
},
'mediaConstraints': <String, dynamic>{
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 11b02e6

Please sign in to comment.