summaryrefslogtreecommitdiffstats
path: root/drm
diff options
context:
space:
mode:
authorTakeshi Aimi <aimitakeshi@gmail.com>2010-09-20 23:40:41 +0900
committerTakeshi Aimi <aimitakeshi@gmail.com>2010-10-04 22:14:53 +0900
commit2272ee27d9022d173b6eab45c409b3c3f57f30ec (patch)
tree42fd86597781bdf6b3795907ec1d086b0b549a5c /drm
parent0335b70c6cdbe96650d4bed817f9233cd8db1c6d (diff)
downloadframeworks_av-2272ee27d9022d173b6eab45c409b3c3f57f30ec.zip
frameworks_av-2272ee27d9022d173b6eab45c409b3c3f57f30ec.tar.gz
frameworks_av-2272ee27d9022d173b6eab45c409b3c3f57f30ec.tar.bz2
Update of DRM framework.
- Change "void" type of return value to "int" for returning status. - Add some of overloaded Java APIs which accept database Uri as input. - Add asynchronous APIs - Add OnEventListener and OnErrorListener for asynchronous APIs - Disable debug log - Change decrypt() API to accept an optional buffer needed by some of DRM schemes Changes are incorporated by Sony Corporation. Change-Id: I414a165e22cc79be6ea7cd28041788aa2b6b8f7c
Diffstat (limited to 'drm')
-rw-r--r--drm/common/DrmConstraints.cpp4
-rw-r--r--drm/common/DrmEngineBase.cpp38
-rw-r--r--drm/common/DrmInfoEvent.cpp4
-rw-r--r--drm/common/DrmRights.cpp22
-rw-r--r--drm/common/DrmSupportInfo.cpp4
-rw-r--r--drm/common/IDrmIOService.cpp4
-rw-r--r--drm/common/IDrmManagerService.cpp114
-rw-r--r--drm/common/IDrmServiceListener.cpp4
-rw-r--r--drm/common/ReadWriteUtils.cpp61
-rw-r--r--drm/drmserver/DrmManager.cpp136
-rw-r--r--drm/drmserver/DrmManagerService.cpp69
-rw-r--r--drm/drmserver/StringTokenizer.cpp2
-rw-r--r--drm/libdrmframework/DrmManagerClient.cpp43
-rw-r--r--drm/libdrmframework/DrmManagerClientImpl.cpp85
-rw-r--r--drm/libdrmframework/include/DrmManager.h24
-rw-r--r--drm/libdrmframework/include/DrmManagerClientImpl.h38
-rw-r--r--drm/libdrmframework/include/DrmManagerService.h24
-rw-r--r--drm/libdrmframework/include/IDrmManagerService.h52
-rw-r--r--drm/libdrmframework/include/ReadWriteUtils.h8
-rw-r--r--drm/libdrmframework/plugins/common/include/DrmEngineBase.h63
-rw-r--r--drm/libdrmframework/plugins/common/include/IDrmEngine.h41
-rw-r--r--drm/libdrmframework/plugins/passthru/include/DrmPassthruPlugIn.h22
-rw-r--r--drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp29
23 files changed, 550 insertions, 341 deletions
diff --git a/drm/common/DrmConstraints.cpp b/drm/common/DrmConstraints.cpp
index 11ce410..4a4d798 100644
--- a/drm/common/DrmConstraints.cpp
+++ b/drm/common/DrmConstraints.cpp
@@ -75,12 +75,10 @@ DrmConstraints::KeyIterator DrmConstraints::keyIterator() {
DrmConstraints::KeyIterator::KeyIterator(const DrmConstraints::KeyIterator& keyIterator)
: mDrmConstraints(keyIterator.mDrmConstraints),
mIndex(keyIterator.mIndex) {
- LOGV("DrmConstraints::KeyIterator::KeyIterator");
}
DrmConstraints::KeyIterator& DrmConstraints::KeyIterator::operator=(
const DrmConstraints::KeyIterator& keyIterator) {
- LOGV("DrmConstraints::KeyIterator::operator=");
mDrmConstraints = keyIterator.mDrmConstraints;
mIndex = keyIterator.mIndex;
return *this;
@@ -94,12 +92,10 @@ DrmConstraints::Iterator DrmConstraints::iterator() {
DrmConstraints::Iterator::Iterator(const DrmConstraints::Iterator& iterator) :
mDrmConstraints(iterator.mDrmConstraints),
mIndex(iterator.mIndex) {
- LOGV("DrmConstraints::Iterator::Iterator");
}
DrmConstraints::Iterator& DrmConstraints::Iterator::operator=(
const DrmConstraints::Iterator& iterator) {
- LOGV("DrmConstraints::Iterator::operator=");
mDrmConstraints = iterator.mDrmConstraints;
mIndex = iterator.mIndex;
return *this;
diff --git a/drm/common/DrmEngineBase.cpp b/drm/common/DrmEngineBase.cpp
index 70398e8..17cdf54 100644
--- a/drm/common/DrmEngineBase.cpp
+++ b/drm/common/DrmEngineBase.cpp
@@ -52,7 +52,7 @@ DrmInfoStatus* DrmEngineBase::processDrmInfo(int uniqueId, const DrmInfo* drmInf
return onProcessDrmInfo(uniqueId, drmInfo);
}
-void DrmEngineBase::saveRights(
+status_t DrmEngineBase::saveRights(
int uniqueId, const DrmRights& drmRights,
const String8& rightsPath, const String8& contentPath) {
return onSaveRights(uniqueId, drmRights, rightsPath, contentPath);
@@ -74,14 +74,14 @@ int DrmEngineBase::checkRightsStatus(int uniqueId, const String8& path, int acti
return onCheckRightsStatus(uniqueId, path, action);
}
-void DrmEngineBase::consumeRights(
+status_t DrmEngineBase::consumeRights(
int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) {
- onConsumeRights(uniqueId, decryptHandle, action, reserve);
+ return onConsumeRights(uniqueId, decryptHandle, action, reserve);
}
-void DrmEngineBase::setPlaybackStatus(
+status_t DrmEngineBase::setPlaybackStatus(
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) {
- onSetPlaybackStatus(uniqueId, decryptHandle, playbackStatus, position);
+ return onSetPlaybackStatus(uniqueId, decryptHandle, playbackStatus, position);
}
bool DrmEngineBase::validateAction(
@@ -90,16 +90,16 @@ bool DrmEngineBase::validateAction(
return onValidateAction(uniqueId, path, action, description);
}
-void DrmEngineBase::removeRights(int uniqueId, const String8& path) {
- onRemoveRights(uniqueId, path);
+status_t DrmEngineBase::removeRights(int uniqueId, const String8& path) {
+ return onRemoveRights(uniqueId, path);
}
-void DrmEngineBase::removeAllRights(int uniqueId) {
- onRemoveAllRights(uniqueId);
+status_t DrmEngineBase::removeAllRights(int uniqueId) {
+ return onRemoveAllRights(uniqueId);
}
-void DrmEngineBase::openConvertSession(int uniqueId, int convertId) {
- onOpenConvertSession(uniqueId, convertId);
+status_t DrmEngineBase::openConvertSession(int uniqueId, int convertId) {
+ return onOpenConvertSession(uniqueId, convertId);
}
DrmConvertedStatus* DrmEngineBase::convertData(
@@ -120,24 +120,24 @@ status_t DrmEngineBase::openDecryptSession(
return onOpenDecryptSession(uniqueId, decryptHandle, fd, offset, length);
}
-void DrmEngineBase::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
- onCloseDecryptSession(uniqueId, decryptHandle);
+status_t DrmEngineBase::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
+ return onCloseDecryptSession(uniqueId, decryptHandle);
}
-void DrmEngineBase::initializeDecryptUnit(
+status_t DrmEngineBase::initializeDecryptUnit(
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo) {
- onInitializeDecryptUnit(uniqueId, decryptHandle, decryptUnitId, headerInfo);
+ return onInitializeDecryptUnit(uniqueId, decryptHandle, decryptUnitId, headerInfo);
}
status_t DrmEngineBase::decrypt(
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
- const DrmBuffer* encBuffer, DrmBuffer** decBuffer) {
- return onDecrypt(uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer);
+ const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
+ return onDecrypt(uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV);
}
-void DrmEngineBase::finalizeDecryptUnit(
+status_t DrmEngineBase::finalizeDecryptUnit(
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {
- onFinalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId);
+ return onFinalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId);
}
ssize_t DrmEngineBase::pread(
diff --git a/drm/common/DrmInfoEvent.cpp b/drm/common/DrmInfoEvent.cpp
index eb58129..8d115a8 100644
--- a/drm/common/DrmInfoEvent.cpp
+++ b/drm/common/DrmInfoEvent.cpp
@@ -14,10 +14,6 @@
* limitations under the License.
*/
-#define LOG_NDEBUG 0
-#define LOG_TAG "DrmInfoEvent"
-#include "utils/Log.h"
-
#include <utils/String8.h>
#include <drm/DrmInfoEvent.h>
diff --git a/drm/common/DrmRights.cpp b/drm/common/DrmRights.cpp
index dc1e6c5..3aecb3d 100644
--- a/drm/common/DrmRights.cpp
+++ b/drm/common/DrmRights.cpp
@@ -15,14 +15,21 @@
*/
#include <drm/DrmRights.h>
+#include <ReadWriteUtils.h>
using namespace android;
DrmRights::DrmRights(const String8& rightsFilePath, const String8& mimeType,
- const String8& accountId, const String8& subscriptionId) {
- /**
- * TODO Read DrmRights from rights file
- */
+ const String8& accountId, const String8& subscriptionId) :
+ mMimeType(mimeType),
+ mAccountId(accountId),
+ mSubscriptionId(subscriptionId),
+ mRightsFromFile(NULL) {
+ int rightsLength = 0;
+ if (String8("") != rightsFilePath) {
+ rightsLength = ReadWriteUtils::readBytes(rightsFilePath, &mRightsFromFile);
+ }
+ mData = DrmBuffer(mRightsFromFile, rightsLength);
}
DrmRights::DrmRights(const DrmBuffer& rightsData, const String8& mimeType,
@@ -30,7 +37,12 @@ DrmRights::DrmRights(const DrmBuffer& rightsData, const String8& mimeType,
mData(rightsData),
mMimeType(mimeType),
mAccountId(accountId),
- mSubscriptionId(subscriptionId) {
+ mSubscriptionId(subscriptionId),
+ mRightsFromFile(NULL) {
+}
+
+DrmRights::~DrmRights() {
+ delete[] mRightsFromFile; mRightsFromFile = NULL;
}
const DrmBuffer& DrmRights::getData(void) const {
diff --git a/drm/common/DrmSupportInfo.cpp b/drm/common/DrmSupportInfo.cpp
index 35e83fc..ffc8953 100644
--- a/drm/common/DrmSupportInfo.cpp
+++ b/drm/common/DrmSupportInfo.cpp
@@ -42,7 +42,7 @@ bool DrmSupportInfo::operator==(const DrmSupportInfo& drmSupportInfo) const {
}
bool DrmSupportInfo::isSupportedMimeType(const String8& mimeType) const {
- for (int i = 0; i < mMimeTypeVector.size(); i++) {
+ for (unsigned int i = 0; i < mMimeTypeVector.size(); i++) {
const String8 item = mMimeTypeVector.itemAt(i);
if (String8("") != mimeType && item.find(mimeType) != -1) {
@@ -53,7 +53,7 @@ bool DrmSupportInfo::isSupportedMimeType(const String8& mimeType) const {
}
bool DrmSupportInfo::isSupportedFileSuffix(const String8& fileType) const {
- for (int i = 0; i < mFileSuffixVector.size(); i++) {
+ for (unsigned int i = 0; i < mFileSuffixVector.size(); i++) {
const String8 item = mFileSuffixVector.itemAt(i);
if (String8("") != fileType && item.find(fileType) != -1) {
diff --git a/drm/common/IDrmIOService.cpp b/drm/common/IDrmIOService.cpp
index 7ce45e7..e44ca55 100644
--- a/drm/common/IDrmIOService.cpp
+++ b/drm/common/IDrmIOService.cpp
@@ -14,10 +14,6 @@
* limitations under the License.
*/
-#define LOG_NDEBUG 0
-#define LOG_TAG "IDrmIOService"
-#include <utils/Log.h>
-
#include <stdint.h>
#include <sys/types.h>
#include <binder/Parcel.h>
diff --git a/drm/common/IDrmManagerService.cpp b/drm/common/IDrmManagerService.cpp
index 4fc828a..c28527c 100644
--- a/drm/common/IDrmManagerService.cpp
+++ b/drm/common/IDrmManagerService.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define LOG_NDEBUG 0
+//#define LOG_NDEBUG 0
#define LOG_TAG "IDrmManagerService(Native)"
#include <utils/Log.h>
@@ -36,6 +36,23 @@
using namespace android;
+int BpDrmManagerService::addUniqueId(int uniqueId) {
+ LOGV("add uniqueid");
+ Parcel data, reply;
+ data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
+ data.writeInt32(uniqueId);
+ remote()->transact(ADD_UNIQUEID, data, &reply);
+ return reply.readInt32();
+}
+
+void BpDrmManagerService::removeUniqueId(int uniqueId) {
+ LOGV("remove uniqueid");
+ Parcel data, reply;
+ data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
+ data.writeInt32(uniqueId);
+ remote()->transact(REMOVE_UNIQUEID, data, &reply);
+}
+
status_t BpDrmManagerService::loadPlugIns(int uniqueId) {
LOGV("load plugins");
Parcel data, reply;
@@ -237,7 +254,7 @@ DrmInfo* BpDrmManagerService::acquireDrmInfo(int uniqueId, const DrmInfoRequest*
return drmInfo;
}
-void BpDrmManagerService::saveRights(
+status_t BpDrmManagerService::saveRights(
int uniqueId, const DrmRights& drmRights,
const String8& rightsPath, const String8& contentPath) {
LOGV("Save Rights");
@@ -264,6 +281,7 @@ void BpDrmManagerService::saveRights(
data.writeString8((contentPath == String8("")) ? String8("NULL") : contentPath);
remote()->transact(SAVE_RIGHTS, data, &reply);
+ return reply.readInt32();
}
String8 BpDrmManagerService::getOriginalMimeType(int uniqueId, const String8& path) {
@@ -307,10 +325,10 @@ int BpDrmManagerService::checkRightsStatus(int uniqueId, const String8& path, in
return reply.readInt32();
}
-void BpDrmManagerService::consumeRights(
+status_t BpDrmManagerService::consumeRights(
int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) {
LOGV("consumeRights");
- Parcel data, reply;
+ Parcel data, reply;
data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
data.writeInt32(uniqueId);
@@ -330,9 +348,10 @@ void BpDrmManagerService::consumeRights(
data.writeInt32(static_cast< int>(reserve));
remote()->transact(CONSUME_RIGHTS, data, &reply);
+ return reply.readInt32();
}
-void BpDrmManagerService::setPlaybackStatus(
+status_t BpDrmManagerService::setPlaybackStatus(
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) {
LOGV("setPlaybackStatus");
Parcel data, reply;
@@ -355,6 +374,7 @@ void BpDrmManagerService::setPlaybackStatus(
data.writeInt32(position);
remote()->transact(SET_PLAYBACK_STATUS, data, &reply);
+ return reply.readInt32();
}
bool BpDrmManagerService::validateAction(
@@ -375,7 +395,7 @@ bool BpDrmManagerService::validateAction(
return static_cast<bool>(reply.readInt32());
}
-void BpDrmManagerService::removeRights(int uniqueId, const String8& path) {
+status_t BpDrmManagerService::removeRights(int uniqueId, const String8& path) {
LOGV("removeRights");
Parcel data, reply;
@@ -384,9 +404,10 @@ void BpDrmManagerService::removeRights(int uniqueId, const String8& path) {
data.writeString8(path);
remote()->transact(REMOVE_RIGHTS, data, &reply);
+ return reply.readInt32();
}
-void BpDrmManagerService::removeAllRights(int uniqueId) {
+status_t BpDrmManagerService::removeAllRights(int uniqueId) {
LOGV("removeAllRights");
Parcel data, reply;
@@ -394,6 +415,7 @@ void BpDrmManagerService::removeAllRights(int uniqueId) {
data.writeInt32(uniqueId);
remote()->transact(REMOVE_ALL_RIGHTS, data, &reply);
+ return reply.readInt32();
}
int BpDrmManagerService::openConvertSession(int uniqueId, const String8& mimeType) {
@@ -517,15 +539,12 @@ DecryptHandle* BpDrmManagerService::openDecryptSession(
Parcel data, reply;
const String16 interfaceDescriptor = IDrmManagerService::getInterfaceDescriptor();
- LOGV("BpDrmManagerService::openDecryptSession: InterfaceDescriptor name is %s",
- interfaceDescriptor.string());
data.writeInterfaceToken(interfaceDescriptor);
data.writeInt32(uniqueId);
data.writeFileDescriptor(fd);
data.writeInt32(offset);
data.writeInt32(length);
- LOGV("try to invoke remote onTransact() with code OPEN_DECRYPT_SESSION");
remote()->transact(OPEN_DECRYPT_SESSION, data, &reply);
DecryptHandle* handle = NULL;
@@ -546,7 +565,7 @@ DecryptHandle* BpDrmManagerService::openDecryptSession(
return handle;
}
-void BpDrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
+status_t BpDrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
LOGV("closeDecryptSession");
Parcel data, reply;
@@ -571,9 +590,10 @@ void BpDrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decry
delete decryptHandle->decryptInfo; decryptHandle->decryptInfo = NULL;
}
delete decryptHandle; decryptHandle = NULL;
+ return reply.readInt32();
}
-void BpDrmManagerService::initializeDecryptUnit(
+status_t BpDrmManagerService::initializeDecryptUnit(
int uniqueId, DecryptHandle* decryptHandle,
int decryptUnitId, const DrmBuffer* headerInfo) {
LOGV("initializeDecryptUnit");
@@ -598,11 +618,12 @@ void BpDrmManagerService::initializeDecryptUnit(
data.write(headerInfo->data, headerInfo->length);
remote()->transact(INITIALIZE_DECRYPT_UNIT, data, &reply);
+ return reply.readInt32();
}
status_t BpDrmManagerService::decrypt(
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
- const DrmBuffer* encBuffer, DrmBuffer** decBuffer) {
+ const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
LOGV("decrypt");
Parcel data, reply;
@@ -626,6 +647,11 @@ status_t BpDrmManagerService::decrypt(
data.writeInt32(encBuffer->length);
data.write(encBuffer->data, encBuffer->length);
+ if (NULL != IV) {
+ data.writeInt32(IV->length);
+ data.write(IV->data, IV->length);
+ }
+
remote()->transact(DECRYPT, data, &reply);
const status_t status = reply.readInt32();
@@ -638,7 +664,7 @@ status_t BpDrmManagerService::decrypt(
return status;
}
-void BpDrmManagerService::finalizeDecryptUnit(
+status_t BpDrmManagerService::finalizeDecryptUnit(
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {
LOGV("finalizeDecryptUnit");
Parcel data, reply;
@@ -660,6 +686,7 @@ void BpDrmManagerService::finalizeDecryptUnit(
data.writeInt32(decryptUnitId);
remote()->transact(FINALIZE_DECRYPT_UNIT, data, &reply);
+ return reply.readInt32();
}
ssize_t BpDrmManagerService::pread(
@@ -702,6 +729,23 @@ status_t BnDrmManagerService::onTransact(
LOGV("Entering BnDrmManagerService::onTransact with code %d", code);
switch (code) {
+ case ADD_UNIQUEID:
+ {
+ LOGV("BnDrmManagerService::onTransact :ADD_UNIQUEID");
+ CHECK_INTERFACE(IDrmManagerService, data, reply);
+ int uniqueId = addUniqueId(data.readInt32());
+ reply->writeInt32(uniqueId);
+ return DRM_NO_ERROR;
+ }
+
+ case REMOVE_UNIQUEID:
+ {
+ LOGV("BnDrmManagerService::onTransact :REMOVE_UNIQUEID");
+ CHECK_INTERFACE(IDrmManagerService, data, reply);
+ removeUniqueId(data.readInt32());
+ return DRM_NO_ERROR;
+ }
+
case LOAD_PLUGINS:
{
LOGV("BnDrmManagerService::onTransact :LOAD_PLUGINS");
@@ -711,7 +755,6 @@ status_t BnDrmManagerService::onTransact(
reply->writeInt32(status);
return DRM_NO_ERROR;
-
}
case LOAD_PLUGINS_FROM_PATH:
@@ -745,7 +788,8 @@ status_t BnDrmManagerService::onTransact(
LOGV("BnDrmManagerService::onTransact :UNLOAD_PLUGINS");
CHECK_INTERFACE(IDrmManagerService, data, reply);
- status_t status = unloadPlugIns(data.readInt32());
+ const int uniqueId = data.readInt32();
+ status_t status = unloadPlugIns(uniqueId);
reply->writeInt32(status);
return DRM_NO_ERROR;
@@ -923,10 +967,11 @@ status_t BnDrmManagerService::onTransact(
((accountId == String8("NULL")) ? String8("") : accountId),
((subscriptionId == String8("NULL")) ? String8("") : subscriptionId));
- saveRights(uniqueId, drmRights,
+ const status_t status = saveRights(uniqueId, drmRights,
((rightsPath == String8("NULL")) ? String8("") : rightsPath),
((contentPath == String8("NULL")) ? String8("") : contentPath));
+ reply->writeInt32(status);
return DRM_NO_ERROR;
}
@@ -985,7 +1030,10 @@ status_t BnDrmManagerService::onTransact(
handle.decryptInfo->decryptBufferLength = bufferLength;
}
- consumeRights(uniqueId, &handle, data.readInt32(), static_cast<bool>(data.readInt32()));
+ const status_t status
+ = consumeRights(uniqueId, &handle, data.readInt32(),
+ static_cast<bool>(data.readInt32()));
+ reply->writeInt32(status);
delete handle.decryptInfo; handle.decryptInfo = NULL;
return DRM_NO_ERROR;
@@ -1011,7 +1059,9 @@ status_t BnDrmManagerService::onTransact(
handle.decryptInfo->decryptBufferLength = bufferLength;
}
- setPlaybackStatus(uniqueId, &handle, data.readInt32(), data.readInt32());
+ const status_t status
+ = setPlaybackStatus(uniqueId, &handle, data.readInt32(), data.readInt32());
+ reply->writeInt32(status);
delete handle.decryptInfo; handle.decryptInfo = NULL;
return DRM_NO_ERROR;
@@ -1037,7 +1087,8 @@ status_t BnDrmManagerService::onTransact(
LOGV("BnDrmManagerService::onTransact :REMOVE_RIGHTS");
CHECK_INTERFACE(IDrmManagerService, data, reply);
- removeRights(data.readInt32(), data.readString8());
+ const status_t status = removeRights(data.readInt32(), data.readString8());
+ reply->writeInt32(status);
return DRM_NO_ERROR;
}
@@ -1047,7 +1098,8 @@ status_t BnDrmManagerService::onTransact(
LOGV("BnDrmManagerService::onTransact :REMOVE_ALL_RIGHTS");
CHECK_INTERFACE(IDrmManagerService, data, reply);
- removeAllRights(data.readInt32());
+ const status_t status = removeAllRights(data.readInt32());
+ reply->writeInt32(status);
return DRM_NO_ERROR;
}
@@ -1207,7 +1259,8 @@ status_t BnDrmManagerService::onTransact(
handle->decryptInfo->decryptBufferLength = bufferLength;
}
- closeDecryptSession(uniqueId, handle);
+ const status_t status = closeDecryptSession(uniqueId, handle);
+ reply->writeInt32(status);
return DRM_NO_ERROR;
}
@@ -1237,7 +1290,9 @@ status_t BnDrmManagerService::onTransact(
DrmBuffer* headerInfo = NULL;
headerInfo = new DrmBuffer((char *)data.readInplace(bufferSize), bufferSize);
- initializeDecryptUnit(uniqueId, &handle, decryptUnitId, headerInfo);
+ const status_t status
+ = initializeDecryptUnit(uniqueId, &handle, decryptUnitId, headerInfo);
+ reply->writeInt32(status);
delete handle.decryptInfo; handle.decryptInfo = NULL;
delete headerInfo; headerInfo = NULL;
@@ -1274,7 +1329,14 @@ status_t BnDrmManagerService::onTransact(
buffer = new char[decBufferSize];
DrmBuffer* decBuffer = new DrmBuffer(buffer, decBufferSize);
- const status_t status = decrypt(uniqueId, &handle, decryptUnitId, encBuffer, &decBuffer);
+ DrmBuffer* IV = NULL;
+ if (0 != data.dataAvail()) {
+ const int ivBufferlength = data.readInt32();
+ IV = new DrmBuffer((char *)data.readInplace(ivBufferlength), ivBufferlength);
+ }
+
+ const status_t status
+ = decrypt(uniqueId, &handle, decryptUnitId, encBuffer, &decBuffer, IV);
reply->writeInt32(status);
@@ -1286,6 +1348,7 @@ status_t BnDrmManagerService::onTransact(
delete encBuffer; encBuffer = NULL;
delete decBuffer; decBuffer = NULL;
delete [] buffer; buffer = NULL;
+ delete IV; IV = NULL;
return DRM_NO_ERROR;
}
@@ -1309,7 +1372,8 @@ status_t BnDrmManagerService::onTransact(
handle.decryptInfo->decryptBufferLength = bufferLength;
}
- finalizeDecryptUnit(uniqueId, &handle, data.readInt32());
+ const status_t status = finalizeDecryptUnit(uniqueId, &handle, data.readInt32());
+ reply->writeInt32(status);
delete handle.decryptInfo; handle.decryptInfo = NULL;
return DRM_NO_ERROR;
diff --git a/drm/common/IDrmServiceListener.cpp b/drm/common/IDrmServiceListener.cpp
index 0a69115..6eeea40 100644
--- a/drm/common/IDrmServiceListener.cpp
+++ b/drm/common/IDrmServiceListener.cpp
@@ -14,10 +14,6 @@
* limitations under the License.
*/
-#define LOG_NDEBUG 0
-#define LOG_TAG "IDrmServiceListener"
-#include <utils/Log.h>
-
#include <stdint.h>
#include <sys/types.h>
#include <binder/Parcel.h>
diff --git a/drm/common/ReadWriteUtils.cpp b/drm/common/ReadWriteUtils.cpp
index 4319c1c..7ec4fa2 100644
--- a/drm/common/ReadWriteUtils.cpp
+++ b/drm/common/ReadWriteUtils.cpp
@@ -14,6 +14,10 @@
* limitations under the License.
*/
+//#define LOG_NDEBUG 0
+#define LOG_TAG "ReadWriteUtils"
+#include <utils/Log.h>
+
#include <ReadWriteUtils.h>
#include <sys/mman.h>
#include <sys/stat.h>
@@ -22,7 +26,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-#include <utils/FileMap.h>
#include <utils/String8.h>
using namespace android;
@@ -39,18 +42,39 @@ String8 ReadWriteUtils::readBytes(const String8& filePath) {
struct stat sb;
if (fstat(fd, &sb) == 0 && sb.st_size > 0) {
- FileMap* fileMap = new FileMap();
- if (fileMap->create(filePath.string(), fd, 0, sb.st_size, true)) {
- char* addr = (char*)fileMap->getDataPtr();
- string.append(addr, sb.st_size);
- fileMap->release();
+ int length = sb.st_size;
+ char* bytes = new char[length];
+ if (length == read(fd, (void*) bytes, length)) {
+ string.append(bytes, length);
}
+ delete bytes;
}
fclose(file);
}
return string;
}
+int ReadWriteUtils::readBytes(const String8& filePath, char** buffer) {
+ FILE* file = NULL;
+ file = fopen(filePath.string(), "r");
+ int length = 0;
+
+ if (NULL != file) {
+ int fd = fileno(file);
+ struct stat sb;
+
+ if (fstat(fd, &sb) == 0 && sb.st_size > 0) {
+ length = sb.st_size;
+ *buffer = new char[length];
+ if (length != read(fd, (void*) *buffer, length)) {
+ length = FAILURE;
+ }
+ }
+ fclose(file);
+ }
+ return length;
+}
+
void ReadWriteUtils::writeToFile(const String8& filePath, const String8& data) {
FILE* file = NULL;
file = fopen(filePath.string(), "w+");
@@ -60,12 +84,8 @@ void ReadWriteUtils::writeToFile(const String8& filePath, const String8& data) {
int size = data.size();
if (FAILURE != ftruncate(fd, size)) {
- FileMap* fileMap = NULL;
- fileMap = new FileMap();
- if (fileMap->create(filePath.string(), fd, 0, size, false)) {
- char* addr = (char*)fileMap->getDataPtr();
- memcpy(addr, data.string(), size);
- fileMap->release();
+ if (size != write(fd, data.string(), size)) {
+ LOGE("Failed to write the data to: %s", filePath.string());
}
}
fclose(file);
@@ -79,20 +99,9 @@ void ReadWriteUtils::appendToFile(const String8& filePath, const String8& data)
if (NULL != file) {
int fd = fileno(file);
- int offset = lseek(fd, 0, SEEK_END);
- if (FAILURE != offset) {
- int newEntrySize = data.size();
- int fileSize = offset + newEntrySize;
-
- if (FAILURE != ftruncate(fd, fileSize)) {
- FileMap* fileMap = NULL;
- fileMap = new FileMap();
- if (fileMap->create(filePath.string(), fd, offset, fileSize, false)) {
- char* addr = (char*)fileMap->getDataPtr();
- memcpy(addr, data.string(), data.size());
- fileMap->release();
- }
- }
+ int size = data.size();
+ if (size != write(fd, data.string(), size)) {
+ LOGE("Failed to write the data to: %s", filePath.string());
}
fclose(file);
}
diff --git a/drm/drmserver/DrmManager.cpp b/drm/drmserver/DrmManager.cpp
index 44886f9..52527dc 100644
--- a/drm/drmserver/DrmManager.cpp
+++ b/drm/drmserver/DrmManager.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define LOG_NDEBUG 0
+//#define LOG_NDEBUG 0
#define LOG_TAG "DrmManager(Native)"
#include "utils/Log.h"
@@ -36,6 +36,7 @@
using namespace android;
+Vector<int> DrmManager::mUniqueIdVector;
const String8 DrmManager::EMPTY_STRING("");
DrmManager::DrmManager() :
@@ -48,6 +49,42 @@ DrmManager::~DrmManager() {
}
+int DrmManager::addUniqueId(int uniqueId) {
+ if (0 == uniqueId) {
+ int temp = 0;
+ bool foundUniqueId = false;
+ srand(time(NULL));
+
+ while (!foundUniqueId) {
+ const int size = mUniqueIdVector.size();
+ temp = rand() % 100;
+
+ int index = 0;
+ for (; index < size; ++index) {
+ if (mUniqueIdVector.itemAt(index) == temp) {
+ foundUniqueId = false;
+ break;
+ }
+ }
+ if (index == size) {
+ foundUniqueId = true;
+ }
+ }
+ uniqueId = temp;
+ }
+ mUniqueIdVector.push(uniqueId);
+ return uniqueId;
+}
+
+void DrmManager::removeUniqueId(int uniqueId) {
+ for (unsigned int i = 0; i < mUniqueIdVector.size(); i++) {
+ if (uniqueId == mUniqueIdVector.itemAt(i)) {
+ mUniqueIdVector.removeAt(i);
+ break;
+ }
+ }
+}
+
status_t DrmManager::loadPlugIns(int uniqueId) {
String8 pluginDirPath("/system/lib/drm/plugins/native");
return loadPlugIns(uniqueId, pluginDirPath);
@@ -82,10 +119,12 @@ status_t DrmManager::unloadPlugIns(int uniqueId) {
rDrmEngine.terminate(uniqueId);
}
- mConvertSessionMap.clear();
- mDecryptSessionMap.clear();
- mSupportInfoToPlugInIdMap.clear();
- mPlugInManager.unloadPlugIns();
+ if (0 >= mUniqueIdVector.size()) {
+ mConvertSessionMap.clear();
+ mDecryptSessionMap.clear();
+ mSupportInfoToPlugInIdMap.clear();
+ mPlugInManager.unloadPlugIns();
+ }
return DRM_NO_ERROR;
}
@@ -159,13 +198,15 @@ DrmInfo* DrmManager::acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoR
return NULL;
}
-void DrmManager::saveRights(int uniqueId, const DrmRights& drmRights,
+status_t DrmManager::saveRights(int uniqueId, const DrmRights& drmRights,
const String8& rightsPath, const String8& contentPath) {
const String8 plugInId = getSupportedPlugInId(drmRights.getMimeType());
+ status_t result = DRM_ERROR_UNKNOWN;
if (EMPTY_STRING != plugInId) {
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
- rDrmEngine.saveRights(uniqueId, drmRights, rightsPath, contentPath);
+ result = rDrmEngine.saveRights(uniqueId, drmRights, rightsPath, contentPath);
}
+ return result;
}
String8 DrmManager::getOriginalMimeType(int uniqueId, const String8& path) {
@@ -195,21 +236,24 @@ int DrmManager::checkRightsStatus(int uniqueId, const String8& path, int action)
return RightsStatus::RIGHTS_INVALID;
}
-void DrmManager::consumeRights(
+status_t DrmManager::consumeRights(
int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) {
+ status_t result = DRM_ERROR_UNKNOWN;
if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) {
IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId);
- drmEngine->consumeRights(uniqueId, decryptHandle, action, reserve);
+ result = drmEngine->consumeRights(uniqueId, decryptHandle, action, reserve);
}
+ return result;
}
-void DrmManager::setPlaybackStatus(
+status_t DrmManager::setPlaybackStatus(
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) {
-
+ status_t result = DRM_ERROR_UNKNOWN;
if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) {
IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId);
- drmEngine->setPlaybackStatus(uniqueId, decryptHandle, playbackStatus, position);
+ result = drmEngine->setPlaybackStatus(uniqueId, decryptHandle, playbackStatus, position);
}
+ return result;
}
bool DrmManager::validateAction(
@@ -222,21 +266,27 @@ bool DrmManager::validateAction(
return false;
}
-void DrmManager::removeRights(int uniqueId, const String8& path) {
+status_t DrmManager::removeRights(int uniqueId, const String8& path) {
const String8 plugInId = getSupportedPlugInIdFromPath(uniqueId, path);
+ status_t result = DRM_ERROR_UNKNOWN;
if (EMPTY_STRING != plugInId) {
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
- rDrmEngine.removeRights(uniqueId, path);
+ result = rDrmEngine.removeRights(uniqueId, path);
}
+ return result;
}
-void DrmManager::removeAllRights(int uniqueId) {
+status_t DrmManager::removeAllRights(int uniqueId) {
Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList();
-
+ status_t result = DRM_ERROR_UNKNOWN;
for (unsigned int index = 0; index < plugInIdList.size(); index++) {
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInIdList.itemAt(index));
- rDrmEngine.removeAllRights(uniqueId);
+ result = rDrmEngine.removeAllRights(uniqueId);
+ if (DRM_NO_ERROR != result) {
+ break;
+ }
}
+ return result;
}
int DrmManager::openConvertSession(int uniqueId, const String8& mimeType) {
@@ -246,12 +296,12 @@ int DrmManager::openConvertSession(int uniqueId, const String8& mimeType) {
if (EMPTY_STRING != plugInId) {
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
- Mutex::Autolock _l(mConvertLock);
- ++mConvertId;
- convertId = mConvertId;
- mConvertSessionMap.add(mConvertId, &rDrmEngine);
-
- rDrmEngine.openConvertSession(uniqueId, mConvertId);
+ if (DRM_NO_ERROR == rDrmEngine.openConvertSession(uniqueId, mConvertId + 1)) {
+ Mutex::Autolock _l(mConvertLock);
+ ++mConvertId;
+ convertId = mConvertId;
+ mConvertSessionMap.add(convertId, &rDrmEngine);
+ }
}
return convertId;
}
@@ -310,7 +360,6 @@ status_t DrmManager::getAllSupportInfo(
}
DecryptHandle* DrmManager::openDecryptSession(int uniqueId, int fd, int offset, int length) {
- LOGV("Entering DrmManager::openDecryptSession");
status_t result = DRM_ERROR_CANNOT_HANDLE;
Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList();
@@ -324,18 +373,15 @@ DecryptHandle* DrmManager::openDecryptSession(int uniqueId, int fd, int offset,
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
result = rDrmEngine.openDecryptSession(uniqueId, handle, fd, offset, length);
- LOGV("plug-in %s return value = %d", plugInId.string(), result);
-
if (DRM_NO_ERROR == result) {
++mDecryptSessionId;
mDecryptSessionMap.add(mDecryptSessionId, &rDrmEngine);
- LOGV("plug-in %s is selected", plugInId.string());
break;
}
}
}
- if (DRM_ERROR_CANNOT_HANDLE == result) {
+ if (DRM_NO_ERROR != result) {
delete handle; handle = NULL;
LOGE("DrmManager::openDecryptSession: no capable plug-in found");
}
@@ -343,39 +389,47 @@ DecryptHandle* DrmManager::openDecryptSession(int uniqueId, int fd, int offset,
return handle;
}
-void DrmManager::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
+status_t DrmManager::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
+ status_t result = DRM_ERROR_UNKNOWN;
if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) {
IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId);
- drmEngine->closeDecryptSession(uniqueId, decryptHandle);
-
- mDecryptSessionMap.removeItem(decryptHandle->decryptId);
+ result = drmEngine->closeDecryptSession(uniqueId, decryptHandle);
+ if (DRM_NO_ERROR == result) {
+ mDecryptSessionMap.removeItem(decryptHandle->decryptId);
+ }
}
+ return result;
}
-void DrmManager::initializeDecryptUnit(
+status_t DrmManager::initializeDecryptUnit(
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo) {
+ status_t result = DRM_ERROR_UNKNOWN;
if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) {
IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId);
- drmEngine->initializeDecryptUnit(uniqueId, decryptHandle, decryptUnitId, headerInfo);
+ result = drmEngine->initializeDecryptUnit(uniqueId, decryptHandle, decryptUnitId, headerInfo);
}
+ return result;
}
-status_t DrmManager::decrypt(int uniqueId, DecryptHandle* decryptHandle,
- int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer) {
- status_t status = DRM_ERROR_UNKNOWN;
+status_t DrmManager::decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
+ const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
+ status_t result = DRM_ERROR_UNKNOWN;
if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) {
IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId);
- status = drmEngine->decrypt(uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer);
+ result = drmEngine->decrypt(
+ uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV);
}
- return status;
+ return result;
}
-void DrmManager::finalizeDecryptUnit(
+status_t DrmManager::finalizeDecryptUnit(
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {
+ status_t result = DRM_ERROR_UNKNOWN;
if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) {
IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId);
- drmEngine->finalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId);
+ result = drmEngine->finalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId);
}
+ return result;
}
ssize_t DrmManager::pread(int uniqueId, DecryptHandle* decryptHandle,
diff --git a/drm/drmserver/DrmManagerService.cpp b/drm/drmserver/DrmManagerService.cpp
index 9d000e9..843dddb 100644
--- a/drm/drmserver/DrmManagerService.cpp
+++ b/drm/drmserver/DrmManagerService.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define LOG_NDEBUG 0
+//#define LOG_NDEBUG 0
#define LOG_TAG "DrmManagerService(Native)"
#include <utils/Log.h>
@@ -29,20 +29,23 @@ using namespace android;
#define SUCCESS 0
#define DRM_DIRECTORY_PERMISSION 0700
+#define DRM_PLUGINS_ROOT "/data/drm/plugins"
+#define DRM_PLUGINS_NATIVE "/data/drm/plugins/native"
+#define DRM_PLUGINS_NATIVE_DATABASES "/data/drm/plugins/native/databases"
void DrmManagerService::instantiate() {
LOGV("instantiate");
- int res = mkdir("/data/drm/plugins", DRM_DIRECTORY_PERMISSION);
- if (SUCCESS == res || EEXIST == errno) {
- res = mkdir("/data/drm/plugins/native", DRM_DIRECTORY_PERMISSION);
- if (SUCCESS == res || EEXIST == errno) {
- res = mkdir("/data/drm/plugins/native/databases", DRM_DIRECTORY_PERMISSION);
- if (SUCCESS == res || EEXIST == errno) {
- defaultServiceManager()
- ->addService(String16("drm.drmManager"), new DrmManagerService());
- }
- }
+ int res = mkdir(DRM_PLUGINS_ROOT, DRM_DIRECTORY_PERMISSION);
+ if (SUCCESS == res || EEXIST == errno) {
+ res = mkdir(DRM_PLUGINS_NATIVE, DRM_DIRECTORY_PERMISSION);
+ if (SUCCESS == res || EEXIST == errno) {
+ res = mkdir(DRM_PLUGINS_NATIVE_DATABASES, DRM_DIRECTORY_PERMISSION);
+ if (SUCCESS == res || EEXIST == errno) {
+ defaultServiceManager()
+ ->addService(String16("drm.drmManager"), new DrmManagerService());
+ }
+ }
}
}
@@ -57,6 +60,14 @@ DrmManagerService::~DrmManagerService() {
delete mDrmManager; mDrmManager = NULL;
}
+int DrmManagerService::addUniqueId(int uniqueId) {
+ return mDrmManager->addUniqueId(uniqueId);
+}
+
+void DrmManagerService::removeUniqueId(int uniqueId) {
+ mDrmManager->removeUniqueId(uniqueId);
+}
+
status_t DrmManagerService::loadPlugIns(int uniqueId) {
LOGV("Entering load plugins");
return mDrmManager->loadPlugIns(uniqueId);
@@ -105,7 +116,7 @@ DrmInfo* DrmManagerService::acquireDrmInfo(int uniqueId, const DrmInfoRequest* d
return mDrmManager->acquireDrmInfo(uniqueId, drmInfoRequest);
}
-void DrmManagerService::saveRights(
+status_t DrmManagerService::saveRights(
int uniqueId, const DrmRights& drmRights,
const String8& rightsPath, const String8& contentPath) {
LOGV("Entering saveRights");
@@ -129,16 +140,16 @@ int DrmManagerService::checkRightsStatus(
return mDrmManager->checkRightsStatus(uniqueId, path, action);
}
-void DrmManagerService::consumeRights(
+status_t DrmManagerService::consumeRights(
int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) {
LOGV("Entering consumeRights");
- mDrmManager->consumeRights(uniqueId, decryptHandle, action, reserve);
+ return mDrmManager->consumeRights(uniqueId, decryptHandle, action, reserve);
}
-void DrmManagerService::setPlaybackStatus(
+status_t DrmManagerService::setPlaybackStatus(
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) {
LOGV("Entering setPlaybackStatus");
- mDrmManager->setPlaybackStatus(uniqueId, decryptHandle, playbackStatus, position);
+ return mDrmManager->setPlaybackStatus(uniqueId, decryptHandle, playbackStatus, position);
}
bool DrmManagerService::validateAction(
@@ -148,14 +159,14 @@ bool DrmManagerService::validateAction(
return mDrmManager->validateAction(uniqueId, path, action, description);
}
-void DrmManagerService::removeRights(int uniqueId, const String8& path) {
+status_t DrmManagerService::removeRights(int uniqueId, const String8& path) {
LOGV("Entering removeRights");
- mDrmManager->removeRights(uniqueId, path);
+ return mDrmManager->removeRights(uniqueId, path);
}
-void DrmManagerService::removeAllRights(int uniqueId) {
+status_t DrmManagerService::removeAllRights(int uniqueId) {
LOGV("Entering removeAllRights");
- mDrmManager->removeAllRights(uniqueId);
+ return mDrmManager->removeAllRights(uniqueId);
}
int DrmManagerService::openConvertSession(int uniqueId, const String8& mimeType) {
@@ -186,28 +197,28 @@ DecryptHandle* DrmManagerService::openDecryptSession(
return mDrmManager->openDecryptSession(uniqueId, fd, offset, length);
}
-void DrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
+status_t DrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
LOGV("Entering closeDecryptSession");
- mDrmManager->closeDecryptSession(uniqueId, decryptHandle);
+ return mDrmManager->closeDecryptSession(uniqueId, decryptHandle);
}
-void DrmManagerService::initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
+status_t DrmManagerService::initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
int decryptUnitId, const DrmBuffer* headerInfo) {
LOGV("Entering initializeDecryptUnit");
- mDrmManager->initializeDecryptUnit(uniqueId,decryptHandle, decryptUnitId, headerInfo);
+ return mDrmManager->initializeDecryptUnit(uniqueId,decryptHandle, decryptUnitId, headerInfo);
}
status_t DrmManagerService::decrypt(
- int uniqueId, DecryptHandle* decryptHandle,
- int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer) {
+ int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
+ const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
LOGV("Entering decrypt");
- return mDrmManager->decrypt(uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer);
+ return mDrmManager->decrypt(uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV);
}
-void DrmManagerService::finalizeDecryptUnit(
+status_t DrmManagerService::finalizeDecryptUnit(
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {
LOGV("Entering finalizeDecryptUnit");
- mDrmManager->finalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId);
+ return mDrmManager->finalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId);
}
ssize_t DrmManagerService::pread(int uniqueId, DecryptHandle* decryptHandle,
diff --git a/drm/drmserver/StringTokenizer.cpp b/drm/drmserver/StringTokenizer.cpp
index 367c9bd..2130a00 100644
--- a/drm/drmserver/StringTokenizer.cpp
+++ b/drm/drmserver/StringTokenizer.cpp
@@ -45,12 +45,10 @@ StringTokenizer::Iterator StringTokenizer::iterator() {
StringTokenizer::Iterator::Iterator(const StringTokenizer::Iterator& iterator) :
mStringTokenizer(iterator.mStringTokenizer),
mIndex(iterator.mIndex) {
- LOGV("StringTokenizer::Iterator::Iterator");
}
StringTokenizer::Iterator& StringTokenizer::Iterator::operator=(
const StringTokenizer::Iterator& iterator) {
- LOGV("StringTokenizer::Iterator::operator=");
mStringTokenizer = iterator.mStringTokenizer;
mIndex = iterator.mIndex;
return *this;
diff --git a/drm/libdrmframework/DrmManagerClient.cpp b/drm/libdrmframework/DrmManagerClient.cpp
index 06c7c50..c996994 100644
--- a/drm/libdrmframework/DrmManagerClient.cpp
+++ b/drm/libdrmframework/DrmManagerClient.cpp
@@ -14,10 +14,6 @@
* limitations under the License.
*/
-#define LOG_NDEBUG 0
-#define LOG_TAG "DrmManagerClient(Native)"
-#include <utils/Log.h>
-
#include <utils/String8.h>
#include <binder/IServiceManager.h>
#include <drm/DrmManagerClient.h>
@@ -37,8 +33,8 @@ DrmManagerClient::DrmManagerClient() {
}
DrmManagerClient::~DrmManagerClient() {
- unloadPlugIns();
DrmManagerClientImpl::remove(mUniqueId);
+ unloadPlugIns();
delete mDrmManagerClientImpl; mDrmManagerClientImpl = NULL;
}
@@ -72,7 +68,7 @@ DrmInfo* DrmManagerClient::acquireDrmInfo(const DrmInfoRequest* drmInfoRequest)
return mDrmManagerClientImpl->acquireDrmInfo(mUniqueId, drmInfoRequest);
}
-void DrmManagerClient::saveRights(
+status_t DrmManagerClient::saveRights(
const DrmRights& drmRights, const String8& rightsPath, const String8& contentPath) {
return mDrmManagerClientImpl->saveRights(mUniqueId, drmRights, rightsPath, contentPath);
}
@@ -89,13 +85,14 @@ int DrmManagerClient::checkRightsStatus(const String8& path, int action) {
return mDrmManagerClientImpl->checkRightsStatus(mUniqueId, path, action);
}
-void DrmManagerClient::consumeRights(DecryptHandle* decryptHandle, int action, bool reserve) {
- mDrmManagerClientImpl->consumeRights(mUniqueId, decryptHandle, action, reserve);
+status_t DrmManagerClient::consumeRights(DecryptHandle* decryptHandle, int action, bool reserve) {
+ return mDrmManagerClientImpl->consumeRights(mUniqueId, decryptHandle, action, reserve);
}
-void DrmManagerClient::setPlaybackStatus(
+status_t DrmManagerClient::setPlaybackStatus(
DecryptHandle* decryptHandle, int playbackStatus, int position) {
- mDrmManagerClientImpl->setPlaybackStatus(mUniqueId, decryptHandle, playbackStatus, position);
+ return mDrmManagerClientImpl
+ ->setPlaybackStatus(mUniqueId, decryptHandle, playbackStatus, position);
}
bool DrmManagerClient::validateAction(
@@ -103,12 +100,12 @@ bool DrmManagerClient::validateAction(
return mDrmManagerClientImpl->validateAction(mUniqueId, path, action, description);
}
-void DrmManagerClient::removeRights(const String8& path) {
- mDrmManagerClientImpl->removeRights(mUniqueId, path);
+status_t DrmManagerClient::removeRights(const String8& path) {
+ return mDrmManagerClientImpl->removeRights(mUniqueId, path);
}
-void DrmManagerClient::removeAllRights() {
- mDrmManagerClientImpl->removeAllRights(mUniqueId);
+status_t DrmManagerClient::removeAllRights() {
+ return mDrmManagerClientImpl->removeAllRights(mUniqueId);
}
int DrmManagerClient::openConvertSession(const String8& mimeType) {
@@ -131,25 +128,25 @@ DecryptHandle* DrmManagerClient::openDecryptSession(int fd, int offset, int leng
return mDrmManagerClientImpl->openDecryptSession(mUniqueId, fd, offset, length);
}
-void DrmManagerClient::closeDecryptSession(DecryptHandle* decryptHandle) {
- mDrmManagerClientImpl->closeDecryptSession(mUniqueId, decryptHandle);
+status_t DrmManagerClient::closeDecryptSession(DecryptHandle* decryptHandle) {
+ return mDrmManagerClientImpl->closeDecryptSession(mUniqueId, decryptHandle);
}
-void DrmManagerClient::initializeDecryptUnit(
+status_t DrmManagerClient::initializeDecryptUnit(
DecryptHandle* decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo) {
- mDrmManagerClientImpl->initializeDecryptUnit(
- mUniqueId, decryptHandle, decryptUnitId, headerInfo);
+ return mDrmManagerClientImpl->initializeDecryptUnit(
+ mUniqueId, decryptHandle, decryptUnitId, headerInfo);
}
status_t DrmManagerClient::decrypt(
DecryptHandle* decryptHandle, int decryptUnitId,
- const DrmBuffer* encBuffer, DrmBuffer** decBuffer) {
+ const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
return mDrmManagerClientImpl->decrypt(
- mUniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer);
+ mUniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV);
}
-void DrmManagerClient::finalizeDecryptUnit(DecryptHandle* decryptHandle, int decryptUnitId) {
- mDrmManagerClientImpl->finalizeDecryptUnit(mUniqueId, decryptHandle, decryptUnitId);
+status_t DrmManagerClient::finalizeDecryptUnit(DecryptHandle* decryptHandle, int decryptUnitId) {
+ return mDrmManagerClientImpl->finalizeDecryptUnit(mUniqueId, decryptHandle, decryptUnitId);
}
ssize_t DrmManagerClient::pread(
diff --git a/drm/libdrmframework/DrmManagerClientImpl.cpp b/drm/libdrmframework/DrmManagerClientImpl.cpp
index 7274b49..272adcd 100644
--- a/drm/libdrmframework/DrmManagerClientImpl.cpp
+++ b/drm/libdrmframework/DrmManagerClientImpl.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define LOG_NDEBUG 0
+//#define LOG_NDEBUG 0
#define LOG_TAG "DrmManagerClientImpl(Native)"
#include <utils/Log.h>
@@ -29,44 +29,21 @@ using namespace android;
#define INVALID_VALUE -1
Mutex DrmManagerClientImpl::mMutex;
-Vector<int> DrmManagerClientImpl::mUniqueIdVector;
sp<IDrmManagerService> DrmManagerClientImpl::mDrmManagerService;
const String8 DrmManagerClientImpl::EMPTY_STRING("");
DrmManagerClientImpl* DrmManagerClientImpl::create(int* pUniqueId) {
if (0 == *pUniqueId) {
- int uniqueId = 0;
- bool foundUniqueId = false;
- srand(time(NULL));
-
- while (!foundUniqueId) {
- const int size = mUniqueIdVector.size();
- uniqueId = rand() % 100;
-
- int index = 0;
- for (; index < size; ++index) {
- if (mUniqueIdVector.itemAt(index) == uniqueId) {
- foundUniqueId = false;
- break;
- }
- }
- if (index == size) {
- foundUniqueId = true;
- }
- }
+ int uniqueId = getDrmManagerService()->addUniqueId(*pUniqueId);
*pUniqueId = uniqueId;
+ } else {
+ getDrmManagerService()->addUniqueId(*pUniqueId);
}
- mUniqueIdVector.push(*pUniqueId);
return new DrmManagerClientImpl();
}
void DrmManagerClientImpl::remove(int uniqueId) {
- for (int i = 0; i < mUniqueIdVector.size(); i++) {
- if (uniqueId == mUniqueIdVector.itemAt(i)) {
- mUniqueIdVector.removeAt(i);
- break;
- }
- }
+ getDrmManagerService()->removeUniqueId(uniqueId);
}
DrmManagerClientImpl::DrmManagerClientImpl() {
@@ -164,11 +141,13 @@ DrmInfo* DrmManagerClientImpl::acquireDrmInfo(int uniqueId, const DrmInfoRequest
return drmInfo;
}
-void DrmManagerClientImpl::saveRights(int uniqueId, const DrmRights& drmRights,
+status_t DrmManagerClientImpl::saveRights(int uniqueId, const DrmRights& drmRights,
const String8& rightsPath, const String8& contentPath) {
+ status_t status = DRM_ERROR_UNKNOWN;
if (EMPTY_STRING != contentPath) {
- getDrmManagerService()->saveRights(uniqueId, drmRights, rightsPath, contentPath);
+ status = getDrmManagerService()->saveRights(uniqueId, drmRights, rightsPath, contentPath);
}
+ return status;
}
String8 DrmManagerClientImpl::getOriginalMimeType(int uniqueId, const String8& path) {
@@ -197,19 +176,23 @@ int DrmManagerClientImpl::checkRightsStatus(
return rightsStatus;
}
-void DrmManagerClientImpl::consumeRights(
+status_t DrmManagerClientImpl::consumeRights(
int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) {
+ status_t status = DRM_ERROR_UNKNOWN;
if (NULL != decryptHandle) {
- getDrmManagerService()->consumeRights(uniqueId, decryptHandle, action, reserve);
+ status = getDrmManagerService()->consumeRights(uniqueId, decryptHandle, action, reserve);
}
+ return status;
}
-void DrmManagerClientImpl::setPlaybackStatus(
+status_t DrmManagerClientImpl::setPlaybackStatus(
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) {
+ status_t status = DRM_ERROR_UNKNOWN;
if (NULL != decryptHandle) {
- getDrmManagerService()->setPlaybackStatus(
+ status = getDrmManagerService()->setPlaybackStatus(
uniqueId, decryptHandle, playbackStatus, position);
}
+ return status;
}
bool DrmManagerClientImpl::validateAction(
@@ -221,14 +204,16 @@ bool DrmManagerClientImpl::validateAction(
return retCode;
}
-void DrmManagerClientImpl::removeRights(int uniqueId, const String8& path) {
+status_t DrmManagerClientImpl::removeRights(int uniqueId, const String8& path) {
+ status_t status = DRM_ERROR_UNKNOWN;
if (EMPTY_STRING != path) {
- getDrmManagerService()->removeRights(uniqueId, path);
+ status = getDrmManagerService()->removeRights(uniqueId, path);
}
+ return status;
}
-void DrmManagerClientImpl::removeAllRights(int uniqueId) {
- getDrmManagerService()->removeAllRights(uniqueId);
+status_t DrmManagerClientImpl::removeAllRights(int uniqueId) {
+ return getDrmManagerService()->removeAllRights(uniqueId);
}
int DrmManagerClientImpl::openConvertSession(int uniqueId, const String8& mimeType) {
@@ -263,40 +248,46 @@ status_t DrmManagerClientImpl::getAllSupportInfo(
DecryptHandle* DrmManagerClientImpl::openDecryptSession(
int uniqueId, int fd, int offset, int length) {
- LOGV("Entering DrmManagerClientImpl::openDecryptSession");
return getDrmManagerService()->openDecryptSession(uniqueId, fd, offset, length);
}
-void DrmManagerClientImpl::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
+status_t DrmManagerClientImpl::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
+ status_t status = DRM_ERROR_UNKNOWN;
if (NULL != decryptHandle) {
- getDrmManagerService()->closeDecryptSession( uniqueId, decryptHandle);
+ status = getDrmManagerService()->closeDecryptSession( uniqueId, decryptHandle);
}
+ return status;
}
-void DrmManagerClientImpl::initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
+status_t DrmManagerClientImpl::initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
int decryptUnitId, const DrmBuffer* headerInfo) {
+ status_t status = DRM_ERROR_UNKNOWN;
if ((NULL != decryptHandle) && (NULL != headerInfo)) {
- getDrmManagerService()->initializeDecryptUnit(
+ status = getDrmManagerService()->initializeDecryptUnit(
uniqueId, decryptHandle, decryptUnitId, headerInfo);
}
+ return status;
}
status_t DrmManagerClientImpl::decrypt(int uniqueId, DecryptHandle* decryptHandle,
- int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer) {
+ int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
status_t status = DRM_ERROR_UNKNOWN;
if ((NULL != decryptHandle) && (NULL != encBuffer)
&& (NULL != decBuffer) && (NULL != *decBuffer)) {
status = getDrmManagerService()->decrypt(
- uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer);
+ uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV);
}
return status;
}
-void DrmManagerClientImpl::finalizeDecryptUnit(
+status_t DrmManagerClientImpl::finalizeDecryptUnit(
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {
+ status_t status = DRM_ERROR_UNKNOWN;
if (NULL != decryptHandle) {
- getDrmManagerService()->finalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId);
+ status
+ = getDrmManagerService()->finalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId);
}
+ return status;
}
ssize_t DrmManagerClientImpl::pread(int uniqueId, DecryptHandle* decryptHandle,
diff --git a/drm/libdrmframework/include/DrmManager.h b/drm/libdrmframework/include/DrmManager.h
index 2ba9e99..dc3e460 100644
--- a/drm/libdrmframework/include/DrmManager.h
+++ b/drm/libdrmframework/include/DrmManager.h
@@ -53,6 +53,9 @@ public:
virtual ~DrmManager();
public:
+ int addUniqueId(int uniqueId);
+
+ void removeUniqueId(int uniqueId);
status_t loadPlugIns(int uniqueId);
@@ -73,7 +76,7 @@ public:
DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest);
- void saveRights(int uniqueId, const DrmRights& drmRights,
+ status_t saveRights(int uniqueId, const DrmRights& drmRights,
const String8& rightsPath, const String8& contentPath);
String8 getOriginalMimeType(int uniqueId, const String8& path);
@@ -82,17 +85,17 @@ public:
int checkRightsStatus(int uniqueId, const String8& path, int action);
- void consumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
+ status_t consumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
- void setPlaybackStatus(
+ status_t setPlaybackStatus(
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position);
bool validateAction(
int uniqueId, const String8& path, int action, const ActionDescription& description);
- void removeRights(int uniqueId, const String8& path);
+ status_t removeRights(int uniqueId, const String8& path);
- void removeAllRights(int uniqueId);
+ status_t removeAllRights(int uniqueId);
int openConvertSession(int uniqueId, const String8& mimeType);
@@ -104,15 +107,15 @@ public:
DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length);
- void closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
+ status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
- void initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
+ status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
int decryptUnitId, const DrmBuffer* headerInfo);
- status_t decrypt(int uniqueId, DecryptHandle* decryptHandle,
- int decryptUnitId, const DrmBuffer* encBuffer,DrmBuffer** decBuffer);
+ status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
+ const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV);
- void finalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
+ status_t finalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
void* buffer, ssize_t numBytes, off_t offset);
@@ -133,6 +136,7 @@ private:
void initializePlugIns(int uniqueId);
private:
+ static Vector<int> mUniqueIdVector;
static const String8 EMPTY_STRING;
int mDecryptSessionId;
diff --git a/drm/libdrmframework/include/DrmManagerClientImpl.h b/drm/libdrmframework/include/DrmManagerClientImpl.h
index e70e6e1..492c7f5 100644
--- a/drm/libdrmframework/include/DrmManagerClientImpl.h
+++ b/drm/libdrmframework/include/DrmManagerClientImpl.h
@@ -132,8 +132,10 @@ public:
* @param[in] drmRights DrmRights to be saved
* @param[in] rightsPath File path where rights to be saved
* @param[in] contentPath File path where content was saved
+ * @return status_t
+ * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
- void saveRights(int uniqueId, const DrmRights& drmRights,
+ status_t saveRights(int uniqueId, const DrmRights& drmRights,
const String8& rightsPath, const String8& contentPath);
/**
@@ -179,8 +181,10 @@ public:
* @param[in] decryptHandle Handle for the decryption session
* @param[in] action Action to perform. (Action::DEFAULT, Action::PLAY, etc)
* @param[in] reserve True if the rights should be reserved.
+ * @return status_t
+ * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
- void consumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
+ status_t consumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
/**
* Informs the DRM engine about the playback actions performed on the DRM files.
@@ -190,8 +194,10 @@ public:
* @param[in] playbackStatus Playback action (Playback::START, Playback::STOP, Playback::PAUSE)
* @param[in] position Position in the file (in milliseconds) where the start occurs.
* Only valid together with Playback::START.
+ * @return status_t
+ * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
- void setPlaybackStatus(
+ status_t setPlaybackStatus(
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position);
/**
@@ -211,16 +217,20 @@ public:
*
* @param[in] uniqueId Unique identifier for a session
* @param[in] path Path of the protected content
+ * @return status_t
+ * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
- void removeRights(int uniqueId, const String8& path);
+ status_t removeRights(int uniqueId, const String8& path);
/**
* Removes all the rights information of each plug-in associated with
* DRM framework. Will be used in master reset
*
* @param[in] uniqueId Unique identifier for a session
+ * @return status_t
+ * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
- void removeAllRights(int uniqueId);
+ status_t removeAllRights(int uniqueId);
/**
* This API is for Forward Lock based DRM scheme.
@@ -295,8 +305,10 @@ public:
*
* @param[in] uniqueId Unique identifier for a session
* @param[in] decryptHandle Handle for the decryption session
+ * @return status_t
+ * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
- void closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
+ status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
/**
* Initialize decryption for the given unit of the protected content
@@ -305,8 +317,10 @@ public:
* @param[in] decryptHandle Handle for the decryption session
* @param[in] decryptUnitId ID which specifies decryption unit, such as track ID
* @param[in] headerInfo Information for initializing decryption of this decrypUnit
+ * @return status_t
+ * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
- void initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
+ status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
int decryptUnitId, const DrmBuffer* headerInfo);
/**
@@ -319,14 +333,15 @@ public:
* @param[in] decryptUnitId ID which specifies decryption unit, such as track ID
* @param[in] encBuffer Encrypted data block
* @param[out] decBuffer Decrypted data block
+ * @param[in] IV Optional buffer
* @return status_t
* Returns the error code for this API
* DRM_NO_ERROR for success, and one of DRM_ERROR_UNKNOWN, DRM_ERROR_LICENSE_EXPIRED
* DRM_ERROR_SESSION_NOT_OPENED, DRM_ERROR_DECRYPT_UNIT_NOT_INITIALIZED,
* DRM_ERROR_DECRYPT for failure.
*/
- status_t decrypt(int uniqueId, DecryptHandle* decryptHandle,
- int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer);
+ status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
+ const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV);
/**
* Finalize decryption for the given unit of the protected content
@@ -334,8 +349,10 @@ public:
* @param[in] uniqueId Unique identifier for a session
* @param[in] decryptHandle Handle for the decryption session
* @param[in] decryptUnitId ID which specifies decryption unit, such as track ID
+ * @return status_t
+ * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
- void finalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
+ status_t finalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
/**
* Reads the specified number of bytes from an open DRM file.
@@ -388,7 +405,6 @@ private:
private:
static Mutex mMutex;
- static Vector<int> mUniqueIdVector;
static sp<IDrmManagerService> mDrmManagerService;
static const sp<IDrmManagerService>& getDrmManagerService();
static const String8 EMPTY_STRING;
diff --git a/drm/libdrmframework/include/DrmManagerService.h b/drm/libdrmframework/include/DrmManagerService.h
index fef121c..f455e15 100644
--- a/drm/libdrmframework/include/DrmManagerService.h
+++ b/drm/libdrmframework/include/DrmManagerService.h
@@ -46,6 +46,10 @@ private:
virtual ~DrmManagerService();
public:
+ int addUniqueId(int uniqueId);
+
+ void removeUniqueId(int uniqueId);
+
status_t loadPlugIns(int uniqueId);
status_t loadPlugIns(int uniqueId, const String8& plugInDirPath);
@@ -65,7 +69,7 @@ public:
DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInforequest);
- void saveRights(int uniqueId, const DrmRights& drmRights,
+ status_t saveRights(int uniqueId, const DrmRights& drmRights,
const String8& rightsPath, const String8& contentPath);
String8 getOriginalMimeType(int uniqueId, const String8& path);
@@ -74,17 +78,17 @@ public:
int checkRightsStatus(int uniqueId, const String8& path,int action);
- void consumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
+ status_t consumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
- void setPlaybackStatus(
+ status_t setPlaybackStatus(
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position);
bool validateAction(int uniqueId, const String8& path,
int action, const ActionDescription& description);
- void removeRights(int uniqueId, const String8& path);
+ status_t removeRights(int uniqueId, const String8& path);
- void removeAllRights(int uniqueId);
+ status_t removeAllRights(int uniqueId);
int openConvertSession(int uniqueId, const String8& mimeType);
@@ -96,15 +100,15 @@ public:
DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length);
- void closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
+ status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
- void initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
+ status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
int decryptUnitId, const DrmBuffer* headerInfo);
- status_t decrypt(int uniqueId, DecryptHandle* decryptHandle,
- int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer);
+ status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
+ const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV);
- void finalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
+ status_t finalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
void* buffer, ssize_t numBytes, off_t offset);
diff --git a/drm/libdrmframework/include/IDrmManagerService.h b/drm/libdrmframework/include/IDrmManagerService.h
index a4d128a..5c668ed 100644
--- a/drm/libdrmframework/include/IDrmManagerService.h
+++ b/drm/libdrmframework/include/IDrmManagerService.h
@@ -44,7 +44,9 @@ class IDrmManagerService : public IInterface
{
public:
enum {
- LOAD_PLUGINS = IBinder::FIRST_CALL_TRANSACTION,
+ ADD_UNIQUEID = IBinder::FIRST_CALL_TRANSACTION,
+ REMOVE_UNIQUEID,
+ LOAD_PLUGINS,
LOAD_PLUGINS_FROM_PATH,
SET_DRM_SERVICE_LISTENER,
UNLOAD_PLUGINS,
@@ -78,6 +80,10 @@ public:
DECLARE_META_INTERFACE(DrmManagerService);
public:
+ virtual int addUniqueId(int uniqueId) = 0;
+
+ virtual void removeUniqueId(int uniqueId) = 0;
+
virtual status_t loadPlugIns(int uniqueId) = 0;
virtual status_t loadPlugIns(int uniqueId, const String8& plugInDirPath) = 0;
@@ -98,7 +104,7 @@ public:
virtual DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInforequest) = 0;
- virtual void saveRights(int uniqueId, const DrmRights& drmRights,
+ virtual status_t saveRights(int uniqueId, const DrmRights& drmRights,
const String8& rightsPath, const String8& contentPath) = 0;
virtual String8 getOriginalMimeType(int uniqueId, const String8& path) = 0;
@@ -108,19 +114,19 @@ public:
virtual int checkRightsStatus(int uniqueId, const String8& path, int action) = 0;
- virtual void consumeRights(
+ virtual status_t consumeRights(
int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) = 0;
- virtual void setPlaybackStatus(
+ virtual status_t setPlaybackStatus(
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) = 0;
virtual bool validateAction(
int uniqueId, const String8& path,
int action, const ActionDescription& description) = 0;
- virtual void removeRights(int uniqueId, const String8& path) = 0;
+ virtual status_t removeRights(int uniqueId, const String8& path) = 0;
- virtual void removeAllRights(int uniqueId) = 0;
+ virtual status_t removeAllRights(int uniqueId) = 0;
virtual int openConvertSession(int uniqueId, const String8& mimeType) = 0;
@@ -134,15 +140,15 @@ public:
virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length) = 0;
- virtual void closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) = 0;
+ virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) = 0;
- virtual void initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
+ virtual status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
int decryptUnitId, const DrmBuffer* headerInfo) = 0;
- virtual status_t decrypt(int uniqueId, DecryptHandle* decryptHandle,
- int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer) = 0;
+ virtual status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
+ const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) = 0;
- virtual void finalizeDecryptUnit(
+ virtual status_t finalizeDecryptUnit(
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) = 0;
virtual ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
@@ -158,6 +164,10 @@ public:
BpDrmManagerService(const sp<IBinder>& impl)
: BpInterface<IDrmManagerService>(impl) {}
+ virtual int addUniqueId(int uniqueId);
+
+ virtual void removeUniqueId(int uniqueId);
+
virtual status_t loadPlugIns(int uniqueId);
virtual status_t loadPlugIns(int uniqueId, const String8& plugInDirPath);
@@ -177,7 +187,7 @@ public:
virtual DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInforequest);
- virtual void saveRights(int uniqueId, const DrmRights& drmRights,
+ virtual status_t saveRights(int uniqueId, const DrmRights& drmRights,
const String8& rightsPath, const String8& contentPath);
virtual String8 getOriginalMimeType(int uniqueId, const String8& path);
@@ -186,18 +196,18 @@ public:
virtual int checkRightsStatus(int uniqueId, const String8& path, int action);
- virtual void consumeRights(
+ virtual status_t consumeRights(
int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
- virtual void setPlaybackStatus(
+ virtual status_t setPlaybackStatus(
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position);
virtual bool validateAction(
int uniqueId, const String8& path, int action, const ActionDescription& description);
- virtual void removeRights(int uniqueId, const String8& path);
+ virtual status_t removeRights(int uniqueId, const String8& path);
- virtual void removeAllRights(int uniqueId);
+ virtual status_t removeAllRights(int uniqueId);
virtual int openConvertSession(int uniqueId, const String8& mimeType);
@@ -211,15 +221,15 @@ public:
virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length);
- virtual void closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
+ virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
- virtual void initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
+ virtual status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
int decryptUnitId, const DrmBuffer* headerInfo);
- virtual status_t decrypt(int uniqueId, DecryptHandle* decryptHandle,
- int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer);
+ virtual status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
+ const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV);
- virtual void finalizeDecryptUnit(
+ virtual status_t finalizeDecryptUnit(
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
virtual ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
diff --git a/drm/libdrmframework/include/ReadWriteUtils.h b/drm/libdrmframework/include/ReadWriteUtils.h
index 022149e..529b342 100644
--- a/drm/libdrmframework/include/ReadWriteUtils.h
+++ b/drm/libdrmframework/include/ReadWriteUtils.h
@@ -47,6 +47,14 @@ public:
*/
static String8 readBytes(const String8& filePath);
/**
+ * Reads the data into the given buffer from the file path provided
+ *
+ * @param[in] filePath Path of the file
+ * @param[out] buffer Data read from the file
+ * @return Length of the data read from the file
+ */
+ static int readBytes(const String8& filePath, char** buffer);
+ /**
* Writes the data into the file path provided
*
* @param[in] filePath Path of the file
diff --git a/drm/libdrmframework/plugins/common/include/DrmEngineBase.h b/drm/libdrmframework/plugins/common/include/DrmEngineBase.h
index 667958a..b355534 100644
--- a/drm/libdrmframework/plugins/common/include/DrmEngineBase.h
+++ b/drm/libdrmframework/plugins/common/include/DrmEngineBase.h
@@ -46,7 +46,7 @@ public:
DrmInfoStatus* processDrmInfo(int uniqueId, const DrmInfo* drmInfo);
- void saveRights(int uniqueId, const DrmRights& drmRights,
+ status_t saveRights(int uniqueId, const DrmRights& drmRights,
const String8& rightsPath, const String8& contentPath);
DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest);
@@ -57,19 +57,19 @@ public:
int checkRightsStatus(int uniqueId, const String8& path, int action);
- void consumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
+ status_t consumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
- void setPlaybackStatus(
+ status_t setPlaybackStatus(
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position);
bool validateAction(
int uniqueId, const String8& path, int action, const ActionDescription& description);
- void removeRights(int uniqueId, const String8& path);
+ status_t removeRights(int uniqueId, const String8& path);
- void removeAllRights(int uniqueId);
+ status_t removeAllRights(int uniqueId);
- void openConvertSession(int uniqueId, int convertId);
+ status_t openConvertSession(int uniqueId, int convertId);
DrmConvertedStatus* convertData(int uniqueId, int convertId, const DrmBuffer* inputData);
@@ -80,15 +80,15 @@ public:
status_t openDecryptSession(
int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length);
- void closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
+ status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
- void initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
+ status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
int decryptUnitId, const DrmBuffer* headerInfo);
- status_t decrypt(int uniqueId, DecryptHandle* decryptHandle,
- int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer);
+ status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
+ const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV);
- void finalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
+ status_t finalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
void* buffer, ssize_t numBytes, off_t offset);
@@ -172,8 +172,10 @@ protected:
* @param[in] drmRights DrmRights to be saved
* @param[in] rightsPath File path where rights to be saved
* @param[in] contentPath File path where content was saved
+ * @return status_t
+ * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
- virtual void onSaveRights(int uniqueId, const DrmRights& drmRights,
+ virtual status_t onSaveRights(int uniqueId, const DrmRights& drmRights,
const String8& rightspath, const String8& contentPath) = 0;
/**
@@ -231,8 +233,10 @@ protected:
* @param[in] decryptHandle Handle for the decryption session
* @param[in] action Action to perform. (Action::DEFAULT, Action::PLAY, etc)
* @param[in] reserve True if the rights should be reserved.
+ * @return status_t
+ * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
- virtual void onConsumeRights(int uniqueId, DecryptHandle* decryptHandle,
+ virtual status_t onConsumeRights(int uniqueId, DecryptHandle* decryptHandle,
int action, bool reserve) = 0;
/**
@@ -243,8 +247,10 @@ protected:
* @param[in] playbackStatus Playback action (Playback::START, Playback::STOP, Playback::PAUSE)
* @param[in] position Position in the file (in milliseconds) where the start occurs.
* Only valid together with Playback::START.
+ * @return status_t
+ * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
- virtual void onSetPlaybackStatus(
+ virtual status_t onSetPlaybackStatus(
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) = 0;
/**
@@ -264,16 +270,20 @@ protected:
*
* @param[in] uniqueId Unique identifier for a session
* @param[in] path Path of the protected content
+ * @return status_t
+ * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
- virtual void onRemoveRights(int uniqueId, const String8& path) = 0;
+ virtual status_t onRemoveRights(int uniqueId, const String8& path) = 0;
/**
* Removes all the rights information of each plug-in associated with
* DRM framework. Will be used in master reset
*
* @param[in] uniqueId Unique identifier for a session
+ * @return status_t
+ * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
- virtual void onRemoveAllRights(int uniqueId) = 0;
+ virtual status_t onRemoveAllRights(int uniqueId) = 0;
/**
* This API is for Forward Lock based DRM scheme.
@@ -283,8 +293,10 @@ protected:
*
* @param[in] uniqueId Unique identifier for a session
* @param[in] convertId Handle for the convert session
+ * @return status_t
+ * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
- virtual void onOpenConvertSession(int uniqueId, int convertId) = 0;
+ virtual status_t onOpenConvertSession(int uniqueId, int convertId) = 0;
/**
* Accepts and converts the input data which is part of DRM file.
@@ -347,8 +359,10 @@ protected:
*
* @param[in] uniqueId Unique identifier for a session
* @param[in] decryptHandle Handle for the decryption session
+ * @return status_t
+ * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
- virtual void onCloseDecryptSession(int uniqueId, DecryptHandle* decryptHandle) = 0;
+ virtual status_t onCloseDecryptSession(int uniqueId, DecryptHandle* decryptHandle) = 0;
/**
* Initialize decryption for the given unit of the protected content
@@ -357,8 +371,10 @@ protected:
* @param[in] decryptId Handle for the decryption session
* @param[in] decryptUnitId ID Specifies decryption unit, such as track ID
* @param[in] headerInfo Information for initializing decryption of this decrypUnit
+ * @return status_t
+ * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
- virtual void onInitializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
+ virtual status_t onInitializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
int decryptUnitId, const DrmBuffer* headerInfo) = 0;
/**
@@ -371,14 +387,15 @@ protected:
* @param[in] decryptUnitId ID Specifies decryption unit, such as track ID
* @param[in] encBuffer Encrypted data block
* @param[out] decBuffer Decrypted data block
+ * @param[in] IV Optional buffer
* @return status_t
* Returns the error code for this API
* DRM_NO_ERROR for success, and one of DRM_ERROR_UNKNOWN, DRM_ERROR_LICENSE_EXPIRED
* DRM_ERROR_SESSION_NOT_OPENED, DRM_ERROR_DECRYPT_UNIT_NOT_INITIALIZED,
* DRM_ERROR_DECRYPT for failure.
*/
- virtual status_t onDecrypt(int uniqueId, DecryptHandle* decryptHandle,
- int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer) = 0;
+ virtual status_t onDecrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
+ const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) = 0;
/**
* Finalize decryption for the given unit of the protected content
@@ -386,8 +403,10 @@ protected:
* @param[in] uniqueId Unique identifier for a session
* @param[in] decryptHandle Handle for the decryption session
* @param[in] decryptUnitId ID Specifies decryption unit, such as track ID
+ * @return status_t
+ * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
- virtual void onFinalizeDecryptUnit(
+ virtual status_t onFinalizeDecryptUnit(
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) = 0;
/**
diff --git a/drm/libdrmframework/plugins/common/include/IDrmEngine.h b/drm/libdrmframework/plugins/common/include/IDrmEngine.h
index 0d52f66..b711500 100644
--- a/drm/libdrmframework/plugins/common/include/IDrmEngine.h
+++ b/drm/libdrmframework/plugins/common/include/IDrmEngine.h
@@ -143,8 +143,10 @@ public:
* @param[in] drmRights DrmRights to be saved
* @param[in] rightsPath File path where rights to be saved
* @param[in] contentPath File path where content was saved
+ * @return status_t
+ * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
- virtual void saveRights(int uniqueId, const DrmRights& drmRights,
+ virtual status_t saveRights(int uniqueId, const DrmRights& drmRights,
const String8& rightsPath, const String8& contentPath) = 0;
/**
@@ -191,8 +193,10 @@ public:
* @param[in] decryptHandle Handle for the decryption session
* @param[in] action Action to perform. (Action::DEFAULT, Action::PLAY, etc)
* @param[in] reserve True if the rights should be reserved.
+ * @return status_t
+ * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
- virtual void consumeRights(
+ virtual status_t consumeRights(
int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) = 0;
/**
@@ -203,8 +207,10 @@ public:
* @param[in] playbackStatus Playback action (Playback::START, Playback::STOP, Playback::PAUSE)
* @param[in] position Position in the file (in milliseconds) where the start occurs.
* Only valid together with Playback::START.
+ * @return status_t
+ * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
- virtual void setPlaybackStatus(int uniqueId, DecryptHandle* decryptHandle,
+ virtual status_t setPlaybackStatus(int uniqueId, DecryptHandle* decryptHandle,
int playbackStatus, int position) = 0;
/**
@@ -224,16 +230,20 @@ public:
*
* @param[in] uniqueId Unique identifier for a session
* @param[in] path Path of the protected content
+ * @return status_t
+ * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
- virtual void removeRights(int uniqueId, const String8& path) = 0;
+ virtual status_t removeRights(int uniqueId, const String8& path) = 0;
/**
* Removes all the rights information of each plug-in associated with
* DRM framework. Will be used in master reset
*
* @param[in] uniqueId Unique identifier for a session
+ * @return status_t
+ * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
- virtual void removeAllRights(int uniqueId) = 0;
+ virtual status_t removeAllRights(int uniqueId) = 0;
/**
* This API is for Forward Lock based DRM scheme.
@@ -243,8 +253,10 @@ public:
*
* @param[in] uniqueId Unique identifier for a session
* @param[in] convertId Handle for the convert session
+ * @return status_t
+ * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
- virtual void openConvertSession(int uniqueId, int convertId) = 0;
+ virtual status_t openConvertSession(int uniqueId, int convertId) = 0;
/**
* Accepts and converts the input data which is part of DRM file.
@@ -307,8 +319,10 @@ public:
*
* @param[in] uniqueId Unique identifier for a session
* @param[in] decryptHandle Handle for the decryption session
+ * @return status_t
+ * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
- virtual void closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) = 0;
+ virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) = 0;
/**
* Initialize decryption for the given unit of the protected content
@@ -317,8 +331,10 @@ public:
* @param[in] decryptHandle Handle for the decryption session
* @param[in] decryptUnitId ID which specifies decryption unit, such as track ID
* @param[in] headerInfo Information for initializing decryption of this decrypUnit
+ * @return status_t
+ * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
- virtual void initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
+ virtual status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
int decryptUnitId, const DrmBuffer* headerInfo) = 0;
/**
@@ -331,14 +347,15 @@ public:
* @param[in] decryptUnitId ID which specifies decryption unit, such as track ID
* @param[in] encBuffer Encrypted data block
* @param[out] decBuffer Decrypted data block
+ * @param[in] IV Optional buffer
* @return status_t
* Returns the error code for this API
* DRM_NO_ERROR for success, and one of DRM_ERROR_UNKNOWN, DRM_ERROR_LICENSE_EXPIRED
* DRM_ERROR_SESSION_NOT_OPENED, DRM_ERROR_DECRYPT_UNIT_NOT_INITIALIZED,
* DRM_ERROR_DECRYPT for failure.
*/
- virtual status_t decrypt(int uniqueId, DecryptHandle* decryptHandle,
- int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer) = 0;
+ virtual status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
+ const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) = 0;
/**
* Finalize decryption for the given unit of the protected content
@@ -346,8 +363,10 @@ public:
* @param[in] uniqueId Unique identifier for a session
* @param[in] decryptHandle Handle for the decryption session
* @param[in] decryptUnitId ID which specifies decryption unit, such as track ID
+ * @return status_t
+ * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
- virtual void finalizeDecryptUnit(
+ virtual status_t finalizeDecryptUnit(
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) = 0;
/**
diff --git a/drm/libdrmframework/plugins/passthru/include/DrmPassthruPlugIn.h b/drm/libdrmframework/plugins/passthru/include/DrmPassthruPlugIn.h
index d2c7852..eed1628 100644
--- a/drm/libdrmframework/plugins/passthru/include/DrmPassthruPlugIn.h
+++ b/drm/libdrmframework/plugins/passthru/include/DrmPassthruPlugIn.h
@@ -40,7 +40,7 @@ protected:
DrmInfoStatus* onProcessDrmInfo(int uniqueId, const DrmInfo* drmInfo);
- void onSaveRights(int uniqueId, const DrmRights& drmRights,
+ status_t onSaveRights(int uniqueId, const DrmRights& drmRights,
const String8& rightsPath, const String8& contentPath);
DrmInfo* onAcquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest);
@@ -51,19 +51,19 @@ protected:
int onCheckRightsStatus(int uniqueId, const String8& path, int action);
- void onConsumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
+ status_t onConsumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
- void onSetPlaybackStatus(
+ status_t onSetPlaybackStatus(
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position);
bool onValidateAction(
int uniqueId, const String8& path, int action, const ActionDescription& description);
- void onRemoveRights(int uniqueId, const String8& path);
+ status_t onRemoveRights(int uniqueId, const String8& path);
- void onRemoveAllRights(int uniqueId);
+ status_t onRemoveAllRights(int uniqueId);
- void onOpenConvertSession(int uniqueId, int convertId);
+ status_t onOpenConvertSession(int uniqueId, int convertId);
DrmConvertedStatus* onConvertData(int uniqueId, int convertId, const DrmBuffer* inputData);
@@ -74,15 +74,15 @@ protected:
status_t onOpenDecryptSession(
int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length);
- void onCloseDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
+ status_t onCloseDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
- void onInitializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
+ status_t onInitializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
int decryptUnitId, const DrmBuffer* headerInfo);
- status_t onDecrypt(int uniqueId, DecryptHandle* decryptHandle,
- int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer);
+ status_t onDecrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
+ const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV);
- void onFinalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
+ status_t onFinalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
ssize_t onPread(int uniqueId, DecryptHandle* decryptHandle,
void* buffer, ssize_t numBytes, off_t offset);
diff --git a/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp b/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp
index 2655d0b..4c7714d 100644
--- a/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp
+++ b/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp
@@ -129,9 +129,10 @@ DrmSupportInfo* DrmPassthruPlugIn::onGetSupportInfo(int uniqueId) {
return drmSupportInfo;
}
-void DrmPassthruPlugIn::onSaveRights(int uniqueId, const DrmRights& drmRights,
+status_t DrmPassthruPlugIn::onSaveRights(int uniqueId, const DrmRights& drmRights,
const String8& rightsPath, const String8& contentPath) {
LOGD("DrmPassthruPlugIn::onSaveRights : %d", uniqueId);
+ return DRM_NO_ERROR;
}
DrmInfo* DrmPassthruPlugIn::onAcquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest) {
@@ -174,14 +175,16 @@ int DrmPassthruPlugIn::onCheckRightsStatus(int uniqueId, const String8& path, in
return rightsStatus;
}
-void DrmPassthruPlugIn::onConsumeRights(int uniqueId, DecryptHandle* decryptHandle,
+status_t DrmPassthruPlugIn::onConsumeRights(int uniqueId, DecryptHandle* decryptHandle,
int action, bool reserve) {
LOGD("DrmPassthruPlugIn::onConsumeRights() : %d", uniqueId);
+ return DRM_NO_ERROR;
}
-void DrmPassthruPlugIn::onSetPlaybackStatus(int uniqueId, DecryptHandle* decryptHandle,
+status_t DrmPassthruPlugIn::onSetPlaybackStatus(int uniqueId, DecryptHandle* decryptHandle,
int playbackStatus, int position) {
LOGD("DrmPassthruPlugIn::onSetPlaybackStatus() : %d", uniqueId);
+ return DRM_NO_ERROR;
}
bool DrmPassthruPlugIn::onValidateAction(int uniqueId, const String8& path,
@@ -190,16 +193,19 @@ bool DrmPassthruPlugIn::onValidateAction(int uniqueId, const String8& path,
return true;
}
-void DrmPassthruPlugIn::onRemoveRights(int uniqueId, const String8& path) {
+status_t DrmPassthruPlugIn::onRemoveRights(int uniqueId, const String8& path) {
LOGD("DrmPassthruPlugIn::onRemoveRights() : %d", uniqueId);
+ return DRM_NO_ERROR;
}
-void DrmPassthruPlugIn::onRemoveAllRights(int uniqueId) {
+status_t DrmPassthruPlugIn::onRemoveAllRights(int uniqueId) {
LOGD("DrmPassthruPlugIn::onRemoveAllRights() : %d", uniqueId);
+ return DRM_NO_ERROR;
}
-void DrmPassthruPlugIn::onOpenConvertSession(int uniqueId, int convertId) {
+status_t DrmPassthruPlugIn::onOpenConvertSession(int uniqueId, int convertId) {
LOGD("DrmPassthruPlugIn::onOpenConvertSession() : %d", uniqueId);
+ return DRM_NO_ERROR;
}
DrmConvertedStatus* DrmPassthruPlugIn::onConvertData(
@@ -237,7 +243,7 @@ status_t DrmPassthruPlugIn::onOpenDecryptSession(
return DRM_ERROR_CANNOT_HANDLE;
}
-void DrmPassthruPlugIn::onCloseDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
+status_t DrmPassthruPlugIn::onCloseDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
LOGD("DrmPassthruPlugIn::onCloseDecryptSession() : %d", uniqueId);
if (NULL != decryptHandle) {
if (NULL != decryptHandle->decryptInfo) {
@@ -245,15 +251,17 @@ void DrmPassthruPlugIn::onCloseDecryptSession(int uniqueId, DecryptHandle* decry
}
delete decryptHandle; decryptHandle = NULL;
}
+ return DRM_NO_ERROR;
}
-void DrmPassthruPlugIn::onInitializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
+status_t DrmPassthruPlugIn::onInitializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
int decryptUnitId, const DrmBuffer* headerInfo) {
LOGD("DrmPassthruPlugIn::onInitializeDecryptUnit() : %d", uniqueId);
+ return DRM_NO_ERROR;
}
status_t DrmPassthruPlugIn::onDecrypt(int uniqueId, DecryptHandle* decryptHandle,
- int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer) {
+ int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
LOGD("DrmPassthruPlugIn::onDecrypt() : %d", uniqueId);
/**
* As a workaround implementation passthru would copy the given
@@ -267,9 +275,10 @@ status_t DrmPassthruPlugIn::onDecrypt(int uniqueId, DecryptHandle* decryptHandle
return DRM_NO_ERROR;
}
-void DrmPassthruPlugIn::onFinalizeDecryptUnit(
+status_t DrmPassthruPlugIn::onFinalizeDecryptUnit(
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {
LOGD("DrmPassthruPlugIn::onFinalizeDecryptUnit() : %d", uniqueId);
+ return DRM_NO_ERROR;
}
ssize_t DrmPassthruPlugIn::onPread(int uniqueId, DecryptHandle* decryptHandle,