
sudo gem install cocoapods
pod init
platform :ios, '8.0'target 'App' dopod 'XMagic'end
platform :ios, '8.0'target 'App' dopod 'XMagic_Smart'end
#请根据你的套餐pod install对应的库#例如:如果你的套餐是all类型,那么只需要pod 'TencentEffect_All'#例如:如果你的套餐是S1-04类型,那么只需要pod 'TencentEffect_S1-04'pod 'TencentEffect_All'#pod 'TencentEffect_A1-00'#pod 'TencentEffect_A1-01'#pod 'TencentEffect_A1-02'#pod 'TencentEffect_A1-03'#pod 'TencentEffect_A1-04'#pod 'TencentEffect_A1-05'#pod 'TencentEffect_A1-06'#pod 'TencentEffect_S1-00'#pod 'TencentEffect_S1-01'#pod 'TencentEffect_S1-02'#pod 'TencentEffect_S1-03'#pod 'TencentEffect_S1-04'#pod 'TencentEffect_S1-05'#pod 'TencentEffect_S1-06'#pod 'TencentEffect_S1-07'#pod 'TencentEffect_X1-01'#pod 'TencentEffect_X1-02'
pod install
.xcworkspace 后缀的工程文件,双击打开即可。-ObjC。XMagic.framework、YTCommonXMagic.framework、libpag.framework 及其所需依赖库MetalPerformanceShaders.framework、CoreTelephony.framework、JavaScriptCore.framework、VideoToolbox.framework、libc++.tbd,根据需要添加其它工具库 Masonry.framework(控件布局库)、SSZipArchive(文件解压库)。

XMagic.framework、YTCommonXMagic.framework、libpag.framework 、Audio2Exp.framework、 TEFFmpeg.framework(version3.0.0以后,改名为:TECodec.framework)及其所需依赖库 MetalPerformanceShaders.framework、CoreTelephony.framework、JavaScriptCore.framework、VideoToolbox.framework、libc++.tbd,根据需要添加其它工具库 Masonry.framework(控件布局库)、SSZipArchive(文件解压库)。
-ObjC。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(@"鉴权成功");} else {NSLog(@"鉴权失败");}}];
错误码 | 说明 |
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 | 鉴权失败 |
其他 | 请联系腾讯云团队处理 |
NSDictionary *assetsDict = @{@"core_name":@"LightCore.bundle",@"root_path":[[NSBundle mainBundle] bundlePath] // LightCore.bundle所在的目录。};
/**previewSize:视图的宽高assetsDict:上一步配置的LightCore.bundle及其路径*/self.xMagicApi = [[XMagic alloc] initWithRenderSize:previewSize assetsDict:assetsDict];
/**以设备摄像头数据输出为例*///sampleBuffer:设备摄像头输出的数据-(CMSampleBufferRef)didProcessCPUData:(CMSampleBufferRef)sampleBuffer{CVPixelBufferRef pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);YTProcessInput *input = [[YTProcessInput alloc] init];input.pixelData = [[YTImagePixelData alloc] init];input.pixelData.data = pixelBuffer;input.dataType = kYTImagePixelData;YTProcessOutput *output = [self.xMagicKit process:input];if (output.pixelData.data != nil) { //output.pixelData.data:美颜SDK处理以后的数据CMSampleBufferRef outSampleBuffer = [self sampleBufferFromPixelBuffer:output.pixelData.data];return outSampleBuffer;}return nil;}//PixelBuffer转sampleBuffer- (CMSampleBufferRef)sampleBufferFromPixelBuffer:(CVPixelBufferRef)pixelBuffer{CFRetain(pixelBuffer);CMSampleBufferRef outputSampleBuffer = NULL;CMSampleTimingInfo timing = {kCMTimeInvalid, kCMTimeInvalid, kCMTimeInvalid};CMVideoFormatDescriptionRef videoInfo = NULL;OSStatus result = CMVideoFormatDescriptionCreateForImageBuffer(NULL, pixelBuffer, &videoInfo);result = CMSampleBufferCreateForImageBuffer(kCFAllocatorDefault, pixelBuffer, true, NULL, NULL, videoInfo, &timing, &outputSampleBuffer);CFArrayRef attachments = CMSampleBufferGetSampleAttachmentsArray(outputSampleBuffer, YES);CFMutableDictionaryRef dict = (CFMutableDictionaryRef)CFArrayGetValueAtIndex(attachments, 0);CFDictionarySetValue(dict, kCMSampleAttachmentKey_DisplayImmediately, kCFBooleanTrue);CFRelease(videoInfo);CFRelease(pixelBuffer);return outputSampleBuffer;}
// 在需要释放SDK资源的地方调用[self.xMagicApi deinit]
文档反馈