am 444dc2a8: Revert "Fix ANRs due to Widevine DRM plugin sniff taking too long." We need to do this because with this patch, SHA/MD5 module may get stuck and cause power consumption regression.
* commit '444dc2a84539f100689642f5756e5e6d6e5cd705': Revert "Fix ANRs due to Widevine DRM plugin sniff taking too long." We need to do this because with this patch, SHA/MD5 module may get stuck and cause power consumption regression.
This commit is contained in:
@@ -710,14 +710,42 @@ status_t WVMDrmPlugin::onRemoveAllRights(int uniqueId) {
|
||||
status_t WVMDrmPlugin::onOpenDecryptSession(
|
||||
int uniqueId, DecryptHandle *decryptHandle, int fd, off64_t offset, off64_t length)
|
||||
{
|
||||
// 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;
|
||||
status_t result = DRM_ERROR_CANNOT_HANDLE;
|
||||
|
||||
//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);
|
||||
return DRM_NO_ERROR;
|
||||
result = DRM_NO_ERROR;
|
||||
} else {
|
||||
//LOGD("WVMDrmPlugin::onOpenDecryptSession - not Widevine media");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -732,19 +760,21 @@ 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;
|
||||
|
||||
decryptHandle->decryptInfo = NULL;
|
||||
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;
|
||||
|
||||
if (mDrmPluginImpl->OpenSession(uri)) {
|
||||
result = DRM_NO_ERROR;
|
||||
}
|
||||
} else {
|
||||
//LOGD("WVMDrmPlugin::onOpenDecryptSession(uri) - not Widevine media");
|
||||
}
|
||||
|
||||
@@ -80,27 +80,6 @@ WVMLoadableExtractor *GetInstance(sp<DataSource> dataSource) {
|
||||
return new WVMExtractorImpl(dataSource);
|
||||
}
|
||||
|
||||
bool IsWidevineMedia(sp<DataSource> dataSource) {
|
||||
char buffer[64 * 1024];
|
||||
|
||||
String8 uri = dataSource->getUri();
|
||||
if (uri.getPathExtension() == ".m3u8" || uri.find(".m3u8?") != -1) {
|
||||
// can't sniff live streams - check for .m3u8 file extension
|
||||
return true;
|
||||
}
|
||||
|
||||
ssize_t bytesRead = dataSource->readAt(0, buffer, sizeof(buffer));
|
||||
if (bytesRead < (ssize_t)sizeof(buffer)) {
|
||||
LOGW("IsWidevineMedia - insufficient data: %d", (int)bytesRead);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool result = WV_IsWidevineMedia(buffer, sizeof(buffer));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
WVMExtractorImpl::WVMExtractorImpl(sp<DataSource> dataSource)
|
||||
: mFileMetaData(new MetaData()),
|
||||
mDataSource(dataSource),
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
namespace android {
|
||||
|
||||
WVMLoadableExtractor *GetInstance(sp<DataSource> dataSource);
|
||||
bool IsWidevineMedia(sp<DataSource> dataSource);
|
||||
|
||||
|
||||
class WVMMediaSource;
|
||||
class WVMFileSource;
|
||||
|
||||
Reference in New Issue
Block a user