switchCamera method

Future<void> switchCamera(
  1. String deviceId,
  2. {bool fastSwitch = false}
)

Implementation

Future<void> switchCamera(String deviceId, {bool fastSwitch = false}) async {
  final options = currentOptions;
  if (options is! CameraCaptureOptions) {
    logger.warning('Not a camera track');
    return;
  }

  if (fastSwitch) {
    currentOptions = options.copyWith(deviceId: deviceId);
    await rtc.Helper.switchCamera(mediaStreamTrack, deviceId, mediaStream);
    return;
  }

  await restartTrack(
    options.copyWith(deviceId: deviceId),
  );

  await replaceTrackForMultiCodecSimulcast(mediaStreamTrack);
}