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
This commit is contained in:
John "Juce" Bruce
2014-10-30 23:40:03 -07:00
parent 12821d5968
commit e4252f3861
10 changed files with 41 additions and 2 deletions

View File

@@ -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();

View File

@@ -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);

View File

@@ -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_; }

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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();

View File

@@ -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();

View File

@@ -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);

View File

@@ -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,

View File

@@ -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