集成
- 将demo中的HM文件夹拖入项目
(注意区分.a文件使用与模拟器还是真机,如果真机用了模拟器的.a会报103个左右错误)
-
根据demo添加相应的库
屏幕快照 2018-06-14 下午2.16.03.png - 将AppDelegate.m改为AppDelegate.mm
hm_sdk是c++编写
.mm文件支持c++和oc混编.
- 在appdelegate中初始化hm_sdk
hm_sdk_init();
至此hm_sdk集成成功!
使用
- 登陆平台
server = (pchar)[@"yun.huamaiyun.com" UTF8String];
name = (pchar)[userName UTF8String];
key = (pchar)[password UTF8String];
LOGIN_SERVER_INFO loginInfo ;
loginInfo.ip = server;
loginInfo.port = 80;
loginInfo.user = name;
loginInfo.password = key;
loginInfo.plat_type = "ios";
loginInfo.keep_time = 60;
loginInfo.hard_ver = "iPhone";
loginInfo.soft_ver = "";
char err[512] = {0};
hm_result result = hm_server_connect(&loginInfo, &server_Id,err,512);
NSString *errorStr = [NSString stringWithUTF8String:err];
NSLog(@"result:%0x",result);
NSLog(@"errorStr:%@",errorStr);
NSLog(@"server_id:%s",server_Id);
if ( result == HMEC_OK)
{
NSLog(@"连接服务器成功");
[self loginServerOperation];
}
else
{
NSLog(@"连接服务器失败");
return;
}
#pragma mark -获取登录时的信息
- (void)loginServerOperation{
hm_result deviceListResult = hm_server_get_device_list(server_Id);
NSLog(@"deviceListResult:%0x",deviceListResult);
if ( deviceListResult != HMEC_OK) {
return;
}
//getTime
uint64 time;
hm_server_get_time(server_Id, &time);
if (time < HMEC_OK) {
return;
}
NSLog(@"time:%llu",time);
//getUserInfo
P_USER_INFO userInfo;
hm_server_get_user_info(server_Id,&userInfo);
if (userInfo == NULL)
{
NSLog(@"获取用户信息失败,%s",userInfo->name);
return;
}
//getTransferInfo
if (userInfo->use_transfer_service != HMEC_OK)
{
if (hm_server_get_transfer_info(server_Id) != HMEC_OK)
{
NSLog(@"获取穿透信息失败");
return;
}
}
//test getTree;
if (hm_server_get_tree(server_Id, &tree_hd) != HMEC_OK)
{
NSLog(@"获取设备树失败");
return;
}
HMPlayerViewController *hm_v_vc = [[HMPlayerViewController alloc]init];
hm_v_vc.tree_hd = tree_hd;
hm_v_vc.sn = sn;
[self presentViewController:hm_v_vc animated:YES completion:nil];
[LCProgressHUD hide];
}
- 根据sn获取处理句柄node_handle
cpchar sn = (cpchar)[self.sn UTF8String];
node_handle nodeHandle;
hm_server_find_device_by_sn(self.tree_hd, sn, &nodeHandle);
if (nodeHandle == NULL) {
return;
}
- 参考demo中的HMPlayerViewController进行播放操作
引入NSCyscleBuffer和OpenGLView20
只需要video相关代码即可
播放几秒崩溃,打开Edit scheme 中的Address sanitizer.
网友评论