SDK初始化
在调用API之前需要进行初始化,您需要在该步骤中填入项目的enterpriseId等参数,如果您已经完成准备工作中的内容,则可以从管理平台获取到enterpriseId。 调用initWithSettings:方法初始化SDK。
SDK初始化接口可以设置企业ID和一些控制开关等,如果您需要更改这些参数,请退出登录后重新初始化。
SDK可支持配置的字段如下:
@interface XYSettings : NSObject
@property (nonatomic, copy) NSString *extId; // 企业ID(必填项,为nil时sdk内部会抛出异常)
@property (nonatomic, copy) NSString *clientID; // 客户端id,在管理平台生成
@property (nonatomic, copy) NSString *clientSecret; // 客户端秘钥,在管理平台生成
@property (nonatomic, copy) NSString *server; // server地址,不设置则默认cloud.xylink.com
@property (nonatomic, assign) XYLogLevel level; // log等级
@property (nonatomic, assign) BOOL enableLog; // 是否打印log
@property (nonatomic, assign) int maxRecvVideoNum; // 最大接收的视频个数,默认值为8
@property (nonatomic, assign) XYLinkSDKLanguageType customLanguageType; // app需要的语言,默认是系统当前的语言
@property (nonatomic, assign) BOOL useMetalRender; // 是否使用metal渲染视频
@property (nonatomic, assign) BOOL enableAiCaption; // 是否开启字幕
+ (XYSettings *)sharedXYSettings;
@end
- (void)initXYLinkSDK
{
NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"XYLinkSDKDemoConfig" ofType:@"plist"];
NSDictionary *plistDict = [NSDictionary dictionaryWithContentsOfFile:plistPath];
NSString *extId = [plistDict valueForKey:@"extId"];
NSDictionary *clientConfig = [plistDict valueForKey:@"ClientConfig"];
NSString *clientId = [clientConfig valueForKey:@"clientId"];
NSString *clientSecret = [clientConfig valueForKey:@"clientSecret"];
if (!extId.length) {
extId = RELEASEID;
}
BOOL enableAiCaption = [[plistDict valueForKey:@"enableAiCaption"] boolValue];
self.linkSDK = [XYLinkSDK sharedXYLinkSDK];
//登录前必须先设置服务器地址
XYSettings *settings = XYSettings.sharedXYSettings;
settings.extId = extId;
settings.clientID = clientId;
settings.clientSecret = clientSecret;
settings.level = XYLogLevel_Debug;
settings.enableLog = true;
settings.useMetalRender = YES;
self.hasSettingServiceAddress = NO;
settings.enableAiCaption = enableAiCaption;
[self.linkSDK initWithSettings:settings block:^(id obj) {
self.hasSettingServiceAddress = YES;
}];
[self.linkSDK filterAudioOutputDevices:@[@"HDMI"]];
self.linkSDK.delegate = self;
NSString *currentLang = [XYSDKPublicUtil currentLocalLanguage];
NSString *langConfig = [currentLang hasPrefix:@"en"] ? @"English" : @"Chinese" ;
[self.linkSDK setSubtitleLanguage:langConfig];
}