IOS

局域网搜索摄像机

版本/作者/日期修改内容
1.0/Sandy/2015-09-24初版

2.局域网搜索摄像机

条件:sdk初始化成功
语法:
1)函数
+(int)startSearch;//开始搜索
+(void)stopSearch;//停止搜索
2)消息

FOUNDATION_EXPORT NSString* const IPCamera_Search_Result_Notification;

3)消息回调函数
-(void)IPCamera_response_function:(NSNotification*)note;     
IPCamera.h宏定义了两种注册消息的方法
#define ADD_IPCAMERA_RESPONSE_WITHOUT_ARG(notice_name) \
    [[NSNotificationCenter defaultCenter] addObserver: self selector:               @selector(IPCamera_response_function:) name: notice_name object: nil]

#define ADD_IPCAMERA_RESPONSE_WITH_ARG(notice_name,camera_object) \
    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(IPCamera_response_function:) name: notice_name object: camera_object]
示列:
1)注册消息通知+搜索
ADD_IPCAMERA_RESPONSE_WITH_ARG( IPCamera_Search_Result_Notification, cam_) 
[IPCamera startSearch ];
2)搜索消息回调
-(void)IPCamera_response_function:(NSNotification*)note
{
    if( [note.name isEqualToString: IPCamera_Search_Result_Notification ])
    {
         if (note.userInfo) {
            NSLog(@"搜索结果返回:搜索到摄像机了");
     NSNumber* result = [ dic objectForKey:@"result"];//搜索结果,参考IPCamera_Search_Result,根据不同类型做删除,连接,添加等动作
          IPCamera_Search_Result option = [result intValue ];
  		 if (  CAM_SEARCH_ADD == option){
//搜索到设备了,开始获取摄像机属性添加
            			[self m_get_cam_infomation: note.userInfo ]; //执行相关动作}
   		else if (  CAM_SEARCH_REMOVE == option){
//搜索到设备已删除了,需在本地删除
            			NSLog(@"摄像机已删除,此时需在本地删除摄像机");}
else if (  CAM_SEARCH_CHANGED == option){
            NSLog(@"搜索到的结果有改变");}
        }
        else
        {
            NSLog(@"搜索结果返回:没有找到摄像机");
        }
    }
}
3)获取摄像机属性
-(void)m_get_cam_infomation:(NSDictionary*)dic
{  
        [dic objectForKey:@"name"]; //名称
        [dic objectForKey:@"ID"]; //id
        [dic objectForKey:@"currect_ip"]; //IP host
        [dic objectForKey:@"port"]; //端口号
        [dic objectForKey:@"currect_netmask"]; //子网掩码
        [dic objectForKey:@"https_flag"];//ssl是否加密传输,1是0否
        [dic objectForKey:@"dhcp_flag"]; // //是否启动DHCP 1启用0不启用
        [dic objectForKey:@"firmware_version"]; //系统固件版本号
        [dic objectForKey:@"web_version"]; //网页固件版本号
        [dic objectForKey:@"model"]; //机型 参考IPCamera_Model
        [dic objectForKey:@"id_type"]; //id类型,参考IPCamera_ID_TYPE
        [dic objectForKey:@"dns1"]; //不启用DHCP时的DNS1
        [dic objectForKey:@"dns2"]; //不启用DHCP时的DNS2
        [dic objectForKey:@"ip"]; //不启用DHCP时的IP
        [dic objectForKey:@"netmask"]; //不启用DHCP时的子网掩码
        [dic objectForKey:@"gateway"];////不启用DHCP时的网关
        [dic objectForKey:@"same_subnet"];
}
4)停止搜索

[IPCamera stopSearch ];

版权所有:深圳新瑞彩网络科技有限公司

信产部备案号:粤ICP备09050685号