TELiveAdapter 是一个可以快速将腾讯特效 SDK 集成进腾讯直播项目中的库,主要用于加快特效 SDK 的集成和解决横屏时美颜适配较复杂问题。
SDK 集成
1. 集成 TEBeautyKit 库,参见 TEBeautyKit 集成指引/iOS 中的集成步骤。
2. 下载并解压 TELiveAdapter。
3. 集成 TELiveAdapter,参见 MLVB demo 工程。
SDK 使用
第一步:配置美颜面板 json 数据
- (void)initBeautyJson{NSString *resourcePath = [[NSBundle mainBundle]pathForResource:@"TEBeautyKitResources" ofType:@"bundle"];NSBundle *bundle = [NSBundle bundleWithPath:resourcePath];[[TEUIConfig shareInstance] setTEPanelViewRes:[bundle pathForResource:@"beauty_S1" ofType:@"json"] beautyBody:[bundle pathForResource:@"beauty_body" ofType:@"json"] lut:[bundle pathForResource:@"lut" ofType:@"json"] motion:[bundle pathForResource:@"motions" ofType:@"json"] makeup:[bundle pathForResource:@"makeup" ofType:@"json"] segmentation:[bundle pathForResource:@"segmentation" ofType:@"json"]];}
第二步:adapter 绑定美颜
-(TEBeautyLiveAdapter *)liveAdapter{if (!_liveAdapter) {_liveAdapter = [[TEBeautyLiveAdapter alloc] init];}return _liveAdapter;}__weak __typeof(self)weakSelf = self;[self.liveAdapter bind:self.livePusher onCreatedTEBeautyKit:^(TEBeautyKit * _Nullable beautyKit, XMagic * _Nullable xmagicApi) {__strong typeof(self) strongSelf = weakSelf;strongSelf.xMagicKit = xmagicApi;[strongSelf.teBeautyKit setXMagicApi:xmagicApi];strongSelf.tePanelView.teBeautyKit = strongSelf.teBeautyKit;[strongSelf.teBeautyKit setTePanelView:strongSelf.tePanelView];[strongSelf.teBeautyKit setLogLevel:YT_SDK_ERROR_LEVEL];strongSelf.tePanelView.beautyKitApi = xmagicApi;[strongSelf.liveAdapter setDeviceOrientation:UIDeviceOrientationPortrait];[strongSelf.xMagicKit registerSDKEventListener:strongSelf];} onDestroyTEBeautyKit:^{}];
第三步:美颜鉴权
[TELicenseCheck setTELicense:@"your license" key:@"your key" completion:^(NSInteger authresult, NSString * _Nonnull errorMsg) {if (authresult == TELicenseCheckOk) {NSLog(@"XMagic 授权成功");} else {NSLog(@"XMagic 授权失败");}}];
第四步:参数变化通知 adapter
//通知adapter前后置摄像头,是否镜像[self.liveAdapter notifyCameraChanged:isFrontCamera mirrorType:mirrorType];//通知adapter屏幕方向改变[self.liveAdapter setDeviceOrientation:orientation];
第五步:解绑 adapter
[self.liveAdapter unbind];