Transport constructor

Transport({
  1. required Direction direction,
  2. required String id,
  3. required IceParameters iceParameters,
  4. required List<IceCandidate> iceCandidates,
  5. required DtlsParameters dtlsParameters,
  6. SctpParameters? sctpParameters,
  7. List<RTCIceServer> iceServers = const <RTCIceServer>[],
  8. RTCIceTransportPolicy? iceTransportPolicy,
  9. Map<String, dynamic> additionalSettings = const <String, dynamic>{},
  10. Map<String, dynamic> proprietaryConstraints = const <String, dynamic>{},
  11. Map<String, dynamic> appData = const <String, dynamic>{},
  12. ExtendedRtpCapabilities? extendedRtpCapabilities,
  13. required CanProduceByKind canProduceByKind,
  14. Function? producerCallback,
  15. Function? consumerCallback,
  16. Function? dataProducerCallback,
  17. Function? dataConsumerCallback,
})

@emits connect - (transportLocalParameters: any, callback: Function, errback: Function) @emits connectionstatechange - (connectionState: ConnectionState) @emits produce - (producerLocalParameters: any, callback: Function, errback: Function) @emits producedata - (dataProducerLocalParameters: any, callback: Function, errback: Function)

Implementation

Transport({
  required Direction direction,
  required String id,
  required IceParameters iceParameters,
  required List<IceCandidate> iceCandidates,
  required DtlsParameters dtlsParameters,
  SctpParameters? sctpParameters,
  List<RTCIceServer> iceServers = const <RTCIceServer>[],
  RTCIceTransportPolicy? iceTransportPolicy,
  Map<String, dynamic> additionalSettings = const <String, dynamic>{},
  Map<String, dynamic> proprietaryConstraints = const <String, dynamic>{},
  Map<String, dynamic> appData = const <String, dynamic>{},
  ExtendedRtpCapabilities? extendedRtpCapabilities,
  required CanProduceByKind canProduceByKind,
  this.producerCallback,
  this.consumerCallback,
  this.dataProducerCallback,
  this.dataConsumerCallback,
}) : super() {
  _logger.debug('constructor() [id:$id, direction:${direction.value}]');

  _id = id;
  _direction = direction;
  _extendedRtpCapabilities = extendedRtpCapabilities;
  _canProduceByKind = canProduceByKind;
  _maxSctpMessageSize = sctpParameters?.maxMessageSize;

  // Clone and sanitize additionalSettings.
  additionalSettings = Map<String, dynamic>.of(additionalSettings);

  additionalSettings.remove('iceServers');
  additionalSettings.remove('iceTransportPolicy');
  additionalSettings.remove('bundlePolicy');
  additionalSettings.remove('rtcpMuxPolicy');
  additionalSettings.remove('sdpSemantics');

  _handler = HandlerInterface.handlerFactory();

  _handler.run(
    options: HandlerRunOptions(
      direction: direction,
      iceParameters: iceParameters,
      iceCandidates: iceCandidates,
      dtlsParameters: dtlsParameters,
      sctpParameters: sctpParameters,
      iceServers: iceServers,
      iceTransportPolicy: iceTransportPolicy,
      additionalSettings: additionalSettings,
      proprietaryConstraints: proprietaryConstraints,
      extendedRtpCapabilities: extendedRtpCapabilities,
    ),
  );

  _appData = appData;

  _handleHandler();
}