Skip to content

Commit

Permalink
feat(iOS): add setDNSResolve interface
Browse files Browse the repository at this point in the history
  • Loading branch information
skufly authored and pingkai committed Apr 9, 2020
1 parent 50a8a55 commit 35d4f06
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
3 changes: 3 additions & 0 deletions platform/Apple/source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ link_directories(${SRC_LIBRARIES_DIR})
set(SOURCE_LIST
CicadaPlayer.mm
CicadaPlayer.h
CicadaPlayerGlobalSettings.h
CicadaPlayerGlobalSettings.mm
CicadaPlayerSDK.h
CicadaConfig.mm
CicadaConfig.h
Expand Down Expand Up @@ -80,6 +82,7 @@ target_include_directories(CicadaPlayerSDK PUBLIC ${PROJECT_SOURCE_DIR})
set_source_files_properties(${XIB_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
set(PUBLIC_HEADERS
CicadaPlayer.h
CicadaPlayerGlobalSettings.h
CicadaConfig.h
CicadaCacheConfig.h
CicadaDef.h
Expand Down
26 changes: 26 additions & 0 deletions platform/Apple/source/CicadaPlayerGlobalSettings.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// CicadaPlayerGlobalSettings.h
// CicadaPlayerGlobalSettings
//
// Created by huang_jiafa on 2020/04/09.
// Copyright © 2020 com.alibaba.AliyunPlayer. All rights reserved.
//

#import <Foundation/Foundation.h>

OBJC_EXPORT
@interface CicadaPlayerGlobalSettings : NSObject

/**
@brief 设置域名对应的解析ip
@param host 域名,需指定端口(http默认端口80,https默认端口443)。例如player.alicdn.com:443
@param ip 相应的ip,设置为空字符串清空设定。
*/
/****
@brief Set a DNS ip to resolve the host.
@param host The host. Need to specify the port (http defualt port is 80,https default port is 443). E.g player.alicdn.com:443
@param ip The ip address, set as empty string to clear the setting.
*/
+(void)setDNSResolve:(NSString *)host ip:(NSString *)ip;

@end
27 changes: 27 additions & 0 deletions platform/Apple/source/CicadaPlayerGlobalSettings.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#import "CicadaPlayerGlobalSettings.h"
#import "utils/globalSettings.h"

@interface CicadaPlayerGlobalSettings ()
{
}
@end

@implementation CicadaPlayerGlobalSettings

+(void)setDNSResolve:(NSString *)host ip:(NSString *)ip
{
if (nil == host) {
return;
}

const string theHost = [host UTF8String];
Cicada::globalSettings::getSetting()->removeResolve(theHost, "");

string theip;
if (nil != ip && 0 < [ip length]) {
theip = [ip UTF8String];
Cicada::globalSettings::getSetting()->addResolve(theHost, theip);
}
}

@end
2 changes: 1 addition & 1 deletion platform/Apple/source/CicadaPlayerSDK.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
#import <CicadaPlayerSDK/CicadaSource.h>
#import <CicadaPlayerSDK/CicadaDef.h>
#import <CicadaPlayerSDK/CicadaCacheConfig.h>

#import <CicadaPlayerSDK/CicadaPlayerGlobalSettings.h>

0 comments on commit 35d4f06

Please sign in to comment.