产品动态
关于腾讯特效 SDK V3.5 版本更新公告
关于腾讯特效 SDK V3.0 版本相关接口及素材变更公告

public interface ITXCustomBeautyProcesserFactory {/*** 创建美颜实例* @return*/ITXCustomBeautyProcesser createCustomBeautyProcesser();/*** 销毁美颜实例(需要在GL线程调用)*/void destroyCustomBeautyProcesser();}public interface ITXCustomBeautyProcesser {//获取美颜支持的视频帧的像素格式。美颜支持的是:OpenGL 2D 纹理。TXCustomBeautyPixelFormat getSupportedPixelFormat();//获取美颜支持的视频数据包装格式。美颜支持的是:V2TXLiveBufferTypeTexture 直接操作纹理 ID,性能最好,画质损失最少。TXCustomBeautyBufferType getSupportedBufferType();//在GL线程调用(srcFrame中需要包含RGBA纹理,以及width,height),美颜处理之后会将处理后的纹理对象放置在dstFrame中的 texture.textureId中。void onProcessVideoFrame(TXCustomBeautyVideoFrame srcFrame, TXCustomBeautyVideoFrame dstFrame);}
com.tencent.effect.tencent_effect_flutter.XmagicProcesserFactory 注册进 TRTC 中(在原生端进行)。

Flutter 层,提供 Future<V2TXLiveCode> enableCustomVideoProcess(bool enable) 接口进行开启或关闭自定义美颜接口。

///implementation 'com.tencent.liteav:custom-video-processor:latest.release'
@objc public protocol ITXCustomBeautyProcesserFactory {/// 创建美颜实例func createCustomBeautyProcesser() -> ITXCustomBeautyProcesser/// 销毁美颜实例func destroyCustomBeautyProcesser()}@objc public protocol ITXCustomBeautyProcesser {/// 获取第三方美颜 PixelFormatfunc getSupportedPixelFormat() -> ITXCustomBeautyPixelFormat/// 获取第三方美颜 BufferTypefunc getSupportedBufferType() -> ITXCustomBeautyBufferType/// 回调NativeSDK视频自定义处理/// - Returns: 返回经过第三方美颜SDK处理后的视频帧对象func onProcessVideoFrame(srcFrame: ITXCustomBeautyVideoFrame, dstFrame: ITXCustomBeautyVideoFrame) -> ITXCustomBeautyVideoFrame}
com.tencent.effect.tencent_effect_flutter.XmagicProcesserFactory 注册进 TRTC 中(在原生端进行)。
Flutter 层,提供 Future<V2TXLiveCode> enableCustomVideoProcess(bool enable) 接口进行开启或关闭自定义美颜接口。/// 开启/关闭自定义视频处理。@objcfunc enableCustomVideoProcess(call: FlutterMethodCall, result: @escaping FlutterResult) {let key = "enable"guard let enable = MethodUtils.getMethodParams(call: call, key: key, resultType: NSNumber.self)?.boolValue else {FlutterResultUtils.handleMethod(code: .paramNotFound, methodName: call.method, paramKey: key, result: result)return}guard let customBeautyInstance = TXLivePluginManager.getBeautyInstance() else {FlutterResultUtils.handleMethod(code: .valueIsNull, methodName: call.method, paramKey: key, result: result)return}customBeautyQueue.async { [weak self] inguard let `self` = self else {FlutterResultUtils.handleMethod(code: .valueIsNull, methodName: call.method, paramKey: key, result: result)return}if (enable && self.beautyInstance == nil) {self.beautyInstance = customBeautyInstance.createCustomBeautyProcesser()}guard let beautyInstance = self.beautyInstance else {FlutterResultUtils.handleMethod(code: .valueIsNull, methodName: call.method, paramKey: key, result: result)return}let pixelFormat = beautyInstance.getSupportedPixelFormat()let bufferType = beautyInstance.getSupportedBufferType()let v2PixelFormat = ConvertBeautyFrame.convertToV2LivePixelFormat(beautyPixelFormat: pixelFormat)let v2BufferType = ConvertBeautyFrame.convertToV2LiveBufferType(beautyBufferType: bufferType)let code = self.pusher.enableCustomVideoProcess(enable,pixelFormat:v2PixelFormat,bufferType:v2BufferType)DispatchQueue.main.async {result(NSNumber(value: code.rawValue))}}}
public static func convertToV2LivePixelFormat(beautyPixelFormat: ITXCustomBeautyPixelFormat) -> V2TXLivePixelFormat {switch beautyPixelFormat {case .Unknown:return .unknowncase .I420:return .I420case .Texture2D:return .texture2Dcase .BGRA:return .BGRA32case .NV12:return .NV12}}public static func convertToV2LiveBufferType(beautyBufferType: ITXCustomBeautyBufferType) -> V2TXLiveBufferType {switch beautyBufferType {case .Unknown:return .unknowncase .PixelBuffer:return .pixelBuffercase .Data:return .nsDatacase .Texture:return .texture}}
///s.dependency 'TXCustomBeautyProcesserPlugin','1.0.2'
文档反馈