FVideoCanvas
视频画布对象的属性。
C++
USTRUCT(BlueprintType)
struct FVideoCanvas
{
GENERATED_BODY()
public:
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|VideoCanvas")
int64 uid = 0;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|VideoCanvas")
int64 subviewUid = 0;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|VideoCanvas")
UImage* view = nullptr;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|VideoCanvas")
int64 backgroundColor = 0;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|VideoCanvas")
ERENDER_MODE_TYPE renderMode = ERENDER_MODE_TYPE::RENDER_MODE_HIDDEN;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|VideoCanvas")
EVIDEO_MIRROR_MODE_TYPE mirrorMode = EVIDEO_MIRROR_MODE_TYPE::VIDEO_MIRROR_MODE_AUTO;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|VideoCanvas")
EVIDEO_VIEW_SETUP_MODE setupMode = EVIDEO_VIEW_SETUP_MODE::VIDEO_VIEW_SETUP_REPLACE;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|VideoCanvas")
EVIDEO_SOURCE_TYPE sourceType = EVIDEO_SOURCE_TYPE::VIDEO_SOURCE_CAMERA_PRIMARY;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|VideoCanvas")
int mediaPlayerId = 0;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|VideoCanvas")
FRectangle cropArea;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|VideoCanvas")
bool enableAlphaMask = false;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|VideoCanvas")
EVIDEO_MODULE_POSITION position = EVIDEO_MODULE_POSITION::POSITION_POST_CAPTURER;
FVideoCanvas(){}
FVideoCanvas(const agora::rtc::VideoCanvas & AgoraData){
view = nullptr; uid = AgoraData.uid;
subviewUid = AgoraData.subviewUid;
backgroundColor = AgoraData.backgroundColor;
renderMode = static_cast<ERENDER_MODE_TYPE>(AgoraData.renderMode);
mirrorMode = static_cast<EVIDEO_MIRROR_MODE_TYPE>(AgoraData.mirrorMode);
setupMode = static_cast<EVIDEO_VIEW_SETUP_MODE>(AgoraData.setupMode);
sourceType = static_cast<EVIDEO_SOURCE_TYPE>(AgoraData.sourceType);
mediaPlayerId = AgoraData.mediaPlayerId;
cropArea = FRectangle(AgoraData.cropArea);
enableAlphaMask = AgoraData.enableAlphaMask;
position = static_cast<EVIDEO_MODULE_POSITION>(AgoraData.position);
}
agora::rtc::VideoCanvas CreateAgoraData() const {
agora::rtc::VideoCanvas AgoraData;
AgoraData.view = (agora::view_t) view;
AgoraData.uid = uid;
AgoraData.subviewUid = subviewUid;
AgoraData.backgroundColor = backgroundColor;
AgoraData.renderMode = static_cast<agora::media::base::RENDER_MODE_TYPE>(renderMode);
AgoraData.mirrorMode = static_cast<agora::rtc::VIDEO_MIRROR_MODE_TYPE>(mirrorMode);
AgoraData.setupMode = static_cast<agora::rtc::VIDEO_VIEW_SETUP_MODE>(setupMode);
AgoraData.sourceType = static_cast<agora::rtc::VIDEO_SOURCE_TYPE>(sourceType);
AgoraData.mediaPlayerId = AgoraData.mediaPlayerId;
AgoraData.cropArea = cropArea.CreateAgoraData();
AgoraData.enableAlphaMask = enableAlphaMask;
AgoraData.position = static_cast<agora::media::base::VIDEO_MODULE_POSITION>(position);
return AgoraData;
}
void FreeAgoraData(agora::rtc::VideoCanvas& AgoraData) const {
cropArea.FreeAgoraData(AgoraData.cropArea);
}
};
uid
发布视频源的用户 ID。
subviewUid
发布某一路合图子视频流的用户 ID。
view
视频图像。你需要定义 UImage 类型的指针,并传入该参数,示例代码如下:
agora::rtc::VideoCanvas videoCanvas; UImage* LocalVideo; videoCanvas.view = LocalVideo;
renderMode
视频渲染模式,详见 ERENDER_MODE_TYPE。
mirrorMode
视图镜像模式,详见 EVIDEO_MIRROR_MODE_TYPE。
注意
该参数不生效。如需实现镜像显示效果,请在 Unreal Engine 中进行镜像设置。
注意
- 本地视图镜像模式:如果你使用前置摄像头,默认启动本地视图镜像模式;如果你使用后置摄像头,默认关闭本地视图镜像模式。
- 远端用户视图镜像模式:默认关闭远端用户的镜像模式。
sourceType
视频源的类型,详见 EVIDEO_SOURCE_TYPE。
setupMode
视图设置模式。详见 EVIDEO_VIEW_SETUP_MODE。
cropArea
backgroundColor
视频画布的背景颜色,格式为 RGBA。默认值为 0x00000000,代表完全透明的黑色。
enableAlphaMask
(可选)是否开启 Alpha 遮罩渲染:
true
:开启 Alpha 遮罩渲染。false
:(默认)关闭 Alpha 遮罩渲染。
Alpha 遮罩渲染可以创建具有透明效果的图像,还可以提取视频中的人像。与其他方法结合使用时,可以实现人像画中画、添加水印等效果。
注意
- 仅当发送端开启 Alpha 传输功能时,接收端才能渲染 Alpha 通道的信息。
- 如需开启 Alpha 传输功能,请联系技术支持。
position
视频帧在视频链路中的位置。详见 EVIDEO_MODULE_POSITION。