CameraCapturerConfiguration
摄像头采集配置。
Java
public class CameraCapturerConfiguration {
public enum CAMERA_DIRECTION {
CAMERA_REAR(0),
CAMERA_FRONT(1),
CAMERA_EXTRA(2);
private int value;
private CAMERA_DIRECTION(int v) {
value = v;
}
@CalledByNative("CAMERA_DIRECTION")
public int getValue() {
return this.value;
}
}
public enum CAMERA_FOCAL_LENGTH_TYPE {
CAMERA_FOCAL_LENGTH_DEFAULT(0),
CAMERA_FOCAL_LENGTH_WIDE_ANGLE(1),
CAMERA_FOCAL_LENGTH_ULTRA_WIDE(2),
CAMERA_FOCAL_LENGTH_TELEPHOTO(3);
private int value;
private CAMERA_FOCAL_LENGTH_TYPE(int v) {
value = v;
}
@CalledByNative("CAMERA_FOCAL_LENGTH_TYPE")
public int getValue() {
return this.value;
}
}
public CAMERA_DIRECTION cameraDirection = null;
public String cameraId = null;
public CAMERA_FOCAL_LENGTH_TYPE cameraFocalLengthType = null;
static public class CaptureFormat {
public int width;
public int height;
public int fps;
public CaptureFormat(int width, int height, int fps) {
this.width = width;
this.height = height;
this.fps = fps;
}
public CaptureFormat() {
this.width = 960;
this.height = 540;
this.fps = 15;
}
@CalledByNative("CaptureFormat")
public int getHeight() {
return height;
}
@CalledByNative("CaptureFormat")
public int getWidth() {
return width;
}
@CalledByNative("CaptureFormat")
public int getFps() {
return fps;
}
@Override
public String toString() {
return "CaptureFormat{"
+ "width=" + width + ", height=" + height + ", fps=" + fps + '}';
}
}
public CaptureFormat captureFormat;
public Boolean followEncodeDimensionRatio = null;
public CameraCapturerConfiguration(CAMERA_DIRECTION cameraDirection) {
this.cameraDirection = cameraDirection;
this.captureFormat = new CaptureFormat(0, 0, 0);
}
public CameraCapturerConfiguration(
CAMERA_DIRECTION cameraDirection, CAMERA_FOCAL_LENGTH_TYPE cameraFocalLengthType) {
this.cameraDirection = cameraDirection;
this.cameraFocalLengthType = cameraFocalLengthType;
this.captureFormat = new CaptureFormat(0, 0, 0);
}
public CameraCapturerConfiguration(CaptureFormat captureFormat) {
this.captureFormat = captureFormat;
}
public CameraCapturerConfiguration(
CAMERA_DIRECTION cameraDirection, CaptureFormat captureFormat) {
this.cameraDirection = cameraDirection;
this.captureFormat = captureFormat;
}
public CameraCapturerConfiguration(CAMERA_DIRECTION cameraDirection,
CAMERA_FOCAL_LENGTH_TYPE cameraFocalLengthType, CaptureFormat captureFormat) {
this.cameraDirection = cameraDirection;
this.cameraFocalLengthType = cameraFocalLengthType;
this.captureFormat = captureFormat;
}
@CalledByNative
public CAMERA_DIRECTION getCameraDirection() {
return cameraDirection;
}
@CalledByNative
public String getCameraId() {
return cameraId;
}
@CalledByNative
public CAMERA_FOCAL_LENGTH_TYPE getCameraFocalLengthType() {
return cameraFocalLengthType;
}
@CalledByNative
public CaptureFormat getCaptureFormat() {
return captureFormat;
}
@CalledByNative
public Boolean isFollowEncodeDimensionRatio() {
return followEncodeDimensionRatio;
}
@Override
public String toString() {
return "CameraCapturerConfiguration{"
+ "cameraDirection=" + cameraDirection + ", captureDimensions=" + captureFormat
+ ", cameraId=" + cameraId + ", followEncodeDimensionRatio=" + followEncodeDimensionRatio
+ ", cameraFocalLengthType=" + cameraFocalLengthType + '}';
}
}
cameraDirection
(可选)摄像头方向。详见 CAMERA_DIRECTION。
cameraId
(可选)摄像头 ID。默认为前置摄像头对应的摄像头 ID。你可以通过 Android 原生系统 API 获取摄像头 ID,详见 Camera.open() 和 CameraManager.getCameraIdList()。
注意
- 该参数和 cameraDirection 均用于指定摄像头,二者为互斥关系,你可以按需选用其中之一,具体区别如下:
- 通过 cameraDirection 指定摄像头的方式更为简便。你只需指定摄像头的方向(前置或后置),无需指定具体的摄像头 ID,SDK 会通过系统 API 去检索和确定实际的摄像头 ID。
- 通过 cameraId 则可以更精确地指定某个特定的摄像头。对于多摄像头的设备,cameraDirection 无法识别或访问全部可用摄像头,这种情况建议使用 cameraId 直接指定你想要的摄像头 ID。
cameraFocalLengthType
(可选)摄像头的焦距类型。详见 CAMERA_FOCAL_LENGTH_TYPE。
注意
- 如需设置摄像头的焦距类型,仅支持通过 cameraDirection 指定摄像头,不支持通过 cameraId 进行指定。
captureFormat
(可选)视频帧格式。详见 CaptureFormat。
followEncodeDimensionRatio
(可选)是否跟随 setVideoEncoderConfiguration 中设置的视频宽高比:
true
:(默认) 跟随。SDK 会将采集到的视频按照已设置的视频宽高比进行裁剪,会同步改变本地预览画面、onCaptureVideoFrame 和 onPreEncodeVideoFrame 中的视频画面。false
:不跟随。SDK不改变采集到的视频帧宽高比。