toMediaConstraintsMap method

  1. @override
Map<String, dynamic> toMediaConstraintsMap()
override

Implementation

@override
Map<String, dynamic> toMediaConstraintsMap() {
  var constraints = <String, dynamic>{};

  /// in we platform it's not possible to provide optional and mandatory parameters.
  /// deviceId is a mandatory parameter
  if (!kIsWeb || (kIsWeb && deviceId == null)) {
    constraints['optional'] = <Map<String, dynamic>>[
      <String, dynamic>{'echoCancellation': echoCancellation},
      <String, dynamic>{'googDAEchoCancellation': echoCancellation},
      <String, dynamic>{'googEchoCancellation': echoCancellation},
      <String, dynamic>{'googEchoCancellation2': echoCancellation},
      <String, dynamic>{'noiseSuppression': noiseSuppression},
      <String, dynamic>{'googNoiseSuppression': noiseSuppression},
      <String, dynamic>{'googNoiseSuppression2': noiseSuppression},
      <String, dynamic>{'googAutoGainControl': autoGainControl},
      <String, dynamic>{'googHighpassFilter': highPassFilter},
      <String, dynamic>{'googTypingNoiseDetection': typingNoiseDetection},
    ];
  }

  if (deviceId != null) {
    if (kIsWeb) {
      constraints['deviceId'] = deviceId;
    } else {
      constraints['optional']
          .cast<Map<String, dynamic>>()
          .add(<String, dynamic>{'sourceId': deviceId});
    }
  }
  return constraints;
}