diff options
Diffstat (limited to 'drm/jni/android_drm_DrmManagerClient.cpp')
-rw-r--r-- | drm/jni/android_drm_DrmManagerClient.cpp | 65 |
1 files changed, 25 insertions, 40 deletions
diff --git a/drm/jni/android_drm_DrmManagerClient.cpp b/drm/jni/android_drm_DrmManagerClient.cpp index 191648c..14ec4d6 100644 --- a/drm/jni/android_drm_DrmManagerClient.cpp +++ b/drm/jni/android_drm_DrmManagerClient.cpp @@ -620,17 +620,8 @@ static jint android_drm_DrmManagerClient_openConvertSession( return convertId; } -static jobject android_drm_DrmManagerClient_convertData( - JNIEnv* env, jobject thiz, jint uniqueId, jint convertId, jbyteArray inputData) { - ALOGV("convertData Enter"); - - int dataLength = 0; - char* mData = Utility::getByteArrayValue(env, inputData, &dataLength); - const DrmBuffer buffer(mData, dataLength); - - DrmConvertedStatus* pDrmConvertedStatus - = getDrmManagerClientImpl(env, thiz)->convertData(uniqueId, convertId, &buffer); - +static jobject GetConvertedStatus(JNIEnv* env, DrmConvertedStatus* pDrmConvertedStatus) { + ALOGV("GetConvertedStatus - Enter"); jclass localRef = env->FindClass("android/drm/DrmConvertedStatus"); jobject drmConvertedStatus = NULL; @@ -642,8 +633,8 @@ static jobject android_drm_DrmManagerClient_convertData( if (NULL != pDrmConvertedStatus->convertedData) { int length = pDrmConvertedStatus->convertedData->length; dataArray = env->NewByteArray(length); - env->SetByteArrayRegion(dataArray, 0, length, - (jbyte*) pDrmConvertedStatus->convertedData->data); + env->SetByteArrayRegion( + dataArray, 0, length, (jbyte*) pDrmConvertedStatus->convertedData->data); delete [] pDrmConvertedStatus->convertedData->data; delete pDrmConvertedStatus->convertedData; pDrmConvertedStatus->convertedData = NULL; @@ -654,48 +645,42 @@ static jobject android_drm_DrmManagerClient_convertData( statusCode, dataArray, pDrmConvertedStatus->offset); } - delete[] mData; mData = NULL; delete pDrmConvertedStatus; pDrmConvertedStatus = NULL; - ALOGV("convertData - Exit"); + ALOGV("GetConvertedStatus - Exit"); return drmConvertedStatus; } -static jobject android_drm_DrmManagerClient_closeConvertSession( - JNIEnv* env, jobject thiz, int uniqueId, jint convertId) { +static jobject android_drm_DrmManagerClient_convertData( + JNIEnv* env, jobject thiz, jint uniqueId, jint convertId, jbyteArray inputData) { + ALOGV("convertData Enter"); - ALOGV("closeConvertSession Enter"); + int dataLength = 0; + char* mData = Utility::getByteArrayValue(env, inputData, &dataLength); + const DrmBuffer buffer(mData, dataLength); DrmConvertedStatus* pDrmConvertedStatus - = getDrmManagerClientImpl(env, thiz)->closeConvertSession(uniqueId, convertId); - - jclass localRef = env->FindClass("android/drm/DrmConvertedStatus"); + = getDrmManagerClientImpl(env, thiz)->convertData(uniqueId, convertId, &buffer); + jobject status = GetConvertedStatus(env, pDrmConvertedStatus); - jobject drmConvertedStatus = NULL; + delete[] mData; + mData = NULL; - if (NULL != localRef && NULL != pDrmConvertedStatus) { - int statusCode = pDrmConvertedStatus->statusCode; + ALOGV("convertData - Exit"); + return status; +} - jbyteArray dataArray = NULL; - if (NULL != pDrmConvertedStatus->convertedData) { - int length = pDrmConvertedStatus->convertedData->length; - dataArray = env->NewByteArray(length); - env->SetByteArrayRegion( - dataArray, 0, length, (jbyte*) pDrmConvertedStatus->convertedData->data); +static jobject android_drm_DrmManagerClient_closeConvertSession( + JNIEnv* env, jobject thiz, int uniqueId, jint convertId) { - delete [] pDrmConvertedStatus->convertedData->data; - delete pDrmConvertedStatus->convertedData; pDrmConvertedStatus->convertedData = NULL; - } - jmethodID constructorId = env->GetMethodID(localRef, "<init>", "(I[BI)V"); - drmConvertedStatus - = env->NewObject(localRef, constructorId, - statusCode, dataArray, pDrmConvertedStatus->offset); - } + ALOGV("closeConvertSession Enter"); - delete pDrmConvertedStatus; pDrmConvertedStatus = NULL; + DrmConvertedStatus* pDrmConvertedStatus + = getDrmManagerClientImpl(env, thiz)->closeConvertSession(uniqueId, convertId); + jobject status = GetConvertedStatus(env, pDrmConvertedStatus); ALOGV("closeConvertSession - Exit"); - return drmConvertedStatus; + return status; } static JNINativeMethod nativeMethods[] = { |