mirror of
https://github.com/openharmony/multimedia_drm_framework.git
synced 2026-07-01 02:07:09 -04:00
@@ -150,7 +150,7 @@ Drm_ErrCode OH_MediaKeySystem_GetConfigurationString(MediaKeySystem *mediaKeySys
|
||||
result = systemObject->systemImpl_->GetConfigurationString(name, valuePtr);
|
||||
DRM_CHECK_AND_RETURN_RET_LOG(result == DRM_ERR_OK, DRM_ERR_INVALID_VAL,
|
||||
"OH_SetConfigurationString mediaKeySystemImpl::GetConfigurationString faild!");
|
||||
DRM_CHECK_AND_RETURN_RET_LOG(valueLen >= valuePtr.size(), DRM_ERR_INVALID_VAL,
|
||||
DRM_CHECK_AND_RETURN_RET_LOG(valueLen >= (int32_t)valuePtr.size(), DRM_ERR_INVALID_VAL,
|
||||
"OH_SetConfigurationString The space for value is too small");
|
||||
memset_s(value, valueLen, 0, valueLen);
|
||||
int32_t ret = memcpy_s(value, valuePtr.size(), valuePtr.c_str(), valuePtr.size());
|
||||
@@ -208,7 +208,7 @@ Drm_ErrCode OH_MediaKeySystem_GetConfigurationByteArray(MediaKeySystem *mediaKey
|
||||
result = systemObject->systemImpl_->GetConfigurationByteArray(name, valuePtr);
|
||||
DRM_CHECK_AND_RETURN_RET_LOG(result == DRM_ERR_OK, DRM_ERR_INVALID_VAL,
|
||||
"OH_GetConfigurationByteArray mediaKeySystemImpl::GetConfigurationByteArray faild!");
|
||||
DRM_CHECK_AND_RETURN_RET_LOG(*valueLen >= valuePtr.size(), DRM_ERR_INVALID_VAL,
|
||||
DRM_CHECK_AND_RETURN_RET_LOG(*valueLen >= (int32_t)valuePtr.size(), DRM_ERR_INVALID_VAL,
|
||||
"OH_GetConfigurationByteArray The space for value is too small!");
|
||||
*valueLen = valuePtr.size();
|
||||
int32_t ret = memcpy_s(value, valuePtr.size(), valuePtr.data(), valuePtr.size());
|
||||
|
||||
@@ -48,7 +48,8 @@ static const std::vector<struct JsEnumInt> g_mediaKeyType = {
|
||||
static const std::vector<struct JsEnumInt> g_offlineMediaKeyStatus = {
|
||||
{ "OFFLINE_MEDIA_KEY_STATUS_UNKNOWN",
|
||||
IMediaKeySessionService::OfflineMediaKeyStatus::OFFLINELICENSESTATUS_UNKNOWN },
|
||||
{ "OFFLINE_MEDIA_KEY_STATUS_USABLE", IMediaKeySessionService::OfflineMediaKeyStatus::OFFLINELICENSESTATUS_USABLE },
|
||||
{ "OFFLINE_MEDIA_KEY_STATUS_USABLE",
|
||||
IMediaKeySessionService::OfflineMediaKeyStatus::OFFLINELICENSESTATUS_USABLE },
|
||||
{ "OFFLINE_MEDIA_KEY_STATUS_INACTIVE",
|
||||
IMediaKeySessionService::OfflineMediaKeyStatus::OFFLINELICENSESTATUS_INACTIVE },
|
||||
};
|
||||
@@ -193,4 +194,4 @@ napi_value DrmEnumNapi::Init(napi_env env, napi_value exports)
|
||||
return exports;
|
||||
}
|
||||
} // namespace drm
|
||||
} // namespace OHOS
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -219,17 +219,17 @@ static napi_value DealMediaKeyRequest(napi_env env, IMediaKeySessionService::Med
|
||||
napi_value result = nullptr;
|
||||
|
||||
if (licenseRequest.requestType == IMediaKeySessionService::REQUEST_TYPE_UNKNOWN) {
|
||||
requestTypeEnum = "ALGTYPE_UNENCRYPTED";
|
||||
requestTypeEnum = "MEDIA_KEY_REQUEST_TYPE_UNKNOWN";
|
||||
} else if (licenseRequest.requestType == IMediaKeySessionService::REQUEST_TYPE_INITIAL) {
|
||||
requestTypeEnum = "REQUEST_TYPE_INITIAL";
|
||||
requestTypeEnum = "MEDIA_KEY_REQUEST_TYPE_INITIAL";
|
||||
} else if (licenseRequest.requestType == IMediaKeySessionService::REQUEST_TYPE_RENEWAL) {
|
||||
requestTypeEnum = "REQUEST_TYPE_RENEWAL";
|
||||
requestTypeEnum = "MEDIA_KEY_REQUEST_TYPE_RENEWAL";
|
||||
} else if (licenseRequest.requestType == IMediaKeySessionService::REQUEST_TYPE_RELEASE) {
|
||||
requestTypeEnum = "REQUEST_TYPE_RELEASE";
|
||||
requestTypeEnum = "MEDIA_KEY_REQUEST_TYPE_RELEASE";
|
||||
} else if (licenseRequest.requestType == IMediaKeySessionService::REQUEST_TYPE_NONE) {
|
||||
requestTypeEnum = "REQUEST_TYPE_NONE";
|
||||
requestTypeEnum = "MEDIA_KEY_REQUEST_TYPE_NONE";
|
||||
} else if (licenseRequest.requestType == IMediaKeySessionService::REQUEST_TYPE_UPDATE) {
|
||||
requestTypeEnum = "REQUEST_TYPE_UPDATE";
|
||||
requestTypeEnum = "MEDIA_KEY_REQUEST_TYPE_UPDATE";
|
||||
} else if (licenseRequest.requestType < IMediaKeySessionService::REQUEST_TYPE_UNKNOWN ||
|
||||
licenseRequest.requestType > IMediaKeySessionService::REQUEST_TYPE_UPDATE) {
|
||||
DRM_ERR_LOG("Do not understand licenseRequest.requestType enum!");
|
||||
@@ -262,6 +262,44 @@ static napi_value DealMediaKeyRequest(napi_env env, IMediaKeySessionService::Med
|
||||
return result;
|
||||
}
|
||||
|
||||
static napi_status FillTmpOptionalData(napi_env env, napi_value *argv, uint32_t optionalDataCount,
|
||||
std::map<std::string, std::string> &tmpOptionalData)
|
||||
{
|
||||
napi_status status = napi_ok;
|
||||
if (optionalDataCount > 0) {
|
||||
for (size_t i = 0; i < optionalDataCount; i++) {
|
||||
napi_value tmpData;
|
||||
napi_value tmpName;
|
||||
napi_value tmpValue;
|
||||
size_t nameLength = 0;
|
||||
size_t valueLength = 0;
|
||||
status = napi_get_element(env, argv[PARAM3], i, &tmpData);
|
||||
DRM_CHECK_AND_RETURN_RET_LOG(status == napi_ok, status, "Could not able to read optionalData element!");
|
||||
status = napi_get_named_property(env, tmpData, "name", &tmpName);
|
||||
DRM_CHECK_AND_RETURN_RET_LOG(status == napi_ok, status, "Could not able to read optionalData property!");
|
||||
status = napi_get_named_property(env, tmpData, "value", &tmpValue);
|
||||
DRM_CHECK_AND_RETURN_RET_LOG(status == napi_ok, status, "Could not able to read optionalData property!");
|
||||
status = napi_get_value_string_utf8(env, tmpName, nullptr, 0, &nameLength);
|
||||
DRM_CHECK_AND_RETURN_RET_LOG(status == napi_ok, status,
|
||||
"Could not able to transfer optionalData buffer info!");
|
||||
status = napi_get_value_string_utf8(env, tmpValue, nullptr, 0, &valueLength);
|
||||
DRM_CHECK_AND_RETURN_RET_LOG(status == napi_ok, status,
|
||||
"Could not able to transfer optionalData buffer info!");
|
||||
std::string name(nameLength, 0);
|
||||
status = napi_get_value_string_utf8(env, tmpName, &name[0], nameLength + 1, &nameLength);
|
||||
DRM_CHECK_AND_RETURN_RET_LOG(status == napi_ok, status,
|
||||
"Could not able to transfer optionalData buffer info!");
|
||||
std::string value(valueLength, 0);
|
||||
status = napi_get_value_string_utf8(env, tmpValue, &value[0], valueLength + 1, &valueLength);
|
||||
DRM_CHECK_AND_RETURN_RET_LOG(status == napi_ok, status,
|
||||
"Could not able to transfer optionalData buffer info!");
|
||||
DRM_INFO_LOG("%{public}s: name : %{public}s", __func__, name.c_str());
|
||||
DRM_INFO_LOG("%{public}s: value : %{public}s", __func__, value.c_str());
|
||||
tmpOptionalData.insert(std::make_pair(name, value));
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
napi_value MediaKeySessionNapi::GenerateMediaKeyRequest(napi_env env, napi_callback_info info)
|
||||
{
|
||||
DRM_INFO_LOG("MediaKeySessionNapi::GenerateMediaKeyRequest enter");
|
||||
@@ -299,43 +337,11 @@ napi_value MediaKeySessionNapi::GenerateMediaKeyRequest(napi_env env, napi_callb
|
||||
DRM_CHECK_AND_RETURN_RET_LOG(status == napi_ok, nullptr, "Could not able to read licenseType argument!");
|
||||
// optional data
|
||||
std::map<std::string, std::string> tmpOptionalData;
|
||||
|
||||
uint32_t optionalDataCount = 0;
|
||||
status = napi_get_array_length(env, argv[PARAM3], &optionalDataCount);
|
||||
DRM_CHECK_AND_RETURN_RET_LOG(status == napi_ok, nullptr, "Could not able to read optionalData argument!");
|
||||
if (optionalDataCount > 0) {
|
||||
for (size_t i = 0; i < optionalDataCount; i++) {
|
||||
napi_value tmpData;
|
||||
napi_value tmpName;
|
||||
napi_value tmpValue;
|
||||
size_t nameLength = 0;
|
||||
size_t valueLength = 0;
|
||||
status = napi_get_element(env, argv[PARAM3], i, &tmpData);
|
||||
DRM_CHECK_AND_RETURN_RET_LOG(status == napi_ok, nullptr, "Could not able to read optionalData element!");
|
||||
status = napi_get_named_property(env, tmpData, "name", &tmpName);
|
||||
DRM_CHECK_AND_RETURN_RET_LOG(status == napi_ok, nullptr, "Could not able to read optionalData property!");
|
||||
status = napi_get_named_property(env, tmpData, "value", &tmpValue);
|
||||
DRM_CHECK_AND_RETURN_RET_LOG(status == napi_ok, nullptr, "Could not able to read optionalData property!");
|
||||
status = napi_get_value_string_utf8(env, tmpName, nullptr, 0, &nameLength);
|
||||
DRM_CHECK_AND_RETURN_RET_LOG(status == napi_ok, nullptr,
|
||||
"Could not able to transfer optionalData buffer info!");
|
||||
status = napi_get_value_string_utf8(env, tmpValue, nullptr, 0, &valueLength);
|
||||
DRM_CHECK_AND_RETURN_RET_LOG(status == napi_ok, nullptr,
|
||||
"Could not able to transfer optionalData buffer info!");
|
||||
std::string name(nameLength, 0);
|
||||
status = napi_get_value_string_utf8(env, tmpName, &name[0], nameLength + 1, &nameLength);
|
||||
DRM_CHECK_AND_RETURN_RET_LOG(status == napi_ok, nullptr,
|
||||
"Could not able to transfer optionalData buffer info!");
|
||||
std::string value(valueLength, 0);
|
||||
status = napi_get_value_string_utf8(env, tmpValue, &value[0], valueLength + 1, &valueLength);
|
||||
DRM_CHECK_AND_RETURN_RET_LOG(status == napi_ok, nullptr,
|
||||
"Could not able to transfer optionalData buffer info!");
|
||||
DRM_INFO_LOG("%{public}s: name : %{public}s", __func__, name.c_str());
|
||||
DRM_INFO_LOG("%{public}s: value : %{public}s", __func__, value.c_str());
|
||||
tmpOptionalData.insert(std::make_pair(name, value));
|
||||
}
|
||||
}
|
||||
|
||||
status = FillTmpOptionalData(env, argv, optionalDataCount, tmpOptionalData);
|
||||
DRM_CHECK_AND_RETURN_RET_LOG(status == napi_ok, nullptr, "FillTmpOptionalData faild!");
|
||||
licenseRequestInfo.mediaKeyType = (IMediaKeySessionService::MediaKeyType)licenseType;
|
||||
licenseRequestInfo.mimeType = std::string(buffer);
|
||||
licenseRequestInfo.initData = initDataStr;
|
||||
|
||||
@@ -75,7 +75,7 @@ void MediaKeySystemCallbackNapi::SendEvent(const std::string event, int32_t extr
|
||||
napi_set_named_property(env, args[0], "info", array);
|
||||
napi_set_named_property(env, args[0], "extraInfo", extraValue);
|
||||
napi_get_reference_value(env, callbackRef, &jsCallback);
|
||||
state = napi_call_function(env, nullptr, jsCallback, ARGS_TWO, args, &retVal);
|
||||
state = napi_call_function(env, nullptr, jsCallback, ARGS_ONE, args, &retVal);
|
||||
DRM_NAPI_CHECK_AND_RETURN_LOG(state == napi_ok,
|
||||
"%{public}s failed to napi_call_function", event.c_str());
|
||||
}
|
||||
|
||||
@@ -54,10 +54,8 @@ ohos_shared_library("drm_framework") {
|
||||
cflags = [
|
||||
"-fPIC",
|
||||
"-Wall",
|
||||
"--coverage",
|
||||
]
|
||||
|
||||
ldflags = [ "--coverage" ]
|
||||
if (target_cpu == "arm") {
|
||||
cflags += [ "-DBINDER_IPC_32BIT" ]
|
||||
}
|
||||
|
||||
@@ -36,13 +36,8 @@ config("drm_framework_capi_unittest_v1_0_config") {
|
||||
"-D_FORTIFY_SOURCE=2",
|
||||
"-Wformat=2",
|
||||
"-Wdate-time",
|
||||
"--coverage",
|
||||
]
|
||||
cflags_cc = [
|
||||
"-fno-rtti",
|
||||
"--coverage",
|
||||
]
|
||||
ldflags = [ "--coverage" ]
|
||||
cflags_cc = [ "-fno-rtti" ]
|
||||
}
|
||||
|
||||
ohos_unittest("drm_framework_capi_unittest_v1_0") {
|
||||
|
||||
@@ -2007,7 +2007,37 @@ HWTEST_F(DrmFrameworkUnitTest, Drm_unittest_GenerateOfflineReleaseRequestNormal_
|
||||
errNo = OH_MediaKeySystem_Destroy(mediaKeySystem);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
}
|
||||
|
||||
void TestPart_046(MediaKeySystem *mediaKeySystem, MediaKeySession *mediaKeySession)
|
||||
{
|
||||
Drm_ErrCode errNo = DRM_ERR_UNKNOWN;
|
||||
unsigned char offlineMediaKeyId[64] = { 0 }; // 64:OFFLINE_MEDIA_KEY_ID_LEN
|
||||
unsigned char testKeySessionResponse[50] = OFFRESPONSE;
|
||||
int32_t offlineMediaKeyIdLen = 64; // 64:OFFLINE_MEDIA_KEY_ID_LEN
|
||||
errNo = OH_MediaKeySession_ProcessMediaKeyResponse(mediaKeySession, testKeySessionResponse,
|
||||
(int32_t)(sizeof(testKeySessionResponse)), offlineMediaKeyId, &offlineMediaKeyIdLen);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
DRM_OfflineMediaKeyStatus OfflineMediaKeyStatus = OFFLINE_MEDIA_KEY_STATUS_UNKNOWN;
|
||||
errNo = OH_MediaKeySystem_GetOfflineMediaKeyStatus(mediaKeySystem, offlineMediaKeyId, offlineMediaKeyIdLen,
|
||||
&OfflineMediaKeyStatus);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
EXPECT_EQ(OfflineMediaKeyStatus, 1);
|
||||
unsigned char releaseRequest[8192] = { 0 }; // 8192:request len
|
||||
int32_t releaseRequestLen = 8192; // 8192:request len
|
||||
errNo = OH_MediaKeySession_GenerateOfflineReleaseRequest(nullptr, offlineMediaKeyId, offlineMediaKeyIdLen,
|
||||
releaseRequest, &releaseRequestLen);
|
||||
EXPECT_NE(errNo, DRM_ERR_OK);
|
||||
releaseRequestLen = 8192; // 8192:request len
|
||||
errNo = OH_MediaKeySession_GenerateOfflineReleaseRequest(mediaKeySession, nullptr, offlineMediaKeyIdLen,
|
||||
releaseRequest, &releaseRequestLen);
|
||||
EXPECT_NE(errNo, DRM_ERR_OK);
|
||||
releaseRequestLen = 8192; // 8192:request len
|
||||
errNo = OH_MediaKeySession_GenerateOfflineReleaseRequest(mediaKeySession, offlineMediaKeyId, offlineMediaKeyIdLen,
|
||||
nullptr, &releaseRequestLen);
|
||||
EXPECT_NE(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySession_GenerateOfflineReleaseRequest(mediaKeySession, offlineMediaKeyId, offlineMediaKeyIdLen,
|
||||
releaseRequest, nullptr);
|
||||
EXPECT_NE(errNo, DRM_ERR_OK);
|
||||
}
|
||||
/*
|
||||
* Feature: Framework
|
||||
* Function: Processing device certificate response testing
|
||||
@@ -2052,6 +2082,15 @@ HWTEST_F(DrmFrameworkUnitTest, Drm_unittest_GenerateOfflineReleaseRequestAbNorma
|
||||
info.optionsCount = 1;
|
||||
errNo = OH_MediaKeySession_GenerateMediaKeyRequest(mediaKeySession, &info, &mediaKeyRequest);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
TestPart_046(mediaKeySystem, mediaKeySession);
|
||||
errNo = OH_MediaKeySession_Destroy(mediaKeySession);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySystem_Destroy(mediaKeySystem);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
}
|
||||
void TestPart_047(MediaKeySystem *mediaKeySystem, MediaKeySession *mediaKeySession)
|
||||
{
|
||||
Drm_ErrCode errNo = DRM_ERR_UNKNOWN;
|
||||
unsigned char offlineMediaKeyId[64] = { 0 }; // 64:OFFLINE_MEDIA_KEY_ID_LEN
|
||||
unsigned char testKeySessionResponse[50] = OFFRESPONSE;
|
||||
int32_t offlineMediaKeyIdLen = 64; // 64:OFFLINE_MEDIA_KEY_ID_LEN
|
||||
@@ -2065,26 +2104,18 @@ HWTEST_F(DrmFrameworkUnitTest, Drm_unittest_GenerateOfflineReleaseRequestAbNorma
|
||||
EXPECT_EQ(OfflineMediaKeyStatus, 1);
|
||||
unsigned char releaseRequest[8192] = { 0 }; // 8192:request len
|
||||
int32_t releaseRequestLen = 8192; // 8192:request len
|
||||
errNo = OH_MediaKeySession_GenerateOfflineReleaseRequest(nullptr, offlineMediaKeyId, offlineMediaKeyIdLen,
|
||||
releaseRequest, &releaseRequestLen);
|
||||
EXPECT_NE(errNo, DRM_ERR_OK);
|
||||
releaseRequestLen = 8192; // 8192:request len
|
||||
errNo = OH_MediaKeySession_GenerateOfflineReleaseRequest(mediaKeySession, nullptr, offlineMediaKeyIdLen,
|
||||
releaseRequest, &releaseRequestLen);
|
||||
EXPECT_NE(errNo, DRM_ERR_OK);
|
||||
releaseRequestLen = 8192; // 8192:request len
|
||||
errNo = OH_MediaKeySession_GenerateOfflineReleaseRequest(mediaKeySession, offlineMediaKeyId, offlineMediaKeyIdLen,
|
||||
nullptr, &releaseRequestLen);
|
||||
EXPECT_NE(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySession_GenerateOfflineReleaseRequest(mediaKeySession, offlineMediaKeyId, offlineMediaKeyIdLen,
|
||||
releaseRequest, nullptr);
|
||||
EXPECT_NE(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySession_Destroy(mediaKeySession);
|
||||
releaseRequest, &releaseRequestLen);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySystem_Destroy(mediaKeySystem);
|
||||
unsigned char testKeyReleaseResponse[50] = OFFRESPONSE;
|
||||
errNo = OH_MediaKeySession_ProcessOfflineReleaseResponse(mediaKeySession, offlineMediaKeyId, offlineMediaKeyIdLen,
|
||||
testKeyReleaseResponse, (int32_t)(sizeof(testKeyReleaseResponse)));
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySystem_GetOfflineMediaKeyStatus(mediaKeySystem, offlineMediaKeyId, offlineMediaKeyIdLen,
|
||||
&OfflineMediaKeyStatus);
|
||||
EXPECT_EQ(OfflineMediaKeyStatus, OFFLINE_MEDIA_KEY_STATUS_INACTIVE);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: Framework
|
||||
* Function: Processing device certificate response testing
|
||||
@@ -2129,30 +2160,7 @@ HWTEST_F(DrmFrameworkUnitTest, Drm_unittest_ProcessOfflineReleaseResponseNormal_
|
||||
info.optionsCount = 1;
|
||||
errNo = OH_MediaKeySession_GenerateMediaKeyRequest(mediaKeySession, &info, &mediaKeyRequest);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
unsigned char offlineMediaKeyId[64] = { 0 }; // 64:OFFLINE_MEDIA_KEY_ID_LEN
|
||||
unsigned char testKeySessionResponse[50] = OFFRESPONSE;
|
||||
int32_t offlineMediaKeyIdLen = 64; // 64:OFFLINE_MEDIA_KEY_ID_LEN
|
||||
errNo = OH_MediaKeySession_ProcessMediaKeyResponse(mediaKeySession, testKeySessionResponse,
|
||||
(int32_t)(sizeof(testKeySessionResponse)), offlineMediaKeyId, &offlineMediaKeyIdLen);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
DRM_OfflineMediaKeyStatus OfflineMediaKeyStatus = OFFLINE_MEDIA_KEY_STATUS_UNKNOWN;
|
||||
errNo = OH_MediaKeySystem_GetOfflineMediaKeyStatus(mediaKeySystem, offlineMediaKeyId, offlineMediaKeyIdLen,
|
||||
&OfflineMediaKeyStatus);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
EXPECT_EQ(OfflineMediaKeyStatus, 1);
|
||||
unsigned char releaseRequest[8192] = { 0 }; // 8192:request len
|
||||
int32_t releaseRequestLen = 8192; // 8192:request len
|
||||
errNo = OH_MediaKeySession_GenerateOfflineReleaseRequest(mediaKeySession, offlineMediaKeyId, offlineMediaKeyIdLen,
|
||||
releaseRequest, &releaseRequestLen);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
unsigned char testKeyReleaseResponse[50] = OFFRESPONSE;
|
||||
errNo = OH_MediaKeySession_ProcessOfflineReleaseResponse(mediaKeySession, offlineMediaKeyId, offlineMediaKeyIdLen,
|
||||
testKeyReleaseResponse, (int32_t)(sizeof(testKeyReleaseResponse)));
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySystem_GetOfflineMediaKeyStatus(mediaKeySystem, offlineMediaKeyId, offlineMediaKeyIdLen,
|
||||
&OfflineMediaKeyStatus);
|
||||
EXPECT_EQ(OfflineMediaKeyStatus, 2);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
TestPart_047(mediaKeySystem, mediaKeySession);
|
||||
errNo = OH_MediaKeySession_Destroy(mediaKeySession);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySystem_Destroy(mediaKeySystem);
|
||||
@@ -2647,6 +2655,40 @@ HWTEST_F(DrmFrameworkUnitTest, Drm_unittest_GetMaxContentProtectionLevelAbNormal
|
||||
}
|
||||
}
|
||||
|
||||
void TestPart_060(MediaKeySystem *mediaKeySystem, MediaKeySession *mediaKeySession)
|
||||
{
|
||||
Drm_ErrCode errNo = DRM_ERR_UNKNOWN;
|
||||
unsigned char offlineMediaKeyId[64] = { 0 }; // 64:OFFLINE_MEDIA_KEY_ID_LEN
|
||||
unsigned char testKeySessionResponse[50] = OFFRESPONSE;
|
||||
int32_t offlineMediaKeyIdLen = 64; // 64:OFFLINE_MEDIA_KEY_ID_LEN
|
||||
errNo = OH_MediaKeySession_ProcessMediaKeyResponse(mediaKeySession, testKeySessionResponse,
|
||||
(int32_t)(sizeof(testKeySessionResponse)), offlineMediaKeyId, &offlineMediaKeyIdLen);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
DRM_OfflineMediaKeyStatus OfflineMediaKeyStatus = OFFLINE_MEDIA_KEY_STATUS_UNKNOWN;
|
||||
errNo = OH_MediaKeySystem_GetOfflineMediaKeyStatus(mediaKeySystem, offlineMediaKeyId, offlineMediaKeyIdLen,
|
||||
&OfflineMediaKeyStatus);
|
||||
EXPECT_EQ(OfflineMediaKeyStatus, 1);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
unsigned char releaseRequest[8192] = { 0 }; // 8192:request len
|
||||
int32_t releaseRequestLen = 8192; // 8192:request len
|
||||
errNo = OH_MediaKeySession_GenerateOfflineReleaseRequest(mediaKeySession, offlineMediaKeyId, offlineMediaKeyIdLen,
|
||||
releaseRequest, &releaseRequestLen);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
unsigned char testKeyReleaseResponse[50] = OFFRESPONSE;
|
||||
errNo = OH_MediaKeySession_ProcessOfflineReleaseResponse(mediaKeySession, offlineMediaKeyId, offlineMediaKeyIdLen,
|
||||
testKeyReleaseResponse, (int32_t)(sizeof(testKeyReleaseResponse)));
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySystem_GetOfflineMediaKeyStatus(mediaKeySystem, offlineMediaKeyId, offlineMediaKeyIdLen,
|
||||
&OfflineMediaKeyStatus);
|
||||
EXPECT_EQ(OfflineMediaKeyStatus, OFFLINE_MEDIA_KEY_STATUS_INACTIVE);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySystem_ClearOfflineMediaKeys(mediaKeySystem, offlineMediaKeyId, offlineMediaKeyIdLen);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySystem_GetOfflineMediaKeyStatus(mediaKeySystem, offlineMediaKeyId, offlineMediaKeyIdLen,
|
||||
&OfflineMediaKeyStatus);
|
||||
EXPECT_EQ(OfflineMediaKeyStatus, 0);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
}
|
||||
/*
|
||||
* Feature: Framework
|
||||
* Function: Processing device certificate response testing
|
||||
@@ -2691,6 +2733,16 @@ HWTEST_F(DrmFrameworkUnitTest, Drm_unittest_ClearOfflineMediaKeysNormal_060, Tes
|
||||
info.optionsCount = 1;
|
||||
errNo = OH_MediaKeySession_GenerateMediaKeyRequest(mediaKeySession, &info, &mediaKeyRequest);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
TestPart_060(mediaKeySystem, mediaKeySession);
|
||||
errNo = OH_MediaKeySession_Destroy(mediaKeySession);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySystem_Destroy(mediaKeySystem);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
}
|
||||
|
||||
void TestPart_061(MediaKeySystem *mediaKeySystem, MediaKeySession *mediaKeySession)
|
||||
{
|
||||
Drm_ErrCode errNo = DRM_ERR_UNKNOWN;
|
||||
unsigned char offlineMediaKeyId[64] = { 0 }; // 64:OFFLINE_MEDIA_KEY_ID_LEN
|
||||
unsigned char testKeySessionResponse[50] = OFFRESPONSE;
|
||||
int32_t offlineMediaKeyIdLen = 64; // 64:OFFLINE_MEDIA_KEY_ID_LEN
|
||||
@@ -2713,20 +2765,17 @@ HWTEST_F(DrmFrameworkUnitTest, Drm_unittest_ClearOfflineMediaKeysNormal_060, Tes
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySystem_GetOfflineMediaKeyStatus(mediaKeySystem, offlineMediaKeyId, offlineMediaKeyIdLen,
|
||||
&OfflineMediaKeyStatus);
|
||||
EXPECT_EQ(OfflineMediaKeyStatus, 2);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySystem_ClearOfflineMediaKeys(mediaKeySystem, offlineMediaKeyId, offlineMediaKeyIdLen);
|
||||
EXPECT_EQ(OfflineMediaKeyStatus, OFFLINE_MEDIA_KEY_STATUS_INACTIVE);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySystem_ClearOfflineMediaKeys(nullptr, offlineMediaKeyId, offlineMediaKeyIdLen);
|
||||
EXPECT_NE(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySystem_ClearOfflineMediaKeys(mediaKeySystem, nullptr, offlineMediaKeyIdLen);
|
||||
EXPECT_NE(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySystem_GetOfflineMediaKeyStatus(mediaKeySystem, offlineMediaKeyId, offlineMediaKeyIdLen,
|
||||
&OfflineMediaKeyStatus);
|
||||
EXPECT_EQ(OfflineMediaKeyStatus, 0);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySession_Destroy(mediaKeySession);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySystem_Destroy(mediaKeySystem);
|
||||
EXPECT_EQ(OfflineMediaKeyStatus, OFFLINE_MEDIA_KEY_STATUS_INACTIVE);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: Framework
|
||||
* Function: Processing device certificate response testing
|
||||
@@ -2771,6 +2820,16 @@ HWTEST_F(DrmFrameworkUnitTest, Drm_unittest_ClearOfflineMediaKeysAbNormal_061, T
|
||||
info.optionsCount = 1;
|
||||
errNo = OH_MediaKeySession_GenerateMediaKeyRequest(mediaKeySession, &info, &mediaKeyRequest);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
TestPart_061(mediaKeySystem, mediaKeySession);
|
||||
errNo = OH_MediaKeySession_Destroy(mediaKeySession);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySystem_Destroy(mediaKeySystem);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
}
|
||||
|
||||
void TestPart_062(MediaKeySystem *mediaKeySystem, MediaKeySession *mediaKeySession)
|
||||
{
|
||||
Drm_ErrCode errNo = DRM_ERR_UNKNOWN;
|
||||
unsigned char offlineMediaKeyId[64] = { 0 }; // 64:OFFLINE_MEDIA_KEY_ID_LEN
|
||||
unsigned char testKeySessionResponse[50] = OFFRESPONSE;
|
||||
int32_t offlineMediaKeyIdLen = 64; // 64:OFFLINE_MEDIA_KEY_ID_LEN
|
||||
@@ -2793,22 +2852,15 @@ HWTEST_F(DrmFrameworkUnitTest, Drm_unittest_ClearOfflineMediaKeysAbNormal_061, T
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySystem_GetOfflineMediaKeyStatus(mediaKeySystem, offlineMediaKeyId, offlineMediaKeyIdLen,
|
||||
&OfflineMediaKeyStatus);
|
||||
EXPECT_EQ(OfflineMediaKeyStatus, 2);
|
||||
EXPECT_EQ(OfflineMediaKeyStatus, OFFLINE_MEDIA_KEY_STATUS_INACTIVE);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySession_RestoreOfflineMediaKeys(mediaKeySession, offlineMediaKeyId, offlineMediaKeyIdLen);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySystem_ClearOfflineMediaKeys(nullptr, offlineMediaKeyId, offlineMediaKeyIdLen);
|
||||
EXPECT_NE(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySystem_ClearOfflineMediaKeys(mediaKeySystem, nullptr, offlineMediaKeyIdLen);
|
||||
EXPECT_NE(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySystem_GetOfflineMediaKeyStatus(mediaKeySystem, offlineMediaKeyId, offlineMediaKeyIdLen,
|
||||
&OfflineMediaKeyStatus);
|
||||
EXPECT_EQ(OfflineMediaKeyStatus, 2);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySession_Destroy(mediaKeySession);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySystem_Destroy(mediaKeySystem);
|
||||
EXPECT_EQ(OfflineMediaKeyStatus, 1);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: Framework
|
||||
* Function: Processing device certificate response testing
|
||||
@@ -2852,6 +2904,15 @@ HWTEST_F(DrmFrameworkUnitTest, Drm_unittest_RestoreOfflineMediaKeysNormal_062, T
|
||||
info.optionsCount = 1;
|
||||
errNo = OH_MediaKeySession_GenerateMediaKeyRequest(mediaKeySession, &info, &mediaKeyRequest);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
TestPart_062(mediaKeySystem, mediaKeySession);
|
||||
errNo = OH_MediaKeySession_Destroy(mediaKeySession);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySystem_Destroy(mediaKeySystem);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
}
|
||||
void TestPart_063(MediaKeySystem *mediaKeySystem, MediaKeySession *mediaKeySession)
|
||||
{
|
||||
Drm_ErrCode errNo = DRM_ERR_UNKNOWN;
|
||||
unsigned char offlineMediaKeyId[64] = { 0 }; // 64:OFFLINE_MEDIA_KEY_ID_LEN
|
||||
unsigned char testKeySessionResponse[50] = OFFRESPONSE;
|
||||
int32_t offlineMediaKeyIdLen = 64; // 64:OFFLINE_MEDIA_KEY_ID_LEN
|
||||
@@ -2874,17 +2935,17 @@ HWTEST_F(DrmFrameworkUnitTest, Drm_unittest_RestoreOfflineMediaKeysNormal_062, T
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySystem_GetOfflineMediaKeyStatus(mediaKeySystem, offlineMediaKeyId, offlineMediaKeyIdLen,
|
||||
&OfflineMediaKeyStatus);
|
||||
EXPECT_EQ(OfflineMediaKeyStatus, 2);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySession_RestoreOfflineMediaKeys(mediaKeySession, offlineMediaKeyId, offlineMediaKeyIdLen);
|
||||
EXPECT_EQ(OfflineMediaKeyStatus, OFFLINE_MEDIA_KEY_STATUS_INACTIVE);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySession_RestoreOfflineMediaKeys(nullptr, offlineMediaKeyId, offlineMediaKeyIdLen);
|
||||
EXPECT_NE(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySession_RestoreOfflineMediaKeys(mediaKeySession, nullptr, offlineMediaKeyIdLen);
|
||||
EXPECT_NE(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySession_RestoreOfflineMediaKeys(mediaKeySession, offlineMediaKeyId, 0);
|
||||
EXPECT_NE(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySystem_GetOfflineMediaKeyStatus(mediaKeySystem, offlineMediaKeyId, offlineMediaKeyIdLen,
|
||||
&OfflineMediaKeyStatus);
|
||||
EXPECT_EQ(OfflineMediaKeyStatus, 1);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySession_Destroy(mediaKeySession);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySystem_Destroy(mediaKeySystem);
|
||||
EXPECT_EQ(OfflineMediaKeyStatus, OFFLINE_MEDIA_KEY_STATUS_INACTIVE);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
}
|
||||
/*
|
||||
@@ -2931,40 +2992,7 @@ HWTEST_F(DrmFrameworkUnitTest, Drm_unittest_RestoreOfflineMediaKeysAbNormal_063,
|
||||
info.optionsCount = 1;
|
||||
errNo = OH_MediaKeySession_GenerateMediaKeyRequest(mediaKeySession, &info, &mediaKeyRequest);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
unsigned char offlineMediaKeyId[64] = { 0 }; // 64:OFFLINE_MEDIA_KEY_ID_LEN
|
||||
unsigned char testKeySessionResponse[50] = OFFRESPONSE;
|
||||
int32_t offlineMediaKeyIdLen = 64; // 64:OFFLINE_MEDIA_KEY_ID_LEN
|
||||
errNo = OH_MediaKeySession_ProcessMediaKeyResponse(mediaKeySession, testKeySessionResponse,
|
||||
(int32_t)(sizeof(testKeySessionResponse)), offlineMediaKeyId, &offlineMediaKeyIdLen);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
DRM_OfflineMediaKeyStatus OfflineMediaKeyStatus = OFFLINE_MEDIA_KEY_STATUS_UNKNOWN;
|
||||
errNo = OH_MediaKeySystem_GetOfflineMediaKeyStatus(mediaKeySystem, offlineMediaKeyId, offlineMediaKeyIdLen,
|
||||
&OfflineMediaKeyStatus);
|
||||
EXPECT_EQ(OfflineMediaKeyStatus, 1);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
unsigned char releaseRequest[8192] = { 0 }; // 8192:request len
|
||||
int32_t releaseRequestLen = 8192; // 8192:request len
|
||||
errNo = OH_MediaKeySession_GenerateOfflineReleaseRequest(mediaKeySession, offlineMediaKeyId, offlineMediaKeyIdLen,
|
||||
releaseRequest, &releaseRequestLen);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
unsigned char testKeyReleaseResponse[50] = OFFRESPONSE;
|
||||
errNo = OH_MediaKeySession_ProcessOfflineReleaseResponse(mediaKeySession, offlineMediaKeyId, offlineMediaKeyIdLen,
|
||||
testKeyReleaseResponse, (int32_t)(sizeof(testKeyReleaseResponse)));
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySystem_GetOfflineMediaKeyStatus(mediaKeySystem, offlineMediaKeyId, offlineMediaKeyIdLen,
|
||||
&OfflineMediaKeyStatus);
|
||||
EXPECT_EQ(OfflineMediaKeyStatus, 2);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySession_RestoreOfflineMediaKeys(nullptr, offlineMediaKeyId, offlineMediaKeyIdLen);
|
||||
EXPECT_NE(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySession_RestoreOfflineMediaKeys(mediaKeySession, nullptr, offlineMediaKeyIdLen);
|
||||
EXPECT_NE(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySession_RestoreOfflineMediaKeys(mediaKeySession, offlineMediaKeyId, 0);
|
||||
EXPECT_NE(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySystem_GetOfflineMediaKeyStatus(mediaKeySystem, offlineMediaKeyId, offlineMediaKeyIdLen,
|
||||
&OfflineMediaKeyStatus);
|
||||
EXPECT_EQ(OfflineMediaKeyStatus, 2);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
TestPart_063(mediaKeySystem, mediaKeySession);
|
||||
errNo = OH_MediaKeySession_Destroy(mediaKeySession);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySystem_Destroy(mediaKeySystem);
|
||||
@@ -3189,8 +3217,8 @@ HWTEST_F(DrmFrameworkUnitTest, Drm_unittest_DecryptModuleNormal_067, TestSize.Le
|
||||
HWTEST_F(DrmFrameworkUnitTest, Drm_unittest_RestoreOfflineMediaKeysAbNormal_068, TestSize.Level0)
|
||||
{
|
||||
Drm_ErrCode errNo = DRM_ERR_UNKNOWN;
|
||||
unsigned char offlineMediaKeyId[2]; // 2:keyId len
|
||||
uint32_t offlineMediaKeyIdLen = 2; // 2:keyId len
|
||||
unsigned char offlineMediaKeyId[88]; // 2:keyId len
|
||||
uint32_t offlineMediaKeyIdLen = 88; // 2:keyId len
|
||||
MediaKeySession *mediaKeySession = (MediaKeySession *)&offlineMediaKeyId;
|
||||
errNo = OH_MediaKeySession_RestoreOfflineMediaKeys(mediaKeySession, offlineMediaKeyId, 0);
|
||||
EXPECT_NE(errNo, DRM_ERR_OK);
|
||||
@@ -3274,10 +3302,8 @@ HWTEST_F(DrmFrameworkUnitTest, Drm_unittest_MediaKeySystemDestroyAbNormal_071, T
|
||||
EXPECT_NE(mediaKeySystem, nullptr);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
unsigned char request[8192] = { 0 }; // 8192:request len
|
||||
int32_t requestLen = 8192; // 8192:request len
|
||||
int32_t valueLen = 32;
|
||||
int32_t requestLen = 8192, valueLen = 32, defaultUrlLen = 2048; // 8192:request len
|
||||
char defaultUrl[2048] = { 0 }; // 2048:url len
|
||||
int32_t defaultUrlLen = 2048; // 2048:url len
|
||||
errNo = OH_MediaKeySystem_GenerateKeySystemRequest(mediaKeySystem, request, &requestLen, defaultUrl,
|
||||
defaultUrlLen);
|
||||
unsigned char KeySystemResponse[50] = OFFRESPONSE;
|
||||
@@ -3289,8 +3315,10 @@ HWTEST_F(DrmFrameworkUnitTest, Drm_unittest_MediaKeySystemDestroyAbNormal_071, T
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySession_Destroy(mediaKeySession);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySystem_Destroy(mediaKeySystem);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
if (mediaKeySystem) {
|
||||
MediaKeySystemObject *systemObject = reinterpret_cast<MediaKeySystemObject *>(mediaKeySystem);
|
||||
systemObject->systemImpl_->~MediaKeySystemImpl();
|
||||
}
|
||||
errNo =
|
||||
OH_MediaKeySystem_SetConfigurationString(mediaKeySystem, "testConfigurationString", "testConfigurationString");
|
||||
EXPECT_NE(errNo, DRM_ERR_OK);
|
||||
@@ -3340,8 +3368,10 @@ HWTEST_F(DrmFrameworkUnitTest, Drm_unittest_OH_MediaKeySystemDestroyAbNormal2_07
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySession_Destroy(mediaKeySession);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySystem_Destroy(mediaKeySystem);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
if (mediaKeySystem) {
|
||||
MediaKeySystemObject *systemObject = reinterpret_cast<MediaKeySystemObject *>(mediaKeySystem);
|
||||
systemObject->systemImpl_->~MediaKeySystemImpl();
|
||||
}
|
||||
errNo = OH_MediaKeySystem_ProcessKeySystemResponse(mediaKeySystem, KeySystemResponse, KeySystemResponseLen);
|
||||
DRM_CertificateStatus certStatus = CERT_STATUS_INVALID;
|
||||
errNo = OH_MediaKeySystem_GetCertificateStatus(mediaKeySystem, &certStatus);
|
||||
@@ -3383,8 +3413,10 @@ HWTEST_F(DrmFrameworkUnitTest, Drm_unittest_MediaKeySessionDestroyAbNormal_073,
|
||||
errNo = OH_MediaKeySystem_CreateMediaKeySession(mediaKeySystem, &contentProtectionLevel, &mediaKeySession);
|
||||
EXPECT_NE(mediaKeySession, nullptr);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
errNo = OH_MediaKeySession_Destroy(mediaKeySession);
|
||||
EXPECT_EQ(errNo, DRM_ERR_OK);
|
||||
if (mediaKeySession) {
|
||||
MediaKeySessionObject *sessionObject = reinterpret_cast<MediaKeySessionObject *>(mediaKeySession);
|
||||
sessionObject->sessionImpl_->~MediaKeySessionImpl();
|
||||
}
|
||||
DRM_MediaKeyRequest mediaKeyRequest;
|
||||
DRM_MediaKeyRequestInfo info;
|
||||
unsigned char testData[139] = REQUESTINFODATA;
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace DrmStandard {
|
||||
namespace MediaKeySessionEvent {
|
||||
const std::string EVENT_STR_KEY_NEEDED = "keyRequired";
|
||||
const std::string EVENT_STR_KEY_EXPIRED = "keyExpired";
|
||||
const std::string EVENT_STR_EXPIRATION_UPDATED = "expirationUpdated";
|
||||
const std::string EVENT_STR_EXPIRATION_UPDATED = "expirationUpdate";
|
||||
const std::string EVENT_STR_KEY_CHANGED = "keysChange";
|
||||
const std::string EVENT_STR_VENDOR_DEFINED = "vendorDefined";
|
||||
}
|
||||
|
||||
@@ -32,15 +32,12 @@ config("drm_capi_common_config") {
|
||||
"-D_FORTIFY_SOURCE=2",
|
||||
"-Wformat=2",
|
||||
"-Wdate-time",
|
||||
"--coverage",
|
||||
]
|
||||
|
||||
cflags_cc = [
|
||||
"-std=c++17",
|
||||
"-fno-rtti",
|
||||
"--coverage",
|
||||
]
|
||||
ldflags = [ "--coverage" ]
|
||||
}
|
||||
|
||||
ohos_shared_library("native_drm") {
|
||||
|
||||
@@ -1,969 +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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file Defines the DRM capability.
|
||||
* @kit DrmKit
|
||||
*/
|
||||
|
||||
/**
|
||||
* This module provides the DRM capability to multimedia player.
|
||||
* @namespace drm
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
declare namespace drm {
|
||||
/**
|
||||
* Enumerates drm error code.
|
||||
* @enum { number }
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
enum DrmErrorCode {
|
||||
/**
|
||||
* All unknown errors.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
ERROR_UNKNOWN = 24700101,
|
||||
/**
|
||||
* Meet max MediaKeySystem num limit.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
MAX_SYSTEM_NUM_REACHED = 24700103,
|
||||
/**
|
||||
* Meet max MediaKeySession num limit.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
MAX_SESSION_NUM_REACHED = 24700104,
|
||||
/**
|
||||
* Service fatal error e.g. service died.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
SERVICE_FATAL_ERROR = 24700201
|
||||
}
|
||||
|
||||
/**
|
||||
* Enumerates which config name we can get.
|
||||
* @enum { string }
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
enum PreDefinedConfigName {
|
||||
/**
|
||||
* Config name vendor
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
CONFIG_DEVICE_VENDOR = 'vendor',
|
||||
/**
|
||||
* Config name version
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
CONFIG_DEVICE_VERSION = 'version',
|
||||
/**
|
||||
* Config name description
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
CONFIG_DEVICE_DESCRIPTION = 'description',
|
||||
/**
|
||||
* Config name algorithms
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
CONFIG_DEVICE_ALGORITHMS = 'algorithms',
|
||||
/**
|
||||
* Config name deviceUniqueId
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
CONFIG_DEVICE_UNIQUE_ID = 'deviceUniqueId',
|
||||
/**
|
||||
* Config name maxSessionNum
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
CONFIG_SESSION_MAX = 'maxSessionNum',
|
||||
/**
|
||||
* Config name currentSessionNum
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
CONFIG_SESSION_CURRENT = 'currentSessionNum',
|
||||
}
|
||||
/**
|
||||
* Enumerates event types of listener.
|
||||
* @enum { number }
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
enum ListenerType {
|
||||
/**
|
||||
* DRM event base.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
LISTENER_DRM_EVENT = 200,
|
||||
/**
|
||||
* Provision required event.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
LISTENER_PROVISION_REQUIRED = 201,
|
||||
/**
|
||||
* Media key required event.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
LISTENER_KEY_REQUIRED = 202,
|
||||
/**
|
||||
* Media key expired event.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
LISTENER_KEY_EXPIRED = 203,
|
||||
/**
|
||||
* Vendor defined event.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
LISTENER_VENDOR_DEFINED = 204,
|
||||
/**
|
||||
* Expiration update event.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
LISTENER_EXPIRATION_UPDATE = 206,
|
||||
/**
|
||||
* Media key change event.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
LISTENER_KEY_CHANGE = 207,
|
||||
}
|
||||
|
||||
/**
|
||||
* Enumerates media key type.
|
||||
* @enum { number }
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
enum MediaKeyType {
|
||||
/**
|
||||
* Offline media key type.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
MEDIA_KEY_TYPE_OFFLINE = 0,
|
||||
/**
|
||||
* Online media key type.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
MEDIA_KEY_TYPE_ONLINE,
|
||||
}
|
||||
|
||||
/**
|
||||
* Enumerates offline media key status.
|
||||
* @enum { number }
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
enum OfflineMediaKeyStatus {
|
||||
/**
|
||||
* Offline media key status unknown.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
OFFLINE_MEDIA_KEY_STATUS_UNKNOWN = 0,
|
||||
/**
|
||||
* Offline media key status usable.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
OFFLINE_MEDIA_KEY_STATUS_USABLE = 1,
|
||||
/**
|
||||
* Offline media key status inactive.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
OFFLINE_MEDIA_KEY_STATUS_INACTIVE = 2,
|
||||
}
|
||||
|
||||
/**
|
||||
* Enumerates certificate status.
|
||||
* @enum { number }
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
enum CertificateStatus {
|
||||
/**
|
||||
* Device already provisioned.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
CERT_STATUS_PROVISIONED = 0,
|
||||
/**
|
||||
* Device not provisioned.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
CERT_STATUS_NOT_PROVISIONED,
|
||||
/**
|
||||
* Cert already expired.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
CERT_STATUS_EXPIRED,
|
||||
/**
|
||||
* Certs are invalid.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
CERT_STATUS_INVALID,
|
||||
/**
|
||||
* Get certs status failed.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
CERT_STATUS_UNAVAILABLE,
|
||||
}
|
||||
|
||||
/**
|
||||
* Enumerates media key request types.
|
||||
* @enum { number }
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
enum MediaKeyRequestType {
|
||||
/**
|
||||
* Media key request type unknown.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
MEDIA_KEY_REQUEST_TYPE_UNKNOWN = 0,
|
||||
/**
|
||||
* Media key request type initial.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
MEDIA_KEY_REQUEST_TYPE_INITIAL = 1,
|
||||
/**
|
||||
* Media key request type renewal.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
MEDIA_KEY_REQUEST_TYPE_RENEWAL = 2,
|
||||
/**
|
||||
* Media key request type release.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
MEDIA_KEY_REQUEST_TYPE_RELEASE = 3,
|
||||
/**
|
||||
* Media key request type none.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
MEDIA_KEY_REQUEST_TYPE_NONE = 4,
|
||||
/**
|
||||
* Media key request type update.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
MEDIA_KEY_REQUEST_TYPE_UPDATE = 5,
|
||||
}
|
||||
|
||||
/**
|
||||
* Enumerates content protection level.
|
||||
* @enum { number }
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
enum ContentProtectionLevel {
|
||||
/**
|
||||
* Device decrypt and decode type unknown.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
CONTENT_PROTECTION_LEVEL_UNKNOWN = 0,
|
||||
/**
|
||||
* Device using software level.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
CONTENT_PROTECTION_LEVEL_SW_CRYPTO,
|
||||
/**
|
||||
* Device using hardware level.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
CONTENT_PROTECTION_LEVEL_HW_CRYPTO,
|
||||
/**
|
||||
* Device using enhanced hardware level.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
CONTENT_PROTECTION_LEVEL_ENHANCED_HW,
|
||||
/**
|
||||
* Max mode.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
CONTENT_PROTECTION_LEVEL_MAX,
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the drm provision request definitions.
|
||||
* @interface ProvisionRequest
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
interface ProvisionRequest {
|
||||
/**
|
||||
* Provision request data sent to provision server.
|
||||
* @type { Uint8Array }
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
data: Uint8Array;
|
||||
/**
|
||||
* Provision server URL.
|
||||
* @type { string }
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
defaultURL: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the drm media key request info optional data.
|
||||
* @interface OptionsData
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
interface OptionsData {
|
||||
/**
|
||||
* App defined optional data name.
|
||||
* @type { string }
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* App defined optional data value.
|
||||
* @type { string }
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
value: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the drm media key request definitions.
|
||||
* @interface MediaKeyRequest
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
interface MediaKeyRequest {
|
||||
/**
|
||||
* Media key request type.
|
||||
* @type { MediaKeyRequestType }
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
mediaKeyRequestType: MediaKeyRequestType;
|
||||
/**
|
||||
* Media key request data sent to media key server.
|
||||
* @type { Uint8Array }
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
data: Uint8Array;
|
||||
/**
|
||||
* Media key server URL.
|
||||
* @type { string }
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
defaultURL: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to indicates the event info attached to specific event type.
|
||||
* @interface EventInfo
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
interface EventInfo {
|
||||
/**
|
||||
* Event info.
|
||||
* @type { Uint8Array }
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
info: Uint8Array;
|
||||
/**
|
||||
* Event extra info.
|
||||
* @type { string }
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
extraInfo: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to indicates the statistic info.
|
||||
* @interface StatisticKeyValue
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
interface StatisticKeyValue {
|
||||
/**
|
||||
* Statistic info name.
|
||||
* @type { string }
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* Statistic info value.
|
||||
* @type { string }
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
value: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to indicates the media key status.
|
||||
* @interface MediaKeyStatus
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
interface MediaKeyStatus {
|
||||
/**
|
||||
* Media key Id in string.
|
||||
* @type { string }
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* Media key status description.
|
||||
* @type { string }
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
value: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to indicates the media key status with a key and its value.
|
||||
* @interface KeysInfo
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
interface KeysInfo {
|
||||
/**
|
||||
* Keys Id in media key.
|
||||
* @type { Uint8Array }
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
keyId: Uint8Array;
|
||||
/**
|
||||
* Keys status description.
|
||||
* @type { string }
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
value: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to indicates the media key system info of media source.
|
||||
* @interface MediaKeySystemInfo
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
interface MediaKeySystemInfo {
|
||||
/**
|
||||
* Drm system ID.
|
||||
* @type { string }
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
uuid: string;
|
||||
/**
|
||||
* PSSH(protection scheme specific header) contain drm info.
|
||||
* @type { Uint8Array }
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
pssh: Uint8Array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a MediaKeySystem name.
|
||||
* @param { string } uuid - The MediaKeySystem's uuid, normally gotten from media source.
|
||||
* @returns { string } The MediaKeySystem name, if not found.
|
||||
* @throws { BusinessError } 401 - The parameter check failed.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
function getMediaKeySystemName(uuid: string): string;
|
||||
|
||||
/**
|
||||
* Creates a MediaKeySystem instance.
|
||||
* @param { string } name - Used to point a Digital Right Management solution.
|
||||
* @returns { MediaKeySystem } The MediaKeySystem instance.
|
||||
* @throws { BusinessError } 401 - The parameter check failed.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @throws { BusinessError } 24700103 - Meet max MediaKeySystem num limit.
|
||||
* @throws { BusinessError } 24700201 - Service fatal error e.g. service died.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
function createMediaKeySystem(name: string): MediaKeySystem;
|
||||
|
||||
/**
|
||||
* Judge whether a system that specifies name, mimetype and content protection level is supported.
|
||||
* @param { string } name - Used to point a Digital Right Management solution.
|
||||
* @param { string } mimeType - Used to specifies the media type.
|
||||
* @param { ContentProtectionLevel } level - Used to specifies the ContentProtectionLevel.
|
||||
* @returns { boolean } Whether these conditions will be met.
|
||||
* @throws { BusinessError } 401 - The parameter check failed.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @throws { BusinessError } 24700201 - Service fatal error e.g. service died.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
function isMediaKeySystemSupported(name: string, mimeType: string, level: ContentProtectionLevel): boolean;
|
||||
|
||||
/**
|
||||
* Judge whether a system that specifies name, mimetype is supported.
|
||||
* @param { string } name - Used to point a Digital Right Management solution.
|
||||
* @param { string } mimeType - Used to specifies the media type.
|
||||
* @returns { boolean } Whether these conditions will be met.
|
||||
* @throws { BusinessError } 401 - The parameter check failed.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @throws { BusinessError } 24700201 - Service fatal error e.g. service died.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
function isMediaKeySystemSupported(name: string, mimeType: string): boolean;
|
||||
|
||||
/**
|
||||
* Judge whether a system that specifies name is supported.
|
||||
* @param { string } name - Used to point a Digital Right Management solution.
|
||||
* @returns { boolean } Whether these conditions will be met.
|
||||
* @throws { BusinessError } 401 - The parameter check failed.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @throws { BusinessError } 24700201 - Service fatal error e.g. service died.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
function isMediaKeySystemSupported(name: string): boolean;
|
||||
|
||||
/**
|
||||
* Manages and record MediaKeySessions. Before calling an MediaKeySystem method, we must use getMediaKeySystem
|
||||
* to get a MediaKeySystem instance, then we can call functions.
|
||||
* @interface MediaKeySystem
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*
|
||||
*/
|
||||
interface MediaKeySystem {
|
||||
/**
|
||||
* Get the specified configuration.
|
||||
* @param { string } - configName - Used to specify the config name.
|
||||
* @returns { string } The config value string.
|
||||
* @throws { BusinessError } 401 - The parameter check failed.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @throws { BusinessError } 24700201 - Service fatal error e.g. service died.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
getConfigurationString(configName: string): string;
|
||||
|
||||
/**
|
||||
* Set the specified configuration.
|
||||
* @param { string } configName - Used to specify the config name.
|
||||
* @param { string } value - The value to be set.
|
||||
* @throws { BusinessError } 401 - The parameter check failed.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @throws { BusinessError } 24700201 - Service fatal error e.g. service died.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
setConfigurationString(configName: string, value: string): void;
|
||||
|
||||
/**
|
||||
* Get the specified configuration.
|
||||
* @param { string } configName - Used to specify the config name.
|
||||
* @returns { Uint8Array } The config value.
|
||||
* @throws { BusinessError } 401 - The parameter check failed.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @throws { BusinessError } 24700201 - Service fatal error e.g. service died.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
getConfigurationByteArray(configName: string): Uint8Array;
|
||||
|
||||
/**
|
||||
* Set the specified configuration.
|
||||
* @param { string } configName - Used to specify the config name.
|
||||
* @param { Uint8Array } value - The value to be set.
|
||||
* @throws { BusinessError } 401 - The parameter check failed.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @throws { BusinessError } 24700201 - Service fatal error e.g. service died.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
setConfigurationByteArray(configName: string, value: Uint8Array): void;
|
||||
|
||||
/**
|
||||
* Get performance statistics information.That includes currentSessionNum, version, decryptNumber,
|
||||
* and errorDecryptNumber.
|
||||
* @returns { StatisticKeyValue[] } A list that includes performance index and corresponding statistics.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @throws { BusinessError } 24700201 - Service fatal error e.g. service died.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
getStatistics(): StatisticKeyValue[];
|
||||
|
||||
/**
|
||||
* Get max content protection level the device supports.
|
||||
* @returns { ContentProtectionLevel } The max content protection level of the MediaKeySystem instance.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @throws { BusinessError } 24700201 - Service fatal error e.g. service died.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
getMaxContentProtectionLevel(): ContentProtectionLevel;
|
||||
|
||||
/**
|
||||
* Generate a media key system provision request.
|
||||
* @returns { Promise<ProvisionRequest> } Promise with ProvisionRequest used to return the result.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @throws { BusinessError } 24700201 - Service fatal error e.g. service died.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
|
||||
generateKeySystemRequest(): Promise<ProvisionRequest>;
|
||||
|
||||
/**
|
||||
* Process the response corresponding the key system request obtained by the application.
|
||||
* @param { Uint8Array } response - Response corresponding to the request.
|
||||
* @returns { Promise<void> } Promise used to return the result.
|
||||
* @throws { BusinessError } 401 - The parameter check failed.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @throws { BusinessError } 24700201 - Service fatal error e.g. service died.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
processKeySystemResponse(response: Uint8Array): Promise<void>;
|
||||
|
||||
/**
|
||||
* Get certificate status of the MediaKeySystem.
|
||||
* @returns { CertificateStatus } Certificate Status of the MediaKeySystem instance.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @throws { BusinessError } 24700201 - Service fatal error e.g. service died.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
getCertificateStatus(): CertificateStatus;
|
||||
|
||||
/**
|
||||
* Register or unregister listens for drm events.
|
||||
* @param { 'keySystemRequired' } type - Type of the drm event to listen for.
|
||||
* @param { function } callback - Used to listen for the key system required event.
|
||||
* @throws { BusinessError } 401 - The parameter check failed.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
on(type: 'keySystemRequired', callback: (eventInfo: EventInfo) => void): void;
|
||||
|
||||
off(type: 'keySystemRequired', callback?: (eventInfo: EventInfo) => void): void;
|
||||
|
||||
/**
|
||||
* Create a MediaKeySession instance with level.
|
||||
* @param { ContentProtectionLevel } level - Used to specify the content protection level.
|
||||
* @returns { MediaKeySession } A MediaKeySession instance.
|
||||
* @throws { BusinessError } 401 - The parameter check failed.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @throws { BusinessError } 24700104 - Meet max MediaKeySession num limit.
|
||||
* @throws { BusinessError } 24700201 - Service fatal error e.g. service died.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
createMediaKeySession(level: ContentProtectionLevel): MediaKeySession;
|
||||
|
||||
/**
|
||||
* Create a MediaKeySession instance.
|
||||
* @returns { MediaKeySession } A MediaKeySession instance.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @throws { BusinessError } 24700104 - Meet max MediaKeySession num limit.
|
||||
* @throws { BusinessError } 24700201 - Service fatal error e.g. service died.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
createMediaKeySession(): MediaKeySession;
|
||||
|
||||
/**
|
||||
* Get the list of offline MediaKeyIds.
|
||||
* @returns { Uint8Array[] } The list of offline MediaKeyIds.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @throws { BusinessError } 24700201 - Service fatal error e.g. service died.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
getOfflineMediaKeyIds(): Uint8Array[];
|
||||
|
||||
/**
|
||||
* Get offline media key status corresponding to the mediaKeyId.
|
||||
* @param { Uint8Array } mediaKeyId - The media key identifier.
|
||||
* @returns { OfflineMediaKeyStatus } Offline media key Status.
|
||||
* @throws { BusinessError } 401 - The parameter check failed.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @throws { BusinessError } 24700201 - Service fatal error e.g. service died.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
getOfflineMediaKeyStatus(mediaKeyId: Uint8Array): OfflineMediaKeyStatus;
|
||||
|
||||
/**
|
||||
* Remove media key corresponding to the mediaKeyId.
|
||||
* @param { Uint8Array } mediaKeyId - The mediaKeyId specifies which media key should be clear.
|
||||
* @throws { BusinessError } 401 - The parameter check failed.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @throws { BusinessError } 24700201 - Service fatal error e.g. service died.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
clearOfflineMediaKeys(mediaKeyId: Uint8Array): void;
|
||||
/**
|
||||
* Release the resource before the MediaKeySystem gonna be unused.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @throws { BusinessError } 24700201 - Service fatal error e.g. service died.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
destroy(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide functions and keep a decrypt module. Before calling an MediaKeySession method, we must
|
||||
* use MediaKeySystem's createMediaKeySession to get a MediaKeySession instance.
|
||||
* @interface MediaKeySession
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
interface MediaKeySession {
|
||||
|
||||
/**
|
||||
* Generate the media key request.
|
||||
* @param { string } mimeType - Media type.
|
||||
* @param { Uint8Array } initData - PSSH after base64 encoding.
|
||||
* @param { number } mediaKeyType - Offline or online.
|
||||
* @param { OptionsData[] } options - Optional data the application set to drm framework.
|
||||
* @returns { Promise<MediaKeyRequest> } Promise with MediaKeyRequest used to return the result.
|
||||
* @throws { BusinessError } 401 - The parameter check failed.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @throws { BusinessError } 24700201 - Service fatal error e.g. service died.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
generateMediaKeyRequest(mimeType: string, initData: Uint8Array, mediaKeyType: number, options?: OptionsData[]): Promise<MediaKeyRequest>;
|
||||
|
||||
/**
|
||||
* Process the response corresponding to the media key request obtained by the application.
|
||||
* @param { Uint8Array } response - The response.
|
||||
* @returns { Promise<Uint8Array> } Promise with media key identifier in Uint8ARRY used to return the result.
|
||||
* @throws { BusinessError } 401 - The parameter check failed.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @throws { BusinessError } 24700201 - Service fatal error e.g. service died.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
processMediaKeyResponse(response: Uint8Array): Promise<Uint8Array>;
|
||||
|
||||
/**
|
||||
* Check the media key status
|
||||
* @returns { MediaKeyStatus[] } A list of media key status description pairs.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @throws { BusinessError } 24700201 - Service fatal error e.g. service died.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
checkMediaKeyStatus(): MediaKeyStatus[];
|
||||
|
||||
/**
|
||||
* Remove media key.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @throws { BusinessError } 24700201 - Service fatal error e.g. service died.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
clearMediaKeys(): void;
|
||||
|
||||
/**
|
||||
* Generate offline media key request.
|
||||
* @param { Uint8Array } mediaKeyId - The mediaKeyId specifies which media content's media key request
|
||||
* should be generated.
|
||||
* @returns { Promise<Uint8Array> } Promise with media key request in Uint8Array used to return the result.
|
||||
* @throws { BusinessError } 401 - The parameter check failed.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @throws { BusinessError } 24700201 - Service fatal error e.g. service died.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
generateOfflineReleaseRequest(mediaKeyId: Uint8Array): Promise<Uint8Array>;
|
||||
|
||||
/**
|
||||
* Process offline media key response.
|
||||
* @param { Uint8Array } mediaKeyId - The mediaKeyId specifies which media content's media key it is.
|
||||
* @param { Uint8Array } response - The offline media key.
|
||||
* @returns { Promise<void> } Promise used to return the result.
|
||||
* @throws { BusinessError } 401 - The parameter check failed.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @throws { BusinessError } 24700201 - Service fatal error e.g. service died.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
processOfflineReleaseResponse(mediaKeyId: Uint8Array, response: Uint8Array): Promise<void>;
|
||||
|
||||
/**
|
||||
* Restore offline media key.
|
||||
* @param { Uint8Array } mediaKeyId - The mediaKeyId specifies which media key should be restore.
|
||||
* @returns { Promise<void> } Promise used to return the result.
|
||||
* @throws { BusinessError } 401 - The parameter check failed.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @throws { BusinessError } 24700201 - Service fatal error e.g. service died.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
restoreOfflineMediaKeys(mediaKeyId: Uint8Array): Promise<void>;
|
||||
|
||||
/**
|
||||
* Get content protection level.
|
||||
* @returns { ContentProtectionLevel } MediaKeySession content protection level.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @throws { BusinessError } 24700201 - Service fatal error e.g. service died.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
getContentProtectionLevel(): ContentProtectionLevel;
|
||||
|
||||
/**
|
||||
* Whether the encrypted content require a secure decoder or not.
|
||||
* @param { string } mimeType - The media type.
|
||||
* @returns { boolean } Whether secure decoder is required.
|
||||
* @throws { BusinessError } 401 - The parameter check failed.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @throws { BusinessError } 24700201 - Service fatal error e.g. service died.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
requireSecureDecoderModule(mimeType: string): boolean;
|
||||
|
||||
/**
|
||||
* Register or unregister keyRequired event.
|
||||
* @param { 'keyRequired' } type - Type of the drm event to listen for.
|
||||
* @param { function } callback used to listen for the key required event.
|
||||
* @throws { BusinessError } 401 - The parameter check failed.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
on(type: 'keyRequired', callback: (eventInfo: EventInfo) => void): void;
|
||||
|
||||
off(type: 'keyRequired', callback?: (eventInfo: EventInfo) => void): void;
|
||||
|
||||
/**
|
||||
* Register or unregister keyExpired event.
|
||||
* @param { 'keyExpired' } type - Type of the drm event to listen for.
|
||||
* @param { function } callback - Used to listen for the key required event.
|
||||
* @throws { BusinessError } 401 - The parameter check failed.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
on(type: 'keyExpired', callback: (eventInfo: EventInfo) => void): void;
|
||||
|
||||
off(type: 'keyExpired', callback?: (eventInfo: EventInfo) => void): void;
|
||||
|
||||
/**
|
||||
* Register or unregister vendorDefined event.
|
||||
* @param { 'vendorDefined' } type - Type of the drm event to listen for.
|
||||
* @param { function } callback - Used to listen for the vendor defined event.
|
||||
* @throws { BusinessError } 401 - The parameter check failed.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
on(type: 'vendorDefined', callback: (eventInfo: EventInfo) => void): void;
|
||||
|
||||
off(type: 'vendorDefined', callback?: (eventInfo: EventInfo) => void): void;
|
||||
|
||||
/**
|
||||
* Register or unregister expirationUpdate event.
|
||||
* @param { 'expirationUpdate' } type - Type of the drm event to listen for.
|
||||
* @param { function } callback - Used to listen for expiration update event.
|
||||
* @throws { BusinessError } 401 - The parameter check failed.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
on(type: 'expirationUpdate', callback: (eventInfo: EventInfo) => void): void;
|
||||
|
||||
off(type: 'expirationUpdate', callback?: (eventInfo: EventInfo) => void): void;
|
||||
|
||||
/**
|
||||
* Register or unregister keysChange event.
|
||||
* @param { 'keysChange' } type - Type of the drm event to listen for.
|
||||
* @param { function } callback - Used to listen for keys change event.
|
||||
* @throws { BusinessError } 401 - The parameter check failed.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
on(type: 'keysChange', callback: (keyInfo: KeysInfo[], newKeyAvailable: boolean) => void): void;
|
||||
|
||||
off(type: 'keysChange', callback?: (keyInfo: KeysInfo[], newKeyAvailable: boolean) => void): void;
|
||||
|
||||
/**
|
||||
* Release the resource before the session gonna be unused.
|
||||
* @throws { BusinessError } 24700101 - All unknown errors.
|
||||
* @throws { BusinessError } 24700201 - Service fatal error e.g. service died.
|
||||
* @syscap SystemCapability.Multimedia.Drm.Core
|
||||
* @since 11
|
||||
*/
|
||||
destroy(): void;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export default drm;
|
||||
@@ -67,11 +67,7 @@ ohos_shared_library("drm_napi") {
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
}
|
||||
cflags = [
|
||||
"-fPIC",
|
||||
"--coverage",
|
||||
]
|
||||
ldflags = [ "--coverage" ]
|
||||
cflags = [ "-fPIC" ]
|
||||
cflags_cc = cflags
|
||||
relative_install_dir = "module/multimedia"
|
||||
part_name = "drm_framework"
|
||||
|
||||
@@ -66,9 +66,7 @@ ohos_shared_library("drm_service") {
|
||||
cflags = [
|
||||
"-Wall",
|
||||
"-fPIC",
|
||||
"--coverage",
|
||||
]
|
||||
ldflags = [ "--coverage" ]
|
||||
if (target_cpu == "arm") {
|
||||
cflags += [ "-DBINDER_IPC_32BIT" ]
|
||||
}
|
||||
|
||||
@@ -126,7 +126,6 @@ private:
|
||||
int32_t MediaKeySessionStubGetVersion(MessageParcel &mediaKeySessionData, MessageParcel &mediaKeySessionReply,
|
||||
MessageOption &mediaKeySessionOption);
|
||||
|
||||
|
||||
static inline ObjectDelegator<OHOS::HDI::Drm::V1_0::MediaKeySessionStub, OHOS::HDI::Drm::V1_0::IMediaKeySession>
|
||||
objDelegator_;
|
||||
sptr<OHOS::HDI::Drm::V1_0::IMediaKeySession> impl_;
|
||||
|
||||
@@ -152,7 +152,6 @@ private:
|
||||
int32_t MediaKeySystemStubGetVersion(MessageParcel &mediaKeySystemData, MessageParcel &mediaKeySystemReply,
|
||||
MessageOption &mediaKeySystemOption);
|
||||
|
||||
|
||||
static inline ObjectDelegator<OHOS::HDI::Drm::V1_0::MediaKeySystemStub, OHOS::HDI::Drm::V1_0::IMediaKeySystem>
|
||||
objDelegator_;
|
||||
sptr<OHOS::HDI::Drm::V1_0::IMediaKeySystem> impl_;
|
||||
|
||||
@@ -56,7 +56,6 @@ private:
|
||||
int32_t OemCertificateStubGetVersion(MessageParcel &oemCertificateData, MessageParcel &oemCertificateReply,
|
||||
MessageOption &oemCertificateOption);
|
||||
|
||||
|
||||
static inline ObjectDelegator<OHOS::HDI::Drm::V1_0::OemCertificateStub, OHOS::HDI::Drm::V1_0::IOemCertificate>
|
||||
objDelegator_;
|
||||
sptr<OHOS::HDI::Drm::V1_0::IOemCertificate> impl_;
|
||||
|
||||
@@ -81,9 +81,7 @@ void DrmHostManager::ProcessMessage()
|
||||
std::thread([this] {
|
||||
while (serviceThreadRunning) {
|
||||
std::unique_lock<std::mutex> lock(queueMutex);
|
||||
cv.wait(lock, [this] {
|
||||
return !this->messageQueue.empty();
|
||||
});
|
||||
cv.wait(lock, [this] { return !this->messageQueue.empty(); });
|
||||
while (!messageQueue.empty()) {
|
||||
auto message = messageQueue.front();
|
||||
messageQueue.pop();
|
||||
|
||||
Reference in New Issue
Block a user