C API

Header files

drmc.h

Defines

MAX_MSG_SIZE

Accelize DRM C Library.

PARAMETERKEY_ITEM(id)

Typedefs

typedef int (*ReadRegisterCallback)(uint32_t, uint32_t *, void *user_p)

FPGA read register callback function. The register offset is relative to first register of DRM controller.

Warning

This function must be thread-safe in case of concurrency on the register bus.

Parameters
  • [in] register_offset: : Register offset relative to DRM controller IP base address.

  • [in] returned_data: : Pointer to an integer that will contain the value of the corresponding register.

  • [in] user_p: : User pointer.

typedef int (*WriteRegisterCallback)(uint32_t, uint32_t, void *user_p)

FPGA write register callback function. The register offset is relative to first register of DRM controller.

Warning

This function must be thread-safe in case of concurrency on the register bus.

Parameters
  • [in] register_offset: : Register offset relative to DRM controller IP base address.

  • [in] data_to_write: : Data to write in register.

  • [in] user_p: : User pointer.

typedef void (*AsynchErrorCallback)(const char *, void *user_p)

Asynchronous Error handling callback function. This function is called in case of asynchronous error during operation.

Parameters
  • [in] error_message: : Error message.

  • [in] user_p: : User pointer.

Enums

enum DrmParameterKey

Typedef enum listing the parameters accessible from User code. Some have ready only access while others have read and write access.

Values:

DRM__ParameterKeyCount

Functions

const char *DrmManager_getApiVersion()

Return API version.

DRM_ErrorCode DrmManager_alloc(DrmManager **p_m, const char *conf_file_path, const char *cred_file_path, ReadRegisterCallback read_register, WriteRegisterCallback write_register, AsynchErrorCallback async_error, void *user_p)

Instantiate and initialize a DRM manager.

See

ReadRegisterCallback WriteRegisterCallback AsynchErrorCallback

Return

An error code defined by the enumerator DRM_ErrorCode indicating the success or the cause of the error during the function execution.

Parameters
  • [in] p_m: : Pointer to a DrmManager pointer that will be set to the new constructed object.

  • [in] conf_file_path: : Path to the DRM configuration JSON file.

  • [in] cred_file_path: : Path to the user Accelize credential JSON file.

  • [in] read_register: : FPGA read register callback function.

  • [in] write_register: : FPGA write register callback function.

  • [in] async_error: : Asynchronous Error handling callback function.

  • [in] user_p: : User pointer that will be passed to the callback functions.

DRM_ErrorCode DrmManager_free(DrmManager **p_m)

Free a DRM manager object.

Return

An error code defined by the enumerator DRM_ErrorCode indicating the success or the cause of the error during the function execution.

Parameters
  • [in] p_m: : Pointer to a DrmManager pointer that will be freed. After *p_m == NULL.

DRM_ErrorCode DrmManager_activate(DrmManager *m, bool resume_session_request)

Activate DRM session.

This function activate/unlocks the hardware by unlocking the protected IPs in the FPGA and opening a DRM session.

If a session is still pending the behavior depends on “resume_session_request” argument. If true the session is reused. Otherwise the session is closed and a new session is created.

This function will start a thread that keeps the hardware unlocked by automatically updating the license when necessary.

Any error during this thread execution will be reported asynchronously through the “async_error” function, if provided in constructor.

When this function returns and the license is valid, the protected IPs are guaranteed to be unlocked.

Return

An error code defined by the enumerator DRM_ErrorCode indicating the success or the cause of the error during the function execution.

Parameters
  • [in] m: : Pointer to a DrmManager object.

  • [in] resume_session_request: : If true, the pending session is reused. If no pending session is found, create a new one. If false and a pending session is found, close it and create a new one. Set to false to have default behavior.

DRM_ErrorCode DrmManager_deactivate(DrmManager *m, bool pause_session_request)

Deactivate DRM session.

This function deactivates/locks the hardware back and close the session unless the “pause_session_request” argument is True. In this case, the session is kept opened for later use.

This function will join the thread keeping the hardware unlocked.

When the function returns, the hardware are guaranteed to be locked.

Return

An error code defined by the enumerator DRM_ErrorCode indicating the success or the cause of the error during the function execution.

Parameters
  • [in] m: : Pointer to a DrmManager object.

  • [in] pause_session_request: : If true, the current session is kept open for later usage. Otherwise, the current session is closed. Set to false to have default behavior.

DRM_ErrorCode DrmManager_get_json_string(DrmManager *m, const char *json_in, char **json_out)

Get information from the DRM system.

This function gives access to the internal parameter of the DRM system.

Return

An error code defined by the enumerator DRM_ErrorCode indicating the success or the cause of the error during the function execution.

Note

The function will allocated the output string, json_out. This is the responsibility to the user to free it: free(json_out)

Parameters
  • [in] m: : Pointer to a DrmManager object.

  • [in] json_in: : JSON formatted string listing the parameter names requested as key associated to any value. For instance, std::string json_string = “{“NUM_ACTIVATORS”: null, “SESSION_ID”: null}”;

  • [out] json_out: : Pointer to a char* that will point to a JSON formatted string containing the parameter names requested and their actual values in the DRM system.

DRM_ErrorCode DrmManager_get_bool(DrmManager *m, const DrmParameterKey key_id, bool *p_value)

Get information from the DRM system.

This function gives access to the internal parameter of the DRM system.

Return

An error code defined by the enumerator DRM_ErrorCode indicating the success or the cause of the error during the function execution.

Parameters
  • [in] m: : Pointer to a DrmManager object.

  • [in] key_id: : Unique identifier of the parameter to access; available IDs are listed in DrmParameterKey.

  • [out] p_value: : Pointer to a boolean that will contain the value of the corresponding parameter.

DRM_ErrorCode DrmManager_get_int(DrmManager *m, const DrmParameterKey key_id, int *p_value)

Get information from the DRM system.

This function gives access to the internal parameter of the DRM system.

Return

An error code defined by the enumerator DRM_ErrorCode indicating the success or the cause of the error during the function execution.

Parameters
  • [in] m: : Pointer to a DrmManager object.

  • [in] key_id: : Unique identifier of the parameter to access; available IDs are listed in DrmParameterKey.

  • [out] p_value: : Pointer to an integer that will contain the value of the corresponding parameter.

DRM_ErrorCode DrmManager_get_uint(DrmManager *m, const DrmParameterKey key_id, unsigned int *p_value)

Get information from the DRM system.

This function gives access to the internal parameter of the DRM system.

Return

An error code defined by the enumerator DRM_ErrorCode indicating the success or the cause of the error during the function execution.

Parameters
  • [in] m: : Pointer to a DrmManager object.

  • [in] key_id: : Unique identifier of the parameter to access; available IDs are listed in DrmParameterKey.

  • [out] p_value: : Pointer to an unsigned integer that will contain the value of the corresponding parameter.

DRM_ErrorCode DrmManager_get_int64(DrmManager *m, const DrmParameterKey key_id, long long *p_value)

Get information from the DRM system.

This function gives access to the internal parameter of the DRM system.

Return

An error code defined by the enumerator DRM_ErrorCode indicating the success or the cause of the error during the function execution.

Parameters
  • [in] m: : Pointer to a DrmManager object.

  • [in] key_id: : Unique identifier of the parameter to access; available IDs are listed in DrmParameterKey.

  • [out] p_value: : Pointer to a long integer that will contain the value of the corresponding parameter.

DRM_ErrorCode DrmManager_get_uint64(DrmManager *m, const DrmParameterKey key_id, unsigned long long *p_value)

Get information from the DRM system.

This function gives access to the internal parameter of the DRM system.

Return

An error code defined by the enumerator DRM_ErrorCode indicating the success or the cause of the error during the function execution.

Parameters
  • [in] m: : Pointer to a DrmManager object.

  • [in] key_id: : Unique identifier of the parameter to access; available IDs are listed in DrmParameterKey.

  • [out] p_value: : Pointer to an unsigned long integer that will contain the value of the corresponding parameter.

DRM_ErrorCode DrmManager_get_float(DrmManager *m, const DrmParameterKey key_id, float *p_value)

Get information from the DRM system.

This function gives access to the internal parameter of the DRM system.

Return

An error code defined by the enumerator DRM_ErrorCode indicating the success or the cause of the error during the function execution.

Parameters
  • [in] m: : Pointer to a DrmManager object.

  • [in] key_id: : Unique identifier of the parameter to access; available IDs are listed in DrmParameterKey.

  • [out] p_value: : Pointer to a float that will contain the value of the corresponding parameter.

DRM_ErrorCode DrmManager_get_double(DrmManager *m, const DrmParameterKey key_id, double *p_value)

Get information from the DRM system.

This function gives access to the internal parameter of the DRM system.

Return

An error code defined by the enumerator DRM_ErrorCode indicating the success or the cause of the error during the function execution.

Parameters
  • [in] m: : Pointer to a DrmManager object.

  • [in] key_id: : Unique identifier of the parameter to access; available IDs are listed in DrmParameterKey.

  • [out] p_value: : Pointer to a double float that will contain the value of the corresponding parameter.

DRM_ErrorCode DrmManager_get_string(DrmManager *m, const DrmParameterKey key_id, char **p_value)

Get information from the DRM system.

This function gives access to the internal parameter of the DRM system.

Return

An error code defined by the enumerator DRM_ErrorCode indicating the success or the cause of the error during the function execution.

Parameters
  • [in] m: : Pointer to a DrmManager object.

  • [in] key_id: : Unique identifier of the parameter to access; available IDs are listed in DrmParameterKey.

  • [out] p_value: : Pointer to a string that will contain the value of the corresponding parameter.

DRM_ErrorCode DrmManager_set_json_string(DrmManager *m, const char *json_in)

Set information of the DRM system.

This function overwrites an internal parameter of the DRM system.

Return

An error code defined by the enumerator DRM_ErrorCode indicating the success or the cause of the error during the function execution.

Parameters
  • [in] m: : Pointer to a DrmManager object.

  • [in] json_in: : JSON formatted string listing the parameter names and corresponding values. For instance, std::string json_string = “{“CUSTOM_FIELD”: 0x12345678}”;

DRM_ErrorCode DrmManager_set_bool(DrmManager *m, const DrmParameterKey key_id, const bool value)

Set information of the DRM system.

This function overwrites an internal parameter of the DRM system.

Return

An error code defined by the enumerator DRM_ErrorCode indicating the success or the cause of the error during the function execution.

Parameters
  • [in] m: : Pointer to a DrmManager object.

  • [in] key_id: : Unique identifier of the parameter to access; available IDs are listed in DrmParameterKey.

  • [in] value: : Boolean value to overwrite with.

DRM_ErrorCode DrmManager_set_int(DrmManager *m, const DrmParameterKey key_id, const int value)

Set information of the DRM system.

This function overwrites an internal parameter of the DRM system.

Return

An error code defined by the enumerator DRM_ErrorCode indicating the success or the cause of the error during the function execution.

Parameters
  • [in] m: : Pointer to a DrmManager object.

  • [in] key_id: : Unique identifier of the parameter to access; available IDs are listed in DrmParameterKey.

  • [in] value: : Integer value to overwrite with.

DRM_ErrorCode DrmManager_set_uint(DrmManager *m, const DrmParameterKey key_id, const unsigned int value)

Set information of the DRM system.

This function overwrites an internal parameter of the DRM system.

Return

An error code defined by the enumerator DRM_ErrorCode indicating the success or the cause of the error during the function execution.

Parameters
  • [in] m: : Pointer to a DrmManager object.

  • [in] key_id: : Unique identifier of the parameter to access; available IDs are listed in DrmParameterKey.

  • [in] value: : Unsigned integer value to overwrite with.

DRM_ErrorCode DrmManager_set_int64(DrmManager *m, const DrmParameterKey key_id, const long long value)

Set information of the DRM system.

This function overwrites an internal parameter of the DRM system.

Return

An error code defined by the enumerator DRM_ErrorCode indicating the success or the cause of the error during the function execution.

Parameters
  • [in] m: : Pointer to a DrmManager object.

  • [in] key_id: : Unique identifier of the parameter to access; available IDs are listed in DrmParameterKey.

  • [in] value: : Long integer value to overwrite with.

DRM_ErrorCode DrmManager_set_uint64(DrmManager *m, const DrmParameterKey key_id, const unsigned long long value)

Set information of the DRM system.

This function overwrites an internal parameter of the DRM system.

Return

An error code defined by the enumerator DRM_ErrorCode indicating the success or the cause of the error during the function execution.

Parameters
  • [in] m: : Pointer to a DrmManager object.

  • [in] key_id: : Unique identifier of the parameter to access; available IDs are listed in DrmParameterKey.

  • [in] value: : Unsigned long integer value to overwrite with.

DRM_ErrorCode DrmManager_set_float(DrmManager *m, const DrmParameterKey key_id, const float value)

Set information of the DRM system.

This function overwrites an internal parameter of the DRM system.

Return

An error code defined by the enumerator DRM_ErrorCode indicating the success or the cause of the error during the function execution.

Parameters
  • [in] m: : Pointer to a DrmManager object.

  • [in] key_id: : Unique identifier of the parameter to access; available IDs are listed in DrmParameterKey.

  • [in] value: : Float value to overwrite with.

DRM_ErrorCode DrmManager_set_double(DrmManager *m, const DrmParameterKey key_id, const double value)

Set information of the DRM system.

This function overwrites an internal parameter of the DRM system.

Return

An error code defined by the enumerator DRM_ErrorCode indicating the success or the cause of the error during the function execution.

Parameters
  • [in] m: : Pointer to a DrmManager object.

  • [in] key_id: : Unique identifier of the parameter to access; available IDs are listed in DrmParameterKey.

  • [in] value: : Double float value to overwrite with.

DRM_ErrorCode DrmManager_set_string(DrmManager *m, const DrmParameterKey key_id, const char *value)

Set information of the DRM system.

This function overwrites an internal parameter of the DRM system.

Return

An error code defined by the enumerator DRM_ErrorCode indicating the success or the cause of the error during the function execution.

Parameters
  • [in] m: : Pointer to a DrmManager object.

  • [in] key_id: : Unique identifier of the parameter to access; available IDs are listed in DrmParameterKey.

  • [in] value: : String value to overwrite with.

struct DrmManager
#include <accelize/drmc/wrapper.h>

Typedef struct handling DRM manager.

Manage error message and Accelize DRM by handling communication with DRM controller IP and Accelize Web service.

Public Members

char error_message[MAX_MSG_SIZE]
struct DrmManager_s *drm

drmc/errorcode.h

Header defining all error codes of DRM Library.

Enums

enum DRM_ErrorCode

Error code enum.

Values:

DRM_OK = 0

Function returned successfully

DRM_BadArg = 00001

Bad argument provided

DRM_BadFormat = 00002

Bad format of provided input or config file

DRM_ExternFail = 00003

Fail happened in an external library

DRM_BadUsage = 00004

Wrong usage of the DRM Library

DRM_BadFrequency = 00005

Wrong value of the DRM frequency provided in the configuration file

DRM_WSRespError = 10001

A malformed response has been received from Accelize WebService

DRM_WSReqError = 10002

Failed during HTTP request to Accelize WebService

DRM_WSError = 10003

Error returned from Accelize WebService

DRM_WSMayRetry = 10004

Error with request to Accelize Webservice, retry advised

DRM_CtlrError = 20001

An error happened on a command to the DRM controller

DRM_Fatal = 30001

Fatal error, unknown error (Please contact Accelize)

DRM_Assert = 30002

Assertion failed internally (Please contact Accelize)

DRM_Debug = 40001

Generated for debug and testing only

DRM_Exit = 99999

Generated for debug and testing only