tencent cloud

Feedback

iOS(3.3.0 and prior)

Last updated: 2024-07-05 12:35:44

    Integration Preparation

    1. Download and unzip the Demo package.
    2. Import the xmagic module (bundle, XmagicIconRes, Xmagic folder) from the Demo project into the actual project.
    3. If the version of XMagic SDK used is 2.5.0 or earlier, import libpag.framework, Masonry.framework, XMagic.framework, YTCommonXMagic.framework in the SDK directory. If the version of XMatic SDK used is 2.5.1 or later, import libpag.framework, Masonry.framework, XMagic.framework, YTCommonXMagic.framework, Audio2Exp.framework, TEFFmpeg.framework(version3.0.0 or later, renamed as:TECodec.framework) in the SDK directory.
    4. For framework signature, select Embed & Sign for General > Masonry.framework and libpag.framework. For YTCommonXMagic.framework, select Do Not Embed for versions before 2.5.1, and select Embed & Sign for versions 2.5.1 and later.
    5. Change the Bundle ID to match the issued authorization.

    Developer Environment Requirements

    Developer tools XCode 14 and later: Go to App Store or click Download link .
    Recommended runtime environment:
    Device requirements: iPhone 5 and above. For iPhone 6 and below, the front camera supports up to 720p, not 1080p.
    System requirements: iOS 10.0 and above.

    C/C++ Layer Development Environment

    Xcode uses the C++ environment by default.
    Type
    Dependency Library
    System dependent library
    Accelerate
    AssetsLibrary
    AVFoundation
    CoreMedia
    CoreFoundation
    CoreML
    Foundation
    JavaScriptCore
    libc++.tbd
    libz.b
    libresolv.tbd
    libsqlite3.0.tbd
    MetalPerformanceShaders
    MetalKit
    MobileCoreServices
    OpneAL
    OpneGLES
    ReplayKit
    SystemConfiguration
    UIKit
    Built-in library
    YTCommon (static authentication library)
    XMagic (static beauty filter library)
    libpag (dynamic video decoding library)
    Masonry (control layout library)
    TXLiteAVSDK_Professional
    TXFFmpeg (renamed TECodec.framework after version 3.0.0)
    TXSoundTouch
    Audio2Exp (included in xmagic sdk version 2.5.1 and later)
    TEFFmpeg (included in xmagic sdk version 2.5.1 and later)

    SDK API Integration

    For Step 1 and Step 2, please refer to the viewDidLoad and buildBeautySDK methods of the ThirdBeautyViewController class in the Demo project; The application method in the AppDelegate class contains code for authenticating Xmagic.
    From Step 4 to Step 7, please refer to the related sample code within the demo project's ThirdBeautyViewController, BeautyView class.

    Step 1. Initialize Authorization

    1. Firstly, add the following authentication code in AppDelegate's didFinishLaunchingWithOptions, where LicenseURL, LicenseKey are the authorization information obtained from Tencent Cloud's official website, please refer to Licenses:
    [TXLiveBase setLicenceURL:LicenseURL key:LicenseKey];
    2. Xmagic authorization: Set the URL and KEY in the initialization code of the relevant business module to trigger License Download, avoiding temporary download before using. Also, you can trigger the download in AppDelegate's didFinishLaunchingWithOptions method. The LicenseURL and LicenseKey are the authorization information generated when binding the License in the console. For SDK versions before 2.5.1, TELicenseCheck.h is within XMagic.framework; For SDK versions 2.5.1 and later, TELicenseCheck.h is within
    YTCommonXMagic.framework.
    [TELicenseCheck setTELicense:LicenseURL key:LicenseKey completion:^(NSInteger authresult, NSString * _Nonnull errorMsg) {
    if (authresult == TELicenseCheckOk) {
    NSLog(@"Authentication successful");
    } else {
    NSLog(@"Authentication failed");
    }
    }];
    Authentication errorCode Description:
    Error code
    Description
    0
    Successful
    -1
    Invalid input parameters. URL, KEY, etc. is empty.
    -3
    Download failed. Please check your network settings.
    -4
    The TE authorization information read from local is empty. It may be caused by IO failure.
    -5
    Content of VCUBE TEMP License file is empty. It may be caused by IO failure.
    -6
    JSON fields in the v_cube.license file are incorrect. Please contact the Tencent Cloud team for assistance.
    -7
    Signature verification failed. Please contact the Tencent Cloud team for assistance.
    -8
    Decryption failed. Please contact the Tencent Cloud team for assistance.
    -9
    JSON fields in the TELicense field are incorrect. Please contact the Tencent Cloud team for assistance.
    -10
    The TE authorization information parsed from the network is empty. Please contact the Tencent Cloud team for assistance.
    -11
    Failed to write TE authorization information to local file. It may be caused by IO failure.
    -12
    Download failed. Local asset parsing also failed.
    -13
    Authentication failed.
    Other
    Please contact the Tencent Cloud team for assistance.

    Step 2. Set the SDK Material Resource Path

    - (void)buildBeautySDK:(int)width and:(int)height texture:(unsigned)textureID {
    NSDictionary *assetsDict = @{@"core_name":@"LightCore.bundle",
    @"root_path":[[NSBundle mainBundle] bundlePath]};
    // Initialize SDK: 'width' and 'height' are respectively the width and height of the texture.
    self.xMagicKit = [[XMagic alloc] initWithRenderSize:CGSizeMake(width,height) assetsDict:assetsDict];
    }

    Step 3. Add the Log and Event Listener

    // Register log
    [self.beautyKit registerSDKEventListener:self];
    [self.beautyKit registerLoggerListener:self withDefaultLevel:YT_SDK_ERROR_LEVEL];

    Step 4. Configure Effects

    - (int)configPropertyWithType:(NSString *_Nonnull)propertyType withName:(NSString *_Nonnull)propertyName withData:(NSString*_Nonnull)propertyValue withExtraInfo:(id _Nullable)extraInfo;

    Step 5. Render Videos

    In the video frame callback interface, construct YTProcessInput and pass it to the SDK for rendering processing. Refer to 'ThirdBeautyViewController' in the Demo.
    [self.xMagicKit process:inputCPU withOrigin:YtLightImageOriginTopLeft withOrientation:YtLightCameraRotation0]

    Step 6. Pause/Resume the SDK

    [self.beautyKit onPause];
    [self.beautyKit onResume];

    Step 7. Add the SDK Effect Panel to the Layout

    UIEdgeInsets gSafeInset;
    #if __IPHONE_11_0 && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_11_0
    if(gSafeInset.bottom > 0){
    }
    if (@available(iOS 11.0, *)) {
    gSafeInset = [UIApplication sharedApplication].keyWindow.safeAreaInsets;
    } else
    #endif
    {
    gSafeInset = UIEdgeInsetsZero;
    }
    
    dispatch_async(dispatch_get_main_queue(), ^{
    // Effect option UI
    _vBeauty = [[BeautyView alloc] init];
    [self.view addSubview:_vBeauty];
    [_vBeauty 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){ // Adapt to full-view screen
    make.bottom.mas_equalTo(self.view.mas_bottom).mas_offset(0);
    } else {
    make.bottom.mas_equalTo(self.view.mas_bottom).mas_offset(-10);
    }
    }];
    _vBeauty.hidden = YES;
    });
    
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support