Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/expose ice transport policy #441

Merged
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
Loading