CameraCapturerConfiguration

Camera capture configuration.

@JsonSerializable(explicitToJson: true, includeIfNull: false)
class CameraCapturerConfiguration {
  const CameraCapturerConfiguration(
      {this.cameraDirection,
      this.cameraFocalLengthType,
      this.deviceId,
      this.cameraId,
      this.followEncodeDimensionRatio,
      this.format});

  @JsonKey(name: 'cameraDirection')
  final CameraDirection? cameraDirection;

  @JsonKey(name: 'cameraFocalLengthType')
  final CameraFocalLengthType? cameraFocalLengthType;

  @JsonKey(name: 'deviceId')
  final String? deviceId;

  @JsonKey(name: 'cameraId')
  final String? cameraId;

  @JsonKey(name: 'followEncodeDimensionRatio')
  final bool? followEncodeDimensionRatio;

  @JsonKey(name: 'format')
  final VideoFormat? format;

  factory CameraCapturerConfiguration.fromJson(Map<String, dynamic> json) =>
      _$CameraCapturerConfigurationFromJson(json);

  Map<String, dynamic> toJson() => _$CameraCapturerConfigurationToJson(this);
}

Properties

cameraDirection
(Optional) Camera direction. See CameraDirection.
Note: This parameter is only applicable to Android and iOS platforms.
cameraId
(Optional) Camera ID. Defaults to the front camera's ID. You can get the camera ID using Android native system APIs. See Camera.open()) and CameraManager.getCameraIdList().
Note:
  • This parameter is only applicable to Android.
  • This parameter and cameraDirection are both used to specify the camera and are mutually exclusive. You can choose either one as needed. The differences are:
  • Using cameraDirection is simpler. You only need to specify the direction (front or rear), and the SDK will determine the actual camera ID via system APIs.
  • Using cameraId allows you to specify a particular camera more precisely. On multi-camera devices, cameraDirection may not detect or access all available cameras. In such cases, it's recommended to use cameraId to directly specify the desired camera ID.
cameraFocalLengthType
(Optional) Camera focal length type. See CameraFocalLengthType.
Note:
  • This parameter is only applicable to Android and iOS.
  • To set the camera focal length type, you can only use cameraDirection to specify the camera. cameraId is not supported.
  • Some iOS devices have composite rear cameras, such as dual (wide and ultra-wide) or triple (wide, ultra-wide, and telephoto). For such composite lenses with ultra-wide capabilities, you can achieve ultra-wide capture using either of the following methods:
  • Method 1: Set this parameter to cameraFocalLengthUltraWide (2) (ultra-wide lens).
  • Method 2: Set this parameter to cameraFocalLengthDefault (0) (standard lens), then call setCameraZoomFactor to set the zoom factor to a value less than 1.0, with a minimum of 0.5.
The difference is that Method 1 has a fixed ultra-wide view, while Method 2 allows flexible zoom adjustment.
format
(Optional) Video frame format. See VideoFormat.
deviceId
(Optional) Camera ID. Maximum length is MaxDeviceIdLengthType.
Note: This parameter is only applicable to Windows and macOS.
followEncodeDimensionRatio
(Optional) Whether to follow the video aspect ratio set in setVideoEncoderConfiguration:
  • true: (Default) Follow. The SDK crops the captured video to match the configured aspect ratio. This also affects local preview, onCaptureVideoFrame, and onPreEncodeVideoFrame.
  • false: Do not follow. The SDK does not change the aspect ratio of the captured video frames.