FCameraCapturerConfiguration
摄像头采集配置。
C++
USTRUCT(BlueprintType)
struct FCameraCapturerConfiguration
{
GENERATED_BODY()
public:
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|CameraCapturerConfiguration")
ECAMERA_DIRECTION cameraDirection = ECAMERA_DIRECTION::CAMERA_FRONT;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|CameraCapturerConfiguration")
ECAMERA_FOCAL_LENGTH_TYPE cameraFocalLengthType = ECAMERA_FOCAL_LENGTH_TYPE::CAMERA_FOCAL_LENGTH_DEFAULT;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|CameraCapturerConfiguration")
bool deviceId_SetValue = false;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|CameraCapturerConfiguration")
FString deviceId = "";
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|CameraCapturerConfiguration")
bool cameraId_SetValue = false;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|CameraCapturerConfiguration")
FString cameraId = "";
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|CameraCapturerConfiguration")
FVideoFormat format = FVideoFormat();
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|ChannelMediaOptions")
EAgoraOptional followEncodeDimensionRatio = EAgoraOptional::AGORA_NULL_VALUE;
FCameraCapturerConfiguration(){}
FCameraCapturerConfiguration(const agora::rtc::CameraCapturerConfiguration & AgoraData){
#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS)
cameraDirection = static_cast<ECAMERA_DIRECTION>(AgoraData.cameraDirection.value());
cameraFocalLengthType = static_cast<ECAMERA_FOCAL_LENGTH_TYPE>(AgoraData.cameraFocalLengthType.value());
#else
SET_UEBP_OPTIONAL_VAL_FString(this->deviceId, AgoraData.deviceId);
#endif
#if defined(__ANDROID__)
cameraId = UTF8_TO_TCHAR(AgoraData.cameraId.value());
#endif
format = FVideoFormat(AgoraData.format);
SET_UEBP_OPTIONAL_VAL_BOOL(followEncodeDimensionRatio ,AgoraData.followEncodeDimensionRatio)
}
agora::rtc::CameraCapturerConfiguration CreateAgoraData() const {
agora::rtc::CameraCapturerConfiguration AgoraData;
#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS)
AgoraData.cameraDirection = static_cast<agora::rtc::CAMERA_DIRECTION>(cameraDirection);
AgoraData.cameraFocalLengthType = static_cast<agora::rtc::CAMERA_FOCAL_LENGTH_TYPE>(cameraFocalLengthType);
#else
SET_AGORA_OPTIONAL_VAL_CHARPTR______MEMOALLOC(AgoraData.deviceId, this->deviceId)
#endif
#if defined(__ANDROID__)
SET_AGORA_OPTIONAL_VAL_CHARPTR______MEMOALLOC(
AgoraData.cameraId,this->cameraId)
#endif
AgoraData.format = format.CreateAgoraData();
SET_AGORA_OPTIONAL_VAL_BOOL(AgoraData.followEncodeDimensionRatio, this->followEncodeDimensionRatio)
return AgoraData;
}
void FreeAgoraData(agora::rtc::CameraCapturerConfiguration& AgoraData) const {
format.FreeAgoraData(AgoraData.format);
#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS)
#else
SET_AGORA_OPTIONAL_VAL_CHARPTR______MEMOFREE(AgoraData.deviceId)
#endif
#if defined(__ANDROID__)
SET_AGORA_OPTIONAL_VAL_CHARPTR______MEMOFREE(AgoraData.cameraId)
#endif
}
};
cameraDirection
(可选)摄像头方向。详见 ECAMERA_DIRECTION。
注意
该参数仅适用于 Android 和 iOS 平台。
cameraId
(可选)摄像头 ID。默认为前置摄像头对应的摄像头 ID。你可以通过 Android 原生系统 API 获取摄像头 ID,详见 Camera.open() 和 CameraManager.getCameraIdList()。
注意
- 该参数仅适用于 Android。
- 该参数和 cameraDirection 均用于指定摄像头,二者为互斥关系,你可以按需选用其中之一,具体区别如下:
- 通过 cameraDirection 指定摄像头的方式更为简便。你只需指定摄像头的方向(前置或后置),无需指定具体的摄像头 ID,SDK 会通过系统 API 去检索和确定实际的摄像头 ID。
- 通过 cameraId 则可以更精确地指定某个特定的摄像头。对于多摄像头的设备,cameraDirection 无法识别或访问全部可用摄像头,这种情况建议使用 cameraId 直接指定你想要的摄像头 ID。
cameraFocalLengthType
(可选)摄像头的焦距类型。详见 ECAMERA_FOCAL_LENGTH_TYPE。
注意
- 该参数仅适用于 Android 和 iOS。
- 如需设置摄像头的焦距类型,仅支持通过 cameraDirection 指定摄像头,不支持通过 cameraId 进行指定。
- 部分 iOS 设备的后置摄像头为多个摄像头组成的融合镜头,如双摄(广角和超广角)或三摄(广角、超广角和长焦),对于这种具备超广角能力的融合镜头,你可以通过以下任意一种方式实现超广角的采集效果:
- 方式一:将该参数设置为 CAMERA_FOCAL_LENGTH_ULTRA_WIDE (2)(超广角镜头)。
- 方式二:将该参数设置为 CAMERA_FOCAL_LENGTH_DEFAULT (0)(标准镜头),然后调用 SetCameraZoomFactor 将相机缩放比例设置为小于 1.0 的数值,最小可以设置为 0.5。
format
(可选)视频帧格式。详见 FVideoFormat。
deviceId
(可选)摄像头的 ID。
注意
该参数仅适用于 Windows 和 macOS。
followEncodeDimensionRatio
(可选)是否跟随 SetVideoEncoderConfiguration 中设置的视频宽高比:
true
:(默认) 跟随。SDK 会将采集到的视频按照已设置的视频宽高比进行裁剪。false
:不跟随。SDK不改变采集到的视频帧宽高比。