Cloud Storage Recording

Last Updated on : 2024-06-19 03:58:29download

IP cameras (IPCs) support the cloud storage service that allows users to save video footage on the IPCs to the cloud.

How it works

  1. Determine whether a device supports cloud storage. If this service is supported, proceed with the process.
  2. Get the cloud storage service status.
  3. Perform steps based on the service status.
    • If the cloud storage service is inactivated or has expired, this service must be purchased to enable cloud storage.

      After the cloud storage service expires, the existing cloud-stored video files will be retained for a period, seven days in most cases. At the end of this period, all cloud-stored video files will be deleted.

    • If the cloud storage service is within the validity period:

      1. Get the date on which the cloud-stored video files were created.
      2. Get the data of the specified date, including cloud storage events, timeline data, and authentication information.
      3. Select a cloud storage event or a time point to start cloud-stored video playback.
      Cloud Storage Recording

Core methods

Demo Class Method Description
IThingIPCCloud isSupportCloudStorage Check support for cloud storage.
IThingIPCCloud createCloudCamera Create a camera object for cloud storage. One device ID matches one camera object.
IThingCloudCamera queryCloudServiceStatus Query cloud storage status.
  • 10001: The cloud storage service is not purchased.
  • 10010: The cloud storage service has already been activated.
  • 10011: The cloud storage service has expired.
IThingCloudCamera getTimeLineInfo Query video clips within a specified period.
IThingCloudCamera playCloudDataWithStartTime Start playback.
IThingCloudCamera stopPlayCloudVideo Stop playback.

Important notes

Some IThingCloudCamera APIs are implemented asynchronously. It is recommended not to call other methods of an object within this object’s callback, as it may cause Application Not Responding (ANR) issues.

Core code

Query cloud storage status

void queryCloudServiceStatus(String devId, IThingResultCallback<CloudStatusBean> callback);

Query video clips within a specified period

void getTimeLineInfo(String devId, long timeGT, long timeLT, IThingResultCallback<List<TimePieceBean>> callback);

Start playback

void playCloudDataWithStartTime(long mStartTime, long mEndTime, boolean isEvent, OperationCallBack callback, OperationCallBack playFinishedCallBack);

Java:

// Check if cloud storage is supported.
IThingIPCCloud cloud = ThingIPCSdk.getCloud();
    if (cloud != null) {
    isSupportCloudStorage = cloud.isSupportCloudStorage(devId);
    }
// Create a camera object.
IThingCloudCamera cloudCamera;
    if (cloud != null) {
    cloudCamera = cloud.createCloudCamera();
    }
// Initialize the device.
cloudCamera.createCloudDevice(cachePath, devId);

ThingCameraView mVideoView = findViewById(R.id.camera_video_view);
// Set the callback for the view rendering container.
mVideoView.setViewCallback(new AbsVideoViewCallback() {
    @Override
    public void onCreated(Object view) {
        super.onCreated(view);
        // When the rendering view is constructed, bind it to IThingCloudCamera.
        if (null != cloudCamera){
            cloudCamera.generateCloudCameraView(view);
        }
    }
});
// Construct the rendering view.
mVideoView.createVideoView(devId);
// Register a listener with IThingCloudCamera to ensure the video feed is displayed correctly.
cloudCamera.registorOnP2PCameraListener(new AbsP2pCameraListener() {
@Override
public void onSessionStatusChanged(Object camera, int sessionId, int sessionStatus) {
        super.onSessionStatusChanged(camera, sessionId, sessionStatus);
        }
        });
// Check cloud storage activation.
cloudCamera.queryCloudServiceStatus(devId, new IThingResultCallback<CloudStatusBean>() {
@Override
public void onSuccess(CloudStatusBean result) {
        //Get cloud storage status
        }

@Override
public void onError(String errorCode, String errorMessage) {

        }
        });
// Get video clips.
CloudDayBean dayBean = dayBeanList.get(0);
        cloudCamera.getTimeLineInfo(devId, dayBean.getCurrentStartDayTime(), dayBean.getCurrentDayEndTime(), new IThingResultCallback<List<TimePieceBean>>() {
@Override
public void onSuccess(List<TimePieceBean> result) {

        }

@Override
public void onError(String errorCode, String errorMessage) {

        }
        });
// Play clip
cloudCamera.playCloudDataWithStartTime(startTime, endTime, isEvent,
        new OperationCallBack() {
@Override
public void onSuccess(int sessionId, int requestId, String data, Object camera) {
        // Callback during playback, playing
        }

@Override
public void onFailure(int sessionId, int requestId, int errCode, Object camera) {

        }
        }, new OperationCallBack() {
@Override
public void onSuccess(int sessionId, int requestId, String data, Object camera) {
        // Callback when playback completes, playCompleted
        }

@Override
public void onFailure(int sessionId, int requestId, int errCode, Object camera) {
        }
        });

// Stop playing.
cloudCamera.stopPlayCloudVideo(new OperationDelegateCallBack() {
@Override
public void onSuccess(int sessionId, int requestId, String data) {
        }

@Override
public void onFailure(int sessionId, int requestId, int errCode) {

        }
        });
// Release the camera object when the page is closed.
// Deinitialize.
cloudCamera.deinitCloudCamera();
// Remove listener.
cloudCamera.removeOnP2PCameraListener();
// Destroy.
cloudCamera.destroy();