Last update:2024-01-02 11:10:15
This document acts as a detailed manual for implementing DRM encryption on a specific stream, beginning with the initial step of transmitting API calls to identify the intended stream for encryption.
Kindly undertake the subsequent tasks beforehand:
The example API call facilitates the encryption of the stream https://drmtest-pull.cdnetworks.com/live/dashdrm.mpd
.
curl -i --url 'http://ca.haplat.net/wslive/drm/register.action?n=accountId&r=random&k=token' \
-X 'POST' \
-H 'Content-Type: application/json' \
-d '{
"url": "https://drmtest-pull.cdnetworks.com/live/drmtest.mpd",
"encryptType": "drm",
"action": "add",
"expire": "1682819355"
}'
The request has successfully initiated the encryption of the stream with streamname drmtest
, under the application named live
. Once encrypted, this DASH stream gains protection from both Widevine and PlayReady. To ascertain whether your stream has been successfully encrypted, examine the HLS or DASH manifest file. In this context, we’ll concentrate on the DASH .mpd file. This manifest file will include a ContentProtection
header, containing the essential objects for generating a license challenge. A brief sample is illustrated below:
</ContentProtection>
<ContentProtection schemeIdUri="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed">
<cenc:pssh>AAAAOHBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAABgSEAnnEHpafEPZng9h+r1lDBZI49yVmwY=</cenc:pssh>
</ContentProtection>
The subsequent headers and parameters are essential for the request:
Item | Type | Required | Description |
---|---|---|---|
Content-Type | Header | yes | application/json |
n | Param | Yes | Represents your account name. |
k | Param | Yes | A unique random string with maximum length of 13, it’s recommended to use timestamp. |
r | Param | Yes | TThe MD5 authentication value. To obtain the value of k , append the apikey string to the end of the r string, then perform an MD5 calculation on the resulting string (k = md5(r + apikey)) . For example, 1. Request and get apikey=012f37a3f2952 2. Randomly generate string r=1409284800 3. Append the apikey to the end of ‘r’, producing the string '1409284800012f37a3f2952’ 4. Calculate the MD5 hash of the new string to obtain the value of ‘k’, which is ‘b9fed80be752551834eec3e52fa94115’ |
Include the following elements in your request body:
Item | Type | Required | Description |
---|---|---|---|
url | String | Yes | This field corresponds to the URL of the stream intended for encryption. For instance: https://poctest-push.8686c.com/live/dashdrm.mpdNotes:1. You must activate HTTPS prior to utilizing DRM. While encryption continues to be possible with HTTP-based URLs, playback might fail since DRM systems necessitate HTTPS.2. There’s no need to encrypt every resolution of the stream; each resolution will be automatically encrypted once the primary stream has undergone encryption. |
encryptType | String | Yes | Should be set to drm . |
action | String | No | Can accept one of the following values: add , del , or update :- add: To set up DRM for a new stream.- del: To deactivate DRM for a previously established stream.- update: To revise the encryption details for an existing stream. |
expire | String | No | The DRM expiration date should be specified in the Linux Timestamp format. If this field remains undefined, the DRM for this particular stream will not expire. |
{
"msg": true,
"code": 200,
"callTime": "2022-12-07 21:50:16"
}
Error Code | Message | Detail |
---|---|---|
400 | Authentication Parameter Missing. | Missing authentication parameters ‘n’, ‘k’, or ‘r’. |
400 | Incorrect encrypt type. | The ‘encryptType’ parameter is not specified as ‘drm’. |
400 | Action method error. | Unsupported operation type. Only ‘add’, ‘del’ or ‘update’ are supported. |
400 | The content has been added to system already. | The content has already been encrypted, and cannot be encrypted again. |
400 | The stream is not existing in record, failed to delete. | No DRM information was found for the stream that you wanted to delete. |
403 | Authentication failed. | Authentication parameter error or no API request permission. |
404 | 404 Not Found. | API request URL is incorrect. |
405 | Request method error. | Not a POST request. |
500 | Internal Server Error. | Service exception. |