Feedback

iOS

This documentation explains integrating and using the TEBeautyKit library in the Mobile Live Video Broadcasting Streaming (MLVB) SDK project.

Integration Steps

1. (Optional) Integrate TELiveAdapter. The TELiveAdapter.framework is used to receive video callbacks from the MLVB SDK, process them internally using the beauty filter SDK, and then return them to the MLVB SDK. If you need to perform custom processing on the video stream, you can skip this step.

2. Integration TEBeautyKit,Edit the Podfile and append the following code snippet and execution pod install.
# Replace S1-07 with the package you purchased,Note that TEBeautyKit and TencentEffect must use the same package
pod 'TEBeautyKit/S1-07', :podspec => 'https://mediacloud-76607.gzc.vod.tencent-cloud.com/TencentEffect/iOS/TEBeautyKit/latest/TEBeautyKit.podspec'
pod 'TencentEffect_S1-07', :podspec => 'https://mediacloud-76607.gzc.vod.tencent-cloud.com/TencentEffect/iOS/podspec/latest/TencentEffect_S1-07.podspec'
3. Integration Panel Resources,download the resource package and incorporate it into your main project. The contents can be found in the appendix.
4. Integration Effect Resources.

Usage Guide

Step 1: Integrated beauty panel

The beauty panel is a custom view control provided by TEBeautyKit. For how to use it, please refer to the TEBeautyKit usage guide.

Step 2: Adapter Binding for Beautification

If TELiveAdapter is not integrated, please refer directly to Step 5.
/// create adapter
- (TEBeautyLiveAdapter *)liveAdapter {
if (!_liveAdapter) {
_liveAdapter = [[TEBeautyLiveAdapter alloc] init];
}
return _liveAdapter;
}
/// bind
- (void)bind {
__weak typeof(self)weakSelf = self;
[self.liveAdapter bind:self.livePusher onCreatedXmagicApi:^(XMagic * _Nullable xmagicApi) {
__strong typeof(weakSelf)strongSelf = weakSelf;
strongSelf.teBeautyKit.xmagicApi = xmagicApi;
strongSelf.tePanelView.teBeautyKit = strongSelf.teBeautyKit;
[strongSelf.tePanelView setDefaultBeauty];
} onDestroyXmagicApi:^{
__strong typeof(weakSelf)strongSelf = weakSelf;
[strongSelf.teBeautyKit onDestroy];
strongSelf.teBeautyKit = nil;
}];
}

Step 3: Parameter Change Notification Adapter

/// Notify the Adapter of the Front and Rear Cameras: Whether to Encode a Mirror Image
[self.liveAdapter notifyCameraChanged:self.isFrontCamera isEncoderMirror:self.isEncoderMirror];
/// Notify the Adapter of Screen Orientation Changes
[self.liveAdapter setDeviceOrientation:orientation];

Step 4: Unbinding the Adapter

[self.liveAdapter unbind];
self.liveAdapter = nil;

Step 5: TELiveAdapter is not integrated.

Listen for MLVB video callbacks, process the beauty effects within the callback, and then return the processed video to MLVB.
1. Initialization
- (void)initXMagic {
__weak typeof(self)weakSelf = self;
[TEBeautyKit createXMagic:EFFECT_MODE_PRO onInitListener:^(TEBeautyKit * _Nullable beautyKit) {
__strong typeof(weakSelf)strongSelf = weakSelf;
strongSelf.teBeautyKit = beautyKit;
strongSelf.tePanelView.teBeautyKit = strongSelf.teBeautyKit;
[strongSelf.tePanelView setDefaultBeauty];
}];
}
2. Processing video data
- (void)onProcessVideoFrame:(V2TXLiveVideoFrame *)srcFrame dstFrame:(V2TXLiveVideoFrame *)dstFrame {
YTProcessOutput *output = [self.teBeautyKit processTexture:srcFrame.textureId
textureWidth:srcFrame.width
textureHeight:srcFrame.height
withOrigin:YtLightImageOriginTopLeft
withOrientation:YtLightCameraRotation0];
dstFrame.textureId = output.textureData.texture;
}
3. Destroy Beauty Filter
- (void)destroyXMagic {
[self.teBeautyKit onDestroy];
self.teBeautyKit = nil;
}