/****************************************************************************** * Compressed Image (not disable CAMERA_MSG_COMPRESSED_IMAGE) * int[0]: current shut index; 0: the first one shut. *******************************************************************************/ void CameraClient:: handleMtkExtDataCompressedImage(const sp<IMemory>& dataPtr, camera_frame_metadata_t *metadata) { MtkCamMsgExtDataHelper MtkExtDataHelper; if ( ! MtkExtDataHelper.init(dataPtr) ) { LOGE("[%s] MtkCamMsgExtDataHelper::init fail - dataPtr(%p), this(%p) \r\n", __FUNCTION__, dataPtr.get(), this); return; } // uint_t const*const pExtParam = (uint_t const*)MtkExtDataHelper.getExtParamBase(); uint_t const uShutIndex = pExtParam[0]; // size_t const imageSize = MtkExtDataHelper.getExtParamSize() - sizeof(uint_t) * 1; ssize_t const imageOffset = MtkExtDataHelper.getExtParamOffset() + sizeof(uint_t) * 1; sp<MemoryBase> image = new MemoryBase(MtkExtDataHelper.getHeap(), imageOffset, imageSize); // MtkExtDataHelper.uninit(); LOGD("[%s] current shut index:%d - (size, offset)=(%d, %ld) \r\n", __FUNCTION__, uShutIndex, imageSize, imageOffset); // if (image == 0) { LOGE("[%s] fail to new MemoryBase \r\n", __FUNCTION__); return; } // sp<ICameraClient> c = mCameraClient; mLock.unlock(); if (c != 0) { c->dataCallback(CAMERA_MSG_COMPRESSED_IMAGE, image, NULL); } }
void MtkJNICameraContext::copyAndPostExtData(JNIEnv* env, const sp<IMemory>& dataPtr, int msgType) { jbyteArray obj = NULL; uint32_t extMsgType = 0; // allocate Java byte array and copy data // MtkCamMsgExtDataHelper MtkExtDataHelper; if ( MtkExtDataHelper.init(dataPtr) ) { const jbyte* data = reinterpret_cast<const jbyte*>(MtkExtDataHelper.getExtParamBase()); const size_t size = MtkExtDataHelper.getExtParamSize(); const MtkCamMsgExtDataHelper::DataHeader extDataHeader = MtkExtDataHelper.getExtDataHeader(); extMsgType = extDataHeader.extMsgType; LOGV("[copyAndPostExtData] Allocating callback buffer"); obj = env->NewByteArray(size); if (obj == NULL) { LOGE("[copyAndPostExtData] Couldn't allocate byte array"); env->ExceptionClear(); } else { env->SetByteArrayRegion(obj, 0, size, data); } MtkExtDataHelper.uninit(); } // post image data to Java env->CallStaticVoidMethod(mCameraJClass, fields.post_event, mCameraJObjectWeak, msgType, extMsgType, 0, obj); if (obj) { env->DeleteLocalRef(obj); } }
void CameraClient:: handleMtkExtData(const sp<IMemory>& dataPtr, camera_frame_metadata_t *metadata) { MtkCamMsgExtDataHelper MtkExtDataHelper; if ( ! MtkExtDataHelper.init(dataPtr) ) { LOGE("[handleMtkExtData] MtkCamMsgExtDataHelper::init fail - dataPtr(%p), this(%p)", dataPtr.get(), this); return; } void* const pvExtParam = MtkExtDataHelper.getExtParamBase(); size_t const ExtParamSize = MtkExtDataHelper.getExtParamSize(); switch (MtkExtDataHelper.getExtMsgType()) { case MTK_CAMERA_MSG_EXT_DATA_COMPRESSED_IMAGE: handleMtkExtDataCompressedImage(dataPtr, metadata); break; // case MTK_CAMERA_MSG_EXT_DATA_BURST_SHOT: handleMtkExtDataBurstShot(dataPtr, metadata); break; // case MTK_CAMERA_MSG_EXT_DATA_CONTINUOUS_SHOT: handleMtkExtDataContinuousShot(dataPtr, metadata); break; // default: handleGenericData(MTK_CAMERA_MSG_EXT_DATA, dataPtr, metadata); break; } MtkExtDataHelper.uninit(); }
/****************************************************************************** * Burst Shot (EV Shot) * int[0]: the total shut count. * int[1]: count-down shut number; 0: the last one shut. ******************************************************************************/ void CameraClient:: handleMtkExtDataBurstShot(const sp<IMemory>& dataPtr, camera_frame_metadata_t */*metadata*/) { MtkCamMsgExtDataHelper MtkExtDataHelper; if ( ! MtkExtDataHelper.init(dataPtr) ) { ALOGE("[%s] MtkCamMsgExtDataHelper::init fail - dataPtr(%p), this(%p) \r\n", __FUNCTION__, dataPtr.get(), this); return; } // uint_t const*const pExtParam = (uint_t const*)MtkExtDataHelper.getExtParamBase(); uint_t const uTotalShutCount = pExtParam[0]; uint_t const uCountdownIndex = pExtParam[1]; // size_t const imageSize = MtkExtDataHelper.getExtParamSize() - sizeof(uint_t) * 2; ssize_t const imageOffset = MtkExtDataHelper.getExtParamOffset() + sizeof(uint_t) * 2; sp<MemoryBase> image = new MemoryBase(MtkExtDataHelper.getHeap(), imageOffset, imageSize); // MtkExtDataHelper.uninit(); // // if (0 < uCountdownIndex) { // not the last one burst shut. ALOGD("[%s] count-down burst shut number:%d/%d - (size, offset)=(%d, %d) \r\n", __FUNCTION__, uCountdownIndex, uTotalShutCount, imageSize, imageOffset); } else { disableMsgType(CAMERA_MSG_COMPRESSED_IMAGE); ALOGD("[%s] the last one burst shut - (size, offset)=(%d, %d) \r\n", __FUNCTION__, imageSize, imageOffset); } // if (image == 0) { ALOGE("[%s] fail to new MemoryBase \r\n", __FUNCTION__); return; } // sp<ICameraClient> c = mRemoteCallback; //!++ #if 1 #else mLock.unlock(); #endif //!-- if (c != 0) { c->dataCallback(CAMERA_MSG_COMPRESSED_IMAGE, image, NULL); } }
/****************************************************************************** * Continuous Shot * int[0]: current continuous shut number. ******************************************************************************/ void CameraClient:: handleMtkExtDataContinuousShot(const sp<IMemory>& dataPtr, camera_frame_metadata_t */*metadata*/) { MtkCamMsgExtDataHelper MtkExtDataHelper; if ( ! MtkExtDataHelper.init(dataPtr) ) { ALOGE("[%s] MtkCamMsgExtDataHelper::init fail - dataPtr(%p), this(%p) \r\n", __FUNCTION__, dataPtr.get(), this); return; } // uint_t const*const pExtParam = (uint_t const*)MtkExtDataHelper.getExtParamBase(); uint_t const uCurShutCount = pExtParam[0]; // size_t const imageSize = MtkExtDataHelper.getExtParamSize() - sizeof(uint_t) * 1; ssize_t const imageOffset = MtkExtDataHelper.getExtParamOffset() + sizeof(uint_t) * 1; sp<MemoryBase> image = new MemoryBase(MtkExtDataHelper.getHeap(), imageOffset, imageSize); // MtkExtDataHelper.uninit(); ALOGD("[%s] current continuous shut number:%d - (size, offset)=(%d, %d) \r\n", __FUNCTION__, uCurShutCount, imageSize, imageOffset); // if (image == 0) { ALOGE("[%s] fail to new MemoryBase \r\n", __FUNCTION__); return; } // sp<ICameraClient> c = mRemoteCallback; //!++ #if 1 #else mLock.unlock(); #endif //!-- if (c != 0) { c->dataCallback(CAMERA_MSG_COMPRESSED_IMAGE, image, NULL); } }