diff options
author | Gloria Wang <gwang@google.com> | 2010-11-03 11:39:04 -0700 |
---|---|---|
committer | Gloria Wang <gwang@google.com> | 2010-11-03 11:39:04 -0700 |
commit | b251f75d5ca3fa19cfe8a284717e00dec31f18ea (patch) | |
tree | edb48bc69001ca3ef96bf072d71441bc8a60d547 /drm/libdrmframework | |
parent | bf3122eed31cd24acdf5cfd25541db0beb77e6f0 (diff) | |
parent | 3041096d137144d9d1ebdd6df88ebe8e85133c05 (diff) | |
download | frameworks_av-b251f75d5ca3fa19cfe8a284717e00dec31f18ea.zip frameworks_av-b251f75d5ca3fa19cfe8a284717e00dec31f18ea.tar.gz frameworks_av-b251f75d5ca3fa19cfe8a284717e00dec31f18ea.tar.bz2 |
resolved conflicts for merge of a8d7b747 to master
Change-Id: I8a4b72c9f9a10de8bbc285e00e2dd5cb9f498349
Diffstat (limited to 'drm/libdrmframework')
-rw-r--r-- | drm/libdrmframework/DrmManagerClient.cpp | 32 | ||||
-rw-r--r-- | drm/libdrmframework/DrmManagerClientImpl.cpp | 32 | ||||
-rw-r--r-- | drm/libdrmframework/include/DrmManager.h | 18 | ||||
-rw-r--r-- | drm/libdrmframework/include/DrmManagerClientImpl.h | 40 | ||||
-rw-r--r-- | drm/libdrmframework/include/DrmManagerService.h | 8 | ||||
-rw-r--r-- | drm/libdrmframework/include/IDrmManagerService.h | 22 | ||||
-rw-r--r-- | drm/libdrmframework/plugins/common/include/DrmEngineBase.h | 15 | ||||
-rw-r--r-- | drm/libdrmframework/plugins/common/include/IDrmEngine.h | 12 | ||||
-rw-r--r-- | drm/libdrmframework/plugins/passthru/include/DrmPassthruPlugIn.h | 3 | ||||
-rw-r--r-- | drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp | 17 |
10 files changed, 108 insertions, 91 deletions
diff --git a/drm/libdrmframework/DrmManagerClient.cpp b/drm/libdrmframework/DrmManagerClient.cpp index c996994..f0439eb 100644 --- a/drm/libdrmframework/DrmManagerClient.cpp +++ b/drm/libdrmframework/DrmManagerClient.cpp @@ -22,36 +22,23 @@ using namespace android; -DrmManagerClient::DrmManagerClient() { - int uniqueId = 0; - mDrmManagerClientImpl = NULL; - - mDrmManagerClientImpl = DrmManagerClientImpl::create(&uniqueId); - mUniqueId = uniqueId; - - loadPlugIns(); +DrmManagerClient::DrmManagerClient(): + mUniqueId(0), mDrmManagerClientImpl(NULL) { + mDrmManagerClientImpl = DrmManagerClientImpl::create(&mUniqueId); + mDrmManagerClientImpl->addClient(mUniqueId); } DrmManagerClient::~DrmManagerClient() { DrmManagerClientImpl::remove(mUniqueId); - unloadPlugIns(); - + mDrmManagerClientImpl->removeClient(mUniqueId); delete mDrmManagerClientImpl; mDrmManagerClientImpl = NULL; } -status_t DrmManagerClient::loadPlugIns() { - return mDrmManagerClientImpl->loadPlugIns(mUniqueId); -} - status_t DrmManagerClient::setOnInfoListener( const sp<DrmManagerClient::OnInfoListener>& infoListener) { return mDrmManagerClientImpl->setOnInfoListener(mUniqueId, infoListener); } -status_t DrmManagerClient::unloadPlugIns() { - return mDrmManagerClientImpl->unloadPlugIns(mUniqueId); -} - DrmConstraints* DrmManagerClient::getConstraints(const String8* path, const int action) { return mDrmManagerClientImpl->getConstraints(mUniqueId, path, action); } @@ -86,6 +73,7 @@ int DrmManagerClient::checkRightsStatus(const String8& path, int action) { } status_t DrmManagerClient::consumeRights(DecryptHandle* decryptHandle, int action, bool reserve) { + Mutex::Autolock _l(mDecryptLock); return mDrmManagerClientImpl->consumeRights(mUniqueId, decryptHandle, action, reserve); } @@ -128,12 +116,17 @@ DecryptHandle* DrmManagerClient::openDecryptSession(int fd, int offset, int leng return mDrmManagerClientImpl->openDecryptSession(mUniqueId, fd, offset, length); } +DecryptHandle* DrmManagerClient::openDecryptSession(const char* uri) { + return mDrmManagerClientImpl->openDecryptSession(mUniqueId, uri); +} + status_t DrmManagerClient::closeDecryptSession(DecryptHandle* decryptHandle) { return mDrmManagerClientImpl->closeDecryptSession(mUniqueId, decryptHandle); } status_t DrmManagerClient::initializeDecryptUnit( DecryptHandle* decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo) { + Mutex::Autolock _l(mDecryptLock); return mDrmManagerClientImpl->initializeDecryptUnit( mUniqueId, decryptHandle, decryptUnitId, headerInfo); } @@ -141,16 +134,19 @@ status_t DrmManagerClient::initializeDecryptUnit( status_t DrmManagerClient::decrypt( DecryptHandle* decryptHandle, int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) { + Mutex::Autolock _l(mDecryptLock); return mDrmManagerClientImpl->decrypt( mUniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV); } status_t DrmManagerClient::finalizeDecryptUnit(DecryptHandle* decryptHandle, int decryptUnitId) { + Mutex::Autolock _l(mDecryptLock); return mDrmManagerClientImpl->finalizeDecryptUnit(mUniqueId, decryptHandle, decryptUnitId); } ssize_t DrmManagerClient::pread( DecryptHandle* decryptHandle, void* buffer, ssize_t numBytes, off_t offset) { + Mutex::Autolock _l(mDecryptLock); return mDrmManagerClientImpl->pread(mUniqueId, decryptHandle, buffer, numBytes, offset); } diff --git a/drm/libdrmframework/DrmManagerClientImpl.cpp b/drm/libdrmframework/DrmManagerClientImpl.cpp index 272adcd..b3ae9a7 100644 --- a/drm/libdrmframework/DrmManagerClientImpl.cpp +++ b/drm/libdrmframework/DrmManagerClientImpl.cpp @@ -46,14 +46,6 @@ void DrmManagerClientImpl::remove(int uniqueId) { getDrmManagerService()->removeUniqueId(uniqueId); } -DrmManagerClientImpl::DrmManagerClientImpl() { - -} - -DrmManagerClientImpl::~DrmManagerClientImpl() { - -} - const sp<IDrmManagerService>& DrmManagerClientImpl::getDrmManagerService() { mMutex.lock(); if (NULL == mDrmManagerService.get()) { @@ -77,16 +69,12 @@ const sp<IDrmManagerService>& DrmManagerClientImpl::getDrmManagerService() { return mDrmManagerService; } -status_t DrmManagerClientImpl::loadPlugIns(int uniqueId) { - return getDrmManagerService()->loadPlugIns(uniqueId); +void DrmManagerClientImpl::addClient(int uniqueId) { + getDrmManagerService()->addClient(uniqueId); } -status_t DrmManagerClientImpl::loadPlugIns(int uniqueId, const String8& plugInDirPath) { - status_t status = DRM_ERROR_UNKNOWN; - if (EMPTY_STRING != plugInDirPath) { - status = getDrmManagerService()->loadPlugIns(uniqueId, plugInDirPath); - } - return status; +void DrmManagerClientImpl::removeClient(int uniqueId) { + getDrmManagerService()->removeClient(uniqueId); } status_t DrmManagerClientImpl::setOnInfoListener( @@ -96,10 +84,6 @@ status_t DrmManagerClientImpl::setOnInfoListener( return getDrmManagerService()->setDrmServiceListener(uniqueId, this); } -status_t DrmManagerClientImpl::unloadPlugIns(int uniqueId) { - return getDrmManagerService()->unloadPlugIns(uniqueId); -} - status_t DrmManagerClientImpl::installDrmEngine(int uniqueId, const String8& drmEngineFile) { status_t status = DRM_ERROR_UNKNOWN; if (EMPTY_STRING != drmEngineFile) { @@ -251,6 +235,14 @@ DecryptHandle* DrmManagerClientImpl::openDecryptSession( return getDrmManagerService()->openDecryptSession(uniqueId, fd, offset, length); } +DecryptHandle* DrmManagerClientImpl::openDecryptSession(int uniqueId, const char* uri) { + DecryptHandle* handle = NULL; + if (NULL != uri) { + handle = getDrmManagerService()->openDecryptSession(uniqueId, uri); + } + return handle; +} + status_t DrmManagerClientImpl::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) { status_t status = DRM_ERROR_UNKNOWN; if (NULL != decryptHandle) { diff --git a/drm/libdrmframework/include/DrmManager.h b/drm/libdrmframework/include/DrmManager.h index dc3e460..d782f5b 100644 --- a/drm/libdrmframework/include/DrmManager.h +++ b/drm/libdrmframework/include/DrmManager.h @@ -57,15 +57,19 @@ public: void removeUniqueId(int uniqueId); - status_t loadPlugIns(int uniqueId); + void addClient(int uniqueId); - status_t loadPlugIns(int uniqueId, const String8& plugInDirPath); + void removeClient(int uniqueId); + + status_t loadPlugIns(); + + status_t loadPlugIns(const String8& plugInDirPath); + + status_t unloadPlugIns(); status_t setDrmServiceListener( int uniqueId, const sp<IDrmServiceListener>& drmServiceListener); - status_t unloadPlugIns(int uniqueId); - status_t installDrmEngine(int uniqueId, const String8& drmEngineFile); DrmConstraints* getConstraints(int uniqueId, const String8* path, const int action); @@ -107,6 +111,8 @@ public: DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length); + DecryptHandle* openDecryptSession(int uniqueId, const char* uri); + status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle); status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, @@ -129,12 +135,8 @@ private: String8 getSupportedPlugInIdFromPath(int uniqueId, const String8& path); - void populate(int uniqueId); - bool canHandle(int uniqueId, const String8& path); - void initializePlugIns(int uniqueId); - private: static Vector<int> mUniqueIdVector; static const String8 EMPTY_STRING; diff --git a/drm/libdrmframework/include/DrmManagerClientImpl.h b/drm/libdrmframework/include/DrmManagerClientImpl.h index 492c7f5..1c6be46 100644 --- a/drm/libdrmframework/include/DrmManagerClientImpl.h +++ b/drm/libdrmframework/include/DrmManagerClientImpl.h @@ -35,36 +35,29 @@ class DrmInfoEvent; */ class DrmManagerClientImpl : public BnDrmServiceListener { private: - DrmManagerClientImpl(); + DrmManagerClientImpl() { } public: static DrmManagerClientImpl* create(int* pUniqueId); static void remove(int uniqueId); - virtual ~DrmManagerClientImpl(); + virtual ~DrmManagerClientImpl() { } public: /** - * Initialize DRM Manager - * load available plug-ins from default plugInDirPath + * Adds the client respective to given unique id. * * @param[in] uniqueId Unique identifier for a session - * @return status_t - * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure */ - status_t loadPlugIns(int uniqueId); + void addClient(int uniqueId); /** - * Finalize DRM Manager - * release resources associated with each plug-in - * unload all plug-ins and etc. + * Removes the client respective to given unique id. * * @param[in] uniqueId Unique identifier for a session - * @return status_t - * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure */ - status_t unloadPlugIns(int uniqueId); + void removeClient(int uniqueId); /** * Register a callback to be invoked when the caller required to @@ -301,6 +294,16 @@ public: DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length); /** + * 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 + * @return + * Handle for the decryption session + */ + DecryptHandle* openDecryptSession(int uniqueId, const char* uri); + + /** * Close the decrypt session for the given handle * * @param[in] uniqueId Unique identifier for a session @@ -379,17 +382,6 @@ public: private: /** - * Initialize DRM Manager - * load available plug-ins from plugInDirPath - * - * @param[in] uniqueId Unique identifier for a session - * @param[in] plugInDirPath Directory from where to load plug-ins - * @return status_t - * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure - */ - status_t loadPlugIns(int uniqueId, const String8& plugInDirPath); - - /** * Install new DRM Engine Plug-in at the runtime * * @param[in] uniqueId Unique identifier for a session diff --git a/drm/libdrmframework/include/DrmManagerService.h b/drm/libdrmframework/include/DrmManagerService.h index f455e15..4a3aeae 100644 --- a/drm/libdrmframework/include/DrmManagerService.h +++ b/drm/libdrmframework/include/DrmManagerService.h @@ -50,15 +50,13 @@ public: void removeUniqueId(int uniqueId); - status_t loadPlugIns(int uniqueId); + void addClient(int uniqueId); - status_t loadPlugIns(int uniqueId, const String8& plugInDirPath); + void removeClient(int uniqueId); status_t setDrmServiceListener( int uniqueId, const sp<IDrmServiceListener>& drmServiceListener); - status_t unloadPlugIns(int uniqueId); - status_t installDrmEngine(int uniqueId, const String8& drmEngineFile); DrmConstraints* getConstraints(int uniqueId, const String8* path, const int action); @@ -100,6 +98,8 @@ public: DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length); + DecryptHandle* openDecryptSession(int uniqueId, const char* uri); + status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle); status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, diff --git a/drm/libdrmframework/include/IDrmManagerService.h b/drm/libdrmframework/include/IDrmManagerService.h index 5c668ed..1275488 100644 --- a/drm/libdrmframework/include/IDrmManagerService.h +++ b/drm/libdrmframework/include/IDrmManagerService.h @@ -46,10 +46,9 @@ public: enum { ADD_UNIQUEID = IBinder::FIRST_CALL_TRANSACTION, REMOVE_UNIQUEID, - LOAD_PLUGINS, - LOAD_PLUGINS_FROM_PATH, + ADD_CLIENT, + REMOVE_CLIENT, SET_DRM_SERVICE_LISTENER, - UNLOAD_PLUGINS, INSTALL_DRM_ENGINE, GET_CONSTRAINTS_FROM_CONTENT, CAN_HANDLE, @@ -69,6 +68,7 @@ public: CLOSE_CONVERT_SESSION, GET_ALL_SUPPORT_INFO, OPEN_DECRYPT_SESSION, + OPEN_DECRYPT_SESSION_FROM_URI, CLOSE_DECRYPT_SESSION, INITIALIZE_DECRYPT_UNIT, DECRYPT, @@ -84,15 +84,13 @@ public: virtual void removeUniqueId(int uniqueId) = 0; - virtual status_t loadPlugIns(int uniqueId) = 0; + virtual void addClient(int uniqueId) = 0; - virtual status_t loadPlugIns(int uniqueId, const String8& plugInDirPath) = 0; + virtual void removeClient(int uniqueId) = 0; virtual status_t setDrmServiceListener( int uniqueId, const sp<IDrmServiceListener>& infoListener) = 0; - virtual status_t unloadPlugIns(int uniqueId) = 0; - virtual status_t installDrmEngine(int uniqueId, const String8& drmEngineFile) = 0; virtual DrmConstraints* getConstraints( @@ -140,6 +138,8 @@ public: virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length) = 0; + virtual DecryptHandle* openDecryptSession(int uniqueId, const char* uri) = 0; + virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) = 0; virtual status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, @@ -168,15 +168,13 @@ public: virtual void removeUniqueId(int uniqueId); - virtual status_t loadPlugIns(int uniqueId); + virtual void addClient(int uniqueId); - virtual status_t loadPlugIns(int uniqueId, const String8& plugInDirPath); + virtual void removeClient(int uniqueId); virtual status_t setDrmServiceListener( int uniqueId, const sp<IDrmServiceListener>& infoListener); - virtual status_t unloadPlugIns(int uniqueId); - virtual status_t installDrmEngine(int uniqueId, const String8& drmEngineFile); virtual DrmConstraints* getConstraints(int uniqueId, const String8* path, const int action); @@ -221,6 +219,8 @@ public: virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length); + virtual DecryptHandle* openDecryptSession(int uniqueId, const char* uri); + virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle); virtual status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, diff --git a/drm/libdrmframework/plugins/common/include/DrmEngineBase.h b/drm/libdrmframework/plugins/common/include/DrmEngineBase.h index b355534..5851af5 100644 --- a/drm/libdrmframework/plugins/common/include/DrmEngineBase.h +++ b/drm/libdrmframework/plugins/common/include/DrmEngineBase.h @@ -80,6 +80,9 @@ public: status_t openDecryptSession( int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length); + status_t openDecryptSession( + int uniqueId, DecryptHandle* decryptHandle, const char* uri); + status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle); status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, @@ -355,6 +358,18 @@ protected: int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int 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] uri Path of the protected content to be decrypted + * @return + * DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success + */ + virtual status_t onOpenDecryptSession( + int uniqueId, DecryptHandle* decryptHandle, const char* uri) = 0; + + /** * Close the decrypt session for the given handle * * @param[in] uniqueId Unique identifier for a session diff --git a/drm/libdrmframework/plugins/common/include/IDrmEngine.h b/drm/libdrmframework/plugins/common/include/IDrmEngine.h index b711500..cc03ef2 100644 --- a/drm/libdrmframework/plugins/common/include/IDrmEngine.h +++ b/drm/libdrmframework/plugins/common/include/IDrmEngine.h @@ -315,6 +315,18 @@ public: int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int 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] uri Path of the protected content to be decrypted + * @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; + + /** * Close the decrypt session for the given handle * * @param[in] uniqueId Unique identifier for a session diff --git a/drm/libdrmframework/plugins/passthru/include/DrmPassthruPlugIn.h b/drm/libdrmframework/plugins/passthru/include/DrmPassthruPlugIn.h index eed1628..ddb7fd3 100644 --- a/drm/libdrmframework/plugins/passthru/include/DrmPassthruPlugIn.h +++ b/drm/libdrmframework/plugins/passthru/include/DrmPassthruPlugIn.h @@ -74,6 +74,9 @@ protected: status_t onOpenDecryptSession( int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length); + status_t onOpenDecryptSession( + int uniqueId, DecryptHandle* decryptHandle, const char* uri); + status_t onCloseDecryptSession(int uniqueId, DecryptHandle* decryptHandle); status_t onInitializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, diff --git a/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp b/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp index 4c7714d..41f8e91 100644 --- a/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp +++ b/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp @@ -74,14 +74,14 @@ DrmInfoStatus* DrmPassthruPlugIn::onProcessDrmInfo(int uniqueId, const DrmInfo* switch (drmInfo->getInfoType()) { case DrmInfoRequest::TYPE_REGISTRATION_INFO: { const DrmBuffer* emptyBuffer = new DrmBuffer(); - drmInfoStatus - = new DrmInfoStatus(DrmInfoStatus::STATUS_OK, emptyBuffer, drmInfo->getMimeType()); + drmInfoStatus = new DrmInfoStatus(DrmInfoStatus::STATUS_OK, + DrmInfoRequest::TYPE_REGISTRATION_INFO, emptyBuffer, drmInfo->getMimeType()); break; } case DrmInfoRequest::TYPE_UNREGISTRATION_INFO: { const DrmBuffer* emptyBuffer = new DrmBuffer(); - drmInfoStatus - = new DrmInfoStatus(DrmInfoStatus::STATUS_OK, emptyBuffer, drmInfo->getMimeType()); + drmInfoStatus = new DrmInfoStatus(DrmInfoStatus::STATUS_OK, + DrmInfoRequest::TYPE_UNREGISTRATION_INFO, emptyBuffer, drmInfo->getMimeType()); break; } case DrmInfoRequest::TYPE_RIGHTS_ACQUISITION_INFO: { @@ -91,8 +91,8 @@ DrmInfoStatus* DrmPassthruPlugIn::onProcessDrmInfo(int uniqueId, const DrmInfo* data = new char[bufferSize]; memcpy(data, licenseString.string(), bufferSize); const DrmBuffer* buffer = new DrmBuffer(data, bufferSize); - drmInfoStatus - = new DrmInfoStatus(DrmInfoStatus::STATUS_OK, buffer, drmInfo->getMimeType()); + drmInfoStatus = new DrmInfoStatus(DrmInfoStatus::STATUS_OK, + DrmInfoRequest::TYPE_RIGHTS_ACQUISITION_INFO, buffer, drmInfo->getMimeType()); break; } } @@ -243,6 +243,11 @@ status_t DrmPassthruPlugIn::onOpenDecryptSession( return DRM_ERROR_CANNOT_HANDLE; } +status_t DrmPassthruPlugIn::onOpenDecryptSession( + int uniqueId, DecryptHandle* decryptHandle, const char* uri) { + return DRM_ERROR_CANNOT_HANDLE; +} + status_t DrmPassthruPlugIn::onCloseDecryptSession(int uniqueId, DecryptHandle* decryptHandle) { LOGD("DrmPassthruPlugIn::onCloseDecryptSession() : %d", uniqueId); if (NULL != decryptHandle) { |