libpag.framework
、Masonry.framework
、XMagic.framework
、YTCommonXMagic.framework
。如果使用的 XMagic SDK 版本在2.5.1及以后,导入 SDK 目录中的 libpag.framework
、 Masonry.framework
、XMagic.framework
、YTCommonXMagic.framework
、Audio2Exp.framework
、TEFFmpeg.framework(version3.0.0以后,改名为:TECodec.framework)
。类型 | 依赖库 |
系统依赖库 | Accelerate AssetsLibrary AVFoundation CoreMedia CoreFoundation CoreML Foundation JavaScriptCore libc++.tbd libz.b libresolv.tbd libsqlite3.0.tbd MetalPerformanceShaders MetalKit MobileCoreServices OpneAL OpneGLES Security ReplayKit SystemConfiguration UIKit |
自带的库 | YTCommon(鉴权静态库) XMagic(美颜静态库) libpag(视频解码动态库) Masonry(控件布局库) TXLiteAVSDK_Professional TXFFmpeg(version3.0.0以后,改名为:TECodec.framework) TXSoundTouch Audio2Exp(xmagic sdk version在2.5.1及以后的版本才有) TEFFmpeg(xmagic sdk version在2.5.1及以后的版本才有) |
import XMagic
***-Bridging-Header.h
,并添加如下代码#import "XMagic.h"。BuildSetting
的Objective-c Bridging header
选项。设置桥接文件的路径并添加到 Objective-c Bridging header
中( 如:$(SRCROOT)/SwiftCallOC/***-Bridging-Header.h,根据项目具体路径确定),编译运行即可。AppDelegate
的 didFinishLaunchingWithOptions
方法里触发下载。其中,LicenseURL
和 LicenseKey
是控制台绑定 License 时生成的授权信息。SDK 版本在2.5.1以前,TELicenseCheck.h
在XMagic.framework
里面;SDK 版本在2.5.1及以后,TELicenseCheck.h
在 YTCommonXMagic.framework
里面。[TELicenseCheck setTELicense:LicenseURL key:LicenseKey completion:^(NSInteger authresult, NSString * _Nonnull errorMsg) {if (authresult == TELicenseCheckOk) {NSLog(@"success");} else {NSLog(@"failed");}}];
TELicenseCheck.setTELicense(LicenseURL, key: LicenseKey) { authresult, errorMsg inif authresult == 0{print("success")}else{print("failed")}}
错误码 | 说明 |
0 | 成功。Success |
-1 | 输入参数无效,例如 URL 或 KEY 为空 |
-3 | 下载环节失败,请检查网络设置 |
-4 | 从本地读取的 TE 授权信息为空,可能是 IO 失败引起 |
-5 | 读取 VCUBE TEMP License文件内容为空,可能是 IO 失败引起 |
-6 | v_cube.license 文件 JSON 字段不对。请联系腾讯云团队处理 |
-7 | 签名校验失败。请联系腾讯云团队处理 |
-8 | 解密失败。请联系腾讯云团队处理 |
-9 | TELicense 字段里的 JSON 字段不对。请联系腾讯云团队处理 |
-10 | 从网络解析的 TE 授权信息为空。请联系腾讯云团队处理 |
-11 | 把TE授权信息写到本地文件时失败,可能是 IO 失败引起 |
-12 | 下载失败,解析本地 asset 也失败 |
-13 | 鉴权失败 |
其他 | 请联系腾讯云团队处理 |
- (void)buildBeautySDK:(int)width and:(int)height texture:(unsigned)textureID {NSDictionary *assetsDict = @{@"core_name":@"LightCore.bundle",@"root_path":[[NSBundle mainBundle] bundlePath]};// 初始化SDK:width和height分别是texture的宽高self.xMagicKit = [[XMagic alloc] initWithRenderSize:CGSizeMake(width,height) assetsDict:assetsDict];}
///初始化SDKfunc buildBeautySDK(width:UInt32,height:UInt32,texture:GLuint){let assetsDict:[String:String] = ["core_name":"LightCore.bundle", "root_path":Bundle.main.bundlePath]let sise = CGSize(width: CGFloat(width), height: CGFloat(height))xMagic = XMagic.init(renderSize: sise, assetsDict: assetsDict)}
// Register log[self.xMagicKit registerSDKEventListener:self];[self.xMagicKit registerLoggerListener:self withDefaultLevel:YT_SDK_ERROR_LEVEL];
xMagic?.register(self)xMagic?.registerLoggerListener(self, withDefaultLevel: YtSDKLoggerLevel.YT_SDK_DEBUG_LEVEL)
// @brief 配置美颜各种效果// @param propertyType 效果类型 字符串:beauty, lut, motion// @param propertyName 效果名称// @param propertyValue 效果数值// @param extraInfo 预留扩展, 附加额外配置dict// @return 成功返回0,失败返回其他- (int)configPropertyWithType:(NSString *_Nonnull)propertyType withName:(NSString *_Nonnull)propertyName withData:(NSString*_Nonnull)propertyValue withExtraInfo:(id _Nullable)extraInfo;
[self.trtcCloud setLocalVideoProcessDelegete:self pixelFormat:TRTCVideoPixelFormat_Texture_2D bufferType:TRTCVideoBufferType_Texture];
trtcCloud.setLocalVideoProcessDelegete(self, pixelFormat: TRTCVideoPixelFormat._Texture_2D, bufferType:.texture)
#pragma mark - TRTCVideoFrameDelegate- (uint32_t)onProcessVideoFrame:(TRTCVideoFrame *_Nonnull)srcFrame dstFrame:(TRTCVideoFrame *_Nonnull)dstFrame {if (srcFrame.width != _renderSize.width || srcFrame.height != _renderSize.height) {_renderSize = CGSizeMake(srcFrame.width, srcFrame.height);if (!_xMagicKit) {[self buildBeautySDK:srcFrame.width and:srcFrame.height];} else {[_xMagicKit setRenderSize:_renderSize];}}YTProcessInput *input = [[YTProcessInput alloc] init];input.textureData = [[YTTextureData alloc] init];input.textureData.texture = srcFrame.textureId;input.textureData.textureWidth = srcFrame.width;input.textureData.textureHeight = srcFrame.height;input.dataType = kYTTextureData;YTProcessOutput *output = [self.xMagicKit process:input withOrigin:YtLightImageOriginTopLeft withOrientation:YtLightCameraRotation0];dstFrame.textureId = output.textureData.texture;return 0;}
#pragma mark - TRTCVideoFrameDelegatefunc onProcessVideoFrame(_ srcFrame: TRTCVideoFrame, dstFrame: TRTCVideoFrame) -> UInt32 {if xMagic == nil {buildBeautySDK(width: srcFrame.width, height: srcFrame.height, texture: srcFrame.textureId)}if xMagic != nil && (heightF != srcFrame.height || widthF != srcFrame.width) {widthF = srcFrame.widthheightF = srcFrame.heightlet rendersize = CGSize(width: CGFloat(srcFrame.width), height: CGFloat(srcFrame.height))xMagic?.setRenderSize(rendersize)}let input = YTProcessInput.init()input.textureData = YTTextureData.init()input.textureData?.texture = Int32(srcFrame.textureId)input.textureData?.textureWidth = Int32(srcFrame.width)input.textureData?.textureHeight = Int32(srcFrame.height)input.dataType = kYTTextureDatalet output = xMagic?.process(input, with: YtLightImageOrigin(rawValue: 0)!, with: YtLightDeviceCameraOrientation(rawValue: 0)!)dstFrame.textureId = GLuint((output?.textureData?.texture)!)return 0}
//暂停SDK[self.xMagicKit onPause];//恢复SDK[self.xMagicKit onResume];//销毁SDK[self.xMagicKit clearListeners];[self.xMagicKit deinit];self.xMagicKit = nil;
//暂停SDKxMagic?.onPause()//恢复SDKxMagic?.onResume()//销毁SDKxMagic?.clearListeners()xMagic?.deinit()xMagic = nil
UIEdgeInsets gSafeInset;#if __IPHONE_11_0 && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_11_0if(gSafeInset.bottom > 0){}if (@available(iOS 11.0, *)) {gSafeInset = [UIApplication sharedApplication].keyWindow.safeAreaInsets;} else#endif{gSafeInset = UIEdgeInsetsZero;}dispatch_async(dispatch_get_main_queue(), ^{//美颜选项界面self.beautyContainer = [[BeautyView alloc] init];[self.view addSubview:self.beautyContainer];[self.beautyContainer mas_makeConstraints:^(MASConstraintMaker *make) {make.width.mas_equalTo(self.view);make.centerX.mas_equalTo(self.view);make.height.mas_equalTo(254);if(gSafeInset.bottom > 0.0){ // 适配全面屏make.bottom.mas_equalTo(self.view.mas_bottom).mas_offset(0);} else {make.bottom.mas_equalTo(self.view.mas_bottom).mas_offset(-10);}}];});
//初始化xmagic以后,把xmagic对象传给beautyViewbeautyView.beautyKitRef = xMagicview.addSubview(beautyView)beautyView.snp.makeConstraints { make inmake.height.equalTo(200)make.bottom.equalTo(switchCamButton.snp.top).offset(10)make.left.right.equalTo(view)}
本页内容是否解决了您的问题?