IOS

监控摄像机状态

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

13.监控摄像机状态

条件:摄像机连接成功
语法:
1)函数

-(int)monitorStatus:(NSArray*)array; 主动去请求获取参数,不主动请求的话,只有参数有变化才有消息通知

2)消息
FOUNDATION_EXPORT NSString* const IPCamera_Monitor_Status_Notification;
FOUNDATION_EXPORT NSString* const IPCamera_Monitor_Status_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_Monitor_Status_Notification, cam_)
    ADD_IPCAMERA_RESPONSE_WITH_ARG( IPCamera_Monitor_Status_Result_Notification, cam_)
2)请求参数
  NSArray* array = [[ NSArray alloc] initWithObjects:@"alarm",@"humidity", nil ];
[cam_ monitorStatus:m_arry];
3)参数获取成功后的消息回调
-(void)IPCamera_response_function:(NSNotification*)note
{       
   if([note.name isEqualToString: IPCamera_Camera_Statistic_Notification ]){

       if( [note.name isEqualToString: IPCamera_Monitor_Status_Result_Notification ])
       {
        //只有请求成功了,后面摄像机参数有变动,才能监控到,才能每次在PCamera_Monitor_Status_Notification有通知
            NSLog(@"请求监控摄像机状态参数成功!");
        }
       if( [note.name isEqualToString:IPCamera_Monitor_Status_Notification ]){
         NSLog(@"摄像机参数有改变!");  
        NSDictionary* dic = note.userInfo;
        if ([dic objectForKey:@"alarm"]) {
            NSLog(@"报警参数值有改变");
        }     
    }
}
版权所有:深圳市瑞彩电子科技有限公司

信产部备案号:粤ICP备09050685号 技术支持:800069965