1# native_mediakeysystem.h 2 3## Overview 4 5The file declares the MediaKeySystem APIs. 6 7The APIs can be used to check whether a specific DRM is supported, create a media key session, obtain and set configurations, obtain statistics information, obtain the content protection level, generate media key system requests, process responses to media key system requests, listen for events, and manage offline media keys. 8 9**File to include**: <multimedia/drm_framework/native_mediakeysystem.h> 10 11**Library**: libnative_drm.z.so 12 13**System capability**: SystemCapability.Multimedia.Drm.Core 14 15**Since**: 11 16 17**Related module**: [Drm](capi-drm.md) 18 19## Summary 20 21### Functions 22 23| Name| typedef Keyword| Description| 24| -- | -- | -- | 25| [typedef Drm_ErrCode (\*MediaKeySystem_Callback)(DRM_EventType eventType, uint8_t *info,int32_t infoLen, char *extra)](#mediakeysystem_callback) | MediaKeySystem_Callback | Defines the callback used to listen for media key system events. No MediaKeySystem instance is returned. This callback applies to the scenario where a single MediaKeySystem instance is used.| 26| [typedef Drm_ErrCode (\*OH_MediaKeySystem_Callback)(MediaKeySystem *mediaKeySystem, DRM_EventType eventType,uint8_t *info, int32_t infoLen, char *extra)](#oh_mediakeysystem_callback) | OH_MediaKeySystem_Callback | Defines the callback used to listen for media key system events. A MediaKeySystem instance is returned. This callback applies to the scenario where multiple MediaKeySystem instances are used.| 27| [Drm_ErrCode OH_MediaKeySystem_SetCallback(MediaKeySystem *mediaKeySystem, OH_MediaKeySystem_Callback callback)](#oh_mediakeysystem_setcallback) | - | Sets a media key system event callback.| 28| [Drm_ErrCode OH_MediaKeySystem_GetMediaKeySystems(DRM_MediaKeySystemDescription *infos, uint32_t *count)](#oh_mediakeysystem_getmediakeysystems) | - | Obtains the name and ID list of the DRM solutions supported by the device.| 29| [bool OH_MediaKeySystem_IsSupported(const char *name)](#oh_mediakeysystem_issupported) | - | Checks whether the device supports the specified DRM solution.| 30| [bool OH_MediaKeySystem_IsSupported2(const char *name, const char *mimeType)](#oh_mediakeysystem_issupported2) | - | Checks whether the device supports the combination of the DRM solution and MIME type.| 31| [bool OH_MediaKeySystem_IsSupported3(const char *name, const char *mimeType,DRM_ContentProtectionLevel contentProtectionLevel)](#oh_mediakeysystem_issupported3) | - | Checks whether the device supports the combination of the DRM solution, MIME type, and content protection level.| 32| [Drm_ErrCode OH_MediaKeySystem_Create(const char *name, MediaKeySystem **mediaKeySystem)](#oh_mediakeysystem_create) | - | Creates a MediaKeySystem instance.| 33| [Drm_ErrCode OH_MediaKeySystem_SetConfigurationString(MediaKeySystem *mediaKeySystem,const char *configName, const char *value)](#oh_mediakeysystem_setconfigurationstring) | - | Sets a configuration item in the form of a string.| 34| [Drm_ErrCode OH_MediaKeySystem_GetConfigurationString(MediaKeySystem *mediaKeySystem,const char *configName, char *value, int32_t valueLen)](#oh_mediakeysystem_getconfigurationstring) | - | Obtains the value of a configuration item in the form of a string.| 35| [Drm_ErrCode OH_MediaKeySystem_SetConfigurationByteArray(MediaKeySystem *mediaKeySystem,const char *configName, uint8_t *value, int32_t valueLen)](#oh_mediakeysystem_setconfigurationbytearray) | - | Sets a configuration item in the form of an array.| 36| [Drm_ErrCode OH_MediaKeySystem_GetConfigurationByteArray(MediaKeySystem *mediaKeySystem,const char *configName, uint8_t *value, int32_t *valueLen)](#oh_mediakeysystem_getconfigurationbytearray) | - | Obtains the value of a configuration item in the form of an array.| 37| [Drm_ErrCode OH_MediaKeySystem_GetStatistics(MediaKeySystem *mediaKeySystem, DRM_Statistics *statistics)](#oh_mediakeysystem_getstatistics) | - | Obtains the statistics information about a media key system.| 38| [Drm_ErrCode OH_MediaKeySystem_GetMaxContentProtectionLevel(MediaKeySystem *mediaKeySystem,DRM_ContentProtectionLevel *contentProtectionLevel)](#oh_mediakeysystem_getmaxcontentprotectionlevel) | - | Obtains the maximum content protection level supported by the device.| 39| [Drm_ErrCode OH_MediaKeySystem_SetMediaKeySystemCallback(MediaKeySystem *mediaKeySystem,MediaKeySystem_Callback callback)](#oh_mediakeysystem_setmediakeysystemcallback) | - | Sets a media key system event callback.| 40| [Drm_ErrCode OH_MediaKeySystem_CreateMediaKeySession(MediaKeySystem *mediaKeySystem,DRM_ContentProtectionLevel *level, MediaKeySession **mediaKeySession)](#oh_mediakeysystem_createmediakeysession) | - | Creates a MediaKeySession instance.| 41| [Drm_ErrCode OH_MediaKeySystem_GenerateKeySystemRequest(MediaKeySystem *mediaKeySystem, uint8_t *request,int32_t *requestLen, char *defaultUrl, int32_t defaultUrlLen)](#oh_mediakeysystem_generatekeysystemrequest) | - | Generates a provision request.| 42| [Drm_ErrCode OH_MediaKeySystem_ProcessKeySystemResponse(MediaKeySystem *mediaKeySystem,uint8_t *response, int32_t responseLen)](#oh_mediakeysystem_processkeysystemresponse) | - | Processes a provision response.| 43| [Drm_ErrCode OH_MediaKeySystem_GetOfflineMediaKeyIds(MediaKeySystem *mediaKeySystem,DRM_OfflineMediakeyIdArray *offlineMediaKeyIds)](#oh_mediakeysystem_getofflinemediakeyids) | - | Obtains the list of offline media key IDs, which are used to manage offline media keys.| 44| [Drm_ErrCode OH_MediaKeySystem_GetOfflineMediaKeyStatus(MediaKeySystem *mediaKeySystem,uint8_t *offlineMediaKeyId, int32_t offlineMediaKeyIdLen, DRM_OfflineMediaKeyStatus *status)](#oh_mediakeysystem_getofflinemediakeystatus) | - | Obtains the status of an offline media key.| 45| [Drm_ErrCode OH_MediaKeySystem_ClearOfflineMediaKeys(MediaKeySystem *mediaKeySystem,uint8_t *offlineMediaKeyId, int32_t offlineMediaKeyIdLen)](#oh_mediakeysystem_clearofflinemediakeys) | - | Clears offline media keys by ID.| 46| [Drm_ErrCode OH_MediaKeySystem_GetCertificateStatus(MediaKeySystem *mediaKeySystem,DRM_CertificateStatus *certStatus)](#oh_mediakeysystem_getcertificatestatus) | - | Obtains the status of a DRM certificate.| 47| [Drm_ErrCode OH_MediaKeySystem_Destroy(MediaKeySystem *mediaKeySystem)](#oh_mediakeysystem_destroy) | - | Destroys a MediaKeySystem instance.| 48 49## Function Description 50 51### MediaKeySystem_Callback() 52 53``` 54typedef Drm_ErrCode (*MediaKeySystem_Callback)(DRM_EventType eventType, uint8_t *info,int32_t infoLen, char *extra) 55``` 56 57**Description** 58 59Defines the callback used to listen for media key system events. No MediaKeySystem instance is returned. This callback applies to the scenario where a single MediaKeySystem instance is used. 60 61**Since**: 11 62 63 64**Parameters** 65 66| Name| Description| 67| -- | -- | 68| [DRM_EventType](capi-native-drm-common-h.md#drm_eventtype) eventType | Event type.| 69| uint8_t *info | Pointer to the event information.| 70| int32_t infoLen | Length of the event information.| 71| char *extra | Pointer to extended event information.| 72 73**Returns** 74 75| Type| Description| 76| -- | -- | 77| [Drm_ErrCode](capi-native-drm-err-h.md#drm_errcode) | **DRM_ERR_OK**: The operation is successful.<br>**DRM_ERR_INVALID_VAL**: An input parameter is invalid.| 78 79### OH_MediaKeySystem_Callback() 80 81``` 82typedef Drm_ErrCode (*OH_MediaKeySystem_Callback)(MediaKeySystem *mediaKeySystem, DRM_EventType eventType,uint8_t *info, int32_t infoLen, char *extra) 83``` 84 85**Description** 86 87Defines the callback used to listen for media key system events. A MediaKeySystem instance is returned. This callback applies to the scenario where multiple MediaKeySystem instances are used. 88 89**Since**: 12 90 91 92**Parameters** 93 94| Name| Description| 95| -- | -- | 96| [MediaKeySystem](capi-drm-mediakeysystem.md) *mediaKeySystem | Pointer to the MediaKeySystem instance.| 97| [DRM_EventType](capi-native-drm-common-h.md#drm_eventtype) eventType | Event type.| 98| uint8_t *info | Pointer to the event information.| 99| int32_t infoLen | Length of the event information.| 100| char *extra | Pointer to extended event information.| 101 102**Returns** 103 104| Type| Description| 105| -- | -- | 106| [Drm_ErrCode](capi-native-drm-err-h.md#drm_errcode) | **DRM_ERR_OK**: The operation is successful.<br>**DRM_ERR_INVALID_VAL**: An input parameter is invalid.| 107 108### OH_MediaKeySystem_SetCallback() 109 110``` 111Drm_ErrCode OH_MediaKeySystem_SetCallback(MediaKeySystem *mediaKeySystem, OH_MediaKeySystem_Callback callback) 112``` 113 114**Description** 115 116Sets a media key system event callback. 117 118**Since**: 12 119 120 121**Parameters** 122 123| Name| Description| 124| -- | -- | 125| [MediaKeySystem](capi-drm-mediakeysystem.md) *mediaKeySystem | Pointer to the MediaKeySystem instance.| 126| [OH_MediaKeySystem_Callback](#oh_mediakeysystem_callback) callback | Callback.| 127 128**Returns** 129 130| Type| Description| 131| -- | -- | 132| [Drm_ErrCode](capi-native-drm-err-h.md#drm_errcode) | **DRM_ERR_OK**: The operation is successful.<br>**DRM_ERR_INVALID_VAL**: The input parameter **mediaKeySystem** is nullptr or invalid.| 133 134### OH_MediaKeySystem_GetMediaKeySystems() 135 136``` 137Drm_ErrCode OH_MediaKeySystem_GetMediaKeySystems(DRM_MediaKeySystemDescription *infos, uint32_t *count) 138``` 139 140**Description** 141 142Obtains the name and ID list of the DRM solutions supported by the device. 143 144**Since**: 12 145 146 147**Parameters** 148 149| Name| Description| 150| -- | -- | 151| [DRM_MediaKeySystemDescription](capi-drm-drm-mediakeysystemdescription.md) *infos | Pointer to the list of the names and UUIDs of DRM solutions.| 152| uint32_t *count | Pointer to the length of the list.| 153 154**Returns** 155 156| Type| Description| 157| -- | -- | 158| [Drm_ErrCode](capi-native-drm-err-h.md#drm_errcode) | **DRM_ERR_OK**: The operation is successful.<br>**DRM_ERR_INVALID_VAL**: Possible causes:<br> 1. The input parameter **infos** or **count** is nullptr.<br> 2. The length of the input parameter **infos** is insufficient.<br>**DRM_ERR_UNKNOWN**: An internal error occurs. Check the log details.| 159 160### OH_MediaKeySystem_IsSupported() 161 162``` 163bool OH_MediaKeySystem_IsSupported(const char *name) 164``` 165 166**Description** 167 168Checks whether the device supports the specified DRM solution. 169 170**Since**: 11 171 172 173**Parameters** 174 175| Name| Description| 176| -- | -- | 177| const char *name | Pointer to the DRM solution name.| 178 179**Returns** 180 181| Type| Description| 182| -- | -- | 183| bool | Check result for the support of the specified DRM solution.| 184 185### OH_MediaKeySystem_IsSupported2() 186 187``` 188bool OH_MediaKeySystem_IsSupported2(const char *name, const char *mimeType) 189``` 190 191**Description** 192 193Checks whether the device supports the combination of the DRM solution and MIME type. 194 195**Since**: 11 196 197 198**Parameters** 199 200| Name| Description| 201| -- | -- | 202| const char *name | Pointer to the DRM solution name.| 203| const char *mimeType | Pointer to the MIME type. The supported MIME types depend on the DRM solution. Example types are video/avc and video/hev.| 204 205**Returns** 206 207| Type| Description| 208| -- | -- | 209| bool | Check result for the support of the combination.| 210 211### OH_MediaKeySystem_IsSupported3() 212 213``` 214bool OH_MediaKeySystem_IsSupported3(const char *name, const char *mimeType,DRM_ContentProtectionLevel contentProtectionLevel) 215``` 216 217**Description** 218 219Checks whether the device supports the combination of the DRM solution, MIME type, and content protection level. 220 221**Since**: 11 222 223 224**Parameters** 225 226| Name| Description| 227| -- | -- | 228| const char *name | Pointer to the DRM solution name.| 229| const char *mimeType | Pointer to the MIME type. The supported MIME types depend on the DRM solution. Example types are video/avc and video/hev.| 230| [DRM_ContentProtectionLevel](capi-native-drm-common-h.md#drm_contentprotectionlevel) contentProtectionLevel | Content protection level.| 231 232**Returns** 233 234| Type| Description| 235| -- | -- | 236| bool | Check result for the support of the combination.| 237 238### OH_MediaKeySystem_Create() 239 240``` 241Drm_ErrCode OH_MediaKeySystem_Create(const char *name, MediaKeySystem **mediaKeySystem) 242``` 243 244**Description** 245 246Creates a MediaKeySystem instance. 247 248**Since**: 11 249 250 251**Parameters** 252 253| Name| Description| 254| -- | -- | 255| const char *name | Pointer to the DRM solution name.| 256| [MediaKeySystem](capi-drm-mediakeysystem.md) **mediaKeySystem | Pointer to the MediaKeySystem instance.| 257 258**Returns** 259 260| Type| Description| 261| -- | -- | 262| [Drm_ErrCode](capi-native-drm-err-h.md#drm_errcode) | **DRM_ERR_OK**: The operation is successful.<br>**DRM_ERR_INVALID_VAL**: Possible causes:<br> 1. The input parameter **name** is nullptr or its length is 0.<br> 2. The input parameter **mediaKeySystem** is nullptr.<br>**DRM_ERR_UNKNOWN**: An internal error occurs. Check the log details.<br>**DRM_ERR_SERVICE_DIED**: The service is dead.<br>DRM_ERR_MAX_SYSTEM_NUM_REACHED: The number of created MediaKeySystem instances has reached the upper limit (64).| 263 264### OH_MediaKeySystem_SetConfigurationString() 265 266``` 267Drm_ErrCode OH_MediaKeySystem_SetConfigurationString(MediaKeySystem *mediaKeySystem,const char *configName, const char *value) 268``` 269 270**Description** 271 272Sets a configuration item in the form of a string. 273 274**Since**: 11 275 276 277**Parameters** 278 279| Name| Description| 280| -- | -- | 281| [MediaKeySystem](capi-drm-mediakeysystem.md) *mediaKeySystem | Pointer to the MediaKeySystem instance.| 282| const char *configName | Pointer to the name of the configuration item in the form of a string. It is determined by the DRM solution on the device and cannot be empty.| 283| const char *value | Pointer to the value of the configuration item in the form of a string. It is determined by the DRM solution on the device and cannot be empty.| 284 285**Returns** 286 287| Type| Description| 288| -- | -- | 289| [Drm_ErrCode](capi-native-drm-err-h.md#drm_errcode) | **DRM_ERR_OK**: The operation is successful.<br>**DRM_ERR_INVALID_VAL**: The input parameter **mediaKeySystem** is nullptr or invalid, or **configName** or **value** is nullptr.| 290 291### OH_MediaKeySystem_GetConfigurationString() 292 293``` 294Drm_ErrCode OH_MediaKeySystem_GetConfigurationString(MediaKeySystem *mediaKeySystem,const char *configName, char *value, int32_t valueLen) 295``` 296 297**Description** 298 299Obtains the value of a configuration item in the form of a string. 300 301**Since**: 11 302 303 304**Parameters** 305 306| Name| Description| 307| -- | -- | 308| [MediaKeySystem](capi-drm-mediakeysystem.md) *mediaKeySystem | Pointer to the MediaKeySystem instance.| 309| const char *configName | Pointer to the name of the configuration item.| 310| char *value | Pointer to the value of the configuration item.| 311| int32_t valueLen | Length of the value.| 312 313**Returns** 314 315| Type| Description| 316| -- | -- | 317| [Drm_ErrCode](capi-native-drm-err-h.md#drm_errcode) | **DRM_ERR_OK**: The operation is successful.<br>**DRM_ERR_NO_MEMORY**: The memory fails to be allocated due to insufficient memory.<br>**DRM_ERR_INVALID_VAL**: The input parameter **mediaKeySystem** is nullptr or invalid, or **configName** or **value** is nullptr.<br>**DRM_ERR_UNKNOWN**: An internal error occurs. Check the log details.| 318 319### OH_MediaKeySystem_SetConfigurationByteArray() 320 321``` 322Drm_ErrCode OH_MediaKeySystem_SetConfigurationByteArray(MediaKeySystem *mediaKeySystem,const char *configName, uint8_t *value, int32_t valueLen) 323``` 324 325**Description** 326 327Sets a configuration item in the form of an array. 328 329**Since**: 11 330 331 332**Parameters** 333 334| Name| Description| 335| -- | -- | 336| [MediaKeySystem](capi-drm-mediakeysystem.md) *mediaKeySystem | Pointer to the MediaKeySystem instance.| 337| const char *configName | Pointer to the name of the configuration item in the form of a character array. It is determined by the DRM solution on the device and cannot be empty.| 338| uint8_t *value | Pointer to the value of the configuration item in the form of a character array. It is determined by the DRM solution on the device and cannot be empty.| 339| int32_t valueLen | Length of the value.| 340 341**Returns** 342 343| Type| Description| 344| -- | -- | 345| [Drm_ErrCode](capi-native-drm-err-h.md#drm_errcode) | **DRM_ERR_OK**: The operation is successful.<br>**DRM_ERR_NO_MEMORY**: The memory fails to be allocated due to insufficient memory.<br>**DRM_ERR_INVALID_VAL**: The input parameter **mediaKeySystem** is nullptr or invalid, or **configName** or **value** is nullptr.<br>**DRM_ERR_UNKNOWN**: An internal error occurs. Check the log details.| 346 347### OH_MediaKeySystem_GetConfigurationByteArray() 348 349``` 350Drm_ErrCode OH_MediaKeySystem_GetConfigurationByteArray(MediaKeySystem *mediaKeySystem,const char *configName, uint8_t *value, int32_t *valueLen) 351``` 352 353**Description** 354 355Obtains the value of a configuration item in the form of an array. 356 357**Since**: 11 358 359 360**Parameters** 361 362| Name| Description| 363| -- | -- | 364| [MediaKeySystem](capi-drm-mediakeysystem.md) *mediaKeySystem | Pointer to the MediaKeySystem instance.| 365| const char *configName | Pointer to the name of the configuration item in the form of a character array. It is determined by the DRM solution on the device and cannot be empty.| 366| uint8_t *value | Pointer to the value of the configuration item.| 367| int32_t *valueLen | Pointer to the length of the value.| 368 369**Returns** 370 371| Type| Description| 372| -- | -- | 373| [Drm_ErrCode](capi-native-drm-err-h.md#drm_errcode) | **DRM_ERR_OK**: The operation is successful.<br>**DRM_ERR_NO_MEMORY**: The memory fails to be allocated due to insufficient memory.<br>**DRM_ERR_INVALID_VAL**: The input parameter **mediaKeySystem** is nullptr or invalid, or **configName**, **value**, or **valueLen** is nullptr.<br>**DRM_ERR_UNKNOWN**: An internal error occurs. Check the log details.| 374 375### OH_MediaKeySystem_GetStatistics() 376 377``` 378Drm_ErrCode OH_MediaKeySystem_GetStatistics(MediaKeySystem *mediaKeySystem, DRM_Statistics *statistics) 379``` 380 381**Description** 382 383Obtains the statistics information about a media key system. 384 385**Since**: 11 386 387 388**Parameters** 389 390| Name| Description| 391| -- | -- | 392| [MediaKeySystem](capi-drm-mediakeysystem.md) *mediaKeySystem | Pointer to the MediaKeySystem instance.| 393| [DRM_Statistics](capi-drm-drm-statistics.md) *statistics | Pointer to the statistical information.| 394 395**Returns** 396 397| Type| Description| 398| -- | -- | 399| [Drm_ErrCode](capi-native-drm-err-h.md#drm_errcode) | **DRM_ERR_OK**: The operation is successful.<br>**DRM_ERR_NO_MEMORY**: The memory fails to be allocated due to insufficient memory.<br>**DRM_ERR_INVALID_VAL**: The input parameter **mediaKeySystem** is nullptr or invalid, or **statistics** is nullptr.<br>**DRM_ERR_UNKNOWN**: An internal error occurs. Check the log details.| 400 401### OH_MediaKeySystem_GetMaxContentProtectionLevel() 402 403``` 404Drm_ErrCode OH_MediaKeySystem_GetMaxContentProtectionLevel(MediaKeySystem *mediaKeySystem,DRM_ContentProtectionLevel *contentProtectionLevel) 405``` 406 407**Description** 408 409Obtains the maximum content protection level supported by the device. 410 411**Since**: 11 412 413 414**Parameters** 415 416| Name| Description| 417| -- | -- | 418| [MediaKeySystem](capi-drm-mediakeysystem.md) *mediaKeySystem | Pointer to the MediaKeySystem instance.| 419| [DRM_ContentProtectionLevel](capi-native-drm-common-h.md#drm_contentprotectionlevel) *contentProtectionLevel | Pointer to the content protection level.| 420 421**Returns** 422 423| Type| Description| 424| -- | -- | 425| [Drm_ErrCode](capi-native-drm-err-h.md#drm_errcode) | **DRM_ERR_OK**: The operation is successful.<br>**DRM_ERR_INVALID_VAL**: The input parameter **mediaKeySystem** is nullptr or invalid, or **contentProtectionLevel** is nullptr.<br>**DRM_ERR_UNKNOWN**: An internal error occurs. Check the log details.| 426 427### OH_MediaKeySystem_SetMediaKeySystemCallback() 428 429``` 430Drm_ErrCode OH_MediaKeySystem_SetMediaKeySystemCallback(MediaKeySystem *mediaKeySystem,MediaKeySystem_Callback callback) 431``` 432 433**Description** 434 435Sets a media key system event callback. 436 437**Since**: 11 438 439 440**Parameters** 441 442| Name| Description| 443| -- | -- | 444| [MediaKeySystem](capi-drm-mediakeysystem.md) *mediaKeySystem | Pointer to the MediaKeySystem instance.| 445| [MediaKeySystem_Callback](#mediakeysystem_callback) callback | Callback.| 446 447**Returns** 448 449| Type| Description| 450| -- | -- | 451| [Drm_ErrCode](capi-native-drm-err-h.md#drm_errcode) | **DRM_ERR_OK**: The operation is successful.<br>**DRM_ERR_INVALID_VAL**: The input parameter **mediaKeySystem** is nullptr or invalid.| 452 453### OH_MediaKeySystem_CreateMediaKeySession() 454 455``` 456Drm_ErrCode OH_MediaKeySystem_CreateMediaKeySession(MediaKeySystem *mediaKeySystem,DRM_ContentProtectionLevel *level, MediaKeySession **mediaKeySession) 457``` 458 459**Description** 460 461Creates a MediaKeySession instance. 462 463**Since**: 11 464 465 466**Parameters** 467 468| Name| Description| 469| -- | -- | 470| [MediaKeySystem](capi-drm-mediakeysystem.md) *mediaKeySystem | Pointer to the MediaKeySystem instance.| 471| [DRM_ContentProtectionLevel](capi-native-drm-common-h.md#drm_contentprotectionlevel) *level | Pointer to the content protection level.| 472| [MediaKeySession](capi-drm-mediakeysession.md) **mediaKeySession | Double pointer to the MediaKeySession instance created.| 473 474**Returns** 475 476| Type| Description| 477| -- | -- | 478| [Drm_ErrCode](capi-native-drm-err-h.md#drm_errcode) | **DRM_ERR_OK**: The operation is successful.<br>**DRM_ERR_NO_MEMORY**: The memory fails to be allocated due to insufficient memory.<br>**DRM_ERR_INVALID_VAL**: The input parameter **mediaKeySystem** is nullptr or invalid, **level** is out of range, or **mediaKeySession** is nullptr.<br>**DRM_ERR_UNKNOWN**: An internal error occurs. Check the log details.<br>**DRM_ERR_SERVICE_DIED**: The service is dead.<br>**DRM_ERR_MAX_SESSION_NUM_REACHED**: The number of MediaKeySession instances created by the MediaKeySystem instance reaches the upper limit (64).| 479 480### OH_MediaKeySystem_GenerateKeySystemRequest() 481 482``` 483Drm_ErrCode OH_MediaKeySystem_GenerateKeySystemRequest(MediaKeySystem *mediaKeySystem, uint8_t *request,int32_t *requestLen, char *defaultUrl, int32_t defaultUrlLen) 484``` 485 486**Description** 487 488Generates a provision request. 489 490**Since**: 11 491 492 493**Parameters** 494 495| Name| Description| 496| -- | -- | 497| [MediaKeySystem](capi-drm-mediakeysystem.md) *mediaKeySystem | Pointer to the MediaKeySystem instance.| 498| uint8_t *request | Pointer to the provision request, which is used to request a DRM certificate from a provisioning server.| 499| int32_t *requestLen | Pointer to the length of the provision request.| 500| char *defaultUrl | Pointer to the URL of the provisioning server.| 501| int32_t defaultUrlLen | Length of the URL of the provisioning server.| 502 503**Returns** 504 505| Type| Description| 506| -- | -- | 507| [Drm_ErrCode](capi-native-drm-err-h.md#drm_errcode) | **DRM_ERR_OK**: The operation is successful.<br>**DRM_ERR_NO_MEMORY**: The memory fails to be allocated due to insufficient memory.<br>**DRM_ERR_INVALID_VAL**: The input parameter **mediaKeySystem** is nullptr or invalid, or another parameter of the pointer type is nullptr.<br>**DRM_ERR_UNKNOWN**: An internal error occurs. Check the log details.| 508 509### OH_MediaKeySystem_ProcessKeySystemResponse() 510 511``` 512Drm_ErrCode OH_MediaKeySystem_ProcessKeySystemResponse(MediaKeySystem *mediaKeySystem,uint8_t *response, int32_t responseLen) 513``` 514 515**Description** 516 517Processes a provision response. 518 519**Since**: 11 520 521 522**Parameters** 523 524| Name| Description| 525| -- | -- | 526| [MediaKeySystem](capi-drm-mediakeysystem.md) *mediaKeySystem | Pointer to the MediaKeySystem instance.| 527| uint8_t *response | Pointer to the provision response.| 528| int32_t responseLen | Length of the provision response.| 529 530**Returns** 531 532| Type| Description| 533| -- | -- | 534| [Drm_ErrCode](capi-native-drm-err-h.md#drm_errcode) | **DRM_ERR_OK**: The operation is successful.<br>**DRM_ERR_INVALID_VAL**: The input parameter **mediaKeySystem** is nullptr or invalid, or **response** is nullptr.<br>**DRM_ERR_UNKNOWN**: An internal error occurs. Check the log details.| 535 536### OH_MediaKeySystem_GetOfflineMediaKeyIds() 537 538``` 539Drm_ErrCode OH_MediaKeySystem_GetOfflineMediaKeyIds(MediaKeySystem *mediaKeySystem,DRM_OfflineMediakeyIdArray *offlineMediaKeyIds) 540``` 541 542**Description** 543 544Obtains the list of offline media key IDs, which are used to manage offline media keys. 545 546**Since**: 11 547 548 549**Parameters** 550 551| Name| Description| 552| -- | -- | 553| [MediaKeySystem](capi-drm-mediakeysystem.md) *mediaKeySystem | Pointer to the MediaKeySystem instance.| 554| [DRM_OfflineMediakeyIdArray](capi-drm-drm-offlinemediakeyidarray.md) *offlineMediaKeyIds | Pointer to the IDs of offline media keys.| 555 556**Returns** 557 558| Type| Description| 559| -- | -- | 560| [Drm_ErrCode](capi-native-drm-err-h.md#drm_errcode) | **DRM_ERR_OK**: The operation is successful.<br>**DRM_ERR_NO_MEMORY**: The memory fails to be allocated due to insufficient memory.<br>**DRM_ERR_INVALID_VAL**: The input parameter **mediaKeySystem** is nullptr or invalid, or **offlineMediaKeyIds** is nullptr.<br>**DRM_ERR_UNKNOWN**: An internal error occurs. Check the log details.| 561 562### OH_MediaKeySystem_GetOfflineMediaKeyStatus() 563 564``` 565Drm_ErrCode OH_MediaKeySystem_GetOfflineMediaKeyStatus(MediaKeySystem *mediaKeySystem,uint8_t *offlineMediaKeyId, int32_t offlineMediaKeyIdLen, DRM_OfflineMediaKeyStatus *status) 566``` 567 568**Description** 569 570Obtains the status of an offline media key. 571 572**Since**: 11 573 574 575**Parameters** 576 577| Name| Description| 578| -- | -- | 579| [MediaKeySystem](capi-drm-mediakeysystem.md) *mediaKeySystem | Pointer to the MediaKeySystem instance.| 580| uint8_t *offlineMediaKeyId | Pointer to the ID of an offline media key.| 581| int32_t offlineMediaKeyIdLen | Length of the offline media key ID.| 582| [DRM_OfflineMediaKeyStatus](capi-native-drm-common-h.md#drm_offlinemediakeystatus) *status | Pointer to the media key status obtained.| 583 584**Returns** 585 586| Type| Description| 587| -- | -- | 588| [Drm_ErrCode](capi-native-drm-err-h.md#drm_errcode) | **DRM_ERR_OK**: The operation is successful.<br>**DRM_ERR_INVALID_VAL**: The input parameter **mediaKeySystem** is nullptr or invalid, or another parameter of the pointer type is nullptr.<br>**DRM_ERR_UNKNOWN**: An internal error occurs. Check the log details.| 589 590### OH_MediaKeySystem_ClearOfflineMediaKeys() 591 592``` 593Drm_ErrCode OH_MediaKeySystem_ClearOfflineMediaKeys(MediaKeySystem *mediaKeySystem,uint8_t *offlineMediaKeyId, int32_t offlineMediaKeyIdLen) 594``` 595 596**Description** 597 598Clears offline media keys by ID. 599 600**Since**: 11 601 602 603**Parameters** 604 605| Name| Description| 606| -- | -- | 607| [MediaKeySystem](capi-drm-mediakeysystem.md) *mediaKeySystem | Pointer to the MediaKeySystem instance.| 608| uint8_t *offlineMediaKeyId | Pointer to the ID of an offline media key.| 609| int32_t offlineMediaKeyIdLen | Length of the offline media key ID.| 610 611**Returns** 612 613| Type| Description| 614| -- | -- | 615| [Drm_ErrCode](capi-native-drm-err-h.md#drm_errcode) | **DRM_ERR_OK**: The operation is successful.<br>**DRM_ERR_INVALID_VAL**: The input parameter **mediaKeySystem** is nullptr or invalid, or **offlineMediaKeyId** is nullptr.<br>**DRM_ERR_UNKNOWN**: An internal error occurs. Check the log details.| 616 617### OH_MediaKeySystem_GetCertificateStatus() 618 619``` 620Drm_ErrCode OH_MediaKeySystem_GetCertificateStatus(MediaKeySystem *mediaKeySystem,DRM_CertificateStatus *certStatus) 621``` 622 623**Description** 624 625Obtains the status of a DRM certificate. 626 627**Since**: 11 628 629 630**Parameters** 631 632| Name| Description| 633| -- | -- | 634| [MediaKeySystem](capi-drm-mediakeysystem.md) *mediaKeySystem | Pointer to the MediaKeySystem instance.| 635| [DRM_CertificateStatus](capi-native-drm-common-h.md#drm_certificatestatus) *certStatus | Pointer to the DRM certificate status.| 636 637**Returns** 638 639| Type| Description| 640| -- | -- | 641| [Drm_ErrCode](capi-native-drm-err-h.md#drm_errcode) | **DRM_ERR_OK**: The operation is successful.<br>**DRM_ERR_INVALID_VAL**: The input parameter **mediaKeySystem** is nullptr or invalid, or **certStatus** is nullptr.<br>**DRM_ERR_UNKNOWN**: An internal error occurs. Check the log details.| 642 643### OH_MediaKeySystem_Destroy() 644 645``` 646Drm_ErrCode OH_MediaKeySystem_Destroy(MediaKeySystem *mediaKeySystem) 647``` 648 649**Description** 650 651Destroys a MediaKeySystem instance. 652 653**Since**: 11 654 655 656**Parameters** 657 658| Name| Description| 659| -- | -- | 660| [MediaKeySystem](capi-drm-mediakeysystem.md) *mediaKeySystem | Pointer to the MediaKeySystem instance.| 661 662**Returns** 663 664| Type| Description| 665| -- | -- | 666| [Drm_ErrCode](capi-native-drm-err-h.md#drm_errcode) | **DRM_ERR_OK**: The operation is successful.<br>**DRM_ERR_INVALID_VAL**: The input parameter **mediaKeySystem** is nullptr or invalid.<br>**DRM_ERR_UNKNOWN**: An internal error occurs. Check the log details.| 667