Last Updated on : 2023-08-09 08:09:35download
Cloud storage stores the recording data on object storage servers provided by third-party cloud vendors. The ring buffer combined with the cloud object storage service enables you to back up recording data to the cloud instantly.
Cloud storage reads audio and video data from the ring buffer and then uploads it to the cloud object storage server after encryption. Cloud storage features:
Both the channel and data are encrypted to secure transmission.
HTTPS protocol secures transferring the data between a device and a cloud object storage server. The device uploads the recording data only after the certificate authority (CA) certificate of the object storage server is verified successfully.
Before the recording data is uploaded, the video I-frames and audio frames will be encrypted with AES algorithms.
svc_cloud_storage
typedef enum
{
CLOUD_STORAGE_TYPE_CONTINUE, // Continuous cloud storage.
CLOUD_STORAGE_TYPE_EVENT, // Event-based cloud storage.
CLOUD_STORAGE_TYPE_INVALID // No subscription.
} CLOUD_STORAGE_TYPE_E;
Initialize the cloud storage service. This allocates the internal buffer memory and creates recording threads.
/**
* @brief initialize cloud storage, which will malloc all needed memory after this
* @return error code
* - OPRT_OK init success
* - Others init failed
*/
OPERATE_RET tuya_ipc_cloud_storage_init(VOID);
Deinitialize the cloud storage service. This deallocates the buffer memory and destroys the recording threads.
/**
* @brief uninit cloud storage, free used memory
* @return VOID
*/
VOID tuya_ipc_cloud_storage_uninit(VOID);
Get the order type to determine if the device has subscribed to the cloud storage service. The order type can be continuous cloud storage, event-based cloud storage, and no subscription.
/**
* @brief get current storage type, based on purchase order
* @return CLOUD_STORAGE_TYPE_E
* - CLOUD_STORAGE_TYPE_CONTINUE continuous record type
* - CLOUD_STORAGE_TYPE_EVENT event-based type, only record and store audio/video when there is event happening
* - CLOUD_STORAGE_TYPE_INVALID no cloud storage order exist
*/
CLOUD_STORAGE_TYPE_E tuya_ipc_cloud_storage_get_store_mode(VOID);
The device records a video clip when an event occurs.
/**
* @brief start event cloud storage
* @return error code
* - OPRT_OK cloud storage start success
* - Others cloud storage start failed
*/
OPERATE_RET tuya_ipc_cloud_storage_event_start(VOID);
The device stops recording when an event ends. This is a synchronous API, with a maximum blocking time of 30 seconds.
/**
* @brief stop event cloud storage, synchronous api
* @return error code
* - OPRT_OK cloud storage stop success
* - Others cloud storage stop failed
*/
OPERATE_RET tuya_ipc_cloud_storage_event_stop(VOID);
The device stops recording when an event ends. This is a non-blocking asynchronous API.
/**
* @brief stop event cloud storage, asynchronous api
* @return error code
* - OPRT_OK cloud storage stop success
* - Others cloud storage stop failed
*/
OPERATE_RET tuya_ipc_cloud_storage_event_stop_async(VOID);
Get the current recording status to determine if the device is recording a video.
/**
* @brief get cloud storage status
* @return BOOL_T
* - TRUE cloud storage is uploading
* - FALSE cloud storage is not uploading
*/
BOOL_T tuya_ipc_cloud_storage_get_status(VOID);
When audio is turned off, only video data is read from the ring buffer for cloud storage.
/**
* @brief set audio open/close
* @param[in] is_audio_open
* @ref TRUE open audio for cloud storage
* @ref FALSE close audio for cloud storage
* @return VOID
*/
VOID tuya_ipc_cloud_storage_set_audio_stat(BOOL_T is_audio_open);
The maximum pre-record duration cannot exceed the maximum ring buffer duration. If you do not specify a value, the default duration is two seconds.
/**
* @brief set cloud storage pre record time duration
* @param[in] pre_recode_time pre record time duration for cloud storage
* - OPRT_OK set pre record time success
* - Others set pre record time failed
*/
OPERATE_RET tuya_ipc_cloud_storage_set_pre_record_time(INT_T pre_record_time);
Temporarily disable recording cloud storage. The recording thread stops reading data from the ring buffer and uploading data to the server. This feature is typically triggered when the user turns on privacy mode.
/**
* @brief pause cloud storage, used in privacy mode e.g.
* @return VOID
*/
VOID tuya_ipc_cloud_storage_pause(VOID);
Resume recording cloud storage and the recording thread. Used with tuya_ipc_cloud_storage_pause
, this feature is triggered when the user turns off privacy mode.
/**
* @brief resume cloud storage which is paused by pause API
* @return VOID
*/
VOID tuya_ipc_cloud_storage_resume(VOID);
Contiguous memory is allocated when the cloud storage service is initialized. This can avoid the out of memory (OOM) error caused by changes in memory usage when the program is run. The footprint is: 11 × bit rate
The allocated memory is used to buffer the encrypted audio and video data to be uploaded to the cloud object storage server.
The allocated memory is freed when the cloud storage is deinitialized.
To locate the pre-frame in the ring buffer, starting from the latest frame, search backward for frame_num
frame and then continue the search until the I-frame is reached. frame_num
is calculated by the formula: pre-record duration × frame rate in fps
Therefore, the pre-frame is not at a fixed position, so the actual pre-record duration might deviate from the set value.
The mainstream is used by default. Substream recording is not supported currently.
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback