From 7eac410b3f6b4c2e3f37d9b412946aa1ce66b2cd Mon Sep 17 00:00:00 2001 From: qiu-qiu-wang Date: Fri, 24 Nov 2023 19:58:20 +0800 Subject: [PATCH 1/7] drm capi pr scan Signed-off-by: qiu-qiu-wang --- multimedia/drm_framework/BUILD.gn | 85 +++++ .../drm_framework/common/native_drm_base.h | 64 ++++ .../drm_framework/common/native_drm_common.h | 330 ++++++++++++++++++ .../drm_framework/common/native_drm_err.h | 91 +++++ .../drm_framework/common/native_drm_object.h | 52 +++ multimedia/drm_framework/include/BUILD.gn | 35 ++ .../include/libnative_drm.ndk.json | 8 + .../include/native_mediakeysession.h | 126 +++++++ .../include/native_mediakeysystem.h | 149 ++++++++ 9 files changed, 940 insertions(+) create mode 100644 multimedia/drm_framework/BUILD.gn create mode 100644 multimedia/drm_framework/common/native_drm_base.h create mode 100644 multimedia/drm_framework/common/native_drm_common.h create mode 100644 multimedia/drm_framework/common/native_drm_err.h create mode 100644 multimedia/drm_framework/common/native_drm_object.h create mode 100644 multimedia/drm_framework/include/BUILD.gn create mode 100644 multimedia/drm_framework/include/libnative_drm.ndk.json create mode 100644 multimedia/drm_framework/include/native_mediakeysession.h create mode 100644 multimedia/drm_framework/include/native_mediakeysystem.h diff --git a/multimedia/drm_framework/BUILD.gn b/multimedia/drm_framework/BUILD.gn new file mode 100644 index 000000000..a55bca69e --- /dev/null +++ b/multimedia/drm_framework/BUILD.gn @@ -0,0 +1,85 @@ +# Copyright (C) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") +import("//build/ohos/ace/ace.gni") + +DRM_ROOT_DIR = "//foundation/multimedia/drm_framework" + +group("drm_capi_package") { + deps = [] + deps += [ + "$DRM_ROOT_DIR/interfaces/kits/c/drm_capi:native_drm", + ] +} + +config("drm_capi_common_config") { + include_dirs = [ + "$DRM_ROOT_DIR/interfaces/kits/c/drm_capi/include", + "$DRM_ROOT_DIR/interfaces/kits/c/drm_capi/common", + "$DRM_ROOT_DIR/interfaces/inner_api/native/drm", + "$DRM_ROOT_DIR/services/utils/include", + "//foundation//arkui/napi/interfaces/kits", + "//utils/system/safwk/native/include", + "//foundation/multimedia/drm_framework/frameworks/native/drm", + ] + cflags = [ + "-fno-exceptions", + "-Wall", + "-fno-common", + "-fstack-protector-all", + "-Wshadow", + "-FPIC", + "-FS", + "-O2", + "-D_FORTIFY_SOURCE=2", + "-Wformat=2", + "-Wdate-time", + ] + + cflags_cc = [ + "-std=c++17", + "-fno-rtti", + ] +} + +ohos_shared_library("native_drm") { + install_enable = true + configs = [ ":drm_capi_common_config" ] + + sanitize = { + cfi = true + cfi_cross_dso = true + debug = true + } + + sources = [ + "$DRM_ROOT_DIR/frameworks/c/drm_capi/native_mediakeysystem.cpp", + "$DRM_ROOT_DIR/frameworks/c/drm_capi/native_mediakeysession.cpp", + ] + + deps = [ + "$DRM_ROOT_DIR/frameworks/native:drm_framework", + ] + + external_deps = [ + "c_utils:utils", + "hilog:libhilog", + "hitrace:hitrace_meter", + "napi:ace_napi", + ] + output_extension = "so" + subsystem_name = "multimedia" + part_name = "multimedia_drm_framework" +} + diff --git a/multimedia/drm_framework/common/native_drm_base.h b/multimedia/drm_framework/common/native_drm_base.h new file mode 100644 index 000000000..fd8e20202 --- /dev/null +++ b/multimedia/drm_framework/common/native_drm_base.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef NATIVE_DRM_BASE_H +#define NATIVE_DRM_BASE_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif +/** + * @brief OH_MediaKeySystem + * @syscap SystemCapability.Multimedia.Drm.Core + * @since 9 + * @version 1.0 + */ +struct OH_MediaKeySystem : public OHOS::RefBase { + OH_MediaKeySystem() = default; + virtual ~OH_MediaKeySystem() = default; +}; + +/** + * @brief OH_MediaKeySession + * @syscap SystemCapability.Multimedia.Drm.Core + * @since 9 + * @version 1.0 + */ +struct OH_MediaKeySession : public OHOS::RefBase { + OH_MediaKeySession() = default; + virtual ~OH_MediaKeySession() = default; +}; + +/** + * @brief OH_MediaDecryptModule + * @syscap SystemCapability.Multimedia.Drm.Core + * @since 9 + * @version 1.0 + */ +struct OH_MediaDecryptModule : public OHOS::RefBase { + OH_MediaDecryptModule() = default; + virtual ~OH_MediaDecryptModule() = default; +}; + + +#ifdef __cplusplus +} +#endif + +#endif // NATIVE_DRM_BASE_H \ No newline at end of file diff --git a/multimedia/drm_framework/common/native_drm_common.h b/multimedia/drm_framework/common/native_drm_common.h new file mode 100644 index 000000000..098a9472f --- /dev/null +++ b/multimedia/drm_framework/common/native_drm_common.h @@ -0,0 +1,330 @@ +/* + * Copyright (C) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef NATIVE_DRM_COMMON_H +#define NATIVE_DRM_COMMON_H + +#include +#include +#include "native_drm_err.h" +#include "native_drm_base.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Content potection level. + * @syscap SystemCapability.Multimedia.Drm.Core + * @since 11 + * @version 1.0 + */ +typedef enum OH_DRM_ContentProtectionLevel { + /** + * Content potection level unknown. + */ + CONTENT_PROTECTION_LEVEL_UNKNOWN = 0, + /** + * Content potection level software crypto. + */ + CONTENT_PROTECTION_LEVEL_SW_CRYPTO, + /** + * Content potection level hardware crypto. + */ + CONTENT_PROTECTION_LEVEL_HW_CRYPTO, + /** + * Content potection level enhanced hardware crypto. + */ + CONTENT_PROTECTION_LEVEL_ENHANCED_HW_CRYPTO, + /** + * Content potection all levels supported. + */ + CONTENT_PROTECTION_LEVEL_HW_ALL, + /** + * Content potection level max stub. + */ + CONTENT_PROTECTION_LEVEL_MAX, +} OH_DRM_ContentProtectionLevel; + +/** + * @brief License type. + * @syscap SystemCapability.Multimedia.Drm.Core + * @since 11 + * @version 1.0 + */ +typedef enum OH_DRM_LicenseType { + /** + * License type online + */ + LICENSE_TYPE_ONLINE = 0, + /** + * License type offline. + */ + LICENSE_TYPE_OFFLINE, +} OH_DRM_LicenseType; + +/** + * @brief License request type. + * @syscap SystemCapability.Multimedia.Drm.Core + * @since 11 + * @version 1.0 + */ +typedef enum OH_DRM_LicenseRequestType { + /** + * License request type unknown. + */ + REQUEST_TYPE_UNKNOWN = 0, + /** + * License request type initial. + */ + REQUEST_TYPE_INITIAL = 1, + /** + * License request type renewal. + */ + REQUEST_TYPE_RENEWAL = 2, + /** + * License request type release. + */ + REQUEST_TYPE_RELEASE = 3, + /** + * License request type none. + */ + REQUEST_TYPE_NONE = 4, +} OH_DRM_LicenseRequestType; + +/** + * @brief Offline media key status. + * @syscap SystemCapability.Multimedia.Drm.Core + * @since 11 + * @version 1.0 + */ +typedef enum OH_DRM_OfflineMediaKeyStatus { + /** + * Offline media key status unknown. + */ + OFFLINE_MEDIA_KEY_STATUS_UNKNOWN = 0, + /** + * Offline media key status usable. + */ + OFFLINE_MEDIA_KEY_STATUS_USABLE, + /** + * Offline media key status inactive. + */ + OFFLINE_MEDIA_KEY_STATUS_INACTIVE, +} OH_DRM_OfflineMediaKeyStatus; + +/** + * @brief Offline media key status. + * @syscap SystemCapability.Multimedia.Drm.Core + * @since 11 + * @version 1.0 + */ +typedef enum OH_DRM_CertificateStatus { + /** + * Device already provisioned. + */ + CERT_STATUS_PROVISIONED = 0, + /** + * Device not provisioned. + */ + CERT_STATUS_NOT_PROVISIONED, + /** + * Cert already expired. + */ + CERT_STATUS_EXPIRED, + /** + * Certs are invalid. + */ + CERT_STATUS_INVALID, + /** + * Get certs status failed. + */ + CERT_STATUS_UNAVAILABLE, +} OH_DRM_CertificateStatus; + +/** + * @brief Offline media key status. + * @syscap SystemCapability.Multimedia.Drm.Core + * @since 11 + * @version 1.0 + */ +typedef enum OH_DRM_LicenseStatus { + /** + * License status OK. + */ + LICENSE_STATUS_OK = 0, + /** + * License is invalid e.g. not exist. + */ + LICENSE_STATUS_NOT_EXIST = 1, +} OH_DRM_LicenseStatus; + +/** + * @brief Unsigned char buffer. + * + * @since 11 + * @version 1.0 + */ +struct OH_DRM_Uint8Buffer { + /** + * Unsigned char buffer addr. + */ + unsigned char *buffer; + /** + * Unsigned char buffer len. + */ + uint32_t bufferLen; +}; + +/** + * @brief Char buffer. + * + * @since 11 + * @version 1.0 + */ +struct OH_DRM_CharBuffer { + /** + * Char buffer addr. + */ + char *buffer; + /** + * Char buffer len. + */ + uint32_t bufferLen; +}; + +/** + * @brief Char-char buffer pair. + * + * @since 11 + * @version 1.0 + */ +struct OH_DRM_CharBufferPair { + /* Name buffer in chars.*/ + OH_DRM_CharBuffer name; + /* Value buffer in chars.*/ + OH_DRM_CharBuffer value; +}; + +/** + * @brief Unsignedchar-char buffer. + * + * @since 11 + * @version 1.0 + */ +struct OH_DRM_Uint8CharBufferPair { + /* Key buffer in Uint8Array.*/ + OH_DRM_Uint8Buffer key; + /* Value buffer in chars.*/ + OH_DRM_CharBuffer value; +}; + +/** + * @brief Defines the handles of models for Neural Network Runtime. + * + * @since 11 + * @version 1.0 + */ +struct OH_DRM_LicenseRequestInfo { + /** + * Offline or online license type. + */ + OH_DRM_LicenseType type; + /** + * Initial data format as PSSH after base64 encoding. + */ + OH_DRM_Uint8Buffer data; + /** + * Media content mime type. + */ + OH_DRM_CharBuffer mimeType; + /** + * OptionsData count. + */ + uint32_t optionsCount; + /** + * Options data the application set to drm framework. + */ + OH_DRM_CharBufferPair *optionsData; +}; + +/** + * @brief Statistics of OH_MediaKeySystem. + * + * @since 11 + * @version 1.0 + */ +struct OH_DRM_Statistics { + /* Statistics count.*/ + uint32_t statisticsCount; + /* Statistics info.*/ + OH_DRM_CharBufferPair *info; +}; + +/** + * @brief License Ids. + * + * @since 11 + * @version 1.0 + */ +struct OH_DRM_LicenseIdArray { + /* License Id count.*/ + uint32_t licenseIdCount; + /* License Ids.*/ + OH_DRM_Uint8Buffer *licenseIds; +}; + +/** + * @brief Media key info. + * + * @since 11 + * @version 1.0 + */ +struct OH_DRM_KeysInfo { + /* Keys count.*/ + uint32_t keysCount; + /* Keys info.*/ + OH_DRM_Uint8CharBufferPair *keysInfo; +}; + +/** + * @brief License description + * + * @since 11 + * @version 1.0 + */ +struct OH_DRM_LicenseDescription { + /* License count.*/ + uint32_t licenseCount; + /* License info.*/ + OH_DRM_CharBufferPair *description; +}; + +typedef struct OH_DRM_Uint8Buffer OH_DRM_Uint8Buffer; +typedef struct OH_DRM_CharBuffer OH_DRM_CharBuffer; +typedef struct OH_DRM_CharBufferPair OH_DRM_CharBufferPair; +typedef struct OH_DRM_Uint8CharBufferPair OH_DRM_Uint8CharBufferPair; +typedef struct OH_DRM_LicenseRequestInfo OH_DRM_LicenseRequestInfo; +typedef struct OH_DRM_MetricInfo OH_DRM_MetricInfo; +typedef struct OH_DRM_Metrics OH_DRM_Metrics; +typedef struct OH_DRM_LicenseIdArray OH_DRM_LicenseIdArray; +typedef struct OH_DRM_LicenseDescription OH_DRM_LicenseDescription; +typedef struct OH_DRM_KeysInfo OH_DRM_KeysInfo; + +#ifdef __cplusplus +} +#endif + +#endif // NATIVE_DRM_COMMON_H \ No newline at end of file diff --git a/multimedia/drm_framework/common/native_drm_err.h b/multimedia/drm_framework/common/native_drm_err.h new file mode 100644 index 000000000..6d29aef10 --- /dev/null +++ b/multimedia/drm_framework/common/native_drm_err.h @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef NATIVE_DRM_ERR_H +#define NATIVE_DRM_ERR_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief DRM error code + * @syscap SystemCapability.Multimedia.Drm.Core + * @since 11 + * @version 1.0 + */ +typedef enum OH_DrmErrCode { + /** + * the operation completed successfully. + */ + DRM_ERR_OK = 0, + /** + * no memory. + */ + DRM_ERR_NO_MEMORY, + /** + * opertation not be permitted. + */ + DRM_ERR_OPERATE_NOT_PERMIT, + /** + * invalid argument. + */ + DRM_ERR_INVALID_VAL, + /** + * IO error. + */ + DRM_ERR_IO, + /** + * network timeout. + */ + DRM_ERR_TIMEOUT, + /** + * unknown error. + */ + DRM_ERR_UNKNOWN, + /** + * drm service died. + */ + DRM_ERR_SERVICE_DIED, + /** + * not support this operation in this state. + */ + DRM_ERR_INVALID_STATE, + /** + * unsupport interface. + */ + DRM_ERR_UNSUPPORT, + /** + * Meet max MediaKeySystem num limit. + */ + DRM_ERR_MAX_SYSTEM_NUM_REACHED, + /** + * Meet max MediaKeySession num limit. + */ + DRM_ERR_MAX_SESSION_NUM_REACHED, + /** + * extend err start. + */ + DRM_ERR_EXTEND_START = 100, +} OH_DrmErrCode; + +#ifdef __cplusplus +} +#endif + +#endif // NATIVE_DRM_ERR_H \ No newline at end of file diff --git a/multimedia/drm_framework/common/native_drm_object.h b/multimedia/drm_framework/common/native_drm_object.h new file mode 100644 index 000000000..91b2145a6 --- /dev/null +++ b/multimedia/drm_framework/common/native_drm_object.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef NATIVE_DRM_OBJECT_H +#define NATIVE_DRM_OBJECT_H + +#include +#include +#include "native_drm_err.h" +#include "native_drm_base.h" + +#include "key_session_impl.h" +#include "media_key_system_impl.h" +#include "media_key_system_factory_impl.h" +#include "media_decrypt_module_impl.h" + +struct MediaKeySystemObject : public OH_MediaKeySystem +{ + explicit MediaKeySystemObject(const OHOS::sptr &impl) + : systemImpl_(impl) + { + } + ~MediaKeySystemObject() = default; + + const OHOS::sptr systemImpl_ = nullptr; +}; + +struct MediaKeySessionObject : public OH_MediaKeySession +{ + explicit MediaKeySessionObject(const OHOS::sptr &impl) + : sessionImpl_(impl) + { + } + ~MediaKeySessionObject() = default; + + const OHOS::sptr sessionImpl_ = nullptr; +}; + + +#endif // NATIVE_DRM_OBJECT_H \ No newline at end of file diff --git a/multimedia/drm_framework/include/BUILD.gn b/multimedia/drm_framework/include/BUILD.gn new file mode 100644 index 000000000..9db3488d4 --- /dev/null +++ b/multimedia/drm_framework/include/BUILD.gn @@ -0,0 +1,35 @@ +# Copyright (C) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") +import("//build/ohos/ndk/ndk.gni") +ohos_ndk_headers("native_drm_header") { + dest_dir = "$ndk_headers_out_dir/multimedia/multimedia_drm_framework" + sources = [ + "//foundation/multimedia/drm_framework/interfaces/kits/c/drm_capi/include/native_mediakeysession.h", + "//foundation/multimedia/drm_framework/interfaces/kits/c/drm_capi/include/native_mediakeysystem.h" + ] +} + +ohos_ndk_library("libnative_drm") { + ndk_description_file = "./libnative_drm.ndk.json" + min_compact_version = "1" + output_name = "native_drm" + output_extension = "so" + + system_capability = "SystemCapability.Multimedia.Drm.Core" + system_capability_headers = [ + "multimedia/drm_framework/native_mediakeysession.h", + "multimedia/drm_framework/native_mediakeysystem.h", + ] +} \ No newline at end of file diff --git a/multimedia/drm_framework/include/libnative_drm.ndk.json b/multimedia/drm_framework/include/libnative_drm.ndk.json new file mode 100644 index 000000000..cd2af3891 --- /dev/null +++ b/multimedia/drm_framework/include/libnative_drm.ndk.json @@ -0,0 +1,8 @@ +[ + { "name": "OH_MediaKeySystem_Create" }, + { "name": "OH_MediaKeySystem_Destroy" }, + { "name": "OH_MediaKeySystem_CreateMediaKeySession" }, + { "name": "OH_MediaKeySession_GenerateLicenseRequest" }, + { "name": "OH_MediaKeySession_ProcessLicenseResponse" }, + { "name": "OH_MediaKeySession_CheckLicenseStatus" } +] \ No newline at end of file diff --git a/multimedia/drm_framework/include/native_mediakeysession.h b/multimedia/drm_framework/include/native_mediakeysession.h new file mode 100644 index 000000000..7fd93ae4e --- /dev/null +++ b/multimedia/drm_framework/include/native_mediakeysession.h @@ -0,0 +1,126 @@ +/* + * Copyright (C) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup Drm + * @{ + * + * @brief Provides APIs of Drm. + * + * @Syscap SystemCapability.Multimedia.Drm.Core + * @since 11 + * @version 1.0 + */ + +/** + * @file native_mediakeysession.h + * + * @brief Defines the Drm MediaKeySession APIs. + * + * @library libdrm_framework.z.so + * @since 11 + * @version 1.0 + */ + +#ifndef OHOS_DRM_NATIVE_MEDIA_KEY_SYSTEM_H +#define OHOS_DRM_NATIVE_MEDIA_KEY_SYSTEM_H + +#include +#include +#include "native_drm_common.h" +#include "native_drm_base.h" +#include "native_drm_err.h" + +#ifdef __cplusplus +extern "C" +{ +#endif +typedef struct OH_MediaKeySession OH_MediaKeySession; + +typedef OH_DrmErrCode (*OH_MediaKeySessionEventCallback)(OH_DRM_CharBufferPair *eventInfo); +typedef OH_DrmErrCode (*OH_MediaKeySessionKeyChangeCallback)(OH_DRM_CharBufferPair *OH_DRM_KeysInfo); +typedef struct OH_MediaKeySessionCallback { + OH_MediaKeySessionEventCallback eventCallback; + OH_MediaKeySessionKeyChangeCallback keyChangeCallback; +} OH_MediaKeySessionCallback; +/** + * @brief Generate license request. + * @syscap SystemCapability.Multimedia.Drm.Core + * @param mediaKeySession Media key session instance. + * if the function returns DRM_ERR_OK. + * @param info License request info. + * @param request Out parameter. License request. + * @returns OH_DrmErrCode refers to OH_DrmErrCode. + * @since 11 + * @version 1.0 + */ +OH_DrmErrCode OH_MediaKeySession_GenerateLicenseRequest(OH_MediaKeySession *keySession, + OH_DRM_LicenseRequestInfo *info, OH_DRM_Uint8Buffer *licenseRequest); + +/** + * @brief Process license request. + * @syscap SystemCapability.Multimedia.Drm.Core + * @param mediaKeySession Media key session instance. + * @param response License resposne. + * @param responseLen The length of license resposne. + * @param licenseId Specifies which license corresponded. + * @param licenseIdLen The length of license id. + * @returns OH_DrmErrCode refers to OH_DrmErrCode. + * @since 11 + * @version 1.0 + */ +OH_DrmErrCode OH_MediaKeySession_ProcessLicenseResponse(OH_MediaKeySession *keySession, + OH_DRM_Uint8Buffer *response, OH_DRM_Uint8Buffer *licenseId); + +/** + * @brief Check license status. + * @syscap SystemCapability.Multimedia.Drm.Core + * @param mediaKeySession Media key session instance. + * @param response License resposne. + * @param responseLen The length of license resposne. + * @param licenseId Specifies which license corresponded. + * @param licenseIdLen The length of license id. + * @returns OH_DrmErrCode refers to OH_DrmErrCode. + * @since 11 + * @version 1.0 + */ +OH_DrmErrCode OH_MediaKeySession_CheckLicenseStatus(OH_MediaKeySession *mediaKeySessoin, + OH_DRM_LicenseDescription *licenseDescription); + +OH_DrmErrCode OH_MediaKeySession_RemoveLicense(OH_MediaKeySession *mediaKeySessoin); + +OH_DrmErrCode OH_MediaKeySession_GenerateOfflineReleaseRequest(OH_MediaKeySession *mediaKeySessoin, + OH_DRM_Uint8Buffer *licenseId, OH_DRM_Uint8Buffer *releaseRequest); +OH_DrmErrCode OH_MediaKeySession_ProcessOfflineReleaseResponse(OH_MediaKeySession *mediaKeySessoin, + OH_DRM_Uint8Buffer *licenseId, OH_DRM_Uint8Buffer *releaseReponse); + +OH_DrmErrCode OH_MediaKeySession_RestoreOfflineLicense(OH_MediaKeySession *mediaKeySessoin, + OH_DRM_Uint8Buffer *licenseId); +OH_DrmErrCode OH_MediaKeySession_GetSecurityLevel(OH_MediaKeySession *mediaKeySessoin, + OH_DRM_ContentProtectionLevel *contentProtectionLevel); + +OH_DrmErrCode OH_MediaKeySession_RequireSecureDecoderModule(OH_MediaKeySession *mediaKeySessoin, + const char *mimeType, bool *status); + +OH_DrmErrCode OH_MediaKeySession_SetMediaKeySessionCallback(OH_MediaKeySession *mediaKeySessoin, + OH_MediaKeySessionCallback *callback); + +OH_DrmErrCode OH_MediaKeySession_Destroy(OH_MediaKeySession *mediaKeySessoin); + +#ifdef __cplusplus +} +#endif + +#endif // OHOS_DRM_NATIVE_MEDIA_KEY_SYSTEM_H \ No newline at end of file diff --git a/multimedia/drm_framework/include/native_mediakeysystem.h b/multimedia/drm_framework/include/native_mediakeysystem.h new file mode 100644 index 000000000..a43d8314a --- /dev/null +++ b/multimedia/drm_framework/include/native_mediakeysystem.h @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup Drm + * @{ + * + * @brief Provides APIs of Drm. + * + * @Syscap SystemCapability.Multimedia.Drm.Core + * @since 11 + * @version 1.0 + */ + +/** + * @file native_mediakeysystem.h + * + * @brief Defines the Drm MediaKeySystem APIs. + * + * @library libdrm_framework.z.so + * @since 11 + * @version 1.0 + */ + +#ifndef OHOS_DRM_NATIVE_MEDIA_KEY_SYSTEM_H +#define OHOS_DRM_NATIVE_MEDIA_KEY_SYSTEM_H + +#include +#include +#include "native_drm_base.h" +#include "native_drm_err.h" +#include "native_drm_common.h" + +#ifdef __cplusplus +extern "C" { +#endif +typedef struct OH_MediaKeySystem OH_MediaKeySystem; +typedef struct OH_MediaKeySession OH_MediaKeySession; + +typedef OH_DrmErrCode (*OH_MediaKeySystemCallback)(OH_DRM_CharBufferPair *eventInfo); +/** + * @brief Query if media key system is supported by name. + * @param name Secifies which drm system will be created. + * @return Returns a Pointer to an OH_MediaKeySystem instance. + * @since 11 + * @version 1.0 + */ +bool OH_MediaKeySystem_IsSupported(const char *name); +/** + * @brief Query if media key system is supported by name. + * @param name Secifies which drm system will be created. + * @return Returns a Pointer to an OH_MediaKeySystem instance. + * @syscap SystemCapability.Multimedia.Drm.Core + * @since 11 + * @version 1.0 + */ +bool OH_MediaKeySystem_IsSupported2(const char *name, const char *mimeType); +/** + * @brief Creates a media key system instance from the uuid. + * @syscap SystemCapability.Multimedia.Drm.Core + * @param uuid Secifies which drm system will be created. + * @return Returns a Pointer to an OH_MediaKeySystem instance. + * @since 11 + * @version 1.0 + */ +bool OH_MediaKeySystem_IsSupported3(const char *name, const char *mimeType, OH_DRM_ContentProtectionLevel contentProtectionLevel); + +/** + * @brief Creates a media key system instance from the uuid. + * @syscap SystemCapability.Multimedia.Drm.Core + * @param uuid Secifies which drm system will be created. + * @return Returns a Pointer to an OH_MediaKeySystem instance. + * @since 11 + * @version 1.0 + */ +OH_MediaKeySystem *OH_MediaKeySystem_Create(const char *name); + +OH_DrmErrCode OH_MediaKeySystem_SetConfigurationString(OH_MediaKeySystem *mediaKeySystem, + const char *configName, const char *value); +OH_DrmErrCode OH_MediaKeySystem_GetConfigurationString(OH_MediaKeySystem *mediaKeySystem, + const char *configName, OH_DRM_CharBuffer *value); +OH_DrmErrCode OH_MediaKeySystem_SetConfigurationByteArray(OH_MediaKeySystem *mediaKeySystem, + const char *configName, OH_DRM_Uint8Buffer *value); +OH_DrmErrCode OH_MediaKeySystem_GetConfigurationByteArray(OH_MediaKeySystem *mediaKeySystem, + const char *configName, OH_DRM_Uint8Buffer *value); + +OH_DrmErrCode OH_MediaKeySystem_GetMetrics(OH_MediaKeySystem *mediaKeySystem, OH_DRM_Metrics *metrics); +OH_DrmErrCode OH_MediaKeySystem_GetMaxSecurityLevel(OH_MediaKeySystem *mediaKeySystem, + OH_DRM_ContentProtectionLevel *contentProtectionLevel); + +OH_DrmErrCode OH_MediaKeySystem_SetMediaKeySystemCallback(OH_MediaKeySystem *mediaKeySystem, + OH_MediaKeySystemCallback callback); + +/** + * @brief Create a media key session instance. + * @syscap SystemCapability.Multimedia.Drm.Core + * @param mediaKeySystem Media key system instance which will create media key session. + * @param OH_DRM_ContentProtectionLevel Specifies the security level. + * @param mediaKeySession Out parameter. Media key session instance has been created + * if the function returns DRM_ERR_OK. + * @returns OH_DrmErrCode refers to OH_DrmErrCode + * @since 11 + * @version 1.0 + */ +OH_DrmErrCode OH_MediaKeySystem_CreateMediaKeySession(OH_MediaKeySystem *mediaKeySystem, + OH_DRM_ContentProtectionLevel *level, OH_MediaKeySession **mediaKeySession); + +OH_DrmErrCode OH_MediaKeySystem_GenerateKeySystemRequest(OH_MediaKeySystem *mediaKeySystem, + OH_DRM_Uint8Buffer *request, OH_DRM_CharBuffer *defaultUrl); +OH_DrmErrCode OH_MediaKeySystem_ProcessKeySystemResponse(OH_MediaKeySystem *mediaKeySystem, + OH_DRM_Uint8Buffer *response); + +OH_DrmErrCode OH_MediaKeySystem_GetOfflineLicenseIds(OH_MediaKeySystem *mediaKeySystem, + OH_DRM_LicenseIdArray *licenseIds); +OH_DrmErrCode OH_MediaKeySystem_GetOfflineLicenseStatus(OH_MediaKeySystem *mediaKeySystem, + OH_DRM_Uint8Buffer *licenseId, OH_DRM_OfflineMediaKeyStatus *status); +OH_DrmErrCode OH_MediaKeySystem_RemoveOfflineLicense(OH_MediaKeySystem *mediaKeySystem, + OH_DRM_Uint8Buffer *licenseId); + +OH_DrmErrCode OH_MediaKeySystem_GetCertificateStatus(OH_MediaKeySystem *mediaKeySystem, + OH_DRM_CertificateStatus *certStatus); + +/** + * @brief Destroy a media key system instance. + * @syscap SystemCapability.Multimedia.Drm.Core + * @param uuid Secifies which media key system instance will be destroyed. + * @since 11 + * @version 1.0 + */ +OH_DrmErrCode OH_MediaKeySystem_Destroy(OH_MediaKeySystem *mediaKeySystem); + + +#ifdef __cplusplus +} +#endif + +#endif // OHOS_DRM_NATIVE_MEDIA_KEY_SYSTEM_H \ No newline at end of file -- Gitee From 87658a68403863178067e219d2ba15e61cb02727 Mon Sep 17 00:00:00 2001 From: qiu-qiu-wang Date: Mon, 27 Nov 2023 22:39:16 +0800 Subject: [PATCH 2/7] add function comment Signed-off-by: qiu-qiu-wang --- .../drm_framework/common/native_drm_base.h | 32 +-- .../drm_framework/common/native_drm_common.h | 183 ++++++++++------- .../include/native_mediakeysession.h | 138 ++++++++++--- .../include/native_mediakeysystem.h | 189 ++++++++++++++---- 4 files changed, 379 insertions(+), 163 deletions(-) diff --git a/multimedia/drm_framework/common/native_drm_base.h b/multimedia/drm_framework/common/native_drm_base.h index fd8e20202..654bb0e02 100644 --- a/multimedia/drm_framework/common/native_drm_base.h +++ b/multimedia/drm_framework/common/native_drm_base.h @@ -24,38 +24,26 @@ extern "C" { #endif /** - * @brief OH_MediaKeySystem - * @syscap SystemCapability.Multimedia.Drm.Core - * @since 9 + * @brief MediaKeySystem struct. + * + * @since 11 * @version 1.0 */ -struct OH_MediaKeySystem : public OHOS::RefBase { +typedef struct OH_MediaKeySystem : public OHOS::RefBase { OH_MediaKeySystem() = default; virtual ~OH_MediaKeySystem() = default; -}; +} OH_MediaKeySystem; /** - * @brief OH_MediaKeySession - * @syscap SystemCapability.Multimedia.Drm.Core - * @since 9 + * @brief MediaKeySession struct. + * + * @since 11 * @version 1.0 */ -struct OH_MediaKeySession : public OHOS::RefBase { +typedef struct OH_MediaKeySession : public OHOS::RefBase { OH_MediaKeySession() = default; virtual ~OH_MediaKeySession() = default; -}; - -/** - * @brief OH_MediaDecryptModule - * @syscap SystemCapability.Multimedia.Drm.Core - * @since 9 - * @version 1.0 - */ -struct OH_MediaDecryptModule : public OHOS::RefBase { - OH_MediaDecryptModule() = default; - virtual ~OH_MediaDecryptModule() = default; -}; - +} OH_MediaKeySession; #ifdef __cplusplus } diff --git a/multimedia/drm_framework/common/native_drm_common.h b/multimedia/drm_framework/common/native_drm_common.h index 098a9472f..cebbf81a1 100644 --- a/multimedia/drm_framework/common/native_drm_common.h +++ b/multimedia/drm_framework/common/native_drm_common.h @@ -25,6 +25,27 @@ extern "C" { #endif +/** + * @addtogroup Drm + * @{ + * + * @brief Provides APIs of Drm. + * + * @Syscap SystemCapability.Multimedia.Drm.Core + * @since 11 + * @version 1.0 + */ + +/** + * @file native_drm_common.h + * + * @brief Defines the Drm common struct. + * + * @library libdrm_framework.z.so + * @since 11 + * @version 1.0 + */ + /** * @brief Content potection level. * @syscap SystemCapability.Multimedia.Drm.Core @@ -59,50 +80,54 @@ typedef enum OH_DRM_ContentProtectionLevel { } OH_DRM_ContentProtectionLevel; /** - * @brief License type. + * @brief Media key type. * @syscap SystemCapability.Multimedia.Drm.Core * @since 11 * @version 1.0 */ -typedef enum OH_DRM_LicenseType { +typedef enum OH_DRM_MediaKeyType { /** - * License type online + * Media key type offline. */ - LICENSE_TYPE_ONLINE = 0, + MEDIA_KEY_TYPE_OFFLINE = 0, /** - * License type offline. + * Media key type online */ - LICENSE_TYPE_OFFLINE, -} OH_DRM_LicenseType; + MEDIA_KEY_TYPE_ONLINE, +} OH_DRM_MediaKeyType; /** - * @brief License request type. + * @brief Media key request type. * @syscap SystemCapability.Multimedia.Drm.Core * @since 11 * @version 1.0 */ -typedef enum OH_DRM_LicenseRequestType { +typedef enum OH_DRM_MediaKeyRequestType { + /** + * Media key request type unknown. + */ + MEDIA_KEY_REQUEST_TYPE_UNKNOWN = 0, /** - * License request type unknown. + * Media key request type initial. */ - REQUEST_TYPE_UNKNOWN = 0, + MEDIA_KEY_REQUEST_TYPE_INITIAL, /** - * License request type initial. + * Media key request type renewal. */ - REQUEST_TYPE_INITIAL = 1, + MEDIA_KEY_REQUEST_TYPE_RENEWAL, /** - * License request type renewal. + * Media key request type release. */ - REQUEST_TYPE_RENEWAL = 2, + MEDIA_KEY_REQUEST_TYPE_RELEASE, /** - * License request type release. + * Media key request type none. */ - REQUEST_TYPE_RELEASE = 3, + MEDIA_KEY_REQUEST_TYPE_NONE, /** - * License request type none. + * Media key request type update. */ - REQUEST_TYPE_NONE = 4, -} OH_DRM_LicenseRequestType; + MEDIA_KEY_REQUEST_TYPE_UPDATE, +} OH_DRM_MediaKeyRequestType; /** * @brief Offline media key status. @@ -126,7 +151,7 @@ typedef enum OH_DRM_OfflineMediaKeyStatus { } OH_DRM_OfflineMediaKeyStatus; /** - * @brief Offline media key status. + * @brief Certificate status. * @syscap SystemCapability.Multimedia.Drm.Core * @since 11 * @version 1.0 @@ -160,16 +185,16 @@ typedef enum OH_DRM_CertificateStatus { * @since 11 * @version 1.0 */ -typedef enum OH_DRM_LicenseStatus { +typedef enum OH_DRM_MediaKeyStatus { /** - * License status OK. + * Media key status OK. */ - LICENSE_STATUS_OK = 0, + MEDIA_KEY_STATUS_OK = 0, /** - * License is invalid e.g. not exist. + * Media key is invalid e.g. not exist. */ - LICENSE_STATUS_NOT_EXIST = 1, -} OH_DRM_LicenseStatus; + MEDIA_KEY_STATUS_NOT_EXIST = 1, +} OH_DRM_MediaKeyStatus; /** * @brief Unsigned char buffer. @@ -177,7 +202,7 @@ typedef enum OH_DRM_LicenseStatus { * @since 11 * @version 1.0 */ -struct OH_DRM_Uint8Buffer { +typedef struct OH_DRM_Uint8Buffer { /** * Unsigned char buffer addr. */ @@ -186,7 +211,7 @@ struct OH_DRM_Uint8Buffer { * Unsigned char buffer len. */ uint32_t bufferLen; -}; +} OH_DRM_Uint8Buffer; /** * @brief Char buffer. @@ -194,7 +219,7 @@ struct OH_DRM_Uint8Buffer { * @since 11 * @version 1.0 */ -struct OH_DRM_CharBuffer { +typedef struct OH_DRM_CharBuffer { /** * Char buffer addr. */ @@ -203,7 +228,7 @@ struct OH_DRM_CharBuffer { * Char buffer len. */ uint32_t bufferLen; -}; +} OH_DRM_CharBuffer; /** * @brief Char-char buffer pair. @@ -211,12 +236,12 @@ struct OH_DRM_CharBuffer { * @since 11 * @version 1.0 */ -struct OH_DRM_CharBufferPair { +typedef struct OH_DRM_CharBufferPair { /* Name buffer in chars.*/ OH_DRM_CharBuffer name; /* Value buffer in chars.*/ OH_DRM_CharBuffer value; -}; +} OH_DRM_CharBufferPair; /** * @brief Unsignedchar-char buffer. @@ -224,24 +249,24 @@ struct OH_DRM_CharBufferPair { * @since 11 * @version 1.0 */ -struct OH_DRM_Uint8CharBufferPair { +typedef struct OH_DRM_Uint8CharBufferPair { /* Key buffer in Uint8Array.*/ OH_DRM_Uint8Buffer key; /* Value buffer in chars.*/ OH_DRM_CharBuffer value; -}; +} OH_DRM_Uint8CharBufferPair; /** - * @brief Defines the handles of models for Neural Network Runtime. + * @brief Media key request info. * * @since 11 * @version 1.0 */ -struct OH_DRM_LicenseRequestInfo { +typedef struct OH_DRM_MediaKeyRequestInfo { /** - * Offline or online license type. + * Offline or online media key type. */ - OH_DRM_LicenseType type; + OH_DRM_MediaKeyType type; /** * Initial data format as PSSH after base64 encoding. */ @@ -258,7 +283,7 @@ struct OH_DRM_LicenseRequestInfo { * Options data the application set to drm framework. */ OH_DRM_CharBufferPair *optionsData; -}; +} OH_DRM_MediaKeyRequestInfo; /** * @brief Statistics of OH_MediaKeySystem. @@ -266,25 +291,25 @@ struct OH_DRM_LicenseRequestInfo { * @since 11 * @version 1.0 */ -struct OH_DRM_Statistics { +typedef struct OH_DRM_Statistics { /* Statistics count.*/ uint32_t statisticsCount; /* Statistics info.*/ OH_DRM_CharBufferPair *info; -}; +} OH_DRM_Statistics; /** - * @brief License Ids. + * @brief MediaKeyIds array. * * @since 11 * @version 1.0 */ -struct OH_DRM_LicenseIdArray { - /* License Id count.*/ - uint32_t licenseIdCount; - /* License Ids.*/ - OH_DRM_Uint8Buffer *licenseIds; -}; +typedef struct OH_DRM_MediakeyIdArray { + /* MediaKeyId count.*/ + uint32_t mediaKeyIdCount; + /* MediaKeyIds.*/ + OH_DRM_Uint8Buffer *mediaKeyIds; +} OH_DRM_MediakeyIdArray; /** * @brief Media key info. @@ -292,36 +317,60 @@ struct OH_DRM_LicenseIdArray { * @since 11 * @version 1.0 */ -struct OH_DRM_KeysInfo { +typedef struct OH_DRM_KeysInfo { /* Keys count.*/ uint32_t keysCount; /* Keys info.*/ OH_DRM_Uint8CharBufferPair *keysInfo; -}; +} OH_DRM_KeysInfo; /** - * @brief License description + * @brief MediaKeydescription * * @since 11 * @version 1.0 */ -struct OH_DRM_LicenseDescription { - /* License count.*/ - uint32_t licenseCount; - /* License info.*/ +typedef struct OH_DRM_MediaKeyDescription { + /* MediaKeycount.*/ + uint32_t mediaKeyCount; + /* MediaKeyinfo.*/ OH_DRM_CharBufferPair *description; -}; +} OH_DRM_MediaKeyDescription; -typedef struct OH_DRM_Uint8Buffer OH_DRM_Uint8Buffer; -typedef struct OH_DRM_CharBuffer OH_DRM_CharBuffer; -typedef struct OH_DRM_CharBufferPair OH_DRM_CharBufferPair; -typedef struct OH_DRM_Uint8CharBufferPair OH_DRM_Uint8CharBufferPair; -typedef struct OH_DRM_LicenseRequestInfo OH_DRM_LicenseRequestInfo; -typedef struct OH_DRM_MetricInfo OH_DRM_MetricInfo; -typedef struct OH_DRM_Metrics OH_DRM_Metrics; -typedef struct OH_DRM_LicenseIdArray OH_DRM_LicenseIdArray; -typedef struct OH_DRM_LicenseDescription OH_DRM_LicenseDescription; -typedef struct OH_DRM_KeysInfo OH_DRM_KeysInfo; +/** + * @brief PSSH info by uuid. + * + * @since 11 + * @version 1.0 + */ +#define UUID_LEN 16 +typedef struct OH_DRM_PsshInfo { + /** + * Uuid. + */ + char uuid[UUID_LEN]; + /** + * Unsigned char PSSH len. + */ + uint32_t dataLen; + /** + * Unsigned char PSSH data. + */ + unsigned char *data; +} OH_DRM_PsshInfo; + +/** + * @brief DrmInfo used for player to get DRM info from media source. + * + * @since 11 + * @version 1.0 + */ +typedef struct OH_DRM_DrmInfo { + /* PSSH count.*/ + uint32_t psshCount; + /* PSSH info.*/ + OH_DRM_PsshInfo *psshInfo; +} OH_DRM_DrmInfo; #ifdef __cplusplus } diff --git a/multimedia/drm_framework/include/native_mediakeysession.h b/multimedia/drm_framework/include/native_mediakeysession.h index 7fd93ae4e..71212f6a3 100644 --- a/multimedia/drm_framework/include/native_mediakeysession.h +++ b/multimedia/drm_framework/include/native_mediakeysession.h @@ -47,76 +47,148 @@ extern "C" { #endif -typedef struct OH_MediaKeySession OH_MediaKeySession; typedef OH_DrmErrCode (*OH_MediaKeySessionEventCallback)(OH_DRM_CharBufferPair *eventInfo); typedef OH_DrmErrCode (*OH_MediaKeySessionKeyChangeCallback)(OH_DRM_CharBufferPair *OH_DRM_KeysInfo); +/** + * @brief OH_MediaKeySessionCallback struct, used to listen event like key expired and + * key change etc.. + * + * @since 11 + * @version 1.0 + */ typedef struct OH_MediaKeySessionCallback { + /** + * Normal event callback like key expired etc.. + */ OH_MediaKeySessionEventCallback eventCallback; + /** + * Key change callback for keys change event. + */ OH_MediaKeySessionKeyChangeCallback keyChangeCallback; } OH_MediaKeySessionCallback; + /** - * @brief Generate license request. - * @syscap SystemCapability.Multimedia.Drm.Core + * @brief Generate media key request. * @param mediaKeySession Media key session instance. - * if the function returns DRM_ERR_OK. - * @param info License request info. - * @param request Out parameter. License request. - * @returns OH_DrmErrCode refers to OH_DrmErrCode. + * if the function return DRM_ERR_OK. + * @param info Media key request info. + * @param mediaKeyRequest Media key request. + * @return OH_DrmErrCode. * @since 11 * @version 1.0 */ -OH_DrmErrCode OH_MediaKeySession_GenerateLicenseRequest(OH_MediaKeySession *keySession, - OH_DRM_LicenseRequestInfo *info, OH_DRM_Uint8Buffer *licenseRequest); +OH_DrmErrCode OH_MediaKeySession_GenerateMediaKeyRequest(OH_MediaKeySession *mediaKeySession, + OH_DRM_MediaKeyRequestInfo *info, unsigned char **mediaKeyRequest, int32_t *mediaKeyRequestLen); /** - * @brief Process license request. - * @syscap SystemCapability.Multimedia.Drm.Core + * @brief Process media key response. * @param mediaKeySession Media key session instance. - * @param response License resposne. - * @param responseLen The length of license resposne. - * @param licenseId Specifies which license corresponded. - * @param licenseIdLen The length of license id. - * @returns OH_DrmErrCode refers to OH_DrmErrCode. + * @param response Media Key resposne. + * @param mediaKeyId Media key identifier. + * @return OH_DrmErrCode. * @since 11 * @version 1.0 */ -OH_DrmErrCode OH_MediaKeySession_ProcessLicenseResponse(OH_MediaKeySession *keySession, - OH_DRM_Uint8Buffer *response, OH_DRM_Uint8Buffer *licenseId); +OH_DrmErrCode OH_MediaKeySession_ProcessMediaKeyResponse(OH_MediaKeySession *keySession, + OH_DRM_Uint8Buffer *response, unsigned char **mediaKeyId, int32_t *mediaKeyIdLen); /** - * @brief Check license status. - * @syscap SystemCapability.Multimedia.Drm.Core + * @brief Check media key status. * @param mediaKeySession Media key session instance. - * @param response License resposne. - * @param responseLen The length of license resposne. - * @param licenseId Specifies which license corresponded. - * @param licenseIdLen The length of license id. - * @returns OH_DrmErrCode refers to OH_DrmErrCode. + * @param mediaKeyDescription Media key status description. + * @return OH_DrmErrCode. * @since 11 * @version 1.0 */ -OH_DrmErrCode OH_MediaKeySession_CheckLicenseStatus(OH_MediaKeySession *mediaKeySessoin, - OH_DRM_LicenseDescription *licenseDescription); +OH_DrmErrCode OH_MediaKeySession_CheckMediaKeyStatus(OH_MediaKeySession *mediaKeySessoin, + OH_DRM_MediaKeyDescription **mediaKeyDescription); -OH_DrmErrCode OH_MediaKeySession_RemoveLicense(OH_MediaKeySession *mediaKeySessoin); +/** + * @brief Clear media keys of the current session . + * @param mediaKeySession Media key session instance. + * @return OH_DrmErrCode. + * @since 11 + * @version 1.0 + */ +OH_DrmErrCode OH_MediaKeySession_ClearMediaKeys(OH_MediaKeySession *mediaKeySessoin); +/** + * @brief Generate offline media key release request. + * @param mediaKeySession Media key session instance. + * @param mediaKeyId Media key identifier. + * @param releaseRequest Media Key release request. + * @return OH_DrmErrCode. + * @since 11 + * @version 1.0 + */ OH_DrmErrCode OH_MediaKeySession_GenerateOfflineReleaseRequest(OH_MediaKeySession *mediaKeySessoin, - OH_DRM_Uint8Buffer *licenseId, OH_DRM_Uint8Buffer *releaseRequest); + OH_DRM_Uint8Buffer *mediaKeyId, unsigned char **releaseRequest, int32_t *releaseRequestLen); + +/** + * @brief Process offline media key release response. + * @param mediaKeySession Media key session instance. + * @param mediaKeyId Media key identifier. + * @param releaseReponse Media Key resposne. + * @return OH_DrmErrCode. + * @since 11 + * @version 1.0 + */ OH_DrmErrCode OH_MediaKeySession_ProcessOfflineReleaseResponse(OH_MediaKeySession *mediaKeySessoin, - OH_DRM_Uint8Buffer *licenseId, OH_DRM_Uint8Buffer *releaseReponse); + OH_DRM_Uint8Buffer *mediaKeyId, OH_DRM_Uint8Buffer *releaseReponse); + +/** + * @brief Restore offline media keys by ID. + * @param mediaKeySession Media key session instance. + * @param mediaKeyId Media key identifier. + * @return OH_DrmErrCode. + * @since 11 + * @version 1.0 + */ +OH_DrmErrCode OH_MediaKeySession_RestoreOfflineMediaKeys(OH_MediaKeySession *mediaKeySessoin, + OH_DRM_Uint8Buffer *mediaKeyId); -OH_DrmErrCode OH_MediaKeySession_RestoreOfflineLicense(OH_MediaKeySession *mediaKeySessoin, - OH_DRM_Uint8Buffer *licenseId); -OH_DrmErrCode OH_MediaKeySession_GetSecurityLevel(OH_MediaKeySession *mediaKeySessoin, +/** + * @brief Get content protection level of the session. + * @param mediaKeySession Media key session instance. + * @param contentProtectionLevel Content protection level. + * @return OH_DrmErrCode. + * @since 11 + * @version 1.0 + */ +OH_DrmErrCode OH_MediaKeySession_GetContentProtectionLevel(OH_MediaKeySession *mediaKeySessoin, OH_DRM_ContentProtectionLevel *contentProtectionLevel); +/** + * @brief Whether the encrypted content require a secure decoder or not. + * @param mediaKeySession Media key session instance. + * @param mimeType The media type. + * @param status Whether secure decoder is required. + * @return OH_DrmErrCode. + * @since 11 + * @version 1.0 + */ OH_DrmErrCode OH_MediaKeySession_RequireSecureDecoderModule(OH_MediaKeySession *mediaKeySessoin, const char *mimeType, bool *status); +/** + * @brief Set media key session event callback. + * @param mediaKeySession Media key session instance. + * @param callback Callback to be set to the media key session. + * @return OH_DrmErrCode. + * @since 11 + * @version 1.0 + */ OH_DrmErrCode OH_MediaKeySession_SetMediaKeySessionCallback(OH_MediaKeySession *mediaKeySessoin, OH_MediaKeySessionCallback *callback); +/** + * @brief Release the resource before the session gonna be unused. + * @param mediaKeySession Media key session instance. + * @return OH_DrmErrCode. + * @since 11 + * @version 1.0 + */ OH_DrmErrCode OH_MediaKeySession_Destroy(OH_MediaKeySession *mediaKeySessoin); #ifdef __cplusplus diff --git a/multimedia/drm_framework/include/native_mediakeysystem.h b/multimedia/drm_framework/include/native_mediakeysystem.h index a43d8314a..427d68c6c 100644 --- a/multimedia/drm_framework/include/native_mediakeysystem.h +++ b/multimedia/drm_framework/include/native_mediakeysystem.h @@ -46,96 +46,203 @@ #ifdef __cplusplus extern "C" { #endif -typedef struct OH_MediaKeySystem OH_MediaKeySystem; -typedef struct OH_MediaKeySession OH_MediaKeySession; + typedef OH_DrmErrCode (*OH_MediaKeySystemCallback)(OH_DRM_CharBufferPair *eventInfo); /** - * @brief Query if media key system is supported by name. - * @param name Secifies which drm system will be created. - * @return Returns a Pointer to an OH_MediaKeySystem instance. + * @brief Query if media key system is supported. + * @param name Used to point a Digital Right Management solution. + * @return Supported or not in boolean. * @since 11 * @version 1.0 */ bool OH_MediaKeySystem_IsSupported(const char *name); /** - * @brief Query if media key system is supported by name. - * @param name Secifies which drm system will be created. - * @return Returns a Pointer to an OH_MediaKeySystem instance. - * @syscap SystemCapability.Multimedia.Drm.Core + * @brief Query if media key system is supported. + * @param name Used to point a Digital Right Management solution. + * @param mimeType Used to specifies the media type. + * @return Supported or not in boolean. * @since 11 * @version 1.0 */ bool OH_MediaKeySystem_IsSupported2(const char *name, const char *mimeType); /** - * @brief Creates a media key system instance from the uuid. - * @syscap SystemCapability.Multimedia.Drm.Core - * @param uuid Secifies which drm system will be created. - * @return Returns a Pointer to an OH_MediaKeySystem instance. + * @brief Query if media key system is supported. + * @param name Used to point a Digital Right Management solution. + * @param mimeType Used to specifies the media type. + * @param contentProtectionLevel Used to specifies the ContentProtectionLevel. + * @return Supported or not in boolean. * @since 11 * @version 1.0 */ bool OH_MediaKeySystem_IsSupported3(const char *name, const char *mimeType, OH_DRM_ContentProtectionLevel contentProtectionLevel); /** - * @brief Creates a media key system instance from the uuid. - * @syscap SystemCapability.Multimedia.Drm.Core - * @param uuid Secifies which drm system will be created. - * @return Returns a Pointer to an OH_MediaKeySystem instance. + * @brief Creates a media key system instance from the name. + * @param name Secifies which drm system will be created by name. + * @param mediaKeySystem Media key system instance. + * @return Returns OH_DrmErrCode. + * @since 11 + * @version 1.0 + */ +OH_DrmErrCode OH_MediaKeySystem_Create(const char *name, OH_MediaKeySystem **mediaKeySystem); +/** + * @brief Set media key system configuration value by name. + * @param mediaKeySystem Media key system instance. + * @param configName Configuratoin name string. + * @param value Configuratoin vaule string to be set. + * @return Returns OH_DrmErrCode. * @since 11 * @version 1.0 */ -OH_MediaKeySystem *OH_MediaKeySystem_Create(const char *name); - OH_DrmErrCode OH_MediaKeySystem_SetConfigurationString(OH_MediaKeySystem *mediaKeySystem, const char *configName, const char *value); +/** + * @brief Get media key system configuration value by name. + * @param mediaKeySystem Media key system instance. + * @param configName Configuratoin name string. + * @param value Configuratoin vaule string to be get. + * @return Returns OH_DrmErrCode. + * @since 11 + * @version 1.0 + */ OH_DrmErrCode OH_MediaKeySystem_GetConfigurationString(OH_MediaKeySystem *mediaKeySystem, - const char *configName, OH_DRM_CharBuffer *value); + const char *configName, char **value, int32_t *valueLen); +/** + * @brief Set media key system configuration value by name. + * @param mediaKeySystem Media key system instance. + * @param configName Configuratoin name string. + * @param value Configuratoin vaule in byte array to be set. + * @return Returns OH_DrmErrCode. + * @since 11 + * @version 1.0 + */ OH_DrmErrCode OH_MediaKeySystem_SetConfigurationByteArray(OH_MediaKeySystem *mediaKeySystem, const char *configName, OH_DRM_Uint8Buffer *value); +/** + * @brief Get media key system configuration value by name. + * @param mediaKeySystem Media key system instance. + * @param configName Configuratoin name string. + * @param value Configuratoin vaule in byte array to be get. + * @return Returns OH_DrmErrCode. + * @since 11 + * @version 1.0 + */ OH_DrmErrCode OH_MediaKeySystem_GetConfigurationByteArray(OH_MediaKeySystem *mediaKeySystem, - const char *configName, OH_DRM_Uint8Buffer *value); - -OH_DrmErrCode OH_MediaKeySystem_GetMetrics(OH_MediaKeySystem *mediaKeySystem, OH_DRM_Metrics *metrics); -OH_DrmErrCode OH_MediaKeySystem_GetMaxSecurityLevel(OH_MediaKeySystem *mediaKeySystem, + const char *configName, unsigned char **value, int32_t *valueLen); +/** + * @brief Get media key system statistics info. + * @param mediaKeySystem Media key system instance. + * @param statistics Statistic info gotten. + * @return Returns OH_DrmErrCode. + * @since 11 + * @version 1.0 + */ +OH_DrmErrCode OH_MediaKeySystem_GetStatistics(OH_MediaKeySystem *mediaKeySystem, OH_DRM_Statistics **statistics); +/** + * @brief Get the max content protection level media key system supported. + * @param mediaKeySystem Media key system instance. + * @param contentProtectionLevel Content protection level. + * @return Returns OH_DrmErrCode. + * @since 11 + * @version 1.0 + */ +OH_DrmErrCode OH_MediaKeySystem_GetMaxContentProtectionLevel(OH_MediaKeySystem *mediaKeySystem, OH_DRM_ContentProtectionLevel *contentProtectionLevel); - +/** + * @brief Set media key system event callback. + * @param mediaKeySystem Media key system instance. + * @param callback Callback to be set to the media key system. + * @return Returns OH_DrmErrCode. + * @since 11 + * @version 1.0 + */ OH_DrmErrCode OH_MediaKeySystem_SetMediaKeySystemCallback(OH_MediaKeySystem *mediaKeySystem, OH_MediaKeySystemCallback callback); /** * @brief Create a media key session instance. - * @syscap SystemCapability.Multimedia.Drm.Core - * @param mediaKeySystem Media key system instance which will create media key session. - * @param OH_DRM_ContentProtectionLevel Specifies the security level. - * @param mediaKeySession Out parameter. Media key session instance has been created - * if the function returns DRM_ERR_OK. - * @returns OH_DrmErrCode refers to OH_DrmErrCode + * @param mediaKeySystem Media key system instance which will create the media key session. + * @param level Specifies the content protection level. + * @param mediaKeySession Media key session instance. + * @return OH_DrmErrCode. * @since 11 * @version 1.0 */ OH_DrmErrCode OH_MediaKeySystem_CreateMediaKeySession(OH_MediaKeySystem *mediaKeySystem, OH_DRM_ContentProtectionLevel *level, OH_MediaKeySession **mediaKeySession); -OH_DrmErrCode OH_MediaKeySystem_GenerateKeySystemRequest(OH_MediaKeySystem *mediaKeySystem, - OH_DRM_Uint8Buffer *request, OH_DRM_CharBuffer *defaultUrl); +/** + * @brief Generate a media key system provision request. + * @param mediaKeySystem Media key system instance. + * @param request Provision request data sent to provision server. + * @param defaultUrl Provision server URL. + * @return OH_DrmErrCode. + * @since 11 + * @version 1.0 + */ +OH_DrmErrCode OH_MediaKeySystem_GenerateKeySystemRequest(OH_MediaKeySystem *mediaKeySystem, unsigned char **request, + int32_t *requestLen, char **defaultUrl, int32_t *defaultUrlLen); + +/** + * @brief Process a media key system provision response. + * @param mediaKeySystem Media key system instance. + * @param response The provision reponse will be processed. + * @return OH_DrmErrCode. + * @since 11 + * @version 1.0 + */ OH_DrmErrCode OH_MediaKeySystem_ProcessKeySystemResponse(OH_MediaKeySystem *mediaKeySystem, OH_DRM_Uint8Buffer *response); -OH_DrmErrCode OH_MediaKeySystem_GetOfflineLicenseIds(OH_MediaKeySystem *mediaKeySystem, - OH_DRM_LicenseIdArray *licenseIds); -OH_DrmErrCode OH_MediaKeySystem_GetOfflineLicenseStatus(OH_MediaKeySystem *mediaKeySystem, - OH_DRM_Uint8Buffer *licenseId, OH_DRM_OfflineMediaKeyStatus *status); -OH_DrmErrCode OH_MediaKeySystem_RemoveOfflineLicense(OH_MediaKeySystem *mediaKeySystem, - OH_DRM_Uint8Buffer *licenseId); +/** + * @brief Get offline media key ids . + * @param mediaKeySystem Media key system instance. + * @param mediaKeyIds Media key ids of all offline media keys. + * @return OH_DrmErrCode. + * @since 11 + * @version 1.0 + */ +OH_DrmErrCode OH_MediaKeySystem_GetOfflineMediaKeyIds(OH_MediaKeySystem *mediaKeySystem, + OH_DRM_MediaKeyIdArray **mediaKeyIds, int32_t *mediaKeyIdsLen); + +/** + * @brief Get offline media key status. + * @param mediaKeySystem Media key system instance. + * @param mediaKeyId Media key identifier. + * @param status The media key status gotten. + * @return OH_DrmErrCode. + * @since 11 + * @version 1.0 + */ +OH_DrmErrCode OH_MediaKeySystem_GetOfflineMediaKeyStatus(OH_MediaKeySystem *mediaKeySystem, + OH_DRM_Uint8Buffer *mediaKeyId, OH_DRM_OfflineMediaKeyStatus *status); +/** + * @brief Clear an offline media key by id. + * @param mediaKeySystem Media key system instance. + * @param mediaKeyId Media key identifier. + * @return OH_DrmErrCode. + * @since 11 + * @version 1.0 + */ +OH_DrmErrCode OH_MediaKeySystem_ClearOfflineMediaKeys(OH_MediaKeySystem *mediaKeySystem, + OH_DRM_Uint8Buffer *mediaKeyId); + +/** + * @brief Get certificate status of media key system. + * @param mediaKeySystem Media key system instance. + * @param certStatus Status will be gotten. + * @return OH_DrmErrCode. + * @since 11 + * @version 1.0 + */ OH_DrmErrCode OH_MediaKeySystem_GetCertificateStatus(OH_MediaKeySystem *mediaKeySystem, OH_DRM_CertificateStatus *certStatus); /** * @brief Destroy a media key system instance. - * @syscap SystemCapability.Multimedia.Drm.Core - * @param uuid Secifies which media key system instance will be destroyed. + * @param mediaKeySystem Secifies which media key system instance will be destroyed. * @since 11 * @version 1.0 */ -- Gitee From 4760a06a5141a12109fb5c2a17642b3e8d00f8ba Mon Sep 17 00:00:00 2001 From: qiu-qiu-wang Date: Tue, 28 Nov 2023 12:43:58 +0800 Subject: [PATCH 3/7] adjust dir Signed-off-by: qiu-qiu-wang --- multimedia/drm_framework/BUILD.gn | 88 ++++--------------- .../drm_framework/common/native_drm_base.h | 11 ++- .../drm_framework/common/native_drm_common.h | 28 +++--- .../drm_framework/common/native_drm_object.h | 7 +- multimedia/drm_framework/include/BUILD.gn | 35 -------- .../include/libnative_drm.ndk.json | 8 -- .../drm_framework/libnativedrm.ndk.json | 32 +++++++ .../{include => }/native_mediakeysession.h | 0 .../{include => }/native_mediakeysystem.h | 7 +- 9 files changed, 78 insertions(+), 138 deletions(-) delete mode 100644 multimedia/drm_framework/include/BUILD.gn delete mode 100644 multimedia/drm_framework/include/libnative_drm.ndk.json create mode 100644 multimedia/drm_framework/libnativedrm.ndk.json rename multimedia/drm_framework/{include => }/native_mediakeysession.h (100%) rename multimedia/drm_framework/{include => }/native_mediakeysystem.h (97%) diff --git a/multimedia/drm_framework/BUILD.gn b/multimedia/drm_framework/BUILD.gn index a55bca69e..dfb7ef5e2 100644 --- a/multimedia/drm_framework/BUILD.gn +++ b/multimedia/drm_framework/BUILD.gn @@ -12,74 +12,24 @@ # limitations under the License. import("//build/ohos.gni") -import("//build/ohos/ace/ace.gni") - -DRM_ROOT_DIR = "//foundation/multimedia/drm_framework" - -group("drm_capi_package") { - deps = [] - deps += [ - "$DRM_ROOT_DIR/interfaces/kits/c/drm_capi:native_drm", - ] -} - -config("drm_capi_common_config") { - include_dirs = [ - "$DRM_ROOT_DIR/interfaces/kits/c/drm_capi/include", - "$DRM_ROOT_DIR/interfaces/kits/c/drm_capi/common", - "$DRM_ROOT_DIR/interfaces/inner_api/native/drm", - "$DRM_ROOT_DIR/services/utils/include", - "//foundation//arkui/napi/interfaces/kits", - "//utils/system/safwk/native/include", - "//foundation/multimedia/drm_framework/frameworks/native/drm", - ] - cflags = [ - "-fno-exceptions", - "-Wall", - "-fno-common", - "-fstack-protector-all", - "-Wshadow", - "-FPIC", - "-FS", - "-O2", - "-D_FORTIFY_SOURCE=2", - "-Wformat=2", - "-Wdate-time", - ] - - cflags_cc = [ - "-std=c++17", - "-fno-rtti", - ] -} - -ohos_shared_library("native_drm") { - install_enable = true - configs = [ ":drm_capi_common_config" ] - - sanitize = { - cfi = true - cfi_cross_dso = true - debug = true - } - - sources = [ - "$DRM_ROOT_DIR/frameworks/c/drm_capi/native_mediakeysystem.cpp", - "$DRM_ROOT_DIR/frameworks/c/drm_capi/native_mediakeysession.cpp", - ] - - deps = [ - "$DRM_ROOT_DIR/frameworks/native:drm_framework", - ] - - external_deps = [ - "c_utils:utils", - "hilog:libhilog", - "hitrace:hitrace_meter", - "napi:ace_napi", - ] - output_extension = "so" - subsystem_name = "multimedia" - part_name = "multimedia_drm_framework" +import("//build/ohos/ndk/ndk.gni") +ohos_ndk_headers("native_drm_header") { + dest_dir = "$ndk_headers_out_dir/multimedia/drm_framework" + sources = [ + "./native_mediakeysession.h", + "./native_mediakeysystem.h" + ] } +ohos_ndk_library("libnative_drm") { + ndk_description_file = "./libnativedrm.ndk.json" + min_compact_version = "1" + output_name = "native_drm" + output_extension = "so" + + system_capability = "SystemCapability.Multimedia.Drm.Core" + system_capability_headers = [ + "multimedia/drm_framework/native_mediakeysession.h", + "multimedia/drm_framework/native_mediakeysystem.h", + ] +} \ No newline at end of file diff --git a/multimedia/drm_framework/common/native_drm_base.h b/multimedia/drm_framework/common/native_drm_base.h index 654bb0e02..455fc15a6 100644 --- a/multimedia/drm_framework/common/native_drm_base.h +++ b/multimedia/drm_framework/common/native_drm_base.h @@ -29,10 +29,10 @@ extern "C" { * @since 11 * @version 1.0 */ -typedef struct OH_MediaKeySystem : public OHOS::RefBase { +struct OH_MediaKeySystem : public OHOS::RefBase { OH_MediaKeySystem() = default; virtual ~OH_MediaKeySystem() = default; -} OH_MediaKeySystem; +}; /** * @brief MediaKeySession struct. @@ -40,10 +40,13 @@ typedef struct OH_MediaKeySystem : public OHOS::RefBase { * @since 11 * @version 1.0 */ -typedef struct OH_MediaKeySession : public OHOS::RefBase { +struct OH_MediaKeySession : public OHOS::RefBase { OH_MediaKeySession() = default; virtual ~OH_MediaKeySession() = default; -} OH_MediaKeySession; +}; + +typedef struct OH_MediaKeySystem OH_MediaKeySystem; +typedef struct OH_MediaKeySession OH_MediaKeySession; #ifdef __cplusplus } diff --git a/multimedia/drm_framework/common/native_drm_common.h b/multimedia/drm_framework/common/native_drm_common.h index cebbf81a1..1f21362cb 100644 --- a/multimedia/drm_framework/common/native_drm_common.h +++ b/multimedia/drm_framework/common/native_drm_common.h @@ -237,9 +237,9 @@ typedef struct OH_DRM_CharBuffer { * @version 1.0 */ typedef struct OH_DRM_CharBufferPair { - /* Name buffer in chars.*/ + /* Name buffer in chars. */ OH_DRM_CharBuffer name; - /* Value buffer in chars.*/ + /* Value buffer in chars. */ OH_DRM_CharBuffer value; } OH_DRM_CharBufferPair; @@ -250,9 +250,9 @@ typedef struct OH_DRM_CharBufferPair { * @version 1.0 */ typedef struct OH_DRM_Uint8CharBufferPair { - /* Key buffer in Uint8Array.*/ + /* Key buffer in Uint8Array. */ OH_DRM_Uint8Buffer key; - /* Value buffer in chars.*/ + /* Value buffer in chars. */ OH_DRM_CharBuffer value; } OH_DRM_Uint8CharBufferPair; @@ -292,9 +292,9 @@ typedef struct OH_DRM_MediaKeyRequestInfo { * @version 1.0 */ typedef struct OH_DRM_Statistics { - /* Statistics count.*/ + /* Statistics count. */ uint32_t statisticsCount; - /* Statistics info.*/ + /* Statistics info. */ OH_DRM_CharBufferPair *info; } OH_DRM_Statistics; @@ -305,9 +305,9 @@ typedef struct OH_DRM_Statistics { * @version 1.0 */ typedef struct OH_DRM_MediakeyIdArray { - /* MediaKeyId count.*/ + /* MediaKeyId count. */ uint32_t mediaKeyIdCount; - /* MediaKeyIds.*/ + /* MediaKeyIds. */ OH_DRM_Uint8Buffer *mediaKeyIds; } OH_DRM_MediakeyIdArray; @@ -318,9 +318,9 @@ typedef struct OH_DRM_MediakeyIdArray { * @version 1.0 */ typedef struct OH_DRM_KeysInfo { - /* Keys count.*/ + /* Keys count. */ uint32_t keysCount; - /* Keys info.*/ + /* Keys info. */ OH_DRM_Uint8CharBufferPair *keysInfo; } OH_DRM_KeysInfo; @@ -331,9 +331,9 @@ typedef struct OH_DRM_KeysInfo { * @version 1.0 */ typedef struct OH_DRM_MediaKeyDescription { - /* MediaKeycount.*/ + /* MediaKeycount. */ uint32_t mediaKeyCount; - /* MediaKeyinfo.*/ + /* MediaKeyinfo. */ OH_DRM_CharBufferPair *description; } OH_DRM_MediaKeyDescription; @@ -366,9 +366,9 @@ typedef struct OH_DRM_PsshInfo { * @version 1.0 */ typedef struct OH_DRM_DrmInfo { - /* PSSH count.*/ + /* PSSH count. */ uint32_t psshCount; - /* PSSH info.*/ + /* PSSH info. */ OH_DRM_PsshInfo *psshInfo; } OH_DRM_DrmInfo; diff --git a/multimedia/drm_framework/common/native_drm_object.h b/multimedia/drm_framework/common/native_drm_object.h index 91b2145a6..eb16c6445 100644 --- a/multimedia/drm_framework/common/native_drm_object.h +++ b/multimedia/drm_framework/common/native_drm_object.h @@ -24,10 +24,8 @@ #include "key_session_impl.h" #include "media_key_system_impl.h" #include "media_key_system_factory_impl.h" -#include "media_decrypt_module_impl.h" -struct MediaKeySystemObject : public OH_MediaKeySystem -{ +struct MediaKeySystemObject : public OH_MediaKeySystem { explicit MediaKeySystemObject(const OHOS::sptr &impl) : systemImpl_(impl) { @@ -37,8 +35,7 @@ struct MediaKeySystemObject : public OH_MediaKeySystem const OHOS::sptr systemImpl_ = nullptr; }; -struct MediaKeySessionObject : public OH_MediaKeySession -{ +struct MediaKeySessionObject : public OH_MediaKeySession { explicit MediaKeySessionObject(const OHOS::sptr &impl) : sessionImpl_(impl) { diff --git a/multimedia/drm_framework/include/BUILD.gn b/multimedia/drm_framework/include/BUILD.gn deleted file mode 100644 index 9db3488d4..000000000 --- a/multimedia/drm_framework/include/BUILD.gn +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright (C) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/ohos.gni") -import("//build/ohos/ndk/ndk.gni") -ohos_ndk_headers("native_drm_header") { - dest_dir = "$ndk_headers_out_dir/multimedia/multimedia_drm_framework" - sources = [ - "//foundation/multimedia/drm_framework/interfaces/kits/c/drm_capi/include/native_mediakeysession.h", - "//foundation/multimedia/drm_framework/interfaces/kits/c/drm_capi/include/native_mediakeysystem.h" - ] -} - -ohos_ndk_library("libnative_drm") { - ndk_description_file = "./libnative_drm.ndk.json" - min_compact_version = "1" - output_name = "native_drm" - output_extension = "so" - - system_capability = "SystemCapability.Multimedia.Drm.Core" - system_capability_headers = [ - "multimedia/drm_framework/native_mediakeysession.h", - "multimedia/drm_framework/native_mediakeysystem.h", - ] -} \ No newline at end of file diff --git a/multimedia/drm_framework/include/libnative_drm.ndk.json b/multimedia/drm_framework/include/libnative_drm.ndk.json deleted file mode 100644 index cd2af3891..000000000 --- a/multimedia/drm_framework/include/libnative_drm.ndk.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - { "name": "OH_MediaKeySystem_Create" }, - { "name": "OH_MediaKeySystem_Destroy" }, - { "name": "OH_MediaKeySystem_CreateMediaKeySession" }, - { "name": "OH_MediaKeySession_GenerateLicenseRequest" }, - { "name": "OH_MediaKeySession_ProcessLicenseResponse" }, - { "name": "OH_MediaKeySession_CheckLicenseStatus" } -] \ No newline at end of file diff --git a/multimedia/drm_framework/libnativedrm.ndk.json b/multimedia/drm_framework/libnativedrm.ndk.json new file mode 100644 index 000000000..859f6423e --- /dev/null +++ b/multimedia/drm_framework/libnativedrm.ndk.json @@ -0,0 +1,32 @@ +[ + { "name": "OH_MediaKeySystem_IsSupported" }, + { "name": "OH_MediaKeySystem_IsSupported2" }, + { "name": "OH_MediaKeySystem_IsSupported3" }, + { "name": "OH_MediaKeySystem_Create" }, + { "name": "OH_MediaKeySystem_SetConfigurationString" }, + { "name": "OH_MediaKeySystem_GetConfigurationString" }, + { "name": "OH_MediaKeySystem_SetConfigurationByteArray" }, + { "name": "OH_MediaKeySystem_GetConfigurationByteArray" }, + { "name": "OH_MediaKeySystem_GetStatistics" }, + { "name": "OH_MediaKeySystem_GetMaxContentProtectionLevel" }, + { "name": "OH_MediaKeySystem_SetMediaKeySystemCallback" }, + { "name": "OH_MediaKeySystem_CreateMediaKeySession" }, + { "name": "OH_MediaKeySystem_GenerateKeySystemRequest" }, + { "name": "OH_MediaKeySystem_ProcessKeySystemResponse" }, + { "name": "OH_MediaKeySystem_GetOfflineMediaKeyIds" }, + { "name": "OH_MediaKeySystem_GetOfflineMediaKeyStatus" }, + { "name": "OH_MediaKeySystem_ClearOfflineMediaKeys" }, + { "name": "OH_MediaKeySystem_GetCertificateStatus" }, + { "name": "OH_MediaKeySystem_Destroy" }, + { "name": "OH_MediaKeySession_GenerateMediaKeyRequest" }, + { "name": "OH_MediaKeySession_ProcessMediaKeyResponse" }, + { "name": "OH_MediaKeySession_CheckMediaKeyStatus" }, + { "name": "OH_MediaKeySession_ClearMediaKeys" }, + { "name": "OH_MediaKeySession_GenerateOfflineReleaseRequest" }, + { "name": "OH_MediaKeySession_ProcessOfflineReleaseResponse" }, + { "name": "OH_MediaKeySession_RestoreOfflineMediaKeys" }, + { "name": "OH_MediaKeySession_GetContentProtectionLevel" }, + { "name": "OH_MediaKeySession_RequireSecureDecoderModule" }, + { "name": "OH_MediaKeySession_SetMediaKeySessionCallback" }, + { "name": "OH_MediaKeySession_Destroy" } +] \ No newline at end of file diff --git a/multimedia/drm_framework/include/native_mediakeysession.h b/multimedia/drm_framework/native_mediakeysession.h similarity index 100% rename from multimedia/drm_framework/include/native_mediakeysession.h rename to multimedia/drm_framework/native_mediakeysession.h diff --git a/multimedia/drm_framework/include/native_mediakeysystem.h b/multimedia/drm_framework/native_mediakeysystem.h similarity index 97% rename from multimedia/drm_framework/include/native_mediakeysystem.h rename to multimedia/drm_framework/native_mediakeysystem.h index 427d68c6c..70441ee65 100644 --- a/multimedia/drm_framework/include/native_mediakeysystem.h +++ b/multimedia/drm_framework/native_mediakeysystem.h @@ -75,7 +75,8 @@ bool OH_MediaKeySystem_IsSupported2(const char *name, const char *mimeType); * @since 11 * @version 1.0 */ -bool OH_MediaKeySystem_IsSupported3(const char *name, const char *mimeType, OH_DRM_ContentProtectionLevel contentProtectionLevel); +bool OH_MediaKeySystem_IsSupported3(const char *name, const char *mimeType, + OH_DRM_ContentProtectionLevel contentProtectionLevel); /** * @brief Creates a media key system instance from the name. @@ -158,7 +159,7 @@ OH_DrmErrCode OH_MediaKeySystem_GetMaxContentProtectionLevel(OH_MediaKeySystem * * @version 1.0 */ OH_DrmErrCode OH_MediaKeySystem_SetMediaKeySystemCallback(OH_MediaKeySystem *mediaKeySystem, - OH_MediaKeySystemCallback callback); + OH_MediaKeySystemCallback callback); /** * @brief Create a media key session instance. @@ -182,7 +183,7 @@ OH_DrmErrCode OH_MediaKeySystem_CreateMediaKeySession(OH_MediaKeySystem *mediaKe * @version 1.0 */ OH_DrmErrCode OH_MediaKeySystem_GenerateKeySystemRequest(OH_MediaKeySystem *mediaKeySystem, unsigned char **request, - int32_t *requestLen, char **defaultUrl, int32_t *defaultUrlLen); + int32_t *requestLen, char **defaultUrl, int32_t *defaultUrlLen); /** * @brief Process a media key system provision response. -- Gitee From e611df622714a88bb0095be54fb2893994423086 Mon Sep 17 00:00:00 2001 From: qiu-qiu-wang Date: Tue, 28 Nov 2023 14:35:30 +0800 Subject: [PATCH 4/7] format gn Signed-off-by: qiu-qiu-wang --- multimedia/drm_framework/BUILD.gn | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/multimedia/drm_framework/BUILD.gn b/multimedia/drm_framework/BUILD.gn index dfb7ef5e2..c28008b1b 100644 --- a/multimedia/drm_framework/BUILD.gn +++ b/multimedia/drm_framework/BUILD.gn @@ -16,9 +16,9 @@ import("//build/ohos/ndk/ndk.gni") ohos_ndk_headers("native_drm_header") { dest_dir = "$ndk_headers_out_dir/multimedia/drm_framework" sources = [ - "./native_mediakeysession.h", - "./native_mediakeysystem.h" - ] + "./native_mediakeysession.h", + "./native_mediakeysystem.h", + ] } ohos_ndk_library("libnative_drm") { @@ -29,7 +29,7 @@ ohos_ndk_library("libnative_drm") { system_capability = "SystemCapability.Multimedia.Drm.Core" system_capability_headers = [ - "multimedia/drm_framework/native_mediakeysession.h", - "multimedia/drm_framework/native_mediakeysystem.h", - ] + "multimedia/drm_framework/native_mediakeysession.h", + "multimedia/drm_framework/native_mediakeysystem.h", + ] } \ No newline at end of file -- Gitee From 6c5fe152a12b5a12b57712493827806939567cf2 Mon Sep 17 00:00:00 2001 From: qiu-qiu-wang Date: Tue, 28 Nov 2023 20:18:45 +0800 Subject: [PATCH 5/7] revise gn and define drm info callback Signed-off-by: qiu-qiu-wang --- multimedia/drm_framework/common/native_drm_common.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/multimedia/drm_framework/common/native_drm_common.h b/multimedia/drm_framework/common/native_drm_common.h index 1f21362cb..37caf6a10 100644 --- a/multimedia/drm_framework/common/native_drm_common.h +++ b/multimedia/drm_framework/common/native_drm_common.h @@ -343,12 +343,12 @@ typedef struct OH_DRM_MediaKeyDescription { * @since 11 * @version 1.0 */ -#define UUID_LEN 16 +#define OH_DRM_UUID_LEN 16 typedef struct OH_DRM_PsshInfo { /** * Uuid. */ - char uuid[UUID_LEN]; + char uuid[OH_DRM_UUID_LEN]; /** * Unsigned char PSSH len. */ @@ -372,6 +372,8 @@ typedef struct OH_DRM_DrmInfo { OH_DRM_PsshInfo *psshInfo; } OH_DRM_DrmInfo; +typedef void(*OH_DRM_DrmInfoCallback)(OH_DRM_DrmInfo* drmInfo); + #ifdef __cplusplus } #endif -- Gitee From dc205a3db55171eccc0c31678c468abc3f3efdec Mon Sep 17 00:00:00 2001 From: qiu-qiu-wang Date: Tue, 28 Nov 2023 22:51:53 +0800 Subject: [PATCH 6/7] remove native_drm_object.h Signed-off-by: qiu-qiu-wang --- .../drm_framework/common/native_drm_object.h | 49 ------------------- 1 file changed, 49 deletions(-) delete mode 100644 multimedia/drm_framework/common/native_drm_object.h diff --git a/multimedia/drm_framework/common/native_drm_object.h b/multimedia/drm_framework/common/native_drm_object.h deleted file mode 100644 index eb16c6445..000000000 --- a/multimedia/drm_framework/common/native_drm_object.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef NATIVE_DRM_OBJECT_H -#define NATIVE_DRM_OBJECT_H - -#include -#include -#include "native_drm_err.h" -#include "native_drm_base.h" - -#include "key_session_impl.h" -#include "media_key_system_impl.h" -#include "media_key_system_factory_impl.h" - -struct MediaKeySystemObject : public OH_MediaKeySystem { - explicit MediaKeySystemObject(const OHOS::sptr &impl) - : systemImpl_(impl) - { - } - ~MediaKeySystemObject() = default; - - const OHOS::sptr systemImpl_ = nullptr; -}; - -struct MediaKeySessionObject : public OH_MediaKeySession { - explicit MediaKeySessionObject(const OHOS::sptr &impl) - : sessionImpl_(impl) - { - } - ~MediaKeySessionObject() = default; - - const OHOS::sptr sessionImpl_ = nullptr; -}; - - -#endif // NATIVE_DRM_OBJECT_H \ No newline at end of file -- Gitee From 41659c5bedf5a4a71bdcaaf89338df63bea15ff9 Mon Sep 17 00:00:00 2001 From: qiu-qiu-wang Date: Wed, 29 Nov 2023 16:43:10 +0800 Subject: [PATCH 7/7] add getMediaKeySystemName remove prefix OH_ from enum, callback and struct rename drminfo to mediakeysysteminfo reformat and remove wrong dependency files, add event listener type Signed-off-by: qiu-qiu-wang --- multimedia/drm_framework/BUILD.gn | 4 +- .../drm_framework/common/native_drm_base.h | 55 ---- .../drm_framework/common/native_drm_common.h | 259 +++++++++++------- .../drm_framework/common/native_drm_err.h | 28 +- .../drm_framework/native_mediakeysession.h | 116 ++++---- .../drm_framework/native_mediakeysystem.h | 125 +++++---- 6 files changed, 332 insertions(+), 255 deletions(-) delete mode 100644 multimedia/drm_framework/common/native_drm_base.h diff --git a/multimedia/drm_framework/BUILD.gn b/multimedia/drm_framework/BUILD.gn index c28008b1b..8c04d9bbb 100644 --- a/multimedia/drm_framework/BUILD.gn +++ b/multimedia/drm_framework/BUILD.gn @@ -23,7 +23,7 @@ ohos_ndk_headers("native_drm_header") { ohos_ndk_library("libnative_drm") { ndk_description_file = "./libnativedrm.ndk.json" - min_compact_version = "1" + min_compact_version = "11" output_name = "native_drm" output_extension = "so" @@ -32,4 +32,4 @@ ohos_ndk_library("libnative_drm") { "multimedia/drm_framework/native_mediakeysession.h", "multimedia/drm_framework/native_mediakeysystem.h", ] -} \ No newline at end of file +} diff --git a/multimedia/drm_framework/common/native_drm_base.h b/multimedia/drm_framework/common/native_drm_base.h deleted file mode 100644 index 455fc15a6..000000000 --- a/multimedia/drm_framework/common/native_drm_base.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef NATIVE_DRM_BASE_H -#define NATIVE_DRM_BASE_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif -/** - * @brief MediaKeySystem struct. - * - * @since 11 - * @version 1.0 - */ -struct OH_MediaKeySystem : public OHOS::RefBase { - OH_MediaKeySystem() = default; - virtual ~OH_MediaKeySystem() = default; -}; - -/** - * @brief MediaKeySession struct. - * - * @since 11 - * @version 1.0 - */ -struct OH_MediaKeySession : public OHOS::RefBase { - OH_MediaKeySession() = default; - virtual ~OH_MediaKeySession() = default; -}; - -typedef struct OH_MediaKeySystem OH_MediaKeySystem; -typedef struct OH_MediaKeySession OH_MediaKeySession; - -#ifdef __cplusplus -} -#endif - -#endif // NATIVE_DRM_BASE_H \ No newline at end of file diff --git a/multimedia/drm_framework/common/native_drm_common.h b/multimedia/drm_framework/common/native_drm_common.h index 37caf6a10..881be7c06 100644 --- a/multimedia/drm_framework/common/native_drm_common.h +++ b/multimedia/drm_framework/common/native_drm_common.h @@ -13,25 +13,12 @@ * limitations under the License. */ -#ifndef NATIVE_DRM_COMMON_H -#define NATIVE_DRM_COMMON_H - -#include -#include -#include "native_drm_err.h" -#include "native_drm_base.h" - -#ifdef __cplusplus -extern "C" { -#endif - /** * @addtogroup Drm * @{ * * @brief Provides APIs of Drm. - * - * @Syscap SystemCapability.Multimedia.Drm.Core + * @kit Drm. * @since 11 * @version 1.0 */ @@ -40,19 +27,62 @@ extern "C" { * @file native_drm_common.h * * @brief Defines the Drm common struct. - * - * @library libdrm_framework.z.so + * @library libnative_drm.z.so + * @Syscap SystemCapability.Multimedia.Drm.Core * @since 11 * @version 1.0 */ +#ifndef NATIVE_DRM_COMMON_H +#define NATIVE_DRM_COMMON_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Enumerates event types of listener. + * @brief Content potection level. + * @since 11 + * @version 1.0 +*/ +typedef enum DRM_ListenerType { + /** + * DRM event base. + */ + LISTENER_DRM_EVENT = 200, + /** + * Provision required event. + */ + LISTENER_PROVISION_REQUIRED = 201, + /** + * Media key required event. + */ + LISTENER_KEY_REQUIRED = 202, + /** + * Media key expired event. + */ + LISTENER_KEY_EXPIRED = 203, + /** + * Vendor defined event. + */ + LISTENER_VENDOR_DEFINED = 204, + /** + * Expiration update event. + */ + LISTENER_EXPIRATION_UPDATE = 206, + } DRM_ListenerType; + /** * @brief Content potection level. - * @syscap SystemCapability.Multimedia.Drm.Core + * @Syscap SystemCapability.Multimedia.Drm.Core * @since 11 * @version 1.0 */ -typedef enum OH_DRM_ContentProtectionLevel { +typedef enum DRM_ContentProtectionLevel { /** * Content potection level unknown. */ @@ -69,23 +99,19 @@ typedef enum OH_DRM_ContentProtectionLevel { * Content potection level enhanced hardware crypto. */ CONTENT_PROTECTION_LEVEL_ENHANCED_HW_CRYPTO, - /** - * Content potection all levels supported. - */ - CONTENT_PROTECTION_LEVEL_HW_ALL, /** * Content potection level max stub. */ CONTENT_PROTECTION_LEVEL_MAX, -} OH_DRM_ContentProtectionLevel; +} DRM_ContentProtectionLevel; /** * @brief Media key type. - * @syscap SystemCapability.Multimedia.Drm.Core + * @Syscap SystemCapability.Multimedia.Drm.Core * @since 11 * @version 1.0 */ -typedef enum OH_DRM_MediaKeyType { +typedef enum DRM_MediaKeyType { /** * Media key type offline. */ @@ -94,15 +120,15 @@ typedef enum OH_DRM_MediaKeyType { * Media key type online */ MEDIA_KEY_TYPE_ONLINE, -} OH_DRM_MediaKeyType; +} DRM_MediaKeyType; /** * @brief Media key request type. - * @syscap SystemCapability.Multimedia.Drm.Core + * @Syscap SystemCapability.Multimedia.Drm.Core * @since 11 * @version 1.0 */ -typedef enum OH_DRM_MediaKeyRequestType { +typedef enum DRM_MediaKeyRequestType { /** * Media key request type unknown. */ @@ -127,15 +153,15 @@ typedef enum OH_DRM_MediaKeyRequestType { * Media key request type update. */ MEDIA_KEY_REQUEST_TYPE_UPDATE, -} OH_DRM_MediaKeyRequestType; +} DRM_MediaKeyRequestType; /** * @brief Offline media key status. - * @syscap SystemCapability.Multimedia.Drm.Core + * @Syscap SystemCapability.Multimedia.Drm.Core * @since 11 * @version 1.0 */ -typedef enum OH_DRM_OfflineMediaKeyStatus { +typedef enum DRM_OfflineMediaKeyStatus { /** * Offline media key status unknown. */ @@ -148,15 +174,15 @@ typedef enum OH_DRM_OfflineMediaKeyStatus { * Offline media key status inactive. */ OFFLINE_MEDIA_KEY_STATUS_INACTIVE, -} OH_DRM_OfflineMediaKeyStatus; +} DRM_OfflineMediaKeyStatus; /** * @brief Certificate status. - * @syscap SystemCapability.Multimedia.Drm.Core + * @Syscap SystemCapability.Multimedia.Drm.Core * @since 11 * @version 1.0 */ -typedef enum OH_DRM_CertificateStatus { +typedef enum DRM_CertificateStatus { /** * Device already provisioned. */ @@ -177,32 +203,47 @@ typedef enum OH_DRM_CertificateStatus { * Get certs status failed. */ CERT_STATUS_UNAVAILABLE, -} OH_DRM_CertificateStatus; +} DRM_CertificateStatus; /** - * @brief Offline media key status. - * @syscap SystemCapability.Multimedia.Drm.Core + * @brief Media key status. + * @Syscap SystemCapability.Multimedia.Drm.Core * @since 11 * @version 1.0 */ -typedef enum OH_DRM_MediaKeyStatus { +typedef enum DRM_MediaKeyStatus { /** - * Media key status OK. + * Media key is usable. */ - MEDIA_KEY_STATUS_OK = 0, + MEDIA_KEY_STATUS_USABLE = 0, /** - * Media key is invalid e.g. not exist. + * Media key expires. */ - MEDIA_KEY_STATUS_NOT_EXIST = 1, -} OH_DRM_MediaKeyStatus; + MEDIA_KEY_STATUS_EXPIRED, + /** + * Output not allowed with the media key. + */ + MEDIA_KEY_STATUS_OUTPUT_NOT_ALLOWED, + /** + * Media key is pending. + */ + MEDIA_KEY_STATUS_PENDING, + /** + * Media key is in internal error. + */ + MEDIA_KEY_STATUS_INTERNAL_ERROR, + /** + * Media key will be usable in future. + */ + MEDIA_KEY_STATUS_USABLE_IN_FUTURE, +} DRM_MediaKeyStatus; /** * @brief Unsigned char buffer. - * * @since 11 * @version 1.0 */ -typedef struct OH_DRM_Uint8Buffer { +typedef struct DRM_Uint8Buffer { /** * Unsigned char buffer addr. */ @@ -211,15 +252,14 @@ typedef struct OH_DRM_Uint8Buffer { * Unsigned char buffer len. */ uint32_t bufferLen; -} OH_DRM_Uint8Buffer; +} DRM_Uint8Buffer; /** * @brief Char buffer. - * * @since 11 * @version 1.0 */ -typedef struct OH_DRM_CharBuffer { +typedef struct DRM_CharBuffer { /** * Char buffer addr. */ @@ -228,53 +268,50 @@ typedef struct OH_DRM_CharBuffer { * Char buffer len. */ uint32_t bufferLen; -} OH_DRM_CharBuffer; +} DRM_CharBuffer; /** * @brief Char-char buffer pair. - * * @since 11 * @version 1.0 */ -typedef struct OH_DRM_CharBufferPair { +typedef struct DRM_CharBufferPair { /* Name buffer in chars. */ - OH_DRM_CharBuffer name; + DRM_CharBuffer name; /* Value buffer in chars. */ - OH_DRM_CharBuffer value; -} OH_DRM_CharBufferPair; + DRM_CharBuffer value; +} DRM_CharBufferPair; /** * @brief Unsignedchar-char buffer. - * * @since 11 * @version 1.0 */ -typedef struct OH_DRM_Uint8CharBufferPair { +typedef struct DRM_Uint8CharBufferPair { /* Key buffer in Uint8Array. */ - OH_DRM_Uint8Buffer key; + DRM_Uint8Buffer key; /* Value buffer in chars. */ - OH_DRM_CharBuffer value; -} OH_DRM_Uint8CharBufferPair; + DRM_CharBuffer value; +} DRM_Uint8CharBufferPair; /** * @brief Media key request info. - * * @since 11 * @version 1.0 */ -typedef struct OH_DRM_MediaKeyRequestInfo { +typedef struct DRM_MediaKeyRequestInfo { /** * Offline or online media key type. */ - OH_DRM_MediaKeyType type; + DRM_MediaKeyType type; /** * Initial data format as PSSH after base64 encoding. */ - OH_DRM_Uint8Buffer data; + DRM_Uint8Buffer data; /** * Media content mime type. */ - OH_DRM_CharBuffer mimeType; + DRM_CharBuffer mimeType; /** * OptionsData count. */ @@ -282,73 +319,94 @@ typedef struct OH_DRM_MediaKeyRequestInfo { /** * Options data the application set to drm framework. */ - OH_DRM_CharBufferPair *optionsData; -} OH_DRM_MediaKeyRequestInfo; + DRM_CharBufferPair optionsData[0]; +} DRM_MediaKeyRequestInfo; /** - * @brief Statistics of OH_MediaKeySystem. - * + * @brief Media key request info. + * @since 11 + * @version 1.0 + */ +typedef struct DRM_MediaKeyRequest { + /** + * Media key request type. + */ + DRM_MediaKeyRequestType type; + /** + * Media key request data sent to media key server. + */ + DRM_Uint8Buffer data; + /** + * Media key server URL. + */ + DRM_CharBuffer defaultUrl; +} DRM_MediaKeyRequest; + +/** + * @brief Statistics of MediaKeySystem. * @since 11 * @version 1.0 */ -typedef struct OH_DRM_Statistics { +typedef struct DRM_Statistics { /* Statistics count. */ uint32_t statisticsCount; /* Statistics info. */ - OH_DRM_CharBufferPair *info; -} OH_DRM_Statistics; + DRM_CharBufferPair info[0]; +} DRM_Statistics; /** * @brief MediaKeyIds array. - * * @since 11 * @version 1.0 */ -typedef struct OH_DRM_MediakeyIdArray { +typedef struct DRM_MediakeyIdArray { /* MediaKeyId count. */ uint32_t mediaKeyIdCount; /* MediaKeyIds. */ - OH_DRM_Uint8Buffer *mediaKeyIds; -} OH_DRM_MediakeyIdArray; + DRM_Uint8Buffer mediaKeyIds[0]; +} DRM_MediakeyIdArray; /** * @brief Media key info. - * * @since 11 * @version 1.0 */ -typedef struct OH_DRM_KeysInfo { +typedef struct DRM_KeysInfo { /* Keys count. */ uint32_t keysCount; /* Keys info. */ - OH_DRM_Uint8CharBufferPair *keysInfo; -} OH_DRM_KeysInfo; + DRM_Uint8CharBufferPair keysInfo[0]; +} DRM_KeysInfo; /** * @brief MediaKeydescription - * * @since 11 * @version 1.0 */ -typedef struct OH_DRM_MediaKeyDescription { +typedef struct DRM_MediaKeyDescription { /* MediaKeycount. */ uint32_t mediaKeyCount; /* MediaKeyinfo. */ - OH_DRM_CharBufferPair *description; -} OH_DRM_MediaKeyDescription; + DRM_CharBufferPair description[0]; +} DRM_MediaKeyDescription; + +/** + * @brief Drm system uuid. + * @since 11 + * @version 1.0 + */ +#define DRM_UUID_LEN 16 /** * @brief PSSH info by uuid. - * * @since 11 * @version 1.0 */ -#define OH_DRM_UUID_LEN 16 -typedef struct OH_DRM_PsshInfo { +typedef struct DRM_PsshInfo { /** * Uuid. */ - char uuid[OH_DRM_UUID_LEN]; + char uuid[DRM_UUID_LEN]; /** * Unsigned char PSSH len. */ @@ -357,22 +415,35 @@ typedef struct OH_DRM_PsshInfo { * Unsigned char PSSH data. */ unsigned char *data; -} OH_DRM_PsshInfo; +} DRM_PsshInfo; /** - * @brief DrmInfo used for player to get DRM info from media source. - * + * @brief MediaKeySystemInfo used for player to get media key system info from media source. * @since 11 * @version 1.0 */ -typedef struct OH_DRM_DrmInfo { +typedef struct DRM_MediaKeySystemInfo { /* PSSH count. */ uint32_t psshCount; /* PSSH info. */ - OH_DRM_PsshInfo *psshInfo; -} OH_DRM_DrmInfo; + DRM_PsshInfo psshInfo[0]; +} DRM_MediaKeySystemInfo; + +typedef void (*DRM_MediaKeySystemInfoCallback)(DRM_MediaKeySystemInfo* mediaKeySystemInfo); -typedef void(*OH_DRM_DrmInfoCallback)(OH_DRM_DrmInfo* drmInfo); +/** + * @brief Media key system struct. + * @since 11 + * @version 1.0 + */ +typedef struct MediaKeySystem MediaKeySystem; + +/** + * @brief Media key session struct. + * @since 11 + * @version 1.0 + */ +typedef struct MediaKeySession MediaKeySession; #ifdef __cplusplus } diff --git a/multimedia/drm_framework/common/native_drm_err.h b/multimedia/drm_framework/common/native_drm_err.h index 6d29aef10..40e5b60ff 100644 --- a/multimedia/drm_framework/common/native_drm_err.h +++ b/multimedia/drm_framework/common/native_drm_err.h @@ -13,6 +13,25 @@ * limitations under the License. */ +/** + * @addtogroup Drm + * @{ + * + * @brief Provides APIs of Drm. + * @kit Drm. + * @since 11 + * @version 1.0 + */ + +/** + * @file native_drm_err.h + * @brief Defines the Drm errors. + * @library libnative_drm.z.so + * @Syscap SystemCapability.Multimedia.Drm.Core + * @since 11 + * @version 1.0 + */ + #ifndef NATIVE_DRM_ERR_H #define NATIVE_DRM_ERR_H @@ -25,11 +44,10 @@ extern "C" { /** * @brief DRM error code - * @syscap SystemCapability.Multimedia.Drm.Core * @since 11 * @version 1.0 */ -typedef enum OH_DrmErrCode { +typedef enum Drm_ErrCode { /** * the operation completed successfully. */ @@ -41,7 +59,7 @@ typedef enum OH_DrmErrCode { /** * opertation not be permitted. */ - DRM_ERR_OPERATE_NOT_PERMIT, + DRM_ERR_OPERATION_NOT_PERMITTED, /** * invalid argument. */ @@ -69,7 +87,7 @@ typedef enum OH_DrmErrCode { /** * unsupport interface. */ - DRM_ERR_UNSUPPORT, + DRM_ERR_UNSUPPORTED, /** * Meet max MediaKeySystem num limit. */ @@ -82,7 +100,7 @@ typedef enum OH_DrmErrCode { * extend err start. */ DRM_ERR_EXTEND_START = 100, -} OH_DrmErrCode; +} Drm_ErrCode; #ifdef __cplusplus } diff --git a/multimedia/drm_framework/native_mediakeysession.h b/multimedia/drm_framework/native_mediakeysession.h index 71212f6a3..9c377ce2a 100644 --- a/multimedia/drm_framework/native_mediakeysession.h +++ b/multimedia/drm_framework/native_mediakeysession.h @@ -18,178 +18,194 @@ * @{ * * @brief Provides APIs of Drm. - * - * @Syscap SystemCapability.Multimedia.Drm.Core + * @kit Drm. * @since 11 * @version 1.0 */ /** * @file native_mediakeysession.h - * - * @brief Defines the Drm MediaKeySession APIs. - * - * @library libdrm_framework.z.so + * @brief Defines the Drm MediaKeySession APIs. Provide following function: + * generate media key request, process media key response, event listening, + * get content protection level, check media key status, remove media key etc.. + * @library libnative_drm.z.so + * @Syscap SystemCapability.Multimedia.Drm.Core * @since 11 * @version 1.0 */ -#ifndef OHOS_DRM_NATIVE_MEDIA_KEY_SYSTEM_H -#define OHOS_DRM_NATIVE_MEDIA_KEY_SYSTEM_H +#ifndef OHOS_DRM_NATIVE_MEDIA_KEY_SESSION_H +#define OHOS_DRM_NATIVE_MEDIA_KEY_SESSION_H #include #include -#include "native_drm_common.h" -#include "native_drm_base.h" #include "native_drm_err.h" +#include "native_drm_common.h" #ifdef __cplusplus extern "C" { #endif -typedef OH_DrmErrCode (*OH_MediaKeySessionEventCallback)(OH_DRM_CharBufferPair *eventInfo); -typedef OH_DrmErrCode (*OH_MediaKeySessionKeyChangeCallback)(OH_DRM_CharBufferPair *OH_DRM_KeysInfo); /** - * @brief OH_MediaKeySessionCallback struct, used to listen event like key expired and - * key change etc.. - * + * @brief Call back will be invoked when event triggers. + * @param eventType Event type. + * @param eventInfo Event info gotten from media key system. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. + * @since 11 + * @version 1.0 + */ +typedef Drm_ErrCode (*MediaKeySession_EventCallback)(DRM_ListenerType eventType, DRM_Uint8CharBufferPair *eventInfo); + +/** + * @brief Call back will be invoked when key changes. + * @param keysInfo Key info gotten from media key system. + * @param newKeysAvailable If new keys available. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. + * @since 11 + * @version 1.0 + */ +typedef Drm_ErrCode (*MediaKeySession_KeyChangeCallback)(DRM_KeysInfo *keysInfo, bool newKeysAvailable); + +/** + * @brief MediaKeySession_Callback struct, used to listen event like key expired and key change etc.. * @since 11 * @version 1.0 */ -typedef struct OH_MediaKeySessionCallback { +typedef struct MediaKeySession_Callback { /** * Normal event callback like key expired etc.. */ - OH_MediaKeySessionEventCallback eventCallback; + MediaKeySession_EventCallback eventCallback; /** * Key change callback for keys change event. */ - OH_MediaKeySessionKeyChangeCallback keyChangeCallback; -} OH_MediaKeySessionCallback; + MediaKeySession_KeyChangeCallback keyChangeCallback; +} MediaKeySession_Callback; /** * @brief Generate media key request. * @param mediaKeySession Media key session instance. - * if the function return DRM_ERR_OK. * @param info Media key request info. * @param mediaKeyRequest Media key request. - * @return OH_DrmErrCode. + * @return Drm_ErrCode. * @since 11 * @version 1.0 */ -OH_DrmErrCode OH_MediaKeySession_GenerateMediaKeyRequest(OH_MediaKeySession *mediaKeySession, - OH_DRM_MediaKeyRequestInfo *info, unsigned char **mediaKeyRequest, int32_t *mediaKeyRequestLen); +Drm_ErrCode OH_MediaKeySession_GenerateMediaKeyRequest(MediaKeySession *mediaKeySession, + DRM_MediaKeyRequestInfo *info, DRM_MediaKeyRequest **mediaKeyRequest); /** * @brief Process media key response. * @param mediaKeySession Media key session instance. * @param response Media Key resposne. * @param mediaKeyId Media key identifier. - * @return OH_DrmErrCode. + * @param mediaKeyIdLen Media key identifier len. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. * @since 11 * @version 1.0 */ -OH_DrmErrCode OH_MediaKeySession_ProcessMediaKeyResponse(OH_MediaKeySession *keySession, - OH_DRM_Uint8Buffer *response, unsigned char **mediaKeyId, int32_t *mediaKeyIdLen); +Drm_ErrCode OH_MediaKeySession_ProcessMediaKeyResponse(MediaKeySession *keySession, + DRM_Uint8Buffer *response, unsigned char **mediaKeyId, int32_t *mediaKeyIdLen); /** * @brief Check media key status. * @param mediaKeySession Media key session instance. * @param mediaKeyDescription Media key status description. - * @return OH_DrmErrCode. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. * @since 11 * @version 1.0 */ -OH_DrmErrCode OH_MediaKeySession_CheckMediaKeyStatus(OH_MediaKeySession *mediaKeySessoin, - OH_DRM_MediaKeyDescription **mediaKeyDescription); +Drm_ErrCode OH_MediaKeySession_CheckMediaKeyStatus(MediaKeySession *mediaKeySessoin, + DRM_MediaKeyDescription **mediaKeyDescription); /** * @brief Clear media keys of the current session . * @param mediaKeySession Media key session instance. - * @return OH_DrmErrCode. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. * @since 11 * @version 1.0 */ -OH_DrmErrCode OH_MediaKeySession_ClearMediaKeys(OH_MediaKeySession *mediaKeySessoin); +Drm_ErrCode OH_MediaKeySession_ClearMediaKeys(MediaKeySession *mediaKeySessoin); /** * @brief Generate offline media key release request. * @param mediaKeySession Media key session instance. * @param mediaKeyId Media key identifier. * @param releaseRequest Media Key release request. - * @return OH_DrmErrCode. + * @param releaseRequestLen Media Key release request len. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. * @since 11 * @version 1.0 */ -OH_DrmErrCode OH_MediaKeySession_GenerateOfflineReleaseRequest(OH_MediaKeySession *mediaKeySessoin, - OH_DRM_Uint8Buffer *mediaKeyId, unsigned char **releaseRequest, int32_t *releaseRequestLen); +Drm_ErrCode OH_MediaKeySession_GenerateOfflineReleaseRequest(MediaKeySession *mediaKeySessoin, + DRM_Uint8Buffer *mediaKeyId, unsigned char **releaseRequest, int32_t *releaseRequestLen); /** * @brief Process offline media key release response. * @param mediaKeySession Media key session instance. * @param mediaKeyId Media key identifier. * @param releaseReponse Media Key resposne. - * @return OH_DrmErrCode. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. * @since 11 * @version 1.0 */ -OH_DrmErrCode OH_MediaKeySession_ProcessOfflineReleaseResponse(OH_MediaKeySession *mediaKeySessoin, - OH_DRM_Uint8Buffer *mediaKeyId, OH_DRM_Uint8Buffer *releaseReponse); +Drm_ErrCode OH_MediaKeySession_ProcessOfflineReleaseResponse(MediaKeySession *mediaKeySessoin, + DRM_Uint8Buffer *mediaKeyId, DRM_Uint8Buffer *releaseReponse); /** * @brief Restore offline media keys by ID. * @param mediaKeySession Media key session instance. * @param mediaKeyId Media key identifier. - * @return OH_DrmErrCode. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. * @since 11 * @version 1.0 */ -OH_DrmErrCode OH_MediaKeySession_RestoreOfflineMediaKeys(OH_MediaKeySession *mediaKeySessoin, - OH_DRM_Uint8Buffer *mediaKeyId); +Drm_ErrCode OH_MediaKeySession_RestoreOfflineMediaKeys(MediaKeySession *mediaKeySessoin, + DRM_Uint8Buffer *mediaKeyId); /** * @brief Get content protection level of the session. * @param mediaKeySession Media key session instance. * @param contentProtectionLevel Content protection level. - * @return OH_DrmErrCode. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. * @since 11 * @version 1.0 */ -OH_DrmErrCode OH_MediaKeySession_GetContentProtectionLevel(OH_MediaKeySession *mediaKeySessoin, - OH_DRM_ContentProtectionLevel *contentProtectionLevel); +Drm_ErrCode OH_MediaKeySession_GetContentProtectionLevel(MediaKeySession *mediaKeySessoin, + DRM_ContentProtectionLevel *contentProtectionLevel); /** * @brief Whether the encrypted content require a secure decoder or not. * @param mediaKeySession Media key session instance. * @param mimeType The media type. * @param status Whether secure decoder is required. - * @return OH_DrmErrCode. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. * @since 11 * @version 1.0 */ -OH_DrmErrCode OH_MediaKeySession_RequireSecureDecoderModule(OH_MediaKeySession *mediaKeySessoin, +Drm_ErrCode OH_MediaKeySession_RequireSecureDecoderModule(MediaKeySession *mediaKeySessoin, const char *mimeType, bool *status); /** * @brief Set media key session event callback. * @param mediaKeySession Media key session instance. * @param callback Callback to be set to the media key session. - * @return OH_DrmErrCode. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. * @since 11 * @version 1.0 */ -OH_DrmErrCode OH_MediaKeySession_SetMediaKeySessionCallback(OH_MediaKeySession *mediaKeySessoin, - OH_MediaKeySessionCallback *callback); +Drm_ErrCode OH_MediaKeySession_SetMediaKeySessionCallback(MediaKeySession *mediaKeySessoin, + MediaKeySession_Callback *callback); /** * @brief Release the resource before the session gonna be unused. * @param mediaKeySession Media key session instance. - * @return OH_DrmErrCode. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. * @since 11 * @version 1.0 */ -OH_DrmErrCode OH_MediaKeySession_Destroy(OH_MediaKeySession *mediaKeySessoin); +Drm_ErrCode OH_MediaKeySession_Destroy(MediaKeySession *mediaKeySessoin); #ifdef __cplusplus } diff --git a/multimedia/drm_framework/native_mediakeysystem.h b/multimedia/drm_framework/native_mediakeysystem.h index 70441ee65..9e6240279 100644 --- a/multimedia/drm_framework/native_mediakeysystem.h +++ b/multimedia/drm_framework/native_mediakeysystem.h @@ -18,18 +18,20 @@ * @{ * * @brief Provides APIs of Drm. - * - * @Syscap SystemCapability.Multimedia.Drm.Core + * @kit Drm. * @since 11 * @version 1.0 */ /** * @file native_mediakeysystem.h - * - * @brief Defines the Drm MediaKeySystem APIs. - * - * @library libdrm_framework.z.so + * @brief Defines the Drm MediaKeySystem APIs. Provide following function: + * query if specific drm supported or not, create media key session, + * get and set configurations, get statistics, get content protection level, + * generate provision request, process provision response, event listening, + * get content protection level, manage offline media key etc.. + * @library libnative_drm.z.so + * @Syscap SystemCapability.Multimedia.Drm.Core * @since 11 * @version 1.0 */ @@ -38,8 +40,8 @@ #define OHOS_DRM_NATIVE_MEDIA_KEY_SYSTEM_H #include +#include #include -#include "native_drm_base.h" #include "native_drm_err.h" #include "native_drm_common.h" @@ -47,8 +49,26 @@ extern "C" { #endif +/** + * @brief Call back will be invoked when event triggers. + * @param eventType Event type. + * @param eventInfo Event info gotten from media key system. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. + * @since 11 + * @version 1.0 + */ +typedef Drm_ErrCode (*MediaKeySystem_Callback)(DRM_ListenerType eventType, DRM_Uint8CharBufferPair *eventInfo); +/** + * @brief Get a media key system name by uuid. + * @param uuid Secifies drm system. + * @param name Name string to be gotten. + * @param nameLen Name string len. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. + * @since 11 + * @version 1.0 + */ +Drm_ErrCode OH_MediaKeySystem_GetMediaKeySystemName(const char *uuid, unsigned char **name, int32_t *nameLen); -typedef OH_DrmErrCode (*OH_MediaKeySystemCallback)(OH_DRM_CharBufferPair *eventInfo); /** * @brief Query if media key system is supported. * @param name Used to point a Digital Right Management solution. @@ -76,178 +96,185 @@ bool OH_MediaKeySystem_IsSupported2(const char *name, const char *mimeType); * @version 1.0 */ bool OH_MediaKeySystem_IsSupported3(const char *name, const char *mimeType, - OH_DRM_ContentProtectionLevel contentProtectionLevel); + DRM_ContentProtectionLevel contentProtectionLevel); /** * @brief Creates a media key system instance from the name. * @param name Secifies which drm system will be created by name. * @param mediaKeySystem Media key system instance. - * @return Returns OH_DrmErrCode. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully, + * return DRM_ERR_MAX_SYSTEM_NUM_REACHED when max num media key system reached. * @since 11 * @version 1.0 */ -OH_DrmErrCode OH_MediaKeySystem_Create(const char *name, OH_MediaKeySystem **mediaKeySystem); +Drm_ErrCode OH_MediaKeySystem_Create(const char *name, MediaKeySystem **mediaKeySystem); /** * @brief Set media key system configuration value by name. * @param mediaKeySystem Media key system instance. * @param configName Configuratoin name string. * @param value Configuratoin vaule string to be set. - * @return Returns OH_DrmErrCode. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. * @since 11 * @version 1.0 */ -OH_DrmErrCode OH_MediaKeySystem_SetConfigurationString(OH_MediaKeySystem *mediaKeySystem, +Drm_ErrCode OH_MediaKeySystem_SetConfigurationString(MediaKeySystem *mediaKeySystem, const char *configName, const char *value); /** * @brief Get media key system configuration value by name. * @param mediaKeySystem Media key system instance. * @param configName Configuratoin name string. * @param value Configuratoin vaule string to be get. - * @return Returns OH_DrmErrCode. + * @param valueLen Configuratoin vaule string len. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. * @since 11 * @version 1.0 */ -OH_DrmErrCode OH_MediaKeySystem_GetConfigurationString(OH_MediaKeySystem *mediaKeySystem, +Drm_ErrCode OH_MediaKeySystem_GetConfigurationString(MediaKeySystem *mediaKeySystem, const char *configName, char **value, int32_t *valueLen); /** * @brief Set media key system configuration value by name. * @param mediaKeySystem Media key system instance. * @param configName Configuratoin name string. * @param value Configuratoin vaule in byte array to be set. - * @return Returns OH_DrmErrCode. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. * @since 11 * @version 1.0 */ -OH_DrmErrCode OH_MediaKeySystem_SetConfigurationByteArray(OH_MediaKeySystem *mediaKeySystem, - const char *configName, OH_DRM_Uint8Buffer *value); +Drm_ErrCode OH_MediaKeySystem_SetConfigurationByteArray(MediaKeySystem *mediaKeySystem, + const char *configName, DRM_Uint8Buffer *value); /** * @brief Get media key system configuration value by name. * @param mediaKeySystem Media key system instance. * @param configName Configuratoin name string. * @param value Configuratoin vaule in byte array to be get. - * @return Returns OH_DrmErrCode. + * @param valueLen Configuratoin vaule len in byte. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. * @since 11 * @version 1.0 */ -OH_DrmErrCode OH_MediaKeySystem_GetConfigurationByteArray(OH_MediaKeySystem *mediaKeySystem, +Drm_ErrCode OH_MediaKeySystem_GetConfigurationByteArray(MediaKeySystem *mediaKeySystem, const char *configName, unsigned char **value, int32_t *valueLen); /** * @brief Get media key system statistics info. * @param mediaKeySystem Media key system instance. * @param statistics Statistic info gotten. - * @return Returns OH_DrmErrCode. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. * @since 11 * @version 1.0 */ -OH_DrmErrCode OH_MediaKeySystem_GetStatistics(OH_MediaKeySystem *mediaKeySystem, OH_DRM_Statistics **statistics); +Drm_ErrCode OH_MediaKeySystem_GetStatistics(MediaKeySystem *mediaKeySystem, DRM_Statistics **statistics); /** * @brief Get the max content protection level media key system supported. * @param mediaKeySystem Media key system instance. * @param contentProtectionLevel Content protection level. - * @return Returns OH_DrmErrCode. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. * @since 11 * @version 1.0 */ -OH_DrmErrCode OH_MediaKeySystem_GetMaxContentProtectionLevel(OH_MediaKeySystem *mediaKeySystem, - OH_DRM_ContentProtectionLevel *contentProtectionLevel); +Drm_ErrCode OH_MediaKeySystem_GetMaxContentProtectionLevel(MediaKeySystem *mediaKeySystem, + DRM_ContentProtectionLevel *contentProtectionLevel); /** * @brief Set media key system event callback. * @param mediaKeySystem Media key system instance. * @param callback Callback to be set to the media key system. - * @return Returns OH_DrmErrCode. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OR when function called successfully. * @since 11 * @version 1.0 */ -OH_DrmErrCode OH_MediaKeySystem_SetMediaKeySystemCallback(OH_MediaKeySystem *mediaKeySystem, - OH_MediaKeySystemCallback callback); +Drm_ErrCode OH_MediaKeySystem_SetMediaKeySystemCallback(MediaKeySystem *mediaKeySystem, + MediaKeySystem_Callback callback); /** * @brief Create a media key session instance. * @param mediaKeySystem Media key system instance which will create the media key session. * @param level Specifies the content protection level. * @param mediaKeySession Media key session instance. - * @return OH_DrmErrCode. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully, + * return DRM_ERR_MAX_SESSION_NUM_REACHED when max num media key system reached. * @since 11 * @version 1.0 */ -OH_DrmErrCode OH_MediaKeySystem_CreateMediaKeySession(OH_MediaKeySystem *mediaKeySystem, - OH_DRM_ContentProtectionLevel *level, OH_MediaKeySession **mediaKeySession); +Drm_ErrCode OH_MediaKeySystem_CreateMediaKeySession(MediaKeySystem *mediaKeySystem, + DRM_ContentProtectionLevel *level, MediaKeySession **mediaKeySession); /** * @brief Generate a media key system provision request. * @param mediaKeySystem Media key system instance. * @param request Provision request data sent to provision server. + * @param requestLen Provision request data len. * @param defaultUrl Provision server URL. - * @return OH_DrmErrCode. + * @param defaultUrlLen Provision server URL len. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. * @since 11 * @version 1.0 */ -OH_DrmErrCode OH_MediaKeySystem_GenerateKeySystemRequest(OH_MediaKeySystem *mediaKeySystem, unsigned char **request, +Drm_ErrCode OH_MediaKeySystem_GenerateKeySystemRequest(MediaKeySystem *mediaKeySystem, unsigned char **request, int32_t *requestLen, char **defaultUrl, int32_t *defaultUrlLen); /** * @brief Process a media key system provision response. * @param mediaKeySystem Media key system instance. * @param response The provision reponse will be processed. - * @return OH_DrmErrCode. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. * @since 11 * @version 1.0 */ -OH_DrmErrCode OH_MediaKeySystem_ProcessKeySystemResponse(OH_MediaKeySystem *mediaKeySystem, - OH_DRM_Uint8Buffer *response); +Drm_ErrCode OH_MediaKeySystem_ProcessKeySystemResponse(MediaKeySystem *mediaKeySystem, + DRM_Uint8Buffer *response); /** * @brief Get offline media key ids . * @param mediaKeySystem Media key system instance. * @param mediaKeyIds Media key ids of all offline media keys. - * @return OH_DrmErrCode. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. * @since 11 * @version 1.0 */ -OH_DrmErrCode OH_MediaKeySystem_GetOfflineMediaKeyIds(OH_MediaKeySystem *mediaKeySystem, - OH_DRM_MediaKeyIdArray **mediaKeyIds, int32_t *mediaKeyIdsLen); +Drm_ErrCode OH_MediaKeySystem_GetOfflineMediaKeyIds(MediaKeySystem *mediaKeySystem, + DRM_MediakeyIdArray **mediaKeyIds); /** * @brief Get offline media key status. * @param mediaKeySystem Media key system instance. * @param mediaKeyId Media key identifier. * @param status The media key status gotten. - * @return OH_DrmErrCode. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. * @since 11 * @version 1.0 */ -OH_DrmErrCode OH_MediaKeySystem_GetOfflineMediaKeyStatus(OH_MediaKeySystem *mediaKeySystem, - OH_DRM_Uint8Buffer *mediaKeyId, OH_DRM_OfflineMediaKeyStatus *status); +Drm_ErrCode OH_MediaKeySystem_GetOfflineMediaKeyStatus(MediaKeySystem *mediaKeySystem, + DRM_Uint8Buffer *mediaKeyId, DRM_OfflineMediaKeyStatus *status); /** * @brief Clear an offline media key by id. * @param mediaKeySystem Media key system instance. * @param mediaKeyId Media key identifier. - * @return OH_DrmErrCode. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. * @since 11 * @version 1.0 */ -OH_DrmErrCode OH_MediaKeySystem_ClearOfflineMediaKeys(OH_MediaKeySystem *mediaKeySystem, - OH_DRM_Uint8Buffer *mediaKeyId); +Drm_ErrCode OH_MediaKeySystem_ClearOfflineMediaKeys(MediaKeySystem *mediaKeySystem, + DRM_Uint8Buffer *mediaKeyId); /** * @brief Get certificate status of media key system. * @param mediaKeySystem Media key system instance. * @param certStatus Status will be gotten. - * @return OH_DrmErrCode. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. * @since 11 * @version 1.0 */ -OH_DrmErrCode OH_MediaKeySystem_GetCertificateStatus(OH_MediaKeySystem *mediaKeySystem, - OH_DRM_CertificateStatus *certStatus); +Drm_ErrCode OH_MediaKeySystem_GetCertificateStatus(MediaKeySystem *mediaKeySystem, + DRM_CertificateStatus *certStatus); /** * @brief Destroy a media key system instance. * @param mediaKeySystem Secifies which media key system instance will be destroyed. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. * @since 11 * @version 1.0 */ -OH_DrmErrCode OH_MediaKeySystem_Destroy(OH_MediaKeySystem *mediaKeySystem); +Drm_ErrCode OH_MediaKeySystem_Destroy(MediaKeySystem *mediaKeySystem); #ifdef __cplusplus -- Gitee