云回看
更新时间:2025-04-01 16:44:30
云端存储录像与事件
// 导入设备管理SDK头文件
#import <RTCXDeviceCenter/RTCXDeviceCenter.h>
云存储录像调用接口
@protocol RTCXCloudStorageProtocol <NSObject>
/**
* 查询云存录像列表
*
* @param req 请求参数对象
* @param onSuccess 成功回调
* @param onError 失败回调
*/
- (void)queryRecordListWithReq:(nonnull RTCXCloudStorageRecordReq *)req onSuccess:(nullable RTCXCloudStorageOnSuccess)onSuccess onError:(nullable RTCXCloudStorageOnError)onError;
/**
* 查询云存事件列表
*
* @param req 请求参数对象
* @param onSuccess 成功回调
* @param onError 失败回调
*/
- (void)queryEventListWithReq:(nonnull RTCXCloudStorageEventReq *)req onSuccess:(nullable RTCXCloudStorageOnSuccess)onSuccess onError:(nullable RTCXCloudStorageOnError)onError;
/**
* 查询云存录像点播地址
*
* @param req 请求参数对象
* @param onSuccess 成功回调
* @param onError 失败回调
*/
- (void)queryVodUrlWithReq:(nonnull RTCXCloudStorageVodUrlReq *)req onSuccess:(nullable RTCXCloudStorageOnSuccess)onSuccess onError:(nullable RTCXCloudStorageOnError)onError;
/**
* 查询云存事件点播地址
*
* @param req 请求参数对象
* @param onSuccess 成功回调
* @param onError 失败回调
*/
- (void)queryVodEventUrlWithReq:(nonnull RTCXCloudStorageVodEventUrlReq *)req onSuccess:(nullable RTCXCloudStorageOnSuccess)onSuccess onError:(nullable RTCXCloudStorageOnError)onError;
/**
* 查询月录像
*
* @param req 请求参数对象
* @param onSuccess 成功回调
* @param onError 失败回调
*/
- (void)queryMonthRecordWithReq:(nonnull RTCXCloudStorageMonthRecordReq *)req onSuccess:(nullable RTCXCloudStorageOnSuccess)onSuccess onError:(nullable RTCXCloudStorageOnError)onError;
/**
* 查询月事件
*
* @param req 请求参数对象
* @param onSuccess 成功回调
* @param onError 失败回调
*/
- (void)queryMonthEventWithReq:(nonnull RTCXCloudStorageMonthEventReq *)req onSuccess:(nullable RTCXCloudStorageOnSuccess)onSuccess onError:(nullable RTCXCloudStorageOnError)onError;
/**
* 查询月消息(消息中心按天统计)
*
* @param req 请求参数对象
* @param onSuccess 成 功回调
* @param onError 失败回调
*/
- (void)queryMonthMessageWithReq:(nonnull RTCXCloudStorageMonthMessageReq *)req onSuccess:(nullable RTCXCloudStorageOnSuccess)onSuccess onError:(nullable RTCXCloudStorageOnError)onError;
/**
* 删除云存录像
*
* @param req 请求参数对象
* @param onSuccess 成功回调
* @param onError 失败回调
*/
- (void)deleteRecordWithReq:(nonnull RTCXCloudStorageDeleteRecordReq *)req onSuccess:(nullable RTCXCloudStorageOnSuccess)onSuccess onError:(nullable RTCXCloudStorageOnError)onError;
/**
* 删除云存事件
*
* @param req 请求参数对象
* @param onSuccess 成功回调
* @param onError 失败回调
*/
- (void)deleteEventWithReq:(nonnull RTCXCloudStorageDeleteEventReq *)req onSuccess:(nullable RTCXCloudStorageOnSuccess)onSuccess onError:(nullable RTCXCloudStorageOnError)onError;
/**
* 查询事件描述(事件最新记录时间,事件小红点)
*
* @param req 请求参数对象
* @param onSuccess 成功回调
* @param onError 失败回调
*/
- (void)queryEventDescWithReq:(nonnull RTCXCloudStorageEventDescReq *)req onSuccess:(nullable RTCXCloudStorageOnSuccess)onSuccess onError:(nullable RTCXCloudStorageOnError)onError;
/**
* 查询消息中心事件描述(消息中心最新记录时间,消息中心小红点)
*
* @param req 请求参数对象
* @param onSuccess 成功回调
* @param onError 失败回调
*/
- (void)queryMessageDescWithReq:(nonnull RTCXCloudStorageMessageDescReq *)req onSuccess:(nullable RTCXCloudStorageOnSuccess)onSuccess onError:(nullable RTCXCloudStorageOnError)onError;
/**
* 查询消息中心事件列表
*
* @param req 请求参数对象
* @param onSuccess 成功回调
* @param onError 失败回调
*/
- (void)queryMessageCenterEventListWithReq:(nonnull RTCXCloudStorageMessageEventReq *)req onSuccess:(nullable RTCXCloudStorageOnSuccess)onSuccess onError:(nullable RTCXCloudStorageOnError)onError;
/**
* 批量删除消息中心事件
*
* @param req 请求参数对象
* @param onSuccess 成功回调
* @param onError 失败回调
*/
- (void)deleteMessageWithReq:(nonnull RTCXCloudStorageDeleteMessageReq *)req onSuccess:(nullable RTCXCloudStorageOnSuccess)onSuccess onError:(nullable RTCXCloudStorageOnError)onError;
@end
云端存储套餐调用接口
@protocol RTCXCloudServicesProtocol <NSObject>
/**
* 查询当前云存储套餐详情
*
* @param req 请求参数对象
* @param onSuccess 成功回调
* @param onError 失败回调
*/
- (void)queryDeviceCurrentCloudServicesWithReq:(nonnull RTCXCloudServicesReq *)req onSuccess:(nullable RTCXCloudServicesOnSuccess)onSuccess onError:(nullable RTCXCloudServicesOnError)onError;
/**
* 查询历史云存储套餐详情
*
* @param req 请求参数对象
* @param onSuccess 成功回调
* @param onError 失败回调
*/
- (void)queryDeviceHistoryCloudServicesWithReq:(nonnull RTCXCloudServicesReq *)req onSuccess:(nullable RTCXCloudServicesOnSuccess)onSuccess onError:(nullable RTCXCloudServicesOnError)onError;
@end
查询云存录像列表
备注:该接口默认一次性返回beginTime和endTime时间段内所有数据,(注意:如果该时间段跨度比较大,可能查询比较耗 时,所以建议不要跨度太大,或者通过分页查询)
- 分页规则:
-
设置pageSize参数,如pageSize = @(10)
-
当响应的RTCXCloudStorageRecordListRsp.nextValid = YES,说明可以继续查询下一页数据,否则没有可查询的更多数据了;
-
查寻下一页时,入参beginTime为上一次的beginTime,endTime为上一次的RTCXCloudStorageRecordListRsp.nextEndTime。
-
RTCXCloudStorageRecordReq *recordReq = [[RTCXCloudStorageRecordReq alloc] init];
recordReq.iotId = weakSelf.curDevice.iotId;
recordReq.beginTime = @(beginTime);
recordReq.endTime = @(endTime);
[RTCXDeviceService(RTCXCloudStorageProtocol) queryRecordListWithReq:recordReq onSuccess:^(id _Nullable data, id _Nullable rawData) {
RTCXCloudStorageRecordListRsp *rsp = data;
NSArray *records = rsp.recordFileList;
NSMutableArray *sectionArray = [[NSMutableArray alloc] initWithCapacity:0];
[records enumerateObjectsUsingBlock:^(RTCXCloudStorageRecordRsp *_Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
TimelineSectionClip *sectionClip = [[TimelineSectionClip alloc] init];
sectionClip.startTime = [NSDate dateWithTimeIntervalSince1970:obj.beginTime/1000];
sectionClip.endTime = [NSDate dateWithTimeIntervalSince1970:obj.endTime/1000];
[sectionArray addObject:sectionClip];
}];
[weakSelf.timelineData insertSectionDatas:sectionArray needUpdateWhenSameID:YES];
} onError:^(NSError * _Nullable error) {
[weakSelf showToast:@"查询云存录像列表失败"];
}];
查询云存事件列表
备注:该接口默认一次性返回beginTime和endTime时间段内所有数据,(注意:如果该时间段跨度比较大,可能查询比较耗时,所以建议不要跨度太大,或者通过分页查询)
- 分页规则:
-
设置pageSize参数,如pageSize = @(50)
-
当响应的RTCXCloudStorageRecordListRsp.nextValid = YES,说明可以继续查询下一页数据,否则没有可查询的更多数据了;
-
查寻下一页时,入参beginTime为上一次的beginTime,endTime为上一次的RTCXCloudStorageRecordListRsp.nextEndTime。
-
RTCXCloudStorageEventReq *eventReq = [[RTCXCloudStorageEventReq alloc] init];
eventReq.iotId = weakSelf.curDevice.iotId;
eventReq.beginTime = @(beginTime);
eventReq.endTime = @(endTime);
[RTCXDeviceService(RTCXCloudStorageProtocol) queryEventListWithReq:eventReq onSuccess:^(id _Nullable data, id _Nullable rawData) {
NSArray *events = data;
NSMutableArray *eventArray = [[NSMutableArray alloc] initWithCapacity:0];
[events enumerateObjectsUsingBlock:^(RTCXCloudStorageEventRsp *_Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
TimelineEventClip *eventClip = [[TimelineEventClip alloc] init];
eventClip.eventID = [NSString stringWithFormat:@"%ld",(long)obj.eventId];
eventClip.startTime = [NSDate dateWithTimeIntervalSince1970:obj.beginTime/1000];
eventClip.endTime = [NSDate dateWithTimeIntervalSince1970:obj.endTime/1000];
eventClip.eventType = [NSString stringWithFormat:@"%ld",(long)IOTEventModeMotion];
eventClip.region = obj.region;
[eventArray addObject:eventClip];
}];
[weakSelf.timelineData insertEventDatas:eventArray needUpdateWhenSameID:YES];
} onError:^(NSError * _Nullable error) {
[weakSelf showToast:@"查询事件列表失败"];
}];
查询云存录像点播地址
RTCXCloudStorageVodUrlReq *req = [[RTCXCloudStorageVodUrlReq alloc] init];
req.iotId = self.observer.iotId;
req.beginTime = @(startTime);
req.endTime = @(endTime);
[RTCXDeviceService(RTCXCloudStorageProtocol) queryVodUrlWithReq:req onSuccess:^(id _Nullable data, id _Nullable rawData) {
RTCXCloudStorageVodUrlRsp *rsp = data;
NSString *vodUrl = rsp.vodUrl;
} onError:^(NSError * _Nullable error) {
}];
查询云存事件点播地址
RTCXCloudStorageVodEventUrlReq *req = [[RTCXCloudStorageVodEventUrlReq alloc] init];
req.iotId = self.observer.iotId;
req.beginTime = @(startTime);
req.endTime = @(endTime);
[RTCXDeviceService(RTCXCloudStorageProtocol) queryVodEventUrlWithReq:req onSuccess:^(id _Nullable data, id _Nullable rawData) {
RTCXCloudStorageVodEventUrlRsp *rsp = data;
NSString *vodUrl = rsp.vodUrl;
} onError:^(NSError * _Nullable error) {
}];
查询月录像
RTCXCloudStorageMonthRecordReq *req = [[RTCXCloudStorageMonthRecordReq alloc] init];
req.iotId = self.curDevice.iotId;
req.beginTime = @(beginTime);
req.endTime = @(endTime);
req.zoneOffsetId = [self getTimeZoneOffset];
[RTCXDeviceService(RTCXCloudStorageProtocol) queryMonthRecordWithReq:req onSuccess:^(id _Nullable data, id _Nullable rawData) {
RTCXCloudStorageMonthRecordRsp *rsp = data;
self.monthRecordRsp = rsp;
[self reloadTableview];
} onError:^(NSError * _Nullable error) {
[self showToast:@"查询云录像统计列表失败"];
}];
查询月事件
RTCXCloudStorageMonthEventReq *req = [[RTCXCloudStorageMonthEventReq alloc] init];
req.iotId = self.curDevice.iotId;
req.beginTime = @(beginTime);
req.endTime = @(endTime);
req.zoneOffsetId = [self getTimeZoneOffset];
[RTCXDeviceService(RTCXCloudStorageProtocol) queryMonthEventWithReq:req onSuccess:^(id _Nullable data, id _Nullable rawData) {
RTCXCloudStorageMonthEventRsp *rsp = data;
self.monthEventRsp = rsp;
[self reloadTableview];
} onError:^(NSError * _Nullable error) {
[self showToast:@"查询云事件统计列表失败"];
}];
查询月消息
__weak typeof(self) weakSelf = self;
RTCXCloudStorageMonthMessageReq *req = [[RTCXCloudStorageMonthMessageReq alloc] init];
req.iotId = self.pickerMenuBar.selectedDevice.iotId;
req.beginTime = @([date?:self.foldingCalendarView.curMonthDate startOfMonthTimestamp]*1000);
req.endTime = @([date?:self.foldingCalendarView.curMonthDate startOfNextMonthTimestamp]*1000);
req.zoneOffsetId = [date?:self.foldingCalendarView.curMonthDate getTimeZoneOffset];
[RTCXDeviceService(RTCXCloudStorageProtocol) queryMonthMessageWithReq:req onSuccess:^(id _Nullable data, id _Nullable rawData) {
RTCXCloudStorageMonthMessageRsp *rsp = data;
NSMutableDictionary *eventDateDic = [[NSMutableDictionary alloc] initWithCapacity:0];
[rsp.eventCntList enumerateObjectsUsingBlock:^(RTCXCloudStorageDayMessageRsp * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
NSDate *date = [NSDate stringToDate:obj.dateStr format:@"yyyy-MM-dd"];
[eventDateDic setValue:date forKey:obj.dateStr];
}];
weakSelf.foldingCalendarView.eventDateDic = eventDateDic;
} onError:^(NSError * _Nullable error) {
[CURRENT_VIEW_CONTROLLER() showToast:@"查询消息统计列表失败"];
}];
删除云存录像
RTCXCloudStorageDeleteRecordReq *deleteRecordReq = [[RTCXCloudStorageDeleteRecordReq alloc] init];
deleteRecordReq.iotId = weakSelf.curDevice.iotId;
deleteRecordReq.beginTime = @(beginTime);
deleteRecordReq.endTime = @(endTime);
[RTCXDeviceService(RTCXCloudStorageProtocol) deleteRecordWithReq:deleteRecordReq onSuccess:^(id _Nullable data, id _Nullable rawData) {
[weakSelf showToast:@"删除云存录像成功"];
[weakSelf queryData];
} onError:^(NSError * _Nullable error) {
[weakSelf showToast:@"删除云存录像失败"];
}];
删除云存事件
RTCXCloudStorageDeleteEventInfo *eventInfo = [[RTCXCloudStorageDeleteEventInfo alloc] init];
eventInfo.eventId = eventId;
eventInfo.region = region;
if (lensId) {
eventInfo.lensId = @(lensId.intValue);
}
RTCXCloudStorageDeleteEventReq *deleteEventReq = [[RTCXCloudStorageDeleteEventReq alloc] init];
deleteEventReq.iotId = weakSelf.curDevice.iotId;
deleteEventReq.events = @[eventInfo];
[RTCXDeviceService(RTCXCloudStorageProtocol) deleteEventWithReq:deleteEventReq onSuccess:^(id _Nullable data, id _Nullable rawData) {
[weakSelf showToast:@"删除事件成功"];
[weakSelf queryData];
} onError:^(NSError * _Nullable error) {
[weakSelf showToast:@"删除事件失败"];
}];
删除消息中心事件
RTCXCloudStorageDeleteMessageInfo *msgInfo = [[RTCXCloudStorageDeleteMessageInfo alloc] init];
msgInfo.eventId = eventId;
msgInfo.region = region;
if (lensId) {
msgInfo.lensId = @(lensId.intValue);
}
RTCXCloudStorageDeleteMessageReq *deleteMsgtReq = [[RTCXCloudStorageDeleteMessageReq alloc] init];
deleteMsgtReq.iotId = weakSelf.curDevice.iotId;
deleteMsgtReq.messages = @[msgInfo];
[RTCXDeviceService(RTCXCloudStorageProtocol) deleteMessageWithReq:deleteMsgtReq onSuccess:^(id _Nullable data, id _Nullable rawData) {
[weakSelf showToast:@"删除消息成功"];
[weakSelf queryData];
} onError:^(NSError * _Nullable error) {
[weakSelf showToast:@"删除消息失败"];
}];
查询事件描述
即:查询事件最新记录时间,事件小红点
RTCXCloudStorageEventDescReq *req = [[RTCXCloudStorageEventDescReq alloc] init];
req.iotId = self.device.iotId;
[RTCXDeviceService(RTCXCloudStorageProtocol) queryEventDescWithReq:req onSuccess:^(id _Nullable data, id _Nullable rawData) {
RTCXCloudStorageEventDescRsp *rsp = data;
self.eventRsp = rsp;
if (rsp.latestBeginTime > 0 && rsp.latestBeginTime > [self getLocalRedDotBeginTimeAtIndex:1]) {
[self.dotStates replaceObjectAtIndex:1 withObject:@YES];
self.categoryView.dotStates = self.dotStates;
[self.categoryView reloadDataWithoutListContainer];
}
} onError:^(NSError * _Nullable error) {
}];
查询消息中心事件描述
即:消息中心最新记录时间,消息中心小红点
RTCXCloudStorageMessageDescReq *req = [[RTCXCloudStorageMessageDescReq alloc] init];
req.iotId = self.device.iotId;
[RTCXDeviceService(RTCXCloudStorageProtocol) queryMessageDescWithReq:req onSuccess:^(id _Nullable data, id _Nullable rawData) {
RTCXCloudStorageMessageDescRsp *rsp = data;
self.messageRsp = rsp;
if (rsp.latestBeginTime > 0 && rsp.latestBeginTime > [self getLocalRedDotBeginTimeAtIndex:2]) {
[self.dotStates replaceObjectAtIndex:2 withObject:@YES];
self.categoryView.dotStates = self.dotStates;
[self.categoryView reloadDataWithoutListContainer];
}
} onError:^(NSError * _Nullable error) {
}];