Last Updated on : 2022-02-17 06:50:20download
Cloud-based video talk is implemented to connect an app with a cloud-based video intercom that supports video surveillance, access control, and more capabilities. This module relies on Tuya Smart Life IPC SDK to enable the desired features.
Use the cloud-based video surveillance management class to load configurations. After a successful callback, initialize a Powered by Tuya
(PBT) IP camera (IPC) and connect to the video streaming channels to enable video previewing.
Add a delegate for TuyaCommunityVisualSpeakManager
.
When device information is received, the delegate method receiveDeviceMessageWithType: messageModel:
is triggered. In the delegate method, load device configurations and connect to the video streaming channels to enable video previewing.
With video previewing enabled, connect to the audio channels to enable voice talk.
The IPC SDK must be integrated. The following IPC SDK version is recommended:
pod 'TuyaSmartCameraKit', '4.28.5.2'
Manages device configurations and executes device communication callbacks.
Class name | Description |
---|---|
TuyaCommunityVisualSpeakManager | The cloud-based video talk management class. It is a singleton class. |
TuyaCommunityVisualSpeakManagerDelegate | The callback that is executed when a message from the cloud-based video intercom is received. For example, make a call, answer the call, or hang up the call. |
Loads device configurations. After the success callback, the subsequent process can continue and the audio and video communication between the app and the device can be started.
API description
- (void)loadConfigWithDeviceId:(NSString *)deviceId
gatewayId:(nullable NSString *)gatewayId
success:(void(^)(void))success
failure:(void(^)(NSError *error))failure;
Request parameter
Parameter | Description |
---|---|
deviceId | The device ID. |
gatewayId | The ID of a gateway. This parameter is only required when the device is connected to the gateway. |
success | The success callback. |
failure | The failure callback. |
Example
[TuyaCommunityVisualSpeakManager.shareInstance loadConfigWithDeviceId:@"device_id" gatewayId:@"gateway_id" success:^{
NSLog(@"load config success");
} failure:^(NSError * _Nonnull error) {
NSLog(@"load config error: %@", error.localizedDescription);
}];
Adds a delegate for the cloud-based video talk management class to implement the communication protocol.
API description
- (void)addDelegate:(id<TuyaCommunityVisualSpeakManagerDelegate>)delegate;
Removes a delegate when it is no longer required.
API description
- (void)removeDelegate:(id<TuyaCommunityVisualSpeakManagerDelegate>)delegate;
Executes the callback in the following delegate method when the app receives a message during the communication with the device.
API description
- (void)receiveDeviceMessageWithMessageModel:(TuyaCommunityVisualSpeakDeviceMessageModel *)messageModel;
Data model of TuyaCommunityVisualSpeakDeviceMessageModel
Property | Description |
---|---|
deviceId | The device ID. |
roomId | The room ID. |
type | The type of communication. The value can be returned by the enumeration class TuyaCommunityVisualSpeakCommunicationType . |
reqType | The type of call. |
sn | The ID of the call. |
Enumeration class of TuyaCommunityVisualSpeakCommunicationType
Type | Description |
---|---|
TuyaCommunityVisualSpeakCommunicationTypeUnknow | An unknown error has occurred. |
TuyaCommunityVisualSpeakCommunicationTypeCalling | The call is in process. |
TuyaCommunityVisualSpeakCommunicationTypeDeviceHungUp | The device hangs up the call. |
TuyaCommunityVisualSpeakCommunicationTypeCallTimeoutHungUp | The call automatically hangs up due to timeout. |
TuyaCommunityVisualSpeakCommunicationTypeCallPassiveHungUp | The call is rejected. |
TuyaCommunityVisualSpeakCommunicationTypeAnswer | The call is answered. |
TuyaCommunityVisualSpeakCommunicationTypeTimeOutHungUp | The call automatically hangs up due to timeout. |
Example
- (void)viewDidLoad {
[super viewDidLoad];
[TuyaCommunityVisualSpeakManager.shareInstance addDelegate:self];
}
#pragma mark - TuyaCommunityVisualSpeakManagerDelegate
- (void)receiveDeviceMessageWithMessageModel:(TuyaCommunityVisualSpeakDeviceMessageModel *)messageModel {
// Receives device messages and processes them based on `model.type`.
}
Users can check video surveillance devices in public areas by using the app.
Classes
Class name | Description |
---|---|
TuyaCommunityPublicMonitorService | The service class for video surveillance in public areas. |
TuyaCommunityPublicMonitorModel | The data model for video surveillance in public areas. |
Data model of TuyaCommunityPublicMonitorModel
Field | Description |
---|---|
deviceId | The device ID. |
deviceName | The name of the device. |
deviceThumbnailsUrl | The URL of the device thumbnail. |
deviceStatus | The device status. |
gatewayId | The gateway ID. |
Returns a list of video surveillance devices in public areas.
API description
- (void)getPublicMonitorListWithCommunityId:(NSString *)communityId
roomId:(NSString *)roomId
success:(void(^)(NSArray<TuyaCommunityPublicMonitorModel *> *list))success
failure:(void(^)(NSError *error))failure;
Request parameter
Parameter | Description |
---|---|
communityId | The community ID. |
roomId | The room ID. |
success | The success callback. |
failure | The failure callback. |
Example
[self.publicMonitorService getPublicMonitorListWithCommunityId:@"community_id" roomId:@"room_id" success:^(NSArray<TuyaCommunityPublicMonitorModel *> * _Nonnull list) {
NSLog(@"get public monitor list success");
} failure:^(NSError * _Nonnull error) {
NSLog(@"get public monitor list failure: %@", error.localizedDescription);
}];
Each video access control device supports the following features:
Class name | Description |
---|---|
TuyaCommunityAccessControlService | The access control service class. |
TuyaCommunityAccessControlModel | The access control data model. |
Data model of TuyaCommunityAccessControlModel
Field | Description |
---|---|
deviceId | The device ID. |
deviceName | The name of the device. |
roomId | The room ID. |
deviceStatus | The device status. |
deviceType | The type of device. The value can be returned by the enumeration class TuyaCommunityVisualSpeakDeviceType . |
TuyaCommunityVisualSpeakDeviceType
Field | Description |
---|---|
TuyaCommunityVisualSpeakDeviceTypeAccessControl | Access control device |
TuyaCommunityVisualSpeakDeviceTypePublicMonitor | Video surveillance device in public areas |
TuyaCommunityVisualSpeakDeviceTypeCentralMachine | Central control system |
Returns a list of access control devices assigned to a user.
API description
- (void)getAccessControlListWithCommunityId:(NSString *)communityId
roomId:(NSString *)roomId
success:(void(^)(NSArray<TuyaCommunityAccessControlModel *> *list))success
failure:(void(^)(NSError *error))failure;
Request parameter
Parameter | Description |
---|---|
communityId | The community ID. |
roomId | The room ID. |
success | The success callback. |
failure | The failure callback. |
Example
[self.accessControlService getAccessControlListWithCommunityId:@"community_id" roomId:@"room_id" success:^(NSArray<TuyaCommunityAccessControlModel *> * _Nonnull list) {
NSLog@(@"get access control list success");
} failure:^(NSError * _Nonnull error) {
NSLog(@"get access control list error: %@", error.localizedDescription);
}];
Returns the maximum number of times the access control videos can be previewed. You can set this upper limit on the platform. The return value of this API method is an integer that indicates the daily preview quota.
API description
- (void)getAccessControlViewableTimesWithCommunityId:(NSString *)communityId
roomId:(NSString *)roomId
deviceId:(NSString *)deviceId
success:(void(^)(int number))success
failure:(void(^)(NSError *error))failure;
Request parameter
Parameter | Description |
---|---|
communityId | The community ID. |
roomId | The room ID. |
deviceId | The device ID. |
success | The success callback. |
failure | The failure callback. |
Example
[self.accessControlService getAccessControlViewableTimesWithCommunityId:@"community_id" roomId:@"room_id" deviceId:@"device_id" success:^(int number) {
NSLog(@"get access control viewable times success");
} failure:^(NSError * _Nonnull error) {
NSLog(@"get access control viewable times failure: %@", error.localizedDescription);
}];
Indicates the access control status after the app receives a call from the device. If the device is in the idle state, users can call the device by using the app.
API description
- (void)getAccessControlStatusWithCommunityId:(NSString *)communityId
roomId:(NSString *)roomId
deviceId:(NSString *)deviceId
sn:(NSString *)sn
success:(void(^)(TuyaCommunityVisualSpeakCommunicationType type))success
failure:(void(^)(NSError *error))failure;
Request parameter
Parameter | Description |
---|---|
communityId | The community ID. |
roomId | The room ID. |
deviceId | The device ID. |
sn | The ID of the call. |
success | The success callback. |
failure | The failure callback. |
Example
[self.accessControlService getAccessControlStatusWithCommunityId:@"community_id" roomId:@"room_id" deviceId:@"device_id" sn:@"sn" success:^(TuyaCommunityVisualSpeakCommunicationType type) {
NSLog(@"get access control status success");
} failure:^(NSError * _Nonnull error) {
NSLog(@"get access control status failure: %@", error.localizedDescription);
}];
Unlocks a door.
API description
- (void)openDoorWithCommunityId:(NSString *)communityId
roomId:(NSString *)roomId
deviceId:(NSString *)deviceId
success:(void(^)(id result))success
failure:(void(^)(NSError *error))failure;
Request parameter
Parameter | Description |
---|---|
communityId | The community ID. |
roomId | The room ID. |
deviceId | The device ID. |
success | The success callback. |
failure | The failure callback. |
Example
[self.accessControlService openDoorWithCommunityId:@"community_id" roomId:@"room_id" deviceId:@"device_id" success:^(id _Nonnull result) {
NSLog(@"open door success");
} failure:^(NSError * _Nonnull error) {
NSLog(@"open door failure: %@", error.localizedDescription);
}];
Rejects a call from the access control device.
API description
- (void)rejectWithCommunityId:(NSString *)communityId
roomId:(NSString *)roomId
deviceId:(NSString *)deviceId
sn:(NSString *)sn
success:(void(^)(id result))success
failure:(void(^)(NSError *error))failure
Request parameter
Parameter | Description |
---|---|
communityId | The community ID. |
roomId | The room ID. |
deviceId | The device ID. |
sn | The ID of the call. |
success | The success callback. |
failure | The failure callback. |
Example
[self.accessControlService rejectWithCommunityId:@"community_id" roomId:@"room_id" deviceId:@"device_id" sn:@"sn" success:^(id _Nonnull result) {
NSLog(@"reject success");
} failure:^(NSError * _Nonnull error) {
NSLog(@"reject failure: %@", error.localizedDescription);
}];
Answers a call from the access control device.
API description
- (void)acceptWithDeviceId:(NSString *)deviceId
success:(nullable void(^)(void))success
failure:(nullable void(^)(NSError *error))failure;
Request parameter
Parameter | Description |
---|---|
deviceId | The device ID. |
success | The success callback. |
failure | The failure callback. |
Example
[self.accessControlService acceptWithDeviceId:@"device_id" success:nil failure:nil];
Hangs up a call from the access control device
API description
- (void)hangUpWithDeviceId:(NSString *)deviceId
success:(nullable void(^)(void))success
failure:(nullable void(^)(NSError *error))failure;
Request parameter
Parameter | Description |
---|---|
deviceId | The device ID. |
success | The success callback. |
failure | The failure callback. |
Example
[self.service hangUpWithDeviceId:"device_id" success:nil failure:nil];
Records the duration of a call after a user hangs up or receives the hangup notification from the device.
API description
- (void)recordTimeWithCommunityId:(NSString *)communityId
roomId:(NSString *)roomId
deviceId:(NSString *)deviceId
callTime:(long long)callTime
talkTime:(NSInteger)talkTime
direction:(NSInteger)direction
success:(nullable void(^)(void))success
failure:(nullable void(^)(NSError *error))failure;
Request parameter
Parameter | Description |
---|---|
communityId | The community ID. |
roomId | The room ID. |
deviceId | The device ID. |
callTime | The start timestamp of the call. Unit: milliseconds. |
talkTime | The duration of the call. Unit: seconds. |
direction | The direction of the call. The value is 1 . |
success | The success callback. |
failure | The failure callback. |
Example
[self.accessControlService recordTimeWithCommunityId:"community_id" roomId:@"room_id" deviceId:@"device_id" callTime:1629890889000 talkTime:10 direction:1 success:^{
NSLog(@"record time success");
} failure:^(NSError * _Nonnull error) {
NSLog(@"record time failure: %@", error.localizedDescription);
}];
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback