From e4252f3861568987bdfee46d583f4b47b0bbbe6d Mon Sep 17 00:00:00 2001 From: "John \"Juce\" Bruce" Date: Thu, 30 Oct 2014 23:40:03 -0700 Subject: [PATCH] Wire Up Max-Res Plumbing (This is a port of http://go/wvgerrit/11556 from the Widevine CDM repo.) This wires up the new method on the crypto interface with the core code that handles the max-res decode. Bug: 16034599 Change-Id: Id2ea5635bf732eabf1fd33712ff8bab6cf1a1745 --- libwvdrmengine/cdm/core/include/cdm_engine.h | 4 ++++ libwvdrmengine/cdm/core/include/cdm_session.h | 3 +++ libwvdrmengine/cdm/core/include/policy_engine.h | 3 +++ libwvdrmengine/cdm/core/src/cdm_engine.cpp | 10 ++++++++-- libwvdrmengine/cdm/core/src/cdm_session.cpp | 4 ++++ libwvdrmengine/cdm/core/src/policy_engine.cpp | 4 ++++ .../cdm/include/wv_content_decryption_module.h | 3 +++ .../cdm/src/wv_content_decryption_module.cpp | 6 ++++++ libwvdrmengine/mediacrypto/include/WVCryptoPlugin.h | 2 ++ libwvdrmengine/mediacrypto/src/WVCryptoPlugin.cpp | 4 ++++ 10 files changed, 41 insertions(+), 2 deletions(-) diff --git a/libwvdrmengine/cdm/core/include/cdm_engine.h b/libwvdrmengine/cdm/core/include/cdm_engine.h index da61b878..242fa0c4 100644 --- a/libwvdrmengine/cdm/core/include/cdm_engine.h +++ b/libwvdrmengine/cdm/core/include/cdm_engine.h @@ -114,6 +114,10 @@ class CdmEngine { virtual bool DetachEventListener(const CdmSessionId& session_id, WvCdmEventListener* listener); + // Used for notifying the Max-Res Engine of resolution changes + virtual void NotifyResolution(const CdmSessionId& session_id, uint32_t width, + uint32_t height); + // Timer expiration method virtual void OnTimerEvent(); diff --git a/libwvdrmengine/cdm/core/include/cdm_session.h b/libwvdrmengine/cdm/core/include/cdm_session.h index 2fb203f1..b1bdb5a7 100644 --- a/libwvdrmengine/cdm/core/include/cdm_session.h +++ b/libwvdrmengine/cdm/core/include/cdm_session.h @@ -80,6 +80,9 @@ class CdmSession { virtual bool AttachEventListener(WvCdmEventListener* listener); virtual bool DetachEventListener(WvCdmEventListener* listener); + // Used for notifying the Policy Engine of resolution changes + virtual void NotifyResolution(uint32_t width, uint32_t height); + virtual void OnTimerEvent(bool update_usage); virtual void OnKeyReleaseEvent(const CdmKeySetId& key_set_id); diff --git a/libwvdrmengine/cdm/core/include/policy_engine.h b/libwvdrmengine/cdm/core/include/policy_engine.h index f9b87278..1df84f80 100644 --- a/libwvdrmengine/cdm/core/include/policy_engine.h +++ b/libwvdrmengine/cdm/core/include/policy_engine.h @@ -56,6 +56,9 @@ class PolicyEngine { virtual void UpdateLicense( const video_widevine_server::sdk::License& license); + // Used for notifying the Policy Engine of resolution changes + virtual void NotifyResolution(uint32_t width, uint32_t height); + virtual CdmResponseType Query(CdmQueryMap* key_info); virtual const LicenseIdentification& license_id() { return license_id_; } diff --git a/libwvdrmengine/cdm/core/src/cdm_engine.cpp b/libwvdrmengine/cdm/core/src/cdm_engine.cpp index c3a866e3..ea9fac77 100644 --- a/libwvdrmengine/cdm/core/src/cdm_engine.cpp +++ b/libwvdrmengine/cdm/core/src/cdm_engine.cpp @@ -760,7 +760,6 @@ bool CdmEngine::FindSessionForKey( bool CdmEngine::AttachEventListener( const CdmSessionId& session_id, WvCdmEventListener* listener) { - CdmSessionMap::iterator iter = sessions_.find(session_id); if (iter == sessions_.end()) { return false; @@ -772,7 +771,6 @@ bool CdmEngine::AttachEventListener( bool CdmEngine::DetachEventListener( const CdmSessionId& session_id, WvCdmEventListener* listener) { - CdmSessionMap::iterator iter = sessions_.find(session_id); if (iter == sessions_.end()) { return false; @@ -781,6 +779,14 @@ bool CdmEngine::DetachEventListener( return iter->second->DetachEventListener(listener); } +void CdmEngine::NotifyResolution(const CdmSessionId& session_id, uint32_t width, + uint32_t height) { + CdmSessionMap::iterator iter = sessions_.find(session_id); + if (iter != sessions_.end()) { + iter->second->NotifyResolution(width, height); + } +} + bool CdmEngine::ValidateKeySystem(const CdmKeySystem& key_system) { return (key_system.find("widevine") != std::string::npos); } diff --git a/libwvdrmengine/cdm/core/src/cdm_session.cpp b/libwvdrmengine/cdm/core/src/cdm_session.cpp index bc64ab76..37098059 100644 --- a/libwvdrmengine/cdm/core/src/cdm_session.cpp +++ b/libwvdrmengine/cdm/core/src/cdm_session.cpp @@ -548,6 +548,10 @@ bool CdmSession::DetachEventListener(WvCdmEventListener* listener) { return (listeners_.erase(listener) == 1); } +void CdmSession::NotifyResolution(uint32_t width, uint32_t height) { + policy_engine_->NotifyResolution(width, height); +} + void CdmSession::OnTimerEvent(bool update_usage) { bool event_occurred = false; CdmEventType event; diff --git a/libwvdrmengine/cdm/core/src/policy_engine.cpp b/libwvdrmengine/cdm/core/src/policy_engine.cpp index 006331f0..2e29782a 100644 --- a/libwvdrmengine/cdm/core/src/policy_engine.cpp +++ b/libwvdrmengine/cdm/core/src/policy_engine.cpp @@ -208,6 +208,10 @@ void PolicyEngine::DecryptionEvent() { last_playback_time_ = clock_->GetCurrentTime(); } +void PolicyEngine::NotifyResolution(uint32_t width, uint32_t height) { + max_res_engine_.SetResolution(width, height); +} + CdmResponseType PolicyEngine::Query(CdmQueryMap* key_info) { std::stringstream ss; int64_t current_time = clock_->GetCurrentTime(); diff --git a/libwvdrmengine/cdm/include/wv_content_decryption_module.h b/libwvdrmengine/cdm/include/wv_content_decryption_module.h index c64d156a..fe12b657 100644 --- a/libwvdrmengine/cdm/include/wv_content_decryption_module.h +++ b/libwvdrmengine/cdm/include/wv_content_decryption_module.h @@ -104,6 +104,9 @@ class WvContentDecryptionModule : public TimerHandler { virtual bool DetachEventListener(const CdmSessionId& session_id, WvCdmEventListener* listener); + virtual void NotifyResolution(const CdmSessionId& session_id, uint32_t width, + uint32_t height); + private: uint32_t GenerateSessionSharingId(); diff --git a/libwvdrmengine/cdm/src/wv_content_decryption_module.cpp b/libwvdrmengine/cdm/src/wv_content_decryption_module.cpp index 2c07020c..23e4baad 100644 --- a/libwvdrmengine/cdm/src/wv_content_decryption_module.cpp +++ b/libwvdrmengine/cdm/src/wv_content_decryption_module.cpp @@ -195,6 +195,12 @@ bool WvContentDecryptionModule::DetachEventListener( return cdm_engine_->DetachEventListener(session_id, listener); } +void WvContentDecryptionModule::NotifyResolution(const CdmSessionId& session_id, + uint32_t width, + uint32_t height) { + cdm_engine_->NotifyResolution(session_id, width, height); +} + void WvContentDecryptionModule::EnablePolicyTimer() { if (!policy_timer_.IsRunning()) policy_timer_.Start(this, kCdmPolicyTimerDurationSeconds); diff --git a/libwvdrmengine/mediacrypto/include/WVCryptoPlugin.h b/libwvdrmengine/mediacrypto/include/WVCryptoPlugin.h index 172935bc..21f4299e 100644 --- a/libwvdrmengine/mediacrypto/include/WVCryptoPlugin.h +++ b/libwvdrmengine/mediacrypto/include/WVCryptoPlugin.h @@ -22,6 +22,8 @@ class WVCryptoPlugin : public android::CryptoPlugin { virtual bool requiresSecureDecoderComponent(const char* mime) const; + virtual void notifyResolution(uint32_t width, uint32_t height); + virtual ssize_t decrypt(bool secure, const uint8_t key[16], const uint8_t iv[16], Mode mode, const void* srcPtr, const SubSample* subSamples, size_t numSubSamples, diff --git a/libwvdrmengine/mediacrypto/src/WVCryptoPlugin.cpp b/libwvdrmengine/mediacrypto/src/WVCryptoPlugin.cpp index 30c7a6a0..a60f6408 100644 --- a/libwvdrmengine/mediacrypto/src/WVCryptoPlugin.cpp +++ b/libwvdrmengine/mediacrypto/src/WVCryptoPlugin.cpp @@ -64,6 +64,10 @@ bool WVCryptoPlugin::requiresSecureDecoderComponent(const char* mime) const { } } +void WVCryptoPlugin::notifyResolution(uint32_t width, uint32_t height) { + mCDM->NotifyResolution(mSessionId, width, height); +} + // Returns negative values for error code and // positive values for the size of decrypted data. In theory, the output size // can be larger than the input size, but in practice this should never happen