Skip to main content
Version: 20 Mar 2024

NativeBindings

See ml_media_drm.h for additional comments.

Inherits from:
MagicLeapNativeBindings

Public Methods

MLResult.Code MLMediaDRMByteArrayAllocAndCopy

Allocate and Copy to byte array buffer.

public MLResult.Code MLMediaDRMByteArrayAllocAndCopy(
IntPtr CopyFrom,
uint Size,
out MLMediaDRMByteArray OutArray
)

Parameters

TypeNameDescription
IntPtrCopyFrom
uintSize
out MLMediaDRMByteArrayOutArrayData type containing byte array buffer and the size.

MLResult.Code MLMediaDRMByteArrayAllocate

String property name: identifies the maker of the DRM engine plugin.

public MLResult.Code MLMediaDRMByteArrayAllocate(
uint Size,
out MLMediaDRMByteArray OutArray
)

Parameters

TypeNameDescription
uintSize
out MLMediaDRMByteArrayOutArrayData type containing byte array buffer and the size.

MLResult.Code MLMediaDRMByteArrayListRelease

Release list of byte array buffer.

public MLResult.Code MLMediaDRMByteArrayListRelease(
ref MLMediaDRMByteArrayList Array
)

Parameters

TypeNameDescription
ref MLMediaDRMByteArrayListArrayData type containing list of byte array buffers and the size.

MLResult.Code MLMediaDRMByteArrayRelease

Release byte array buffer.

public MLResult.Code MLMediaDRMByteArrayRelease(
ref MLMediaDRMByteArray array
)

Parameters

TypeNameDescription
ref MLMediaDRMByteArrayarrayData type containing byte array buffer and the size.

MLResult.Code MLMediaDRMCloseSession

Closes a session that was previously opened.

public MLResult.Code MLMediaDRMCloseSession(
ulong drmHandle,
ref MLMediaDRMByteArray sessionId
)

Parameters

TypeNameDescription
ulongdrmHandle
ref MLMediaDRMByteArraysessionIdData type containing byte array buffer and the size.

MLResult.Code MLMediaDRMCreate

Create a

public MLResult.Code MLMediaDRMCreate(
Native.MagicLeapNativeBindings.MLUUID uuid,
out ulong handle
)

Parameters

TypeNameDescription
Native.MagicLeapNativeBindings.MLUUIDuuidUniversally unique identifier
out ulonghandle

MLResult.Code MLMediaDRMDecrypt

Decrypt the data referenced by input using algorithm if specified, and write the encrypted result into output. The key to use is identified by the 16 byte keyId. The key must have been loaded into the session using MLMediaDRMProvideKeyResponse().

public MLResult.Code MLMediaDRMDecrypt(
ulong MediaDrm,
ref MLMediaDRMByteArray SessionId,
ref MLMediaDRMCryptoInputParam CryptoKeyParam,
ref MLMediaDRMByteArray Input,
out MLMediaDRMByteArray Output
)

Parameters

TypeNameDescription
ulongMediaDrm
ref MLMediaDRMByteArraySessionIdData type containing byte array buffer and the size.
ref MLMediaDRMCryptoInputParamCryptoKeyParamData type that encapsulates algorithm, key_set_id and IV for Encryption/Decryption.
ref MLMediaDRMByteArrayInputData type containing byte array buffer and the size.
out MLMediaDRMByteArrayOutputData type containing byte array buffer and the size.

MLResult.Code MLMediaDRMEncrypt

Encrypt the data referenced by input using algorithm if specified, and write the encrypted result into output. The key to use is identified by the 16 byte keyId. The key must have been loaded into the session using MLMediaDRMProvideKeyResponse().

public MLResult.Code MLMediaDRMEncrypt(
ulong MediaDrm,
ref MLMediaDRMByteArray SessionId,
ref MLMediaDRMCryptoInputParam CryptoKeyParam,
ref MLMediaDRMByteArray Input,
out MLMediaDRMByteArray Output
)

Parameters

TypeNameDescription
ulongMediaDrm
ref MLMediaDRMByteArraySessionIdData type containing byte array buffer and the size.
ref MLMediaDRMCryptoInputParamCryptoKeyParamData type that encapsulates algorithm, key_set_id and IV for Encryption/Decryption.
ref MLMediaDRMByteArrayInputData type containing byte array buffer and the size.
out MLMediaDRMByteArrayOutputData type containing byte array buffer and the size.

MLResult.Code MLMediaDRMGetKeyRequest

A key request/response exchange occurs between the app and a license server to obtain or release keys used to decrypt encrypted content. MLMediaDRMGetKeyRequest() is used to obtain an opaque key request byte array that is delivered to the license server. The opaque key request byte array is returned in out_key_request. request The recommended URL to deliver the key request to is returned in out_key_request. default_URL. After the app has received the key request response from the server, it should deliver to the response to the DRM engine plugin using the method MLMediaDRMProvideKeyResponse().

public MLResult.Code MLMediaDRMGetKeyRequest(
ulong drmHandle,
ref MLMediaDRMByteArray sessionId,
ref MLMediaDRMKeyRequestInputParam keyRequestParam,
out MLMediaDRMRequestMessage keyRequest
)

Parameters

TypeNameDescription
ulongdrmHandle
ref MLMediaDRMByteArraysessionIdData type containing byte array buffer and the size.
ref MLMediaDRMKeyRequestInputParamkeyRequestParamData type that encapsulates Key Request input arguments.
out MLMediaDRMRequestMessagekeyRequestData type that encapsulates either of the following along with an URL: For Key Request Message: an opaque key request byte array that should be delivered to the license server. For Provision Request Message: an opaque provision request byte array that should be delivered to the provisioning server.

MLResult.Code MLMediaDRMGetPropertyByteArray

Read a DRM engine plugin byte array property value, given the property name.

public MLResult.Code MLMediaDRMGetPropertyByteArray(
ulong MediaDrm,
string PropertyName,
out MLMediaDRMByteArray OutPropertyValue
)

Parameters

TypeNameDescription
ulongMediaDrm
stringPropertyName
out MLMediaDRMByteArrayOutPropertyValueData type containing byte array buffer and the size.

MLResult.Code MLMediaDRMGetPropertyString

Read a DRM engine plugin String property value, given the property name.

public MLResult.Code MLMediaDRMGetPropertyString(
ulong MediaDrm,
string PropertyName,
out string OutPropertyValue
)

Parameters

TypeNameDescription
ulongMediaDrm
stringPropertyName
out stringOutPropertyValue

MLResult.Code MLMediaDRMGetProvisionRequest

A provision request/response exchange occurs between the app and a provisioning server to retrieve a device certificate. If provisioning is required, the #EVENT_PROVISION_REQUIRED event will be sent to the event handler. MLMediaDRMGetProvisionRequest() is used to obtain the opaque provision request byte array that should be delivered to the provisioning server.

public MLResult.Code MLMediaDRMGetProvisionRequest(
ulong drmHandle,
string certType,
out MLMediaDRMRequestMessage provisionRequest
)

Parameters

TypeNameDescription
ulongdrmHandle
stringcertType
out MLMediaDRMRequestMessageprovisionRequestData type that encapsulates either of the following along with an URL: For Key Request Message: an opaque key request byte array that should be delivered to the license server. For Provision Request Message: an opaque provision request byte array that should be delivered to the provisioning server.

MLResult.Code MLMediaDRMGetSecureStop

Access secure stop by secure stop ID.

public MLResult.Code MLMediaDRMGetSecureStop(
ulong MediaDrm,
ref MLMediaDRMByteArray SecureStopId,
out MLMediaDRMByteArray SecureStop
)

Parameters

TypeNameDescription
ulongMediaDrm
ref MLMediaDRMByteArraySecureStopIdData type containing byte array buffer and the size.
out MLMediaDRMByteArraySecureStopData type containing byte array buffer and the size.

See: MLMediaDRMGetSecureStops()


MLResult.Code MLMediaDRMGetSecureStops

Access all secure stops. Secure Stop: A means of enforcing limits on the number of concurrent streams per subscriber across devices is provided via #SecureStop. This is achieved by securely monitoring the lifetime of sessions. Information from the server related to the current playback session is written to persistent storage on the device when each #MediaCrypto object is created. In the normal case, playback will be completed, the session destroyed and the Secure Stops will be queried. The app queries secure stops and forwards the secure stop message to the server which verifies the signature and notifies the server side database that the session destruction has been confirmed. The persisted record on the client is only removed after positive confirmation that the server received the message using releaseSecureStops().

public MLResult.Code MLMediaDRMGetSecureStops(
ulong MediaDrm,
out MLMediaDRMByteArrayList SecureStops
)

Parameters

TypeNameDescription
ulongMediaDrm
out MLMediaDRMByteArrayListSecureStopsData type containing list of byte array buffers and the size.

MLResult.Code MLMediaDRMIsCryptoSchemeSupported

Query if the given scheme identified by its UUID is supported on this device. And whether the drm plugin is able to handle the media container format.

public MLResult.Code MLMediaDRMIsCryptoSchemeSupported(
Native.MagicLeapNativeBindings.MLUUID Uuid,
IntPtr MimeType,
out bool supported
)

Parameters

TypeNameDescription
Native.MagicLeapNativeBindings.MLUUIDUuidUniversally unique identifier
IntPtrMimeType
out boolsupported

MLResult.Code MLMediaDRMKeyValueArrayAdd

Add a {key, value} pair to the array of {key, value} pairs.

public MLResult.Code MLMediaDRMKeyValueArrayAdd(
ref MLMediaDRMKeyValue Pair,
out MLMediaDRMKeyValueArray OutArray
)

Parameters

TypeNameDescription
ref MLMediaDRMKeyValuePairData type containing {key, value} pair.
out MLMediaDRMKeyValueArrayOutArrayData type containing array of {key, value} pair.

MLResult.Code MLMediaDRMKeyValueArrayAllocate

Allocate array of {key, value} pairs.

public MLResult.Code MLMediaDRMKeyValueArrayAllocate(
uint Size,
out MLMediaDRMKeyValueArray OutArray
)

Parameters

TypeNameDescription
uintSize
out MLMediaDRMKeyValueArrayOutArrayData type containing array of {key, value} pair.

MLResult.Code MLMediaDRMKeyValueArrayRelease

Release {key, value} pair array.

public MLResult.Code MLMediaDRMKeyValueArrayRelease(
ref MLMediaDRMKeyValueArray Array
)

Parameters

TypeNameDescription
ref MLMediaDRMKeyValueArrayArrayData type containing array of {key, value} pair.

MLResult.Code MLMediaDRMOpenSession

Opens a new session. A session ID is returned.

public MLResult.Code MLMediaDRMOpenSession(
ulong MediaDrm,
out MLMediaDRMByteArray sessionId
)

Parameters

TypeNameDescription
ulongMediaDrm
out MLMediaDRMByteArraysessionIdData type containing byte array buffer and the size.

MLResult.Code MLMediaDRMProvideKeyResponse

A key response is received from the license server by the app, then it is provided to the DRM engine plugin using MLMediaDRMProvideKeyResponse(). When the response is for an offline key request, a key_set_id is returned that can be used to later restore the keys to a new session with restoreKeys(). When the response is for a streaming or release request, a null key_set_id is returned.

public MLResult.Code MLMediaDRMProvideKeyResponse(
ulong drmHandle,
ref MLMediaDRMByteArray sessionId,
ref MLMediaDRMByteArray response,
out MLMediaDRMByteArray keySetId
)

Parameters

TypeNameDescription
ulongdrmHandle
ref MLMediaDRMByteArraysessionIdData type containing byte array buffer and the size.
ref MLMediaDRMByteArrayresponseData type containing byte array buffer and the size.
out MLMediaDRMByteArraykeySetIdData type containing byte array buffer and the size.

MLResult.Code MLMediaDRMProvideProvisionResponse

After a provision response is received by the app, it is provided to the DRM engine plugin using this method.

public MLResult.Code MLMediaDRMProvideProvisionResponse(
ulong drmHandle,
ref MLMediaDRMByteArray response,
out MLMediaDRMByteArray certificate,
out MLMediaDRMByteArray wrappedKey
)

Parameters

TypeNameDescription
ulongdrmHandle
ref MLMediaDRMByteArrayresponseData type containing byte array buffer and the size.
out MLMediaDRMByteArraycertificateData type containing byte array buffer and the size.
out MLMediaDRMByteArraywrappedKeyData type containing byte array buffer and the size.

MLResult.Code MLMediaDRMQueryKeyStatus

Request an informative description of the key status for the session. The status is in the form of {key, value} pairs. Since DRM license policies vary by vendor, the specific status field names are determined by each DRM vendor. Refer to your DRM provider documentation for definitions of the field names for a particular DRM engine plugin.

public MLResult.Code MLMediaDRMQueryKeyStatus(
ulong MediaDrm,
ref MLMediaDRMByteArray sessionId,
out MLMediaDRMKeyValueArray OutInfoMap
)

Parameters

TypeNameDescription
ulongMediaDrm
ref MLMediaDRMByteArraysessionIdData type containing byte array buffer and the size.
out MLMediaDRMKeyValueArrayOutInfoMapData type containing array of {key, value} pair.

MLResult.Code MLMediaDRMRelease

Release the

public MLResult.Code MLMediaDRMRelease(
ulong drmHandle
)

Parameters

TypeNameDescription
ulongdrmHandle

MLResult.Code MLMediaDRMReleaseAllSecureStops

Remove all the SecureStops.

public MLResult.Code MLMediaDRMReleaseAllSecureStops(
ulong MediaDrm
)

Parameters

TypeNameDescription
ulongMediaDrm

MLResult.Code MLMediaDRMReleaseSecureStops

Process the SecureStop server response message. After authenticating the message, remove the SecureStops identified in the response.

public MLResult.Code MLMediaDRMReleaseSecureStops(
ulong MediaDrm,
ref MLMediaDRMByteArray SecureStop
)

Parameters

TypeNameDescription
ulongMediaDrm
ref MLMediaDRMByteArraySecureStopData type containing byte array buffer and the size.

MLResult.Code MLMediaDRMRemoveKeys

Remove the current keys from a session.

public MLResult.Code MLMediaDRMRemoveKeys(
ulong MediaDrm,
ref MLMediaDRMByteArray SessionId,
ref MLMediaDRMByteArray KeySetId
)

Parameters

TypeNameDescription
ulongMediaDrm
ref MLMediaDRMByteArraySessionIdData type containing byte array buffer and the size.
ref MLMediaDRMByteArrayKeySetIdData type containing byte array buffer and the size.

MLResult.Code MLMediaDRMRequestMessageRelease

Release Request Message.

public MLResult.Code MLMediaDRMRequestMessageRelease(
ref MLMediaDRMRequestMessage Request
)

Parameters

TypeNameDescription
ref MLMediaDRMRequestMessageRequestData type that encapsulates either of the following along with an URL: For Key Request Message: an opaque key request byte array that should be delivered to the license server. For Provision Request Message: an opaque provision request byte array that should be delivered to the provisioning server.

MLResult.Code MLMediaDRMRestoreKeys

Restore persisted offline keys into a new session. key_set_id identifies the keys to load, obtained from a prior call to MLMediaDRMProvideKeyResponse().

public MLResult.Code MLMediaDRMRestoreKeys(
ulong MediaDrm,
ref MLMediaDRMByteArray sessionId,
ref MLMediaDRMByteArray KeySetId
)

Parameters

TypeNameDescription
ulongMediaDrm
ref MLMediaDRMByteArraysessionIdData type containing byte array buffer and the size.
ref MLMediaDRMByteArrayKeySetIdData type containing byte array buffer and the size.

MLResult.Code MLMediaDRMSetOnEventListenerEx

Register a callback to be invoked when an event occurs.

public MLResult.Code MLMediaDRMSetOnEventListenerEx(
ulong MediaDrm,
ref MLMediaDRMEventCallbacks Listener,
IntPtr data
)

Parameters

TypeNameDescription
ulongMediaDrm
ref MLMediaDRMEventCallbacksListenerData type containing array of {key, value} pair.
IntPtrdata

MLResult.Code MLMediaDRMSetPropertyByteArray

Set a DRM engine plugin byte array property value.

public MLResult.Code MLMediaDRMSetPropertyByteArray(
ulong MediaDrm,
string PropertyName,
ref MLMediaDRMByteArray PropertyValue
)

Parameters

TypeNameDescription
ulongMediaDrm
stringPropertyName
ref MLMediaDRMByteArrayPropertyValueData type containing byte array buffer and the size.

MLResult.Code MLMediaDRMSetPropertyString

Set a DRM engine plugin String property value.

public MLResult.Code MLMediaDRMSetPropertyString(
ulong MediaDrm,
string PropertyName,
string PropertyValue
)

Parameters

TypeNameDescription
ulongMediaDrm
stringPropertyName
stringPropertyValue

MLResult.Code MLMediaDRMSign

Generate a signature using the specified algorithm (if provided) over the message data and store the signature. The key to use is identified by the 16 byte keyId. The key must have been loaded into the session using MLMediaDRMProvideKeyResponse().

public MLResult.Code MLMediaDRMSign(
ulong MediaDrm,
ref MLMediaDRMByteArray SessionId,
ref MLMediaDRMHMACInputParam HMACParam,
ref MLMediaDRMByteArray Message,
out MLMediaDRMByteArray Signature
)

Parameters

TypeNameDescription
ulongMediaDrm
ref MLMediaDRMByteArraySessionIdData type containing byte array buffer and the size.
ref MLMediaDRMHMACInputParamHMACParamData type that encapsulates algorithm, key_set_id for HMAC based Sign/Verify.
ref MLMediaDRMByteArrayMessageData type containing byte array buffer and the size.
out MLMediaDRMByteArraySignatureData type containing byte array buffer and the size.

MLResult.Code MLMediaDRMSignRSA

Generate a signature using the specified RSA Key and algorithm.

public MLResult.Code MLMediaDRMSignRSA(
ulong MediaDrm,
ref MLMediaDRMByteArray SessionId,
ref MLMediaDRMRSAInputParam HMACParam,
ref MLMediaDRMByteArray Message,
out MLMediaDRMByteArray Signature
)

Parameters

TypeNameDescription
ulongMediaDrm
ref MLMediaDRMByteArraySessionIdData type containing byte array buffer and the size.
ref MLMediaDRMRSAInputParamHMACParamData type that encapsulates algorithm, wrapped_key for RSA operation.
ref MLMediaDRMByteArrayMessageData type containing byte array buffer and the size.
out MLMediaDRMByteArraySignatureData type containing byte array buffer and the size.

MLResult.Code MLMediaDRMVerify

Perform a signature verification using the specified algorithm (if specified) over the message data referenced by the message parameter. The key must have been loaded into the session using MLMediaDRMProvideKeyResponse().

public MLResult.Code MLMediaDRMVerify(
ulong MediaDrm,
ref MLMediaDRMByteArray SessionId,
ref MLMediaDRMHMACInputParam HMACParam,
ref MLMediaDRMByteArray Message,
ref MLMediaDRMByteArray Signature,
out bool IsMatch
)

Parameters

TypeNameDescription
ulongMediaDrm
ref MLMediaDRMByteArraySessionIdData type containing byte array buffer and the size.
ref MLMediaDRMHMACInputParamHMACParamData type that encapsulates algorithm, key_set_id for HMAC based Sign/Verify.
ref MLMediaDRMByteArrayMessageData type containing byte array buffer and the size.
ref MLMediaDRMByteArraySignatureData type containing byte array buffer and the size.
out boolIsMatch

delegate void OnEventDelegate

public delegate void OnEventDelegate(
ulong handle,
ref MLMediaDRMEventInfo info
)

Parameters

TypeNameDescription
ulonghandle
ref MLMediaDRMEventInfoinfoMediaDRM event info associated with a session.

delegate void OnExpirationUpdateDelegate

public delegate void OnExpirationUpdateDelegate(
ulong handle,
ref MLMediaDRMExpirationUpdateInfo info
)

Parameters

TypeNameDescription
ulonghandle
ref MLMediaDRMExpirationUpdateInfoinfoMediaDRM expiration update info associated with a session.

delegate void OnKeyStatusChangeDelegate

public delegate void OnKeyStatusChangeDelegate(
ulong handle,
ref MLMediaDRMKeyStatusInfo info
)

Parameters

TypeNameDescription
ulonghandle
ref MLMediaDRMKeyStatusInfoinfoMediaDRM session keys status change info.