C++ API

Header files

drm.h

Defines

PARAMETERKEY_ITEM(id)

Include the Parameter ID.

namespace Accelize

Accelize DRM C++ Library.

Accelize interfaces and implementations

namespace DRM

DRM specific interface and implementation.

Enums

enum ParameterKey

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

Values:

ParameterKeyCount

Functions

const char *getApiVersion()

Return API version.

Variables

Accelize::DRM::ParameterKey DRM_EXPORT
class DrmManager
#include <accelize/drm/drm_manager.h>

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

Public Types

typedef std::function<int(uint32_t, uint32_t *)> ReadRegisterCallback

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.

typedef std::function<int(uint32_t, uint32_t)> WriteRegisterCallback

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.

typedef std::function<void(const std::string&)> AsynchErrorCallback

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

Parameters
  • [in] error_message: : Error message.

Public Functions

DrmManager()

No default constructor.

DrmManager(const std::string &conf_file_path, const std::string &cred_file_path, ReadRegisterCallback read_register, WriteRegisterCallback write_register, AsynchErrorCallback async_error)

Instantiate and initialize a DRM manager.

See

ReadRegisterCallback WriteRegisterCallback AsynchErrorCallback

Parameters
  • [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.

DrmManager(const DrmManager&)

Non-copyable.

DrmManager(DrmManager&&)

Support move.

~DrmManager()

Destructor.

void activate(const bool &resume_session_request = false)

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.

Parameters
  • [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. Default to False.

void deactivate(const bool &pause_session_request = false)

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.

Parameters
  • [in] pause_session_request: : If true, the current session is kept open for later usage. Otherwise, the current session is closed. Default to false.

void get(Json::Value &json_value) const

Get information from the DRM system.

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

Parameters
  • [inout] json_value: : Json::Value object containing all the parameters requested. When the function returns this object is overwritten with the values corresponding to the parameters so that the user application can parse it to access to them. For instance, Json::Value json_value; json_value[“CUSTOM_FIELD”]=json::nullValue; json_value[“NUM_ACTIVATORS”]=json::nullValue;

void get(std::string &json_string) const

Get information from the DRM system.

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

Parameters
  • [inout] json_string: : JSON formatted string listing the parameter names requested as key and Json::nullValue as value. For instance, std::string json_string = “{“NUM_ACTIVATORS”: null, “SESSION_ID”: null}”;

template<typename T>
T get(const ParameterKey key_id) const

Get information from the DRM system.

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

Return

the value of the corresponding parameter.

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

void set(const Json::Value &json_value)

Set information of the DRM system.

This function overwrites an internal parameter of the DRM system.

Parameters
  • [in] json_value: : Json::Value object listing the parameter with its new value. For instance, Json::Value json_value; json_value[“CUSTOM_FIELD”]=0x12345678;

void set(const std::string &json_string)

Set information of the DRM system.

This function overwrites an internal parameter of the DRM system.

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

template<typename T>
void set(const ParameterKey key_id, const T &value)

Set information of the DRM system.

This function overwrites an internal parameter of the DRM system.

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

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

Private Members

Impl *pImpl

Internal representation.

Internal representation

drm/error.h

namespace Accelize

Accelize DRM C++ Library.

Accelize interfaces and implementations

namespace DRM

DRM specific interface and implementation.

class Exception : public runtime_error
#include <accelize/drm/error.h>

Exception class with error code for the DRM Library.

This class is an exception that may be thrown by the DRM Library in case of synchronous error

Public Functions

template<class S>
Exception(DRM_ErrorCode errCode, S &&errMsg)
virtual ~Exception()
DRM_ErrorCode getErrCode() const
virtual const char *what() const

Protected Attributes

DRM_ErrorCode errCode

error code from the DRM_ErrorCode enum

std::string errWhat

internal error message to be accessed from what()