turnCameraOn method

void turnCameraOn({
  1. bool? isFront,
})

Implementation

void turnCameraOn({bool? isFront}) async {
  Log().info("turnCameraOn, isFront = $isFront");
  var facingMode = "user";
  if (isFront == null) {
    if (CameraManager().currentFacingMode == null) {
      facingMode = "user";
    } else if (CameraManager().currentFacingMode == "user") {
      facingMode = "user";
    } else {
      facingMode = "environment";
    }
  } else {
    facingMode = isFront ? "user" : "environment";
  }

  CameraManager().cameraShouldOn = true;
  final rtcClient = _webrtcClient;
  if (rtcClient != null) {
    if (rtcClient.peerTransmitType == RtcClientTransmitType.full) {
      await rtcClient.startCameraStream(facingMode: facingMode);
      CameraManager().currentFacingMode = facingMode;
      final localVideoStream = rtcClient.localVideoStream;
      if (localVideoStream != null) {
        Log().info("turnCameraOn, localRenderer setSrcObject");
        _localRenderer?.setSrcObject(stream: null);
        _localRenderer?.setSrcObject(stream: localVideoStream);
        _notifyLocalRendererAdded();
        if (_startedMoment != null) {
          Future.delayed(const Duration(milliseconds: 10), () async {
            sendMuteVideo(isMuted: false);
            await _peerRestartICE();
            _sendPeerSDP();
          });
        }
      }
    }
  }
}