Merge "Fix ANRs due to Widevine DRM plugin sniff taking too long." into ics-mr1
This commit is contained in:
@ -2091,7 +2091,7 @@ status_t AwesomePlayer::finishSetDataSource_l() {
|
|||||||
String8 mimeType;
|
String8 mimeType;
|
||||||
float confidence;
|
float confidence;
|
||||||
sp<AMessage> dummy;
|
sp<AMessage> dummy;
|
||||||
bool success = SniffDRM(dataSource, &mimeType, &confidence, &dummy);
|
bool success = SniffWVM(dataSource, &mimeType, &confidence, &dummy);
|
||||||
|
|
||||||
if (!success
|
if (!success
|
||||||
|| strcasecmp(
|
|| strcasecmp(
|
||||||
@ -2099,6 +2099,8 @@ status_t AwesomePlayer::finishSetDataSource_l() {
|
|||||||
return ERROR_UNSUPPORTED;
|
return ERROR_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dataSource->DrmInitialization();
|
||||||
|
|
||||||
mWVMExtractor = new WVMExtractor(dataSource);
|
mWVMExtractor = new WVMExtractor(dataSource);
|
||||||
mWVMExtractor->setAdaptiveStreamingMode(true);
|
mWVMExtractor->setAdaptiveStreamingMode(true);
|
||||||
extractor = mWVMExtractor;
|
extractor = mWVMExtractor;
|
||||||
|
@ -282,13 +282,13 @@ bool SniffDRM(
|
|||||||
if (decryptHandle != NULL) {
|
if (decryptHandle != NULL) {
|
||||||
if (decryptHandle->decryptApiType == DecryptApiType::CONTAINER_BASED) {
|
if (decryptHandle->decryptApiType == DecryptApiType::CONTAINER_BASED) {
|
||||||
*mimeType = String8("drm+container_based+") + decryptHandle->mimeType;
|
*mimeType = String8("drm+container_based+") + decryptHandle->mimeType;
|
||||||
|
*confidence = 10.0f;
|
||||||
} else if (decryptHandle->decryptApiType == DecryptApiType::ELEMENTARY_STREAM_BASED) {
|
} else if (decryptHandle->decryptApiType == DecryptApiType::ELEMENTARY_STREAM_BASED) {
|
||||||
*mimeType = String8("drm+es_based+") + decryptHandle->mimeType;
|
*mimeType = String8("drm+es_based+") + decryptHandle->mimeType;
|
||||||
} else if (decryptHandle->decryptApiType == DecryptApiType::WV_BASED) {
|
*confidence = 10.0f;
|
||||||
*mimeType = MEDIA_MIMETYPE_CONTAINER_WVM;
|
} else {
|
||||||
LOGW("SniffWVM: found match\n");
|
return false;
|
||||||
}
|
}
|
||||||
*confidence = 10.0f;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "include/DRMExtractor.h"
|
#include "include/DRMExtractor.h"
|
||||||
#include "include/FLACExtractor.h"
|
#include "include/FLACExtractor.h"
|
||||||
#include "include/AACExtractor.h"
|
#include "include/AACExtractor.h"
|
||||||
|
#include "include/WVMExtractor.h"
|
||||||
|
|
||||||
#include "matroska/MatroskaExtractor.h"
|
#include "matroska/MatroskaExtractor.h"
|
||||||
|
|
||||||
@ -113,6 +114,7 @@ void DataSource::RegisterDefaultSniffers() {
|
|||||||
RegisterSniffer(SniffMP3);
|
RegisterSniffer(SniffMP3);
|
||||||
RegisterSniffer(SniffAAC);
|
RegisterSniffer(SniffAAC);
|
||||||
RegisterSniffer(SniffMPEG2PS);
|
RegisterSniffer(SniffMPEG2PS);
|
||||||
|
RegisterSniffer(SniffWVM);
|
||||||
|
|
||||||
char value[PROPERTY_VALUE_MAX];
|
char value[PROPERTY_VALUE_MAX];
|
||||||
if (property_get("drm.service.enabled", value, NULL)
|
if (property_get("drm.service.enabled", value, NULL)
|
||||||
|
@ -45,17 +45,12 @@ namespace android {
|
|||||||
static Mutex gWVMutex;
|
static Mutex gWVMutex;
|
||||||
|
|
||||||
WVMExtractor::WVMExtractor(const sp<DataSource> &source)
|
WVMExtractor::WVMExtractor(const sp<DataSource> &source)
|
||||||
: mDataSource(source) {
|
: mDataSource(source)
|
||||||
{
|
{
|
||||||
Mutex::Autolock autoLock(gWVMutex);
|
Mutex::Autolock autoLock(gWVMutex);
|
||||||
if (gVendorLibHandle == NULL) {
|
|
||||||
gVendorLibHandle = dlopen("libwvm.so", RTLD_NOW);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gVendorLibHandle == NULL) {
|
if (!getVendorLibHandle()) {
|
||||||
LOGE("Failed to open libwvm.so");
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef WVMLoadableExtractor *(*GetInstanceFunc)(sp<DataSource>);
|
typedef WVMLoadableExtractor *(*GetInstanceFunc)(sp<DataSource>);
|
||||||
@ -71,6 +66,19 @@ WVMExtractor::WVMExtractor(const sp<DataSource> &source)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WVMExtractor::getVendorLibHandle()
|
||||||
|
{
|
||||||
|
if (gVendorLibHandle == NULL) {
|
||||||
|
gVendorLibHandle = dlopen("libwvm.so", RTLD_NOW);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gVendorLibHandle == NULL) {
|
||||||
|
LOGE("Failed to open libwvm.so");
|
||||||
|
}
|
||||||
|
|
||||||
|
return gVendorLibHandle != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
WVMExtractor::~WVMExtractor() {
|
WVMExtractor::~WVMExtractor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,5 +121,33 @@ void WVMExtractor::setAdaptiveStreamingMode(bool adaptive) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SniffWVM(
|
||||||
|
const sp<DataSource> &source, String8 *mimeType, float *confidence,
|
||||||
|
sp<AMessage> *) {
|
||||||
|
|
||||||
|
Mutex::Autolock autoLock(gWVMutex);
|
||||||
|
|
||||||
|
if (!WVMExtractor::getVendorLibHandle()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef WVMLoadableExtractor *(*SnifferFunc)(sp<DataSource>);
|
||||||
|
SnifferFunc snifferFunc =
|
||||||
|
(SnifferFunc) dlsym(gVendorLibHandle,
|
||||||
|
"_ZN7android15IsWidevineMediaENS_2spINS_10DataSourceEEE");
|
||||||
|
|
||||||
|
if (snifferFunc) {
|
||||||
|
if ((*snifferFunc)(source)) {
|
||||||
|
*mimeType = MEDIA_MIMETYPE_CONTAINER_WVM;
|
||||||
|
*confidence = 10.0f;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LOGE("IsWidevineMedia not found in libwvm.so");
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
} //namespace android
|
} //namespace android
|
||||||
|
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
|
|
||||||
|
struct AMessage;
|
||||||
|
class String8;
|
||||||
class DataSource;
|
class DataSource;
|
||||||
|
|
||||||
class WVMLoadableExtractor : public MediaExtractor {
|
class WVMLoadableExtractor : public MediaExtractor {
|
||||||
@ -58,6 +60,8 @@ public:
|
|||||||
// is used.
|
// is used.
|
||||||
void setAdaptiveStreamingMode(bool adaptive);
|
void setAdaptiveStreamingMode(bool adaptive);
|
||||||
|
|
||||||
|
static bool getVendorLibHandle();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~WVMExtractor();
|
virtual ~WVMExtractor();
|
||||||
|
|
||||||
@ -69,6 +73,10 @@ private:
|
|||||||
WVMExtractor &operator=(const WVMExtractor &);
|
WVMExtractor &operator=(const WVMExtractor &);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool SniffWVM(
|
||||||
|
const sp<DataSource> &source, String8 *mimeType, float *confidence,
|
||||||
|
sp<AMessage> *);
|
||||||
|
|
||||||
} // namespace android
|
} // namespace android
|
||||||
|
|
||||||
#endif // DRM_EXTRACTOR_H_
|
#endif // DRM_EXTRACTOR_H_
|
||||||
|
Reference in New Issue
Block a user