Integrating the camera registry

Clearance Developer Guide

Content type
Guides > Developer guides
Product line
Clearance
Language
English
Applies to
Genetec Clearance

The camera registry connects networked security cameras, helping authorities in accessing Genetec Clearance™ evidence. It integrates using a specific Agent protocol, compatible with cloud or on-premises, allowing display and automatic media extraction based on registry requests.

The registry protocol is an agent-based job processing framework where Agents (your integration) act as a client that communicates through REST with the Clearance Registry Agent service (the Registry). The Agent polls the service for available jobs to complete. Once a job is available, the Agent must lock the job and process it. Once the process is complete, it must complete the job with the service.

This document goes through the various functionalities that your Agent must implement to properly integrate to the registry.


image

For more information, consult the full API documentation.

There are currently three types of job that the Agent can do:

  • mediarequest: This job's objective is to extract a media file from the external or proprietary system.

  • discovery: This job's objective is to discover the available device in the external or proprietary system.

  • thumbnail: This job's objective is to extract a thumbnail image from the device in the external or proprietary system.

The authentication mechanism is the same across all Clearance APIs as explained in Authentication.

Media request job

The first call that the Agents have to make is to get the jobs that are available for their Agent. If no jobs are returned, then there is nothing for the Agent to do currently. The agent should poll this endpoint at regular intervals to see if a new job has been posted.

Once the agent has a list of available jobs, they can choose, based on their own criteria which one they take.

Once a job is selected, the Agent locks the job to avoid having two Agents work on the same job.

(Optional) The Agent can report the progress of their work by updating the job. This is done by providing a taskProgress and a taskTotal. The progress is divided by the total to obtain a progress percentage.

(Optional) The Agent is responsible for renewing their lock when it approaches the provided expiration date. Failure to renew the lock results in the job becoming available again for pickup, and in the loss of progress.

Once the job is finished, the Agent can complete the job with a state (Completed, PartiallyCompleted, or Failed).

The actual processing of the job is explained in the Uploading a job result section below.


image

Device discovery job

The process of discovering devices or thumbnails starts the same way as a media requests. A discovery-type job is posted. Then, the Agent polls for jobs. Once the job is available, the Agent can choose to pick this job and lock it.

(Optional) The Agent can provide updates on the progress of this job.

(Optional) The Agent can renew the lock on the job if it gets close to the expiration time to avoid losing the lock and the progress on the current job.

Once the work is done, the Agent completes the job, similar as to with a media request.

The actual processing of the job is explained in the Uploading a job result section below.


image

Thumbnail job

The process of the thumbnail job starts the same way as a media request job. A thumbnail-type job is posted. Then, the Agent polls for jobs. Once the job is available, the Agent can choose to pick this job and lock it.

(Optional) The Agent can provide updates on the progress of this job.

(Optional) The Agent can renew the lock on the job if it gets close to the expiration time to avoid losing the lock and the progress on the current job.

Once the work is done, the Agent completes the job, similar as in a media request.

The actual processing of the job is explained in the Uploading a job result section below.


image

Uploading a job result

After locking a job, the Agent knows they are responsible for providing the requested files. To do so, the Agent uses the File APIs.

First, the Agent calls the InitializeUpload, a single endpoint for any job type.

Calling this endpoint provide three important details to the Agent:

  • The file ID used when calling the API endpoints.

  • The JsonWebKey used to encrypt each block of the file that is being uploaded.

  • The Uri, which contains the SAS token, specifying where to upload the file.

Next, the Agent encrypts the file and uploads it using the key and the URI provided in the InitializeUpload response.

The encryption data then needs to be added to the file storage as a metadata, using encryptiondata as the metadata key and a serialized version of the EncryptionDataModel used to encrypt the file.

Once the file is uploaded, the Agent calls the CompleteMedia, CompleteDiscovery, or CompleteThumbnail, according to the job type.

Once the file upload is complete, the Agent can upload other files for the same job. If there is only one file, the Agent can complete the job as shown in the previous diagrams.


image

EncryptionDataModel

/// <summary>
/// Data used for the encryption of the content and the key
/// </summary>
public class EncryptionDataModel
{
    /// <summary>
    /// Encryption IV used for the encryption of the content
    /// </summary>
    public byte[] ContentEncryptionIV { get; set; }

    /// <summary>
    /// Encryption information of the content
    /// </summary>
    public EncryptionDataAgentModel EncryptionAgent { get; set; }

    /// <summary>
    /// Encryption information of the key used to encrypt the content
    /// </summary>
    public EncryptionDataContentKeyModel WrappedContentKey { get; set; }
}

public class EncryptionDataAgentModel
{
    /// <summary>
    /// Encryption algorithm used for the content
    /// </summary>
    public string EncryptionAlgorithm { get; set; } = "AES_CBC_256";
}

public class EncryptionDataContentKeyModel
{
    /// <summary>
    /// Algorithm used to encrypt the content encryption key
    /// </summary>
    public string Algorithm { get; set; } = "RSA-OAEP";

    /// <summary>
    /// Encrypted content encryption key 
    /// </summary>
    public byte[] EncryptedKey { get; set; }

    /// <summary>
    /// Encryption key id
    /// </summary>
    public string KeyId { get; set; }
}

Canceling a job

If the Agent is unable to fulfill a job for any reason, they can cancel it. Once canceled, the job remains unavailable.


image

Releasing a job

If the Agent is currently unable to fulfill a job but anticipates being able to do so later, they can choose to release the job. Releasing the job makes it available again for another Agent to pick up. The Agent then has the freedom to select a job of their choice from the list of available jobs.


image

Code sample

You can download a code sample, which requires a connection string that Genetec provides upon request.