createPeerConnection method

  1. @override
Future<RTCPeerConnection> createPeerConnection(
  1. Map<String, dynamic> configuration, [
  2. Map<String, dynamic> constraints = const {}
])
override

Implementation

@override
Future<RTCPeerConnection> createPeerConnection(
    Map<String, dynamic> configuration,
    [Map<String, dynamic> constraints = const {}]) async {
  var defaultConstraints = <String, dynamic>{
    'mandatory': {},
    'optional': [
      {'DtlsSrtpKeyAgreement': true},
    ],
  };

  final response = await WebRTC.invokeMethod(
    'createPeerConnection',
    <String, dynamic>{
      'configuration': configuration,
      'constraints': constraints.isEmpty ? defaultConstraints : constraints
    },
  );

  String peerConnectionId = response['peerConnectionId'];
  return RTCPeerConnectionNative(peerConnectionId, configuration);
}