Merge "Separate sniffing from session initialization"
This commit is contained in:
@@ -120,13 +120,23 @@ DrmSupportInfo* DrmEngineBase::getSupportInfo(int uniqueId) {
|
||||
}
|
||||
|
||||
status_t DrmEngineBase::openDecryptSession(
|
||||
int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length) {
|
||||
return onOpenDecryptSession(uniqueId, decryptHandle, fd, offset, length);
|
||||
int uniqueId, DecryptHandle* decryptHandle,
|
||||
int fd, off64_t offset, off64_t length, const char* mime) {
|
||||
|
||||
if (!mime || mime[0] == '\0') {
|
||||
return onOpenDecryptSession(uniqueId, decryptHandle, fd, offset, length);
|
||||
}
|
||||
|
||||
return onOpenDecryptSession(uniqueId, decryptHandle, fd, offset, length, mime);
|
||||
}
|
||||
|
||||
status_t DrmEngineBase::openDecryptSession(
|
||||
int uniqueId, DecryptHandle* decryptHandle, const char* uri) {
|
||||
return onOpenDecryptSession(uniqueId, decryptHandle, uri);
|
||||
int uniqueId, DecryptHandle* decryptHandle,
|
||||
const char* uri, const char* mime) {
|
||||
if (!mime || mime[0] == '\0') {
|
||||
return onOpenDecryptSession(uniqueId, decryptHandle, uri);
|
||||
}
|
||||
return onOpenDecryptSession(uniqueId, decryptHandle, uri, mime);
|
||||
}
|
||||
|
||||
status_t DrmEngineBase::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
|
||||
|
||||
@@ -600,7 +600,7 @@ status_t BpDrmManagerService::getAllSupportInfo(
|
||||
}
|
||||
|
||||
DecryptHandle* BpDrmManagerService::openDecryptSession(
|
||||
int uniqueId, int fd, off64_t offset, off64_t length) {
|
||||
int uniqueId, int fd, off64_t offset, off64_t length, const char* mime) {
|
||||
ALOGV("Entering BpDrmManagerService::openDecryptSession");
|
||||
Parcel data, reply;
|
||||
|
||||
@@ -609,6 +609,11 @@ DecryptHandle* BpDrmManagerService::openDecryptSession(
|
||||
data.writeFileDescriptor(fd);
|
||||
data.writeInt64(offset);
|
||||
data.writeInt64(length);
|
||||
String8 mimeType;
|
||||
if (mime) {
|
||||
mimeType = mime;
|
||||
}
|
||||
data.writeString8(mimeType);
|
||||
|
||||
remote()->transact(OPEN_DECRYPT_SESSION, data, &reply);
|
||||
|
||||
@@ -620,13 +625,20 @@ DecryptHandle* BpDrmManagerService::openDecryptSession(
|
||||
return handle;
|
||||
}
|
||||
|
||||
DecryptHandle* BpDrmManagerService::openDecryptSession(int uniqueId, const char* uri) {
|
||||
ALOGV("Entering BpDrmManagerService::openDecryptSession");
|
||||
DecryptHandle* BpDrmManagerService::openDecryptSession(
|
||||
int uniqueId, const char* uri, const char* mime) {
|
||||
|
||||
ALOGV("Entering BpDrmManagerService::openDecryptSession: mime=%s", mime? mime: "NULL");
|
||||
Parcel data, reply;
|
||||
|
||||
data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
|
||||
data.writeInt32(uniqueId);
|
||||
data.writeString8(String8(uri));
|
||||
String8 mimeType;
|
||||
if (mime) {
|
||||
mimeType = mime;
|
||||
}
|
||||
data.writeString8(mimeType);
|
||||
|
||||
remote()->transact(OPEN_DECRYPT_SESSION_FROM_URI, data, &reply);
|
||||
|
||||
@@ -1265,8 +1277,10 @@ status_t BnDrmManagerService::onTransact(
|
||||
|
||||
const off64_t offset = data.readInt64();
|
||||
const off64_t length = data.readInt64();
|
||||
const String8 mime = data.readString8();
|
||||
|
||||
DecryptHandle* handle
|
||||
= openDecryptSession(uniqueId, fd, offset, length);
|
||||
= openDecryptSession(uniqueId, fd, offset, length, mime.string());
|
||||
|
||||
if (NULL != handle) {
|
||||
writeDecryptHandleToParcelData(handle, reply);
|
||||
@@ -1283,8 +1297,9 @@ status_t BnDrmManagerService::onTransact(
|
||||
|
||||
const int uniqueId = data.readInt32();
|
||||
const String8 uri = data.readString8();
|
||||
const String8 mime = data.readString8();
|
||||
|
||||
DecryptHandle* handle = openDecryptSession(uniqueId, uri.string());
|
||||
DecryptHandle* handle = openDecryptSession(uniqueId, uri.string(), mime.string());
|
||||
|
||||
if (NULL != handle) {
|
||||
writeDecryptHandleToParcelData(handle, reply);
|
||||
|
||||
@@ -426,7 +426,9 @@ status_t DrmManager::getAllSupportInfo(
|
||||
return DRM_NO_ERROR;
|
||||
}
|
||||
|
||||
DecryptHandle* DrmManager::openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length) {
|
||||
DecryptHandle* DrmManager::openDecryptSession(
|
||||
int uniqueId, int fd, off64_t offset, off64_t length, const char* mime) {
|
||||
|
||||
Mutex::Autolock _l(mDecryptLock);
|
||||
status_t result = DRM_ERROR_CANNOT_HANDLE;
|
||||
Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList();
|
||||
@@ -438,7 +440,7 @@ DecryptHandle* DrmManager::openDecryptSession(int uniqueId, int fd, off64_t offs
|
||||
for (unsigned int index = 0; index < plugInIdList.size(); index++) {
|
||||
String8 plugInId = plugInIdList.itemAt(index);
|
||||
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
|
||||
result = rDrmEngine.openDecryptSession(uniqueId, handle, fd, offset, length);
|
||||
result = rDrmEngine.openDecryptSession(uniqueId, handle, fd, offset, length, mime);
|
||||
|
||||
if (DRM_NO_ERROR == result) {
|
||||
++mDecryptSessionId;
|
||||
@@ -453,7 +455,8 @@ DecryptHandle* DrmManager::openDecryptSession(int uniqueId, int fd, off64_t offs
|
||||
return handle;
|
||||
}
|
||||
|
||||
DecryptHandle* DrmManager::openDecryptSession(int uniqueId, const char* uri) {
|
||||
DecryptHandle* DrmManager::openDecryptSession(
|
||||
int uniqueId, const char* uri, const char* mime) {
|
||||
Mutex::Autolock _l(mDecryptLock);
|
||||
status_t result = DRM_ERROR_CANNOT_HANDLE;
|
||||
Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList();
|
||||
@@ -465,7 +468,7 @@ DecryptHandle* DrmManager::openDecryptSession(int uniqueId, const char* uri) {
|
||||
for (unsigned int index = 0; index < plugInIdList.size(); index++) {
|
||||
String8 plugInId = plugInIdList.itemAt(index);
|
||||
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
|
||||
result = rDrmEngine.openDecryptSession(uniqueId, handle, uri);
|
||||
result = rDrmEngine.openDecryptSession(uniqueId, handle, uri, mime);
|
||||
|
||||
if (DRM_NO_ERROR == result) {
|
||||
++mDecryptSessionId;
|
||||
|
||||
@@ -208,20 +208,20 @@ status_t DrmManagerService::getAllSupportInfo(
|
||||
}
|
||||
|
||||
DecryptHandle* DrmManagerService::openDecryptSession(
|
||||
int uniqueId, int fd, off64_t offset, off64_t length) {
|
||||
int uniqueId, int fd, off64_t offset, off64_t length, const char* mime) {
|
||||
ALOGV("Entering DrmManagerService::openDecryptSession");
|
||||
if (isProtectedCallAllowed()) {
|
||||
return mDrmManager->openDecryptSession(uniqueId, fd, offset, length);
|
||||
return mDrmManager->openDecryptSession(uniqueId, fd, offset, length, mime);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DecryptHandle* DrmManagerService::openDecryptSession(
|
||||
int uniqueId, const char* uri) {
|
||||
int uniqueId, const char* uri, const char* mime) {
|
||||
ALOGV("Entering DrmManagerService::openDecryptSession with uri");
|
||||
if (isProtectedCallAllowed()) {
|
||||
return mDrmManager->openDecryptSession(uniqueId, uri);
|
||||
return mDrmManager->openDecryptSession(uniqueId, uri, mime);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
@@ -116,12 +116,18 @@ status_t DrmManagerClient::getAllSupportInfo(int* length, DrmSupportInfo** drmSu
|
||||
return mDrmManagerClientImpl->getAllSupportInfo(mUniqueId, length, drmSupportInfoArray);
|
||||
}
|
||||
|
||||
sp<DecryptHandle> DrmManagerClient::openDecryptSession(int fd, off64_t offset, off64_t length) {
|
||||
return mDrmManagerClientImpl->openDecryptSession(mUniqueId, fd, offset, length);
|
||||
sp<DecryptHandle> DrmManagerClient::openDecryptSession(
|
||||
int fd, off64_t offset, off64_t length, const char* mime) {
|
||||
|
||||
return mDrmManagerClientImpl->openDecryptSession(
|
||||
mUniqueId, fd, offset, length, mime);
|
||||
}
|
||||
|
||||
sp<DecryptHandle> DrmManagerClient::openDecryptSession(const char* uri) {
|
||||
return mDrmManagerClientImpl->openDecryptSession(mUniqueId, uri);
|
||||
sp<DecryptHandle> DrmManagerClient::openDecryptSession(
|
||||
const char* uri, const char* mime) {
|
||||
|
||||
return mDrmManagerClientImpl->openDecryptSession(
|
||||
mUniqueId, uri, mime);
|
||||
}
|
||||
|
||||
status_t DrmManagerClient::closeDecryptSession(sp<DecryptHandle> &decryptHandle) {
|
||||
|
||||
@@ -255,15 +255,19 @@ status_t DrmManagerClientImpl::getAllSupportInfo(
|
||||
}
|
||||
|
||||
sp<DecryptHandle> DrmManagerClientImpl::openDecryptSession(
|
||||
int uniqueId, int fd, off64_t offset, off64_t length) {
|
||||
return getDrmManagerService()->openDecryptSession(uniqueId, fd, offset, length);
|
||||
int uniqueId, int fd, off64_t offset,
|
||||
off64_t length, const char* mime) {
|
||||
|
||||
return getDrmManagerService()->openDecryptSession(
|
||||
uniqueId, fd, offset, length, mime);
|
||||
}
|
||||
|
||||
sp<DecryptHandle> DrmManagerClientImpl::openDecryptSession(
|
||||
int uniqueId, const char* uri) {
|
||||
int uniqueId, const char* uri, const char* mime) {
|
||||
|
||||
DecryptHandle* handle = NULL;
|
||||
if (NULL != uri) {
|
||||
handle = getDrmManagerService()->openDecryptSession(uniqueId, uri);
|
||||
handle = getDrmManagerService()->openDecryptSession(uniqueId, uri, mime);
|
||||
}
|
||||
return handle;
|
||||
}
|
||||
|
||||
@@ -111,9 +111,10 @@ public:
|
||||
|
||||
status_t getAllSupportInfo(int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray);
|
||||
|
||||
DecryptHandle* openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length);
|
||||
DecryptHandle* openDecryptSession(
|
||||
int uniqueId, int fd, off64_t offset, off64_t length, const char* mime);
|
||||
|
||||
DecryptHandle* openDecryptSession(int uniqueId, const char* uri);
|
||||
DecryptHandle* openDecryptSession(int uniqueId, const char* uri, const char* mime);
|
||||
|
||||
status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
|
||||
|
||||
|
||||
@@ -300,20 +300,24 @@ public:
|
||||
* @param[in] fd File descriptor of the protected content to be decrypted
|
||||
* @param[in] offset Start position of the content
|
||||
* @param[in] length The length of the protected content
|
||||
* @param[in] mime The mime type of the protected content if it is not NULL or empty
|
||||
* @return
|
||||
* Handle for the decryption session
|
||||
*/
|
||||
sp<DecryptHandle> openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length);
|
||||
sp<DecryptHandle> openDecryptSession(
|
||||
int uniqueId, int fd, off64_t offset, off64_t length, const char* mime);
|
||||
|
||||
/**
|
||||
* Open the decrypt session to decrypt the given protected content
|
||||
*
|
||||
* @param[in] uniqueId Unique identifier for a session
|
||||
* @param[in] uri Path of the protected content to be decrypted
|
||||
* @param[in] mime The mime type of the protected content if it is not NULL or empty
|
||||
* @return
|
||||
* Handle for the decryption session
|
||||
*/
|
||||
sp<DecryptHandle> openDecryptSession(int uniqueId, const char* uri);
|
||||
sp<DecryptHandle> openDecryptSession(
|
||||
int uniqueId, const char* uri, const char* mime);
|
||||
|
||||
/**
|
||||
* Close the decrypt session for the given handle
|
||||
|
||||
@@ -98,9 +98,11 @@ public:
|
||||
|
||||
status_t getAllSupportInfo(int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray);
|
||||
|
||||
DecryptHandle* openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length);
|
||||
DecryptHandle* openDecryptSession(
|
||||
int uniqueId, int fd, off64_t offset, off64_t length, const char *mime);
|
||||
|
||||
DecryptHandle* openDecryptSession(int uniqueId, const char* uri);
|
||||
DecryptHandle* openDecryptSession(
|
||||
int uniqueId, const char* uri, const char* mime);
|
||||
|
||||
status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
|
||||
|
||||
|
||||
@@ -139,9 +139,12 @@ public:
|
||||
virtual status_t getAllSupportInfo(
|
||||
int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray) = 0;
|
||||
|
||||
virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length) = 0;
|
||||
virtual DecryptHandle* openDecryptSession(
|
||||
int uniqueId, int fd, off64_t offset,
|
||||
off64_t length, const char* mime) = 0;
|
||||
|
||||
virtual DecryptHandle* openDecryptSession(int uniqueId, const char* uri) = 0;
|
||||
virtual DecryptHandle* openDecryptSession(
|
||||
int uniqueId, const char* uri, const char* mime) = 0;
|
||||
|
||||
virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) = 0;
|
||||
|
||||
@@ -222,9 +225,12 @@ public:
|
||||
virtual status_t getAllSupportInfo(
|
||||
int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray);
|
||||
|
||||
virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length);
|
||||
virtual DecryptHandle* openDecryptSession(
|
||||
int uniqueId, int fd, off64_t offset, off64_t length,
|
||||
const char* mime);
|
||||
|
||||
virtual DecryptHandle* openDecryptSession(int uniqueId, const char* uri);
|
||||
virtual DecryptHandle* openDecryptSession(
|
||||
int uniqueId, const char* uri, const char* mime);
|
||||
|
||||
virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
|
||||
|
||||
|
||||
@@ -80,10 +80,12 @@ public:
|
||||
DrmSupportInfo* getSupportInfo(int uniqueId);
|
||||
|
||||
status_t openDecryptSession(
|
||||
int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length);
|
||||
int uniqueId, DecryptHandle* decryptHandle,
|
||||
int fd, off64_t offset, off64_t length, const char* mime);
|
||||
|
||||
status_t openDecryptSession(
|
||||
int uniqueId, DecryptHandle* decryptHandle, const char* uri);
|
||||
int uniqueId, DecryptHandle* decryptHandle,
|
||||
const char* uri, const char* mime);
|
||||
|
||||
status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
|
||||
|
||||
@@ -375,7 +377,29 @@ protected:
|
||||
* DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
|
||||
*/
|
||||
virtual status_t onOpenDecryptSession(
|
||||
int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length) = 0;
|
||||
int uniqueId, DecryptHandle* decryptHandle,
|
||||
int fd, off64_t offset, off64_t length) = 0;
|
||||
|
||||
/**
|
||||
* Open the decrypt session to decrypt the given protected content
|
||||
*
|
||||
* @param[in] uniqueId Unique identifier for a session
|
||||
* @param[in] decryptHandle Handle for the current decryption session
|
||||
* @param[in] fd File descriptor of the protected content to be decrypted
|
||||
* @param[in] offset Start position of the content
|
||||
* @param[in] length The length of the protected content
|
||||
* @param[in] mime Mime type of the protected content
|
||||
* drm plugin may do some optimization since the mime type is known.
|
||||
* @return
|
||||
* DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
|
||||
*/
|
||||
virtual status_t onOpenDecryptSession(
|
||||
int uniqueId, DecryptHandle* decryptHandle,
|
||||
int fd, off64_t offset, off64_t length,
|
||||
const char* mime) {
|
||||
|
||||
return DRM_ERROR_CANNOT_HANDLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the decrypt session to decrypt the given protected content
|
||||
@@ -387,7 +411,26 @@ protected:
|
||||
* DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
|
||||
*/
|
||||
virtual status_t onOpenDecryptSession(
|
||||
int uniqueId, DecryptHandle* decryptHandle, const char* uri) = 0;
|
||||
int uniqueId, DecryptHandle* decryptHandle,
|
||||
const char* uri) = 0;
|
||||
|
||||
/**
|
||||
* Open the decrypt session to decrypt the given protected content
|
||||
*
|
||||
* @param[in] uniqueId Unique identifier for a session
|
||||
* @param[in] decryptHandle Handle for the current decryption session
|
||||
* @param[in] uri Path of the protected content to be decrypted
|
||||
* @param[in] mime Mime type of the protected content. The corresponding
|
||||
* drm plugin may do some optimization since the mime type is known.
|
||||
* @return
|
||||
* DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
|
||||
*/
|
||||
virtual status_t onOpenDecryptSession(
|
||||
int uniqueId, DecryptHandle* decryptHandle,
|
||||
const char* uri, const char* mime) {
|
||||
|
||||
return DRM_ERROR_CANNOT_HANDLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the decrypt session for the given handle
|
||||
|
||||
@@ -320,11 +320,14 @@ public:
|
||||
* @param[in] fd File descriptor of the protected content to be decrypted
|
||||
* @param[in] offset Start position of the content
|
||||
* @param[in] length The length of the protected content
|
||||
* @param[in] mime Mime type of the protected content if it is
|
||||
* not NULL or empty
|
||||
* @return
|
||||
* DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
|
||||
*/
|
||||
virtual status_t openDecryptSession(
|
||||
int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length) = 0;
|
||||
int uniqueId, DecryptHandle* decryptHandle,
|
||||
int fd, off64_t offset, off64_t length, const char* mime) = 0;
|
||||
|
||||
/**
|
||||
* Open the decrypt session to decrypt the given protected content
|
||||
@@ -332,11 +335,14 @@ public:
|
||||
* @param[in] uniqueId Unique identifier for a session
|
||||
* @param[in] decryptHandle Handle for the current decryption session
|
||||
* @param[in] uri Path of the protected content to be decrypted
|
||||
* @param[in] mime Mime type of the protected content if it is
|
||||
* not NULL or empty
|
||||
* @return
|
||||
* DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
|
||||
*/
|
||||
virtual status_t openDecryptSession(
|
||||
int uniqueId, DecryptHandle* decryptHandle, const char* uri) = 0;
|
||||
int uniqueId, DecryptHandle* decryptHandle,
|
||||
const char* uri, const char* mime) = 0;
|
||||
|
||||
/**
|
||||
* Close the decrypt session for the given handle
|
||||
|
||||
@@ -66,19 +66,21 @@ public:
|
||||
* @param[in] fd File descriptor of the protected content to be decrypted
|
||||
* @param[in] offset Start position of the content
|
||||
* @param[in] length The length of the protected content
|
||||
* @param[in] mime Mime type of the protected content if it is not NULL or empty
|
||||
* @return
|
||||
* Handle for the decryption session
|
||||
*/
|
||||
sp<DecryptHandle> openDecryptSession(int fd, off64_t offset, off64_t length);
|
||||
sp<DecryptHandle> openDecryptSession(int fd, off64_t offset, off64_t length, const char* mime);
|
||||
|
||||
/**
|
||||
* Open the decrypt session to decrypt the given protected content
|
||||
*
|
||||
* @param[in] uri Path of the protected content to be decrypted
|
||||
* @param[in] mime Mime type of the protected content if it is not NULL or empty
|
||||
* @return
|
||||
* Handle for the decryption session
|
||||
*/
|
||||
sp<DecryptHandle> openDecryptSession(const char* uri);
|
||||
sp<DecryptHandle> openDecryptSession(const char* uri, const char* mime);
|
||||
|
||||
/**
|
||||
* Close the decrypt session for the given handle
|
||||
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
static void RegisterDefaultSniffers();
|
||||
|
||||
// for DRM
|
||||
virtual sp<DecryptHandle> DrmInitialization() {
|
||||
virtual sp<DecryptHandle> DrmInitialization(const char *mime = NULL) {
|
||||
return NULL;
|
||||
}
|
||||
virtual void getDrmInfo(sp<DecryptHandle> &handle, DrmManagerClient **client) {};
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
|
||||
virtual status_t getSize(off64_t *size);
|
||||
|
||||
virtual sp<DecryptHandle> DrmInitialization();
|
||||
virtual sp<DecryptHandle> DrmInitialization(const char *mime);
|
||||
|
||||
virtual void getDrmInfo(sp<DecryptHandle> &handle, DrmManagerClient **client);
|
||||
|
||||
|
||||
@@ -56,10 +56,10 @@ public:
|
||||
virtual uint32_t flags() const;
|
||||
|
||||
// for DRM
|
||||
virtual void setDrmFlag(bool flag) {
|
||||
void setDrmFlag(bool flag) {
|
||||
mIsDrm = flag;
|
||||
};
|
||||
virtual bool getDrmFlag() {
|
||||
bool getDrmFlag() {
|
||||
return mIsDrm;
|
||||
}
|
||||
virtual char* getDrmTrackInfo(size_t trackID, int *len) {
|
||||
|
||||
@@ -335,6 +335,14 @@ status_t AwesomePlayer::setDataSource_l(
|
||||
return UNKNOWN_ERROR;
|
||||
}
|
||||
|
||||
if (extractor->getDrmFlag()) {
|
||||
checkDrmStatus(dataSource);
|
||||
}
|
||||
|
||||
return setDataSource_l(extractor);
|
||||
}
|
||||
|
||||
void AwesomePlayer::checkDrmStatus(const sp<DataSource>& dataSource) {
|
||||
dataSource->getDrmInfo(mDecryptHandle, &mDrmManagerClient);
|
||||
if (mDecryptHandle != NULL) {
|
||||
CHECK(mDrmManagerClient);
|
||||
@@ -342,8 +350,6 @@ status_t AwesomePlayer::setDataSource_l(
|
||||
notifyListener_l(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, ERROR_DRM_NO_LICENSE);
|
||||
}
|
||||
}
|
||||
|
||||
return setDataSource_l(extractor);
|
||||
}
|
||||
|
||||
status_t AwesomePlayer::setDataSource_l(const sp<MediaExtractor> &extractor) {
|
||||
@@ -2095,7 +2101,7 @@ status_t AwesomePlayer::finishSetDataSource_l() {
|
||||
String8 mimeType;
|
||||
float confidence;
|
||||
sp<AMessage> dummy;
|
||||
bool success = SniffDRM(dataSource, &mimeType, &confidence, &dummy);
|
||||
bool success = SniffWVM(dataSource, &mimeType, &confidence, &dummy);
|
||||
|
||||
if (!success
|
||||
|| strcasecmp(
|
||||
@@ -2115,13 +2121,8 @@ status_t AwesomePlayer::finishSetDataSource_l() {
|
||||
}
|
||||
}
|
||||
|
||||
dataSource->getDrmInfo(mDecryptHandle, &mDrmManagerClient);
|
||||
|
||||
if (mDecryptHandle != NULL) {
|
||||
CHECK(mDrmManagerClient);
|
||||
if (RightsStatus::RIGHTS_VALID != mDecryptHandle->status) {
|
||||
notifyListener_l(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, ERROR_DRM_NO_LICENSE);
|
||||
}
|
||||
if (extractor->getDrmFlag()) {
|
||||
checkDrmStatus(dataSource);
|
||||
}
|
||||
|
||||
status_t err = setDataSource_l(extractor);
|
||||
|
||||
@@ -282,13 +282,13 @@ bool SniffDRM(
|
||||
if (decryptHandle != NULL) {
|
||||
if (decryptHandle->decryptApiType == DecryptApiType::CONTAINER_BASED) {
|
||||
*mimeType = String8("drm+container_based+") + decryptHandle->mimeType;
|
||||
*confidence = 10.0f;
|
||||
} else if (decryptHandle->decryptApiType == DecryptApiType::ELEMENTARY_STREAM_BASED) {
|
||||
*mimeType = String8("drm+es_based+") + decryptHandle->mimeType;
|
||||
} else if (decryptHandle->decryptApiType == DecryptApiType::WV_BASED) {
|
||||
*mimeType = MEDIA_MIMETYPE_CONTAINER_WVM;
|
||||
ALOGW("SniffWVM: found match\n");
|
||||
*confidence = 10.0f;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
*confidence = 10.0f;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "include/DRMExtractor.h"
|
||||
#include "include/FLACExtractor.h"
|
||||
#include "include/AACExtractor.h"
|
||||
#include "include/WVMExtractor.h"
|
||||
|
||||
#include "matroska/MatroskaExtractor.h"
|
||||
|
||||
@@ -120,6 +121,7 @@ void DataSource::RegisterDefaultSniffers() {
|
||||
RegisterSniffer(SniffAAC);
|
||||
RegisterSniffer(SniffAVI);
|
||||
RegisterSniffer(SniffMPEG2PS);
|
||||
RegisterSniffer(SniffWVM);
|
||||
|
||||
char value[PROPERTY_VALUE_MAX];
|
||||
if (property_get("drm.service.enabled", value, NULL)
|
||||
|
||||
@@ -127,7 +127,7 @@ status_t FileSource::getSize(off64_t *size) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
sp<DecryptHandle> FileSource::DrmInitialization() {
|
||||
sp<DecryptHandle> FileSource::DrmInitialization(const char *mime) {
|
||||
if (mDrmManagerClient == NULL) {
|
||||
mDrmManagerClient = new DrmManagerClient();
|
||||
}
|
||||
@@ -138,7 +138,7 @@ sp<DecryptHandle> FileSource::DrmInitialization() {
|
||||
|
||||
if (mDecryptHandle == NULL) {
|
||||
mDecryptHandle = mDrmManagerClient->openDecryptSession(
|
||||
mFd, mOffset, mLength);
|
||||
mFd, mOffset, mLength, mime);
|
||||
}
|
||||
|
||||
if (mDecryptHandle == NULL) {
|
||||
|
||||
@@ -603,8 +603,8 @@ void NuCachedSource2::resumeFetchingIfNecessary() {
|
||||
restartPrefetcherIfNecessary_l(true /* ignore low water threshold */);
|
||||
}
|
||||
|
||||
sp<DecryptHandle> NuCachedSource2::DrmInitialization() {
|
||||
return mSource->DrmInitialization();
|
||||
sp<DecryptHandle> NuCachedSource2::DrmInitialization(const char* mime) {
|
||||
return mSource->DrmInitialization(mime);
|
||||
}
|
||||
|
||||
void NuCachedSource2::getDrmInfo(sp<DecryptHandle> &handle, DrmManagerClient **client) {
|
||||
|
||||
@@ -45,17 +45,12 @@ namespace android {
|
||||
static Mutex gWVMutex;
|
||||
|
||||
WVMExtractor::WVMExtractor(const sp<DataSource> &source)
|
||||
: mDataSource(source) {
|
||||
{
|
||||
Mutex::Autolock autoLock(gWVMutex);
|
||||
if (gVendorLibHandle == NULL) {
|
||||
gVendorLibHandle = dlopen("libwvm.so", RTLD_NOW);
|
||||
}
|
||||
: mDataSource(source)
|
||||
{
|
||||
Mutex::Autolock autoLock(gWVMutex);
|
||||
|
||||
if (gVendorLibHandle == NULL) {
|
||||
ALOGE("Failed to open libwvm.so");
|
||||
return;
|
||||
}
|
||||
if (!getVendorLibHandle()) {
|
||||
return;
|
||||
}
|
||||
|
||||
typedef WVMLoadableExtractor *(*GetInstanceFunc)(sp<DataSource>);
|
||||
@@ -64,13 +59,28 @@ WVMExtractor::WVMExtractor(const sp<DataSource> &source)
|
||||
"_ZN7android11GetInstanceENS_2spINS_10DataSourceEEE");
|
||||
|
||||
if (getInstanceFunc) {
|
||||
CHECK(source->DrmInitialization(MEDIA_MIMETYPE_CONTAINER_WVM) != NULL);
|
||||
mImpl = (*getInstanceFunc)(source);
|
||||
CHECK(mImpl != NULL);
|
||||
setDrmFlag(true);
|
||||
} else {
|
||||
ALOGE("Failed to locate GetInstance in libwvm.so");
|
||||
}
|
||||
}
|
||||
|
||||
bool WVMExtractor::getVendorLibHandle()
|
||||
{
|
||||
if (gVendorLibHandle == NULL) {
|
||||
gVendorLibHandle = dlopen("libwvm.so", RTLD_NOW);
|
||||
}
|
||||
|
||||
if (gVendorLibHandle == NULL) {
|
||||
ALOGE("Failed to open libwvm.so");
|
||||
}
|
||||
|
||||
return gVendorLibHandle != NULL;
|
||||
}
|
||||
|
||||
WVMExtractor::~WVMExtractor() {
|
||||
}
|
||||
|
||||
@@ -113,5 +123,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)(const sp<DataSource>&);
|
||||
SnifferFunc snifferFunc =
|
||||
(SnifferFunc) dlsym(gVendorLibHandle,
|
||||
"_ZN7android15IsWidevineMediaERKNS_2spINS_10DataSourceEEE");
|
||||
|
||||
if (snifferFunc) {
|
||||
if ((*snifferFunc)(source)) {
|
||||
*mimeType = MEDIA_MIMETYPE_CONTAINER_WVM;
|
||||
*confidence = 10.0f;
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
ALOGE("IsWidevineMedia not found in libwvm.so");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} //namespace android
|
||||
|
||||
|
||||
@@ -259,7 +259,7 @@ void ChromiumHTTPDataSource::onDisconnectComplete() {
|
||||
mCondition.broadcast();
|
||||
}
|
||||
|
||||
sp<DecryptHandle> ChromiumHTTPDataSource::DrmInitialization() {
|
||||
sp<DecryptHandle> ChromiumHTTPDataSource::DrmInitialization(const char* mime) {
|
||||
Mutex::Autolock autoLock(mLock);
|
||||
|
||||
if (mDrmManagerClient == NULL) {
|
||||
@@ -275,7 +275,7 @@ sp<DecryptHandle> ChromiumHTTPDataSource::DrmInitialization() {
|
||||
* original one
|
||||
*/
|
||||
mDecryptHandle = mDrmManagerClient->openDecryptSession(
|
||||
String8(mURI.c_str()));
|
||||
String8(mURI.c_str()), mime);
|
||||
}
|
||||
|
||||
if (mDecryptHandle == NULL) {
|
||||
|
||||
@@ -290,6 +290,7 @@ private:
|
||||
|
||||
bool isStreamingHTTP() const;
|
||||
void sendCacheStats();
|
||||
void checkDrmStatus(const sp<DataSource>& dataSource);
|
||||
|
||||
enum FlagMode {
|
||||
SET,
|
||||
|
||||
@@ -43,7 +43,7 @@ struct ChromiumHTTPDataSource : public HTTPBase {
|
||||
virtual status_t getSize(off64_t *size);
|
||||
virtual uint32_t flags();
|
||||
|
||||
virtual sp<DecryptHandle> DrmInitialization();
|
||||
virtual sp<DecryptHandle> DrmInitialization(const char *mime);
|
||||
|
||||
virtual void getDrmInfo(sp<DecryptHandle> &handle, DrmManagerClient **client);
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ struct NuCachedSource2 : public DataSource {
|
||||
virtual status_t getSize(off64_t *size);
|
||||
virtual uint32_t flags();
|
||||
|
||||
virtual sp<DecryptHandle> DrmInitialization();
|
||||
virtual sp<DecryptHandle> DrmInitialization(const char* mime);
|
||||
virtual void getDrmInfo(sp<DecryptHandle> &handle, DrmManagerClient **client);
|
||||
virtual String8 getUri();
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
|
||||
namespace android {
|
||||
|
||||
struct AMessage;
|
||||
class String8;
|
||||
class DataSource;
|
||||
|
||||
class WVMLoadableExtractor : public MediaExtractor {
|
||||
@@ -58,6 +60,8 @@ public:
|
||||
// is used.
|
||||
void setAdaptiveStreamingMode(bool adaptive);
|
||||
|
||||
static bool getVendorLibHandle();
|
||||
|
||||
protected:
|
||||
virtual ~WVMExtractor();
|
||||
|
||||
@@ -69,6 +73,10 @@ private:
|
||||
WVMExtractor &operator=(const WVMExtractor &);
|
||||
};
|
||||
|
||||
bool SniffWVM(
|
||||
const sp<DataSource> &source, String8 *mimeType, float *confidence,
|
||||
sp<AMessage> *);
|
||||
|
||||
} // namespace android
|
||||
|
||||
#endif // DRM_EXTRACTOR_H_
|
||||
|
||||
Reference in New Issue
Block a user