Skip to content
Browse files

mm-video: Create Decrypt handle internally

Decoder will create decrypt handle internally, when needed.

(cherry picked from commit 31c0e9a)

Change-Id: I782e8b4c8451f74920925deae47b2f6295233029
  • Loading branch information...
1 parent ff1a7f8 commit 4cd02cc48509d0367b1d5c870dd5705c24069bc3 vivek mehta committed with Yen-Pin Hsiao Feb 24, 2012
Showing with 131 additions and 110 deletions.
  1. +3 −3 DivxDrmDecrypt/inc/DivXDrmDecrypt.h
  2. +93 −87 DivxDrmDecrypt/src/DivXDrmDecrypt.cpp
  3. +1 −1 vidc/vdec/inc/omx_vdec.h
  4. +34 −19 vidc/vdec/src/omx_vdec.cpp
View
6 DivxDrmDecrypt/inc/DivXDrmDecrypt.h
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------------
-Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
+Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -35,7 +35,7 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
class DivXDrmDecrypt
{
public:
- static DivXDrmDecrypt* Create( OMX_PTR drmHandle );
+ static DivXDrmDecrypt* Create();
virtual OMX_ERRORTYPE Init() = 0;
virtual OMX_ERRORTYPE Decrypt(OMX_BUFFERHEADERTYPE* buffer) = 0;
inline virtual ~DivXDrmDecrypt() {}
@@ -44,6 +44,6 @@ class DivXDrmDecrypt
//.so file should provide a function with the name createDivXDrmDecrypt with
//prototype of DivXDrmDecryptFactory.
static const char* MEDIA_CREATE_DIVX_DRM_DECRYPT = "createDivXDrmDecrypt";
-typedef DivXDrmDecrypt* (*DivXDrmDecryptFactory)( OMX_PTR drmHandle );
+typedef DivXDrmDecrypt* (*DivXDrmDecryptFactory)();
#endif //__DIVXDRMDECRYPT_H__
View
180 DivxDrmDecrypt/src/DivXDrmDecrypt.cpp
@@ -1,87 +1,93 @@
-/*--------------------------------------------------------------------------
-Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- * Neither the name of Code Aurora nor
- the names of its contributors may be used to endorse or promote
- products derived from this software without specific prior written
- permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------*/
-
-#include "DivXDrmDecrypt.h"
-#include <dlfcn.h> // for dlopen/dlclose
-
-#define LOG_NDEBUG 0
-#define LOG_TAG "DivXDrmDecrypt"
-#include <utils/Log.h>
-
-static const char* MM_PARSER_LIB = "libmmparser.so";
-
-void* MmParserLib() {
- static void* mmParserLib = NULL;
-
- if( mmParserLib != NULL ) {
- return mmParserLib;
- }
-
- mmParserLib = ::dlopen(MM_PARSER_LIB, RTLD_NOW);
-
- if (mmParserLib == NULL) {
- LOGE("Failed to open MM_PARSER_LIB \n");
- }
-
- return mmParserLib;
-}
-
-DivXDrmDecryptFactory DrmDecryptFactoryFunction() {
- static DivXDrmDecryptFactory drmDecryptFactoryFunction = NULL;
-
- if( drmDecryptFactoryFunction != NULL ) {
- return drmDecryptFactoryFunction;
- }
-
- void *mmParserLib = MmParserLib();
- if (mmParserLib == NULL) {
- return NULL;
- }
-
- drmDecryptFactoryFunction = (DivXDrmDecryptFactory) dlsym(mmParserLib, MEDIA_CREATE_DIVX_DRM_DECRYPT);
-
- if( drmDecryptFactoryFunction == NULL ) {
- LOGE(" dlsym for DrmDecrypt factory function failed \n");
- }
-
- return drmDecryptFactoryFunction;
-}
-
-DivXDrmDecrypt* DivXDrmDecrypt::Create( OMX_PTR drmHandle ) {
- DivXDrmDecryptFactory drmCreateFunc = DrmDecryptFactoryFunction();
- if( drmCreateFunc == NULL ) {
- return NULL;
- }
-
- DivXDrmDecrypt* decrypt = drmCreateFunc( drmHandle );
- if( decrypt == NULL ) {
- LOGE(" failed to instantiate DrmDecoder \n");
- }
- return decrypt;
-}
-
+/*--------------------------------------------------------------------------
+Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Code Aurora nor
+ the names of its contributors may be used to endorse or promote
+ products derived from this software without specific prior written
+ permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+--------------------------------------------------------------------------*/
+
+#include "DivXDrmDecrypt.h"
+#include <dlfcn.h> // for dlopen/dlclose
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "DivXDrmDecrypt"
+#include <utils/Log.h>
+
+static const char* DIVX_DRM_SHIM_LIB = "libSHIMDivxDrm.so";
+
+void* getDecryptHandle() {
+ static void* decryptLib = NULL;
+ static bool decryptLibOpened = false;
+
+ if(decryptLibOpened) {
+ return decryptLib;
+ }
+
+ decryptLib = ::dlopen(DIVX_DRM_SHIM_LIB, RTLD_NOW);
+ decryptLibOpened = true;
+
+ if (decryptLib == NULL) {
+ LOGE("Failed to open DIVX_DRM_SHIM_LIB \n");
+ }
+
+ return decryptLib;
+}
+
+DivXDrmDecryptFactory DrmDecryptFactoryFunction() {
+ static DivXDrmDecryptFactory drmDecryptFactoryFunction = NULL;
+ static bool alreadyTriedToFindFactoryFunction = false;
+
+ if(alreadyTriedToFindFactoryFunction) {
+ return drmDecryptFactoryFunction;
+ }
+
+ void *pDecryptLib = getDecryptHandle();
+ if (pDecryptLib == NULL) {
+ return NULL;
+ }
+
+ drmDecryptFactoryFunction = (DivXDrmDecryptFactory) dlsym(pDecryptLib, MEDIA_CREATE_DIVX_DRM_DECRYPT);
+ alreadyTriedToFindFactoryFunction = true;
+
+ if(!drmDecryptFactoryFunction) {
+ LOGE(" dlsym for DrmDecrypt factory function failed \n");
+ }
+
+ return drmDecryptFactoryFunction;
+}
+
+
+
+DivXDrmDecrypt* DivXDrmDecrypt::Create() {
+ DivXDrmDecryptFactory drmCreateFunc = DrmDecryptFactoryFunction();
+ if( drmCreateFunc == NULL ) {
+ return NULL;
+ }
+
+ DivXDrmDecrypt* decrypt = drmCreateFunc();
+ if( decrypt == NULL ) {
+ LOGE(" failed to instantiate DrmDecoder \n");
+ }
+ return decrypt;
+}
+
View
2 vidc/vdec/inc/omx_vdec.h
@@ -634,7 +634,7 @@ class omx_vdec: public qc_omx_component
}
}
#ifdef _ANDROID_
- OMX_ERRORTYPE createDivxDrmContext( OMX_PTR drmHandle );
+ OMX_ERRORTYPE createDivxDrmContext();
#endif //_ANDROID_
#if defined (_ANDROID_HONEYCOMB_) || defined (_ANDROID_ICS_)
OMX_ERRORTYPE use_android_native_buffer(OMX_IN OMX_HANDLETYPE hComp, OMX_PTR data);
View
53 vidc/vdec/src/omx_vdec.cpp
@@ -1243,7 +1243,13 @@ OMX_ERRORTYPE omx_vdec::component_init(OMX_STRING role)
eCompressionFormat = (OMX_VIDEO_CODINGTYPE)QOMX_VIDEO_CodingDivx;
codec_type_parse = CODEC_TYPE_DIVX;
m_frame_parser.init_start_codes (codec_type_parse);
-
+#ifdef _ANDROID_
+ OMX_ERRORTYPE err = createDivxDrmContext();
+ if( err != OMX_ErrorNone ) {
+ DEBUG_PRINT_ERROR("createDivxDrmContext Failed");
+ return err;
+ }
+#endif //_ANDROID_
}
else if(!strncmp(drv_ctx.kind, "OMX.qcom.video.decoder.divx4",\
OMX_MAX_STRINGNAME_SIZE))
@@ -1254,7 +1260,13 @@ OMX_ERRORTYPE omx_vdec::component_init(OMX_STRING role)
eCompressionFormat = (OMX_VIDEO_CODINGTYPE)QOMX_VIDEO_CodingDivx;
codec_type_parse = CODEC_TYPE_DIVX;
m_frame_parser.init_start_codes (codec_type_parse);
-
+#ifdef _ANDROID_
+ OMX_ERRORTYPE err = createDivxDrmContext();
+ if( err != OMX_ErrorNone ) {
+ DEBUG_PRINT_ERROR("createDivxDrmContext Failed");
+ return err;
+ }
+#endif //_ANDROID_
}
else if(!strncmp(drv_ctx.kind, "OMX.qcom.video.decoder.divx",\
OMX_MAX_STRINGNAME_SIZE))
@@ -1265,7 +1277,13 @@ OMX_ERRORTYPE omx_vdec::component_init(OMX_STRING role)
eCompressionFormat = (OMX_VIDEO_CODINGTYPE)QOMX_VIDEO_CodingDivx;
codec_type_parse = CODEC_TYPE_DIVX;
m_frame_parser.init_start_codes (codec_type_parse);
-
+#ifdef _ANDROID_
+ OMX_ERRORTYPE err = createDivxDrmContext();
+ if( err != OMX_ErrorNone ) {
+ DEBUG_PRINT_ERROR("createDivxDrmContext Failed");
+ return err;
+ }
+#endif //_ANDROID_
}
#else
else if((!strncmp(drv_ctx.kind, "OMX.qcom.video.decoder.divx4",\
@@ -1279,6 +1297,13 @@ OMX_ERRORTYPE omx_vdec::component_init(OMX_STRING role)
codec_type_parse = CODEC_TYPE_DIVX;
m_frame_parser.init_start_codes (codec_type_parse);
+#ifdef _ANDROID_
+ OMX_ERRORTYPE err = createDivxDrmContext();
+ if( err != OMX_ErrorNone ) {
+ DEBUG_PRINT_ERROR("createDivxDrmContext Failed");
+ return err;
+ }
+#endif //_ANDROID_
}
#endif
else if(!strncmp(drv_ctx.kind, "OMX.qcom.video.decoder.avc",\
@@ -3345,16 +3370,13 @@ OMX_ERRORTYPE omx_vdec::set_parameter(OMX_IN OMX_HANDLETYPE hComp,
break;
case OMX_QcomIndexParamVideoDivx:
{
- QOMX_VIDEO_PARAM_DIVXTYPE* divXType = (QOMX_VIDEO_PARAM_DIVXTYPE *) paramData;
#ifdef MAX_RES_720P
- if(divXType->eFormat == QOMX_VIDEO_DIVXFormat311) {
+ QOMX_VIDEO_PARAM_DIVXTYPE* divXType = (QOMX_VIDEO_PARAM_DIVXTYPE *) paramData;
+ if((divXType) && (divXType->eFormat == QOMX_VIDEO_DIVXFormat311)) {
DEBUG_PRINT_HIGH("set_parameter: DivX 3.11 not supported in 7x30 core.");
eRet = OMX_ErrorUnsupportedSetting;
}
#endif
-#ifdef _ANDROID_
- createDivxDrmContext( divXType->pDrmHandle );
-#endif
}
break;
case OMX_QcomIndexPlatformPvt:
@@ -8579,28 +8601,21 @@ void omx_vdec::vdec_dealloc_h264_mv()
#endif
#ifdef _ANDROID_
-OMX_ERRORTYPE omx_vdec::createDivxDrmContext( OMX_PTR drmHandle )
+OMX_ERRORTYPE omx_vdec::createDivxDrmContext()
{
OMX_ERRORTYPE err = OMX_ErrorNone;
- if( drmHandle == NULL ) {
- DEBUG_PRINT_HIGH("\n This clip is not DRM encrypted");
- iDivXDrmDecrypt = NULL;
- return err;
- }
-
- iDivXDrmDecrypt = DivXDrmDecrypt::Create( drmHandle );
+ iDivXDrmDecrypt = DivXDrmDecrypt::Create();
if (iDivXDrmDecrypt) {
- DEBUG_PRINT_LOW("\nCreated DIVX DRM, now calling Init");
OMX_ERRORTYPE err = iDivXDrmDecrypt->Init();
if(err!=OMX_ErrorNone) {
- DEBUG_PRINT_ERROR("\nERROR:iDivXDrmDecrypt->Init %d", err);
+ DEBUG_PRINT_ERROR("\nERROR :iDivXDrmDecrypt->Init %d", err);
delete iDivXDrmDecrypt;
iDivXDrmDecrypt = NULL;
}
}
else {
DEBUG_PRINT_ERROR("\nUnable to Create DIVX DRM");
- return OMX_ErrorUndefined;
+ err = OMX_ErrorUndefined;
}
return err;
}

0 comments on commit 4cd02cc

Please sign in to comment.
Something went wrong with that request. Please try again.