diff --git a/libwvdrmengine/cdm/core/include/cdm_engine.h b/libwvdrmengine/cdm/core/include/cdm_engine.h index 0de009c5..fb1eec33 100644 --- a/libwvdrmengine/cdm/core/include/cdm_engine.h +++ b/libwvdrmengine/cdm/core/include/cdm_engine.h @@ -168,7 +168,7 @@ class CdmEngine { void OnKeyReleaseEvent(const CdmKeySetId& key_set_id); - std::string MapHdcpVersion(CryptoSession::OemCryptoHdcpVersion version); + std::string MapHdcpVersion(CryptoSession::HdcpCapability version); // instance variables CdmSessionMap sessions_; diff --git a/libwvdrmengine/cdm/core/include/crypto_session.h b/libwvdrmengine/cdm/core/include/crypto_session.h index 13698492..1e8d52c2 100644 --- a/libwvdrmengine/cdm/core/include/crypto_session.h +++ b/libwvdrmengine/cdm/core/include/crypto_session.h @@ -18,18 +18,7 @@ typedef std::map CryptoKeyMap; class CryptoSession { public: - // This enum should be kept in sync with the values specified for - // HDCP capabilities in OEMCryptoCENC.h. (See comments for - // OEMCrypto_GetHDCPCapability) - typedef enum { - kOemCryptoHdcpNotSupported = 0, - kOemCryptoHdcpVersion1 = 1, - kOemCryptoHdcpVersion2 = 2, - kOemCryptoHdcpVersion2_1 = 3, - kOemCryptoHdcpVersion2_2 = 4, - kOemCryptoNoHdcpDeviceAttached = 0xff, - } OemCryptoHdcpVersion; - + typedef OEMCrypto_HDCP_Capability HdcpCapability; typedef enum { kUsageDurationsInvalid = 0, kUsageDurationPlaybackNotBegun = 1, @@ -107,8 +96,8 @@ class CryptoSession { virtual CdmResponseType DeleteAllUsageReports(); virtual bool IsAntiRollbackHwPresent(); - virtual bool GetHdcpCapabilities(OemCryptoHdcpVersion* current, - OemCryptoHdcpVersion* max); + virtual bool GetHdcpCapabilities(HdcpCapability* current, + HdcpCapability* max); virtual bool GetRandom(size_t data_length, uint8_t* random_data); virtual bool GetNumberOfOpenSessions(size_t* count); virtual bool GetMaxNumberOfSessions(size_t* max); diff --git a/libwvdrmengine/cdm/core/include/max_res_engine.h b/libwvdrmengine/cdm/core/include/max_res_engine.h index 53f52514..9a28d140 100644 --- a/libwvdrmengine/cdm/core/include/max_res_engine.h +++ b/libwvdrmengine/cdm/core/include/max_res_engine.h @@ -62,19 +62,19 @@ class MaxResEngine { bool can_decrypt() const { return can_decrypt_; } void Update(uint32_t res, - CryptoSession::OemCryptoHdcpVersion current_hdcp_level); + CryptoSession::HdcpCapability current_hdcp_level); private: void Init(const ConstraintList& constraints); VideoResolutionConstraint* GetConstraintForRes(uint32_t res); - static CryptoSession::OemCryptoHdcpVersion ProtobufHdcpToOemCryptoHdcp( + static CryptoSession::HdcpCapability ProtobufHdcpToOemCryptoHdcp( const OutputProtection::HDCP& input); bool can_decrypt_; - CryptoSession::OemCryptoHdcpVersion default_hdcp_level_; + CryptoSession::HdcpCapability default_hdcp_level_; ConstraintList constraints_; }; diff --git a/libwvdrmengine/cdm/core/src/cdm_engine.cpp b/libwvdrmengine/cdm/core/src/cdm_engine.cpp index 0fdc331a..a67e491a 100644 --- a/libwvdrmengine/cdm/core/src/cdm_engine.cpp +++ b/libwvdrmengine/cdm/core/src/cdm_engine.cpp @@ -428,8 +428,8 @@ CdmResponseType CdmEngine::QueryStatus(CdmQueryMap* key_info) { (*key_info)[QUERY_KEY_PROVISIONING_ID] = provisioning_id; } - CryptoSession::OemCryptoHdcpVersion current_hdcp; - CryptoSession::OemCryptoHdcpVersion max_hdcp; + CryptoSession::HdcpCapability current_hdcp; + CryptoSession::HdcpCapability max_hdcp; success = crypto_session.GetHdcpCapabilities(¤t_hdcp, &max_hdcp); if (success) { (*key_info)[QUERY_KEY_CURRENT_HDCP_LEVEL] = MapHdcpVersion(current_hdcp); @@ -927,20 +927,20 @@ void CdmEngine::OnKeyReleaseEvent(const CdmKeySetId& key_set_id) { } std::string CdmEngine::MapHdcpVersion( - CryptoSession::OemCryptoHdcpVersion version) { + CryptoSession::HdcpCapability version) { switch (version) { - case CryptoSession::kOemCryptoNoHdcpDeviceAttached: - return QUERY_VALUE_DISCONNECTED; - case CryptoSession::kOemCryptoHdcpNotSupported: + case HDCP_NONE: return QUERY_VALUE_UNPROTECTED; - case CryptoSession::kOemCryptoHdcpVersion1: + case HDCP_V1: return QUERY_VALUE_HDCP_V1; - case CryptoSession::kOemCryptoHdcpVersion2: + case HDCP_V2: return QUERY_VALUE_HDCP_V2_0; - case CryptoSession::kOemCryptoHdcpVersion2_1: + case HDCP_V2_1: return QUERY_VALUE_HDCP_V2_1; - case CryptoSession::kOemCryptoHdcpVersion2_2: + case HDCP_V2_2: return QUERY_VALUE_HDCP_V2_2; + case HDCP_NO_DIGITAL_OUTPUT: + return QUERY_VALUE_DISCONNECTED; } return ""; } diff --git a/libwvdrmengine/cdm/core/src/crypto_session.cpp b/libwvdrmengine/cdm/core/src/crypto_session.cpp index 3843b8a5..d36245bd 100644 --- a/libwvdrmengine/cdm/core/src/crypto_session.cpp +++ b/libwvdrmengine/cdm/core/src/crypto_session.cpp @@ -994,27 +994,20 @@ bool CryptoSession::RewrapDeviceRSAKey(const std::string& message, return true; } -bool CryptoSession::GetHdcpCapabilities(OemCryptoHdcpVersion* current_version, - OemCryptoHdcpVersion* max_version) { +bool CryptoSession::GetHdcpCapabilities(HdcpCapability* current, + HdcpCapability* max) { LOGV("GetHdcpCapabilities: id=%ld", (uint32_t)oec_session_id_); if (!initialized_) return false; - if (current_version == NULL || max_version == NULL) { - LOGE( - "CryptoSession::GetHdcpCapabilities: |current_version|, " - "|max_version| cannot be NULL"); + if (current == NULL || max == NULL) { + LOGE("CryptoSession::GetHdcpCapabilities: |current|, |max| cannot be NULL"); return false; } - OEMCrypto_HDCP_Capability current, max; OEMCryptoResult status = OEMCrypto_GetHDCPCapability( - requested_security_level_, ¤t, &max); - + requested_security_level_, current, max); if (OEMCrypto_SUCCESS != status) { LOGW("OEMCrypto_GetHDCPCapability fails with %d", status); return false; } - *current_version = static_cast(current); - *max_version = static_cast(max); - return true; } diff --git a/libwvdrmengine/cdm/core/src/license.cpp b/libwvdrmengine/cdm/core/src/license.cpp index 6a70cad0..1aacd692 100644 --- a/libwvdrmengine/cdm/core/src/license.cpp +++ b/libwvdrmengine/cdm/core/src/license.cpp @@ -282,35 +282,35 @@ bool CdmLicense::PrepareKeyRequest(const InitializationData& init_data, client_capabilities->set_oem_crypto_api_version(api_version); } - CryptoSession::OemCryptoHdcpVersion current_version, max_version; + CryptoSession::HdcpCapability current_version, max_version; if (session_->GetHdcpCapabilities(¤t_version, &max_version)) { switch (max_version) { - case CryptoSession::kOemCryptoHdcpNotSupported: + case HDCP_NONE: client_capabilities->set_max_hdcp_version( video_widevine_server::sdk:: ClientIdentification_ClientCapabilities_HdcpVersion_HDCP_NONE); break; - case CryptoSession::kOemCryptoHdcpVersion1: + case HDCP_V1: client_capabilities->set_max_hdcp_version( video_widevine_server::sdk:: ClientIdentification_ClientCapabilities_HdcpVersion_HDCP_V1); break; - case CryptoSession::kOemCryptoHdcpVersion2: + case HDCP_V2: client_capabilities->set_max_hdcp_version( video_widevine_server::sdk:: ClientIdentification_ClientCapabilities_HdcpVersion_HDCP_V2); break; - case CryptoSession::kOemCryptoHdcpVersion2_1: + case HDCP_V2_1: client_capabilities->set_max_hdcp_version( video_widevine_server::sdk:: ClientIdentification_ClientCapabilities_HdcpVersion_HDCP_V2_1); break; - case CryptoSession::kOemCryptoHdcpVersion2_2: + case HDCP_V2_2: client_capabilities->set_max_hdcp_version( video_widevine_server::sdk:: ClientIdentification_ClientCapabilities_HdcpVersion_HDCP_V2_2); break; - case CryptoSession::kOemCryptoNoHdcpDeviceAttached: + case HDCP_NO_DIGITAL_OUTPUT: client_capabilities->set_max_hdcp_version( video_widevine_server::sdk:: ClientIdentification_ClientCapabilities_HdcpVersion_HDCP_NO_DIGITAL_OUTPUT); diff --git a/libwvdrmengine/cdm/core/src/max_res_engine.cpp b/libwvdrmengine/cdm/core/src/max_res_engine.cpp index ad9214a4..fbc28a81 100644 --- a/libwvdrmengine/cdm/core/src/max_res_engine.cpp +++ b/libwvdrmengine/cdm/core/src/max_res_engine.cpp @@ -76,10 +76,10 @@ void MaxResEngine::OnTimerEvent() { int64_t current_time = clock_->GetCurrentTime(); if (!keys_.empty() && current_resolution_ != kNoResolution && current_time >= next_check_time_) { - CryptoSession::OemCryptoHdcpVersion current_hdcp_level; - CryptoSession::OemCryptoHdcpVersion ignored; + CryptoSession::HdcpCapability current_hdcp_level; + CryptoSession::HdcpCapability ignored; if (!crypto_session_->GetHdcpCapabilities(¤t_hdcp_level, &ignored)) { - current_hdcp_level = CryptoSession::kOemCryptoHdcpNotSupported; + current_hdcp_level = HDCP_NONE; } for (KeyIterator i = keys_.begin(); i != keys_.end(); ++i) { i->second->Update(current_resolution_, current_hdcp_level); @@ -95,7 +95,7 @@ void MaxResEngine::DeleteAllKeys() { } MaxResEngine::KeyStatus::KeyStatus(const ConstraintList& constraints) - : default_hdcp_level_(CryptoSession::kOemCryptoHdcpNotSupported) { + : default_hdcp_level_(HDCP_NONE) { Init(constraints); } @@ -113,7 +113,7 @@ void MaxResEngine::KeyStatus::Init(const ConstraintList& constraints) { } void MaxResEngine::KeyStatus::Update( - uint32_t res, CryptoSession::OemCryptoHdcpVersion current_hdcp_level) { + uint32_t res, CryptoSession::HdcpCapability current_hdcp_level) { VideoResolutionConstraint* current_constraint = GetConstraintForRes(res); if (current_constraint == NULL) { @@ -121,7 +121,7 @@ void MaxResEngine::KeyStatus::Update( return; } - CryptoSession::OemCryptoHdcpVersion desired_hdcp_level; + CryptoSession::HdcpCapability desired_hdcp_level; if (current_constraint->has_required_protection()) { desired_hdcp_level = ProtobufHdcpToOemCryptoHdcp( current_constraint->required_protection().hdcp()); @@ -147,25 +147,26 @@ MaxResEngine::KeyStatus::GetConstraintForRes(uint32_t res) { return NULL; } -CryptoSession::OemCryptoHdcpVersion +CryptoSession::HdcpCapability MaxResEngine::KeyStatus::ProtobufHdcpToOemCryptoHdcp( const OutputProtection::HDCP& input) { switch (input) { case OutputProtection::HDCP_NONE: - return CryptoSession::kOemCryptoHdcpNotSupported; + return HDCP_NONE; case OutputProtection::HDCP_V1: - return CryptoSession::kOemCryptoHdcpVersion1; + return HDCP_V1; case OutputProtection::HDCP_V2: - return CryptoSession::kOemCryptoHdcpVersion2; + return HDCP_V2; case OutputProtection::HDCP_V2_1: - return CryptoSession::kOemCryptoHdcpVersion2_1; + return HDCP_V2_1; case OutputProtection::HDCP_V2_2: - return CryptoSession::kOemCryptoHdcpVersion2_2; + return HDCP_V2_2; + case OutputProtection::HDCP_NO_DIGITAL_OUTPUT: + return HDCP_NO_DIGITAL_OUTPUT; default: - LOGE( - "MaxResEngine::KeyStatus::ProtobufHdcpToOemCryptoHdcp: " - "Unknown HDCP Level"); - return CryptoSession::kOemCryptoNoHdcpDeviceAttached; + LOGE("MaxResEngine::KeyStatus::ProtobufHdcpToOemCryptoHdcp: " + "Unknown HDCP Level"); + return HDCP_NO_DIGITAL_OUTPUT; } } diff --git a/libwvdrmengine/cdm/core/test/license_unittest.cpp b/libwvdrmengine/cdm/core/test/license_unittest.cpp index 43c5cbbf..73d99659 100644 --- a/libwvdrmengine/cdm/core/test/license_unittest.cpp +++ b/libwvdrmengine/cdm/core/test/license_unittest.cpp @@ -97,8 +97,7 @@ class MockCryptoSession : public CryptoSession { MOCK_METHOD0(IsOpen, bool()); MOCK_METHOD1(GenerateRequestId, bool(std::string*)); MOCK_METHOD1(UsageInformationSupport, bool(bool*)); - MOCK_METHOD2(GetHdcpCapabilities, - bool(OemCryptoHdcpVersion*, OemCryptoHdcpVersion*)); + MOCK_METHOD2(GetHdcpCapabilities, bool(HdcpCapability*, HdcpCapability*)); MOCK_METHOD1(GetApiVersion, bool(uint32_t*)); MOCK_METHOD1(GenerateNonce, bool(uint32_t*)); MOCK_METHOD3(PrepareRequest, bool(const std::string&, bool, std::string*)); @@ -178,10 +177,8 @@ TEST_F(CdmLicenseTest, InitFail_PolicyEngineNull) { TEST_F(CdmLicenseTest, PrepareKeyRequestValidation) { bool usage_information_support = true; - CryptoSession::OemCryptoHdcpVersion current_hdcp_version = - CryptoSession::kOemCryptoNoHdcpDeviceAttached; - CryptoSession::OemCryptoHdcpVersion max_hdcp_version = - CryptoSession::kOemCryptoHdcpVersion2_1; + CryptoSession::HdcpCapability current_hdcp_version = HDCP_NO_DIGITAL_OUTPUT; + CryptoSession::HdcpCapability max_hdcp_version = HDCP_V2_1; uint32_t crypto_session_api_version = 9; EXPECT_CALL(*crypto_session_, IsOpen()).WillOnce(Return(true)); diff --git a/libwvdrmengine/cdm/core/test/max_res_engine_unittest.cpp b/libwvdrmengine/cdm/core/test/max_res_engine_unittest.cpp index d5d0e2bd..34289f9f 100644 --- a/libwvdrmengine/cdm/core/test/max_res_engine_unittest.cpp +++ b/libwvdrmengine/cdm/core/test/max_res_engine_unittest.cpp @@ -49,8 +49,7 @@ const int64_t kHdcpInterval = 10; class HdcpOnlyMockCryptoSession : public CryptoSession { public: - MOCK_METHOD2(GetHdcpCapabilities, - bool(OemCryptoHdcpVersion*, OemCryptoHdcpVersion*)); + MOCK_METHOD2(GetHdcpCapabilities, bool(HdcpCapability*, HdcpCapability*)); }; ACTION_P2(IncrementAndReturnPointee, p, a) { @@ -188,7 +187,7 @@ TEST_F(MaxResEngineTest, IsPermissiveWithoutAResolution) { TEST_F(MaxResEngineTest, HandlesResolutionsBasedOnConstraints) { EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _)) .WillRepeatedly( - DoAll(SetArgPointee<0>(CryptoSession::kOemCryptoNoHdcpDeviceAttached), + DoAll(SetArgPointee<0>(HDCP_NO_DIGITAL_OUTPUT), Return(true))); max_res_engine_->SetLicense(license_); @@ -229,14 +228,14 @@ TEST_F(MaxResEngineTest, RequestsHdcpImmediatelyAndOnlyAfterInterval) { EXPECT_CALL(*mock_clock_, GetCurrentTime()).WillOnce(Return(start_time)); EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _)) .WillOnce( - DoAll(SetArgPointee<0>(CryptoSession::kOemCryptoHdcpVersion2_2), + DoAll(SetArgPointee<0>(HDCP_V2_2), Return(true))); EXPECT_CALL(*mock_clock_, GetCurrentTime()) .WillOnce(Return(start_time + kHdcpInterval / 2)) .WillOnce(Return(start_time + kHdcpInterval)); EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _)) .WillOnce( - DoAll(SetArgPointee<0>(CryptoSession::kOemCryptoHdcpVersion2_2), + DoAll(SetArgPointee<0>(HDCP_V2_2), Return(true))); } @@ -256,7 +255,7 @@ TEST_F(MaxResEngineTest, DoesNotRequestHdcpWithoutALicense) { TEST_F(MaxResEngineTest, HandlesConstraintOverridingHdcp) { EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _)) .WillRepeatedly( - DoAll(SetArgPointee<0>(CryptoSession::kOemCryptoHdcpVersion2), + DoAll(SetArgPointee<0>(HDCP_V2), Return(true))); max_res_engine_->SetLicense(license_); @@ -283,7 +282,7 @@ TEST_F(MaxResEngineTest, HandlesConstraintOverridingHdcp) { TEST_F(MaxResEngineTest, HandlesNoHdcp) { EXPECT_CALL(crypto_session_, GetHdcpCapabilities(_, _)) .WillRepeatedly( - DoAll(SetArgPointee<0>(CryptoSession::kOemCryptoHdcpNotSupported), + DoAll(SetArgPointee<0>(HDCP_NONE), Return(true))); max_res_engine_->SetLicense(license_);