iOS

SDK Integration

1. For integrating Tencent Effect SDK, see Integrating Tencent Effect into TRTC SDK.
2. This documentation explains integrating and using the TEBeautyKit library in the TRTC SDK project.
3. Refer to demo.

Utilization of SDK

Step 1: Integrate TEBeautyKit

1. Download and extract TEBeautyKit.
2. Download and extract TRTCAdapter.
3. Copy the TEBeautyKit folder into your project and make it the same level as the podfile directory.
4. Incorporate the `TRTCAdapter.framework` into your project.

5. Edit the podfile and add the following code:
pod 'TEBeautyKit',:path => 'TEBeautyKit/TEBeautyKit.podspec'
6. Execute the command `pod install`.

Step 2: Authenticate

[TEBeautyKit setTELicense:@"your license" key:@"your key" completion:^(NSInteger authresult, NSString * _Nullable errorMsg) {
NSLog(@"----------result: %zd %@",authresult,errorMsg);
}];

Step 3: Configure the beauty material path

If the materials configured in the JSON file are local, you need to add the beauty materials to your project.
- (void)initBeautyJson{
[[TEUIConfig shareInstance] setPanelLevel:S1_07];
}

Step 4: Initialize and add TEPanelView

-(TEPanelView *)tePanelView{
if (!_tePanelView) {
_tePanelView = [[TEPanelView alloc] init:nil comboType:nil];
_tePanelView.delegate = self;
}
return _tePanelView;
}
[self.view addSubview:self.tePanelView];
[self.tePanelView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(self.view);
make.centerX.mas_equalTo(self.view);
make.height.mas_equalTo(250);
make.bottom.mas_equalTo(self.view.mas_bottom);
}];

Step 5: Adapter Binding for Beautification

-(TEBeautyTRTCAdapter *)trtcAdapter{
if (!_trtcAdapter) {
_trtcAdapter = [[TEBeautyTRTCAdapter alloc] init];
}
return _trtcAdapter;
}
__weak __typeof(self)weakSelf = self;
[self.trtcAdapter bind:self.trtcCloud onCreatedXmaicApi:^(XMagic * _Nullable xmagicApi) {
__strong typeof(self) strongSelf = weakSelf;
strongSelf.teBeautyKit.xmagicApi = xmagicApi;
[strongSelf.teBeautyKit setLogLevel:YT_SDK_ERROR_LEVEL];
strongSelf.tePanelView.teBeautyKit = strongSelf.teBeautyKit;
[strongSelf.tePanelView setDefaultBeauty];
}onDestroyXmaicApi:^{
__strong typeof(self) strongSelf = weakSelf;
[strongSelf.teBeautyKit onDestroy];
strongSelf.teBeautyKit = nil;
}];


Step 6: Parameter Change Notification Adapter

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

Step 7: Unlink the adapter and terminate the beauty enhancement feature

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