Fix ANRs due to Widevine DRM plugin sniff taking too long.

Add a Widevine-specific format sniffer to avoid having to
refetch data from the remote server.

related-to-bug: 5725548

Change-Id: I622e39930f8d243111e4731557b0df17c4e2651d
This commit is contained in:
Jeff Tinker
2011-12-07 20:28:03 -08:00
parent 94edc18bde
commit 95d4dc7776
3 changed files with 36 additions and 45 deletions

View File

@@ -80,6 +80,27 @@ 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),