am 95d4dc77: Fix ANRs due to Widevine DRM plugin sniff taking too long.

* commit '95d4dc7776b0202f22bd743e1e2b86a444a247a3':
  Fix ANRs due to Widevine DRM plugin sniff taking too long.
This commit is contained in:
Jeff Tinker
2011-12-09 14:25:42 -08:00
committed by Android Git Automerger
3 changed files with 36 additions and 45 deletions

View File

@@ -710,42 +710,14 @@ status_t WVMDrmPlugin::onRemoveAllRights(int uniqueId) {
status_t WVMDrmPlugin::onOpenDecryptSession(
int uniqueId, DecryptHandle *decryptHandle, int fd, off64_t offset, off64_t length)
{
status_t result = DRM_ERROR_CANNOT_HANDLE;
// For efficiency, we rely on the WVMExtractor's sniff result instead of
// setting mimeType and decryptApiType here for the DRMExtractor's sniff.
// WVMExtractor's sniff uses the cached data source for the sniff.
decryptHandle->decryptInfo = NULL;
decryptHandle->status = DRM_NO_ERROR;
//LOGD("onOpenDecryptSession: fd=%d, offset=%lld, length=%lld", fd, offset, length);
char buffer[64 * 1024];
int dupfd = dup(fd);
if (dupfd == -1)
return result;
FILE *f = fdopen(dupfd, "rb");
if (f) {
fseek(f, 0, SEEK_SET);
if (fread(buffer, 1, sizeof(buffer), f) != sizeof(buffer)) {
fclose(f);
return DRM_ERROR_CANNOT_HANDLE;
}
fclose(f);
} else {
close(dupfd);
return result;
}
if (WV_IsWidevineMedia(buffer, sizeof(buffer))) {
//LOGD("WVMDrmPlugin::onOpenDecryptSession - WV_IsWidevineMedia: true");
decryptHandle->mimeType = String8("video/wvm");
decryptHandle->decryptApiType = DecryptApiType::WV_BASED;
decryptHandle->status = DRM_NO_ERROR;
decryptHandle->decryptInfo = NULL;
mDrmPluginImpl->OpenSession(NULL);
result = DRM_NO_ERROR;
} else {
//LOGD("WVMDrmPlugin::onOpenDecryptSession - not Widevine media");
}
return result;
mDrmPluginImpl->OpenSession(NULL);
return DRM_NO_ERROR;
}
/**
@@ -760,21 +732,19 @@ status_t WVMDrmPlugin::onOpenDecryptSession(
status_t WVMDrmPlugin::onOpenDecryptSession(
int uniqueId, DecryptHandle* decryptHandle, const char* uri)
{
// For efficiency, we rely on the WVMExtractor's sniff result instead of
// setting mimeType and decryptApiType here for the DRMExtractor's sniff.
// WVMExtractor's sniff uses the cached data source for the sniff.
status_t result = DRM_ERROR_CANNOT_HANDLE;
if (!uri)
return result;
if (mDrmPluginImpl->IsSupportedMediaType(uri)) {
//LOGD("WVMDrmPlugin::onOpenDecryptSession(uri) : %d - match", uniqueId);
decryptHandle->mimeType = String8("video/wvm");
decryptHandle->decryptApiType = DecryptApiType::WV_BASED;
decryptHandle->status = DRM_NO_ERROR;
decryptHandle->decryptInfo = NULL;
decryptHandle->decryptInfo = NULL;
decryptHandle->status = DRM_NO_ERROR;
if (mDrmPluginImpl->OpenSession(uri)) {
result = DRM_NO_ERROR;
}
if (mDrmPluginImpl->OpenSession(uri)) {
result = DRM_NO_ERROR;
} else {
//LOGD("WVMDrmPlugin::onOpenDecryptSession(uri) - not Widevine media");
}