am 6bed7bfe: Fix for b/4132041 Widevine DRM plugin getConstraints not returning error

* commit '6bed7bfe90dfac8d24a25842dadb5e35088f2cbe':
  Fix for b/4132041 Widevine DRM plugin getConstraints not returning error
This commit is contained in:
Jeffrey Tinker
2011-03-18 16:56:51 -07:00
committed by Android Git Automerger
3 changed files with 29 additions and 26 deletions

View File

@@ -331,36 +331,39 @@ DrmConstraints* WVMDrmPlugin::onGetConstraints(int uniqueId, const String8* path
bool denyHD;
std::string assetPath(path->string());
if (!mDrmPluginImpl->GetConstraints(assetPath, &timeSincePlayback, &timeRemaining,
&licenseDuration, lastError, allowOffline,
allowStreaming, denyHD))
return NULL;
bool isValid = mDrmPluginImpl->GetConstraints(assetPath, &timeSincePlayback, &timeRemaining,
&licenseDuration, lastError, allowOffline,
allowStreaming, denyHD);
DrmConstraints* drmConstraints = new DrmConstraints();
char charValue[16]; // max uint32 = 0xffffffff + terminating char
memset(charValue, 0, 16);
sprintf(charValue, "%lu", (unsigned long)timeSincePlayback);
drmConstraints->put(&(DrmConstraints::LICENSE_START_TIME), charValue);
memset(charValue, 0, 16);
sprintf(charValue, "%lu", (unsigned long)timeRemaining);
drmConstraints->put(&(DrmConstraints::LICENSE_EXPIRY_TIME), charValue);
memset(charValue, 0, 16);
sprintf(charValue, "%lu", (unsigned long)licenseDuration);
drmConstraints->put(&(DrmConstraints::LICENSE_AVAILABLE_TIME), charValue);
String8 key = String8("WVLicenseTypeKey");
sprintf(charValue, "%u", (allowStreaming ? 1 : 0) | (allowOffline ? 2 : 0));
drmConstraints->put(&key, charValue);
key = String8("WVLicensedResolutionKey");
sprintf(charValue, "%u", (denyHD ? 1 : 2));
drmConstraints->put(&key, charValue);
key = String8("WVLastErrorKey");
String8 key = String8("WVLastErrorKey");
drmConstraints->put(&key, lastError.c_str());
if (isValid) {
char charValue[16]; // max uint32 = 0xffffffff + terminating char
memset(charValue, 0, 16);
sprintf(charValue, "%lu", (unsigned long)timeSincePlayback);
drmConstraints->put(&(DrmConstraints::LICENSE_START_TIME), charValue);
memset(charValue, 0, 16);
sprintf(charValue, "%lu", (unsigned long)timeRemaining);
drmConstraints->put(&(DrmConstraints::LICENSE_EXPIRY_TIME), charValue);
memset(charValue, 0, 16);
sprintf(charValue, "%lu", (unsigned long)licenseDuration);
drmConstraints->put(&(DrmConstraints::LICENSE_AVAILABLE_TIME), charValue);
key = String8("WVLicenseTypeKey");
sprintf(charValue, "%u", (allowStreaming ? 1 : 0) | (allowOffline ? 2 : 0));
drmConstraints->put(&key, charValue);
key = String8("WVLicensedResolutionKey");
sprintf(charValue, "%u", (denyHD ? 1 : 2));
drmConstraints->put(&key, charValue);
}
return drmConstraints;
}