// stop preview mode void CameraClient::stopPreview() { LOG1("stopPreview (pid %d)", getCallingPid()); #ifdef QCOM_HARDWARE disableMsgType(CAMERA_MSG_PREVIEW_METADATA); #endif Mutex::Autolock lock(mLock); if (checkPidAndHardware() != NO_ERROR) return; #ifdef OMAP_ENHANCEMENT // According to framework documentation, preview needs // to be started for image capture. This will make sure // that image capture related messages get disabled if // not done already in their respective handlers. // If these messages come when in the midddle of // stopping preview we will deadlock the system in // lockIfMessageWanted(). disableMsgType(CAMERA_MSG_POSTVIEW_FRAME); #endif disableMsgType(CAMERA_MSG_PREVIEW_FRAME); #ifdef QCOM_HARDWARE //Disable picture related message types ALOGI("stopPreview: Disable picture related messages"); int picMsgType = 0; picMsgType = (CAMERA_MSG_SHUTTER | CAMERA_MSG_POSTVIEW_FRAME | CAMERA_MSG_RAW_IMAGE | CAMERA_MSG_RAW_IMAGE_NOTIFY | CAMERA_MSG_COMPRESSED_IMAGE); disableMsgType(picMsgType); #endif mHardware->stopPreview(); mPreviewBuffer.clear(); }
/****************************************************************************** * Capture done (disable CAMERA_MSG_SHUTTER / CAMERA_MSG_COMPRESSED_IMAGE) ******************************************************************************/ void CameraClient:: handleMtkExtCaptureDone(int32_t /*ext1*/, int32_t /*ext2*/) { ALOGD("[%s] disable CAMERA_MSG_SHUTTER / CAMERA_MSG_COMPRESSED_IMAGE \r\n", __FUNCTION__); disableMsgType(CAMERA_MSG_SHUTTER); disableMsgType(CAMERA_MSG_COMPRESSED_IMAGE); }
status_t CameraClient::sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) { LOG1("sendCommand (pid %d)", getCallingPid()); int orientation; Mutex::Autolock lock(mLock); status_t result = checkPidAndHardware(); if (result != NO_ERROR) return result; if (cmd == CAMERA_CMD_SET_DISPLAY_ORIENTATION) { // Mirror the preview if the camera is front-facing. orientation = getOrientation(arg1, mCameraFacing == CAMERA_FACING_FRONT); if (orientation == -1) return BAD_VALUE; if (mOrientation != orientation) { mOrientation = orientation; if (mPreviewWindow != 0) { native_window_set_buffers_transform(mPreviewWindow.get(), mOrientation); } } return OK; } else if (cmd == CAMERA_CMD_ENABLE_SHUTTER_SOUND) { switch (arg1) { case 0: return enableShutterSound(false); case 1: return enableShutterSound(true); default: return BAD_VALUE; } return OK; } else if (cmd == CAMERA_CMD_PLAY_RECORDING_SOUND) { mCameraService->playSound(CameraService::SOUND_RECORDING); } else if (cmd == CAMERA_CMD_SET_VIDEO_BUFFER_COUNT) { // Silently ignore this command return INVALID_OPERATION; } else if (cmd == CAMERA_CMD_PING) { // If mHardware is 0, checkPidAndHardware will return error. return OK; #ifdef QCOM_HARDWARE } else if (cmd == CAMERA_CMD_HISTOGRAM_ON) { enableMsgType(CAMERA_MSG_STATS_DATA); } else if (cmd == CAMERA_CMD_HISTOGRAM_OFF) { disableMsgType(CAMERA_MSG_STATS_DATA); } else if (cmd == CAMERA_CMD_METADATA_ON) { enableMsgType(CAMERA_MSG_META_DATA); } else if (cmd == CAMERA_CMD_METADATA_OFF) { disableMsgType(CAMERA_MSG_META_DATA); } else if ( cmd == CAMERA_CMD_LONGSHOT_ON ) { mLongshotEnabled = true; } else if ( cmd == CAMERA_CMD_LONGSHOT_OFF ) { mLongshotEnabled = false; disableMsgType(CAMERA_MSG_SHUTTER); disableMsgType(CAMERA_MSG_COMPRESSED_IMAGE); #endif } return mHardware->sendCommand(cmd, arg1, arg2); }
/****************************************************************************** * Continuous EndCallback Handler ******************************************************************************/ void CameraClient:: handleMtkExtContinuousEnd(int32_t ext1, int32_t ext2) { disableMsgType(CAMERA_MSG_SHUTTER); disableMsgType(CAMERA_MSG_COMPRESSED_IMAGE); handleGenericNotify(MTK_CAMERA_MSG_EXT_NOTIFY, ext1, ext2); ALOGD("[handleMtkExtContinuousEnd] total continuous shut number is %d \n", ext2); }
status_t CameraService::Client::sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) { LOG1("sendCommand (pid %d)", getCallingPid()); int orientation; Mutex::Autolock lock(mLock); status_t result = checkPidAndHardware(); if (result != NO_ERROR) return result; if (cmd == CAMERA_CMD_SET_DISPLAY_ORIENTATION) { // Mirror the preview if the camera is front-facing. orientation = getOrientation(arg1, mCameraFacing == CAMERA_FACING_FRONT); if (orientation == -1) return BAD_VALUE; if (mOrientation != orientation) { mOrientation = orientation; if (mPreviewWindow != 0) { native_window_set_buffers_transform(mPreviewWindow.get(), mOrientation); } } return OK; } else if (cmd == CAMERA_CMD_ENABLE_SHUTTER_SOUND) { switch (arg1) { case 0: enableShutterSound(false); break; case 1: enableShutterSound(true); break; default: return BAD_VALUE; } return OK; } else if (cmd == CAMERA_CMD_PLAY_RECORDING_SOUND) { mCameraService->playSound(SOUND_RECORDING); } else if (cmd == CAMERA_CMD_HISTOGRAM_ON ) { enableMsgType(CAMERA_MSG_STATS_DATA); } else if (cmd == CAMERA_CMD_HISTOGRAM_OFF) { disableMsgType(CAMERA_MSG_STATS_DATA); } else if (cmd == CAMERA_CMD_START_FACE_DETECTION) { mFaceDetection = true; enableMsgType(CAMERA_MSG_PREVIEW_METADATA); } else if (cmd == CAMERA_CMD_STOP_FACE_DETECTION) { mFaceDetection = false; disableMsgType(CAMERA_MSG_PREVIEW_METADATA); } return mHardware->sendCommand(cmd, arg1, arg2); }
// stop preview mode void CameraService::Client::stopPreview() { LOG1("stopPreview (pid %d)", getCallingPid()); disableMsgType(CAMERA_MSG_PREVIEW_METADATA); Mutex::Autolock lock(mLock); if (checkPidAndHardware() != NO_ERROR) return; //zxj ++ mstopPreview = true; //zxj -- disableMsgType(CAMERA_MSG_PREVIEW_FRAME); mHardware->stopPreview(); mPreviewBuffer.clear(); }
// snapshot taken callback void CameraClient::handleShutter(void) { if (mPlayShutterSound) { mCameraService->playSound(CameraService::SOUND_SHUTTER); } sp<ICameraClient> c = mRemoteCallback; if (c != 0) { //!++ #if 1 #else mLock.unlock(); #endif //!-- c->notifyCallback(CAMERA_MSG_SHUTTER, 0, 0); if (!lockIfMessageWanted(CAMERA_MSG_SHUTTER)) return; } disableMsgType(CAMERA_MSG_SHUTTER); //!++ #if 1 #else mLock.unlock(); #endif //!-- }
status_t CameraClient::startPreviewMode() { LOG1("startPreviewMode"); status_t result = NO_ERROR; // if preview has been enabled, nothing needs to be done if (mHardware->previewEnabled()) { return NO_ERROR; } if (mPreviewWindow != 0) { native_window_set_scaling_mode(mPreviewWindow.get(), NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW); native_window_set_buffers_transform(mPreviewWindow.get(), mOrientation); } #if defined(OMAP_ICS_CAMERA) || defined(OMAP_ENHANCEMENT_BURST_CAPTURE) disableMsgType(CAMERA_MSG_COMPRESSED_BURST_IMAGE); #endif mHardware->setPreviewWindow(mPreviewWindow); result = mHardware->startPreview(); return result; }
// take a picture - image is returned in callback status_t CameraService::Client::takePicture(int msgType) { char prop[PROPERTY_VALUE_MAX]; LOG1("takePicture (pid %d): 0x%x", getCallingPid(), msgType); Mutex::Autolock lock(mLock); status_t result = checkPidAndHardware(); if (result != NO_ERROR) return result; //zxj ++ mstopPreview = true; //zxj -- if ((msgType & CAMERA_MSG_RAW_IMAGE) && (msgType & CAMERA_MSG_RAW_IMAGE_NOTIFY)) { LOGE("CAMERA_MSG_RAW_IMAGE and CAMERA_MSG_RAW_IMAGE_NOTIFY" " cannot be both enabled"); return BAD_VALUE; } // We only accept picture related message types // and ignore other types of messages for takePicture(). int picMsgType = msgType & (CAMERA_MSG_SHUTTER | CAMERA_MSG_POSTVIEW_FRAME | CAMERA_MSG_RAW_IMAGE | CAMERA_MSG_RAW_IMAGE_NOTIFY | CAMERA_MSG_COMPRESSED_IMAGE); disableMsgType(CAMERA_MSG_PREVIEW_METADATA); enableMsgType(picMsgType); mburstCnt = mHardware->getParameters().getInt("num-snaps-per-shutter"); if(mburstCnt <= 0) mburstCnt = 1; LOG1("mburstCnt = %d", mburstCnt); return mHardware->takePicture(); }
// preview callback - frame buffer update void CameraClient::handlePreviewData(int32_t msgType, const sp<IMemory>& mem, camera_frame_metadata_t *metadata) { ssize_t offset; size_t size; sp<IMemoryHeap> heap = mem->getMemory(&offset, &size); // local copy of the callback flags int flags = mPreviewCallbackFlag; // is callback enabled? if (!(flags & CAMERA_FRAME_CALLBACK_FLAG_ENABLE_MASK)) { // If the enable bit is off, the copy-out and one-shot bits are ignored LOG2("frame callback is disabled"); //!++ #if 1 #else mLock.unlock(); #endif //!-- return; } // hold a strong pointer to the client sp<ICameraClient> c = mRemoteCallback; // clear callback flags if no client or one-shot mode if (c == 0 || (mPreviewCallbackFlag & CAMERA_FRAME_CALLBACK_FLAG_ONE_SHOT_MASK)) { LOG2("Disable preview callback"); mPreviewCallbackFlag &= ~(CAMERA_FRAME_CALLBACK_FLAG_ONE_SHOT_MASK | CAMERA_FRAME_CALLBACK_FLAG_COPY_OUT_MASK | CAMERA_FRAME_CALLBACK_FLAG_ENABLE_MASK); disableMsgType(CAMERA_MSG_PREVIEW_FRAME); } if (c != 0) { // Is the received frame copied out or not? if (flags & CAMERA_FRAME_CALLBACK_FLAG_COPY_OUT_MASK) { LOG2("frame is copied"); copyFrameAndPostCopiedFrame(msgType, c, heap, offset, size, metadata); } else { LOG2("frame is forwarded"); //!++ #if 1 #else mLock.unlock(); #endif //!-- c->dataCallback(msgType, mem, metadata); } } else { //!++ #if 1 #else mLock.unlock(); #endif //!-- } }
// snapshot taken callback // "size" is the width and height of yuv picture for registerBuffer. // If it is NULL, use the picture size from parameters. void CameraService::Client::handleShutter(image_rect_type *size #ifdef BOARD_USE_CAF_LIBCAMERA , bool playShutterSoundOnly #endif ) { #ifdef BOARD_USE_CAF_LIBCAMERA if(playShutterSoundOnly) { #endif mCameraService->playSound(SOUND_SHUTTER); #ifdef BOARD_USE_CAF_LIBCAMERA sp<ICameraClient> c = mCameraClient; if (c != 0) { mLock.unlock(); c->notifyCallback(CAMERA_MSG_SHUTTER, 0, 0); } return; } #endif // Screen goes black after the buffer is unregistered. if (mSurface != 0 && !mUseOverlay) { mSurface->unregisterBuffers(); } sp<ICameraClient> c = mCameraClient; if (c != 0) { mLock.unlock(); c->notifyCallback(CAMERA_MSG_SHUTTER, 0, 0); if (!lockIfMessageWanted(CAMERA_MSG_SHUTTER)) return; } disableMsgType(CAMERA_MSG_SHUTTER); // It takes some time before yuvPicture callback to be called. // Register the buffer for raw image here to reduce latency. if (mSurface != 0 && !mUseOverlay) { int w, h; CameraParameters params(mHardware->getParameters()); if (size == NULL) { params.getPictureSize(&w, &h); } else { w = size->width; h = size->height; w &= ~1; h &= ~1; LOG1("Snapshot image width=%d, height=%d", w, h); } // FIXME: don't use hardcoded format constants here ISurface::BufferHeap buffers(w, h, w, h, HAL_PIXEL_FORMAT_YCrCb_420_SP, mOrientation, 0, mHardware->getRawHeap()); mSurface->registerBuffers(buffers); IPCThreadState::self()->flushCommands(); } mLock.unlock(); }
// picture callback - postview image ready void CameraService::Client::handlePostview(const sp<IMemory>& mem) { disableMsgType(CAMERA_MSG_POSTVIEW_FRAME); sp<ICameraClient> c = mCameraClient; mLock.unlock(); if (c != 0) { c->dataCallback(CAMERA_MSG_POSTVIEW_FRAME, mem, NULL); } }
// picture callback - compressed picture ready void CameraService::Client::handleCompressedPicture(const sp<IMemory>& mem) { disableMsgType(CAMERA_MSG_COMPRESSED_IMAGE); sp<ICameraClient> c = mCameraClient; mLock.unlock(); if (c != 0) { c->dataCallback(CAMERA_MSG_COMPRESSED_IMAGE, mem, NULL); } }
// stop recording mode void CameraService::Client::stopRecording() { LOG1("stopRecording (pid %d)", getCallingPid()); Mutex::Autolock lock(mLock); if (checkPidAndHardware() != NO_ERROR) return; mCameraService->playSound(SOUND_RECORDING); disableMsgType(CAMERA_MSG_VIDEO_FRAME); mHardware->stopRecording(); mPreviewBuffer.clear(); }
// set the preview callback flag to affect how the received frames from // preview are handled. void CameraService::Client::setPreviewCallbackFlag(int callback_flag) { LOG1("setPreviewCallbackFlag(%d) (pid %d)", callback_flag, getCallingPid()); Mutex::Autolock lock(mLock); if (checkPidAndHardware() != NO_ERROR) return; mPreviewCallbackFlag = callback_flag; if (mPreviewCallbackFlag & CAMERA_FRAME_CALLBACK_FLAG_ENABLE_MASK) { enableMsgType(CAMERA_MSG_PREVIEW_FRAME); } else { disableMsgType(CAMERA_MSG_PREVIEW_FRAME); } }
// take a picture - image is returned in callback status_t CameraClient::takePicture(int msgType) { LOG1("takePicture (pid %d): 0x%x", getCallingPid(), msgType); Mutex::Autolock lock(mLock); status_t result = checkPidAndHardware(); if (result != NO_ERROR) return result; if ((msgType & CAMERA_MSG_RAW_IMAGE) && (msgType & CAMERA_MSG_RAW_IMAGE_NOTIFY)) { ALOGE("CAMERA_MSG_RAW_IMAGE and CAMERA_MSG_RAW_IMAGE_NOTIFY" " cannot be both enabled"); return BAD_VALUE; } // We only accept picture related message types // and ignore other types of messages for takePicture(). int picMsgType = msgType & (CAMERA_MSG_SHUTTER | CAMERA_MSG_POSTVIEW_FRAME | CAMERA_MSG_RAW_IMAGE | CAMERA_MSG_RAW_IMAGE_NOTIFY | #if defined(OMAP_ICS_CAMERA) || defined(OMAP_ENHANCEMENT_BURST_CAPTURE) CAMERA_MSG_RAW_BURST | #endif CAMERA_MSG_COMPRESSED_IMAGE); #if defined(OMAP_ICS_CAMERA) || defined(OMAP_ENHANCEMENT_BURST_CAPTURE) picMsgType |= CAMERA_MSG_COMPRESSED_BURST_IMAGE; #endif #ifdef CAMERA_MSG_MGMT disableMsgType(CAMERA_MSG_PREVIEW_METADATA); #endif enableMsgType(picMsgType); #ifdef QCOM_HARDWARE mBurstCnt = mHardware->getParameters().getInt("num-snaps-per-shutter"); if(mBurstCnt <= 0) mBurstCnt = 1; LOG1("mBurstCnt = %d", mBurstCnt); // HTC HDR mode requires that we snap multiple times, but only get one jpeg int numJpegs = mHardware->getParameters().getInt("num-jpegs-per-shutter"); if (numJpegs == 1 && mBurstCnt > 1) { while (mBurstCnt > 1) { result = mHardware->takePicture(); mBurstCnt--; } } #endif return mHardware->takePicture(); }
// picture callback - raw image ready void CameraService::Client::handleRawPicture(const sp<IMemory>& mem) { disableMsgType(CAMERA_MSG_RAW_IMAGE); ssize_t offset; size_t size; sp<IMemoryHeap> heap = mem->getMemory(&offset, &size); sp<ICameraClient> c = mCameraClient; mLock.unlock(); if (c != 0) { c->dataCallback(CAMERA_MSG_RAW_IMAGE, mem, NULL); } }
// stop recording mode void CameraClient::stopRecording() { LOG1("stopRecording (pid %d)", getCallingPid()); Mutex::Autolock lock(mLock); if (checkPidAndHardware() != NO_ERROR) return; disableMsgType(CAMERA_MSG_VIDEO_FRAME); #ifdef QCOM_HARDWARE //Disable picture related message types ALOGI("stopRecording: Disable picture related messages"); int picMsgType = 0; picMsgType = (CAMERA_MSG_SHUTTER | CAMERA_MSG_POSTVIEW_FRAME | CAMERA_MSG_RAW_IMAGE | CAMERA_MSG_RAW_IMAGE_NOTIFY | CAMERA_MSG_COMPRESSED_IMAGE); disableMsgType(picMsgType); #endif mHardware->stopRecording(); mCameraService->playSound(CameraService::SOUND_RECORDING); mPreviewBuffer.clear(); }
// preview callback - frame buffer update void CameraService::Client::handlePreviewData(const sp<IMemory>& mem) { ssize_t offset; size_t size; sp<IMemoryHeap> heap = mem->getMemory(&offset, &size); if (!mUseOverlay) { if (mSurface != 0) { mSurface->postBuffer(offset); } } // local copy of the callback flags int flags = mPreviewCallbackFlag; // is callback enabled? if (!(flags & FRAME_CALLBACK_FLAG_ENABLE_MASK)) { // If the enable bit is off, the copy-out and one-shot bits are ignored LOG2("frame callback is disabled"); mLock.unlock(); return; } // hold a strong pointer to the client sp<ICameraClient> c = mCameraClient; // clear callback flags if no client or one-shot mode if (c == 0 || (mPreviewCallbackFlag & FRAME_CALLBACK_FLAG_ONE_SHOT_MASK)) { LOG2("Disable preview callback"); mPreviewCallbackFlag &= ~(FRAME_CALLBACK_FLAG_ONE_SHOT_MASK | FRAME_CALLBACK_FLAG_COPY_OUT_MASK | FRAME_CALLBACK_FLAG_ENABLE_MASK); if (mUseOverlay) { disableMsgType(CAMERA_MSG_PREVIEW_FRAME); } } if (c != 0) { // Is the received frame copied out or not? if (flags & FRAME_CALLBACK_FLAG_COPY_OUT_MASK) { LOG2("frame is copied"); copyFrameAndPostCopiedFrame(c, heap, offset, size); } else { LOG2("frame is forwarded"); mLock.unlock(); c->dataCallback(CAMERA_MSG_PREVIEW_FRAME, mem); } } else { mLock.unlock(); } }
// picture callback - postview image ready void CameraClient::handlePostview(const sp<IMemory>& mem) { disableMsgType(CAMERA_MSG_POSTVIEW_FRAME); sp<ICameraClient> c = mRemoteCallback; //!++ #if 1 #else mLock.unlock(); #endif //!-- if (c != 0) { c->dataCallback(CAMERA_MSG_POSTVIEW_FRAME, mem, NULL); } }
// picture callback - compressed picture ready void CameraClient::handleCompressedPicture(const sp<IMemory>& mem) { disableMsgType(CAMERA_MSG_COMPRESSED_IMAGE); sp<ICameraClient> c = mRemoteCallback; //!++ #if 1 #else mLock.unlock(); #endif //!-- if (c != 0) { c->dataCallback(CAMERA_MSG_COMPRESSED_IMAGE, mem, NULL); } }
void CameraClient::disconnect() { int callingPid = getCallingPid(); LOG1("disconnect E (pid %d)", callingPid); Mutex::Autolock lock(mLock); // Allow both client and the media server to disconnect at all times if (callingPid != mClientPid && callingPid != mServicePid) { ALOGW("different client - don't disconnect"); return; } if (mClientPid <= 0) { LOG1("camera is unlocked (mClientPid = %d), don't tear down hardware", mClientPid); return; } // Make sure disconnect() is done once and once only, whether it is called // from the user directly, or called by the destructor. if (mHardware == 0) return; LOG1("hardware teardown"); // Before destroying mHardware, we must make sure it's in the // idle state. // Turn off all messages. disableMsgType(CAMERA_MSG_ALL_MSGS); mHardware->stopPreview(); mHardware->cancelPicture(); // Release the hardware resources. mHardware->release(); // Release the held ANativeWindow resources. if (mPreviewWindow != 0) { #ifdef QCOM_HARDWARE #ifndef NO_UPDATE_PREVIEW mHardware->setPreviewWindow(0); #endif #endif disconnectWindow(mPreviewWindow); mPreviewWindow = 0; #ifndef QCOM_HARDWARE mHardware->setPreviewWindow(mPreviewWindow); #endif } mHardware.clear(); CameraService::Client::disconnect(); LOG1("disconnect X (pid %d)", callingPid); }
// snapshot taken callback void CameraService::Client::handleShutter(void) { if (mPlayShutterSound) { mCameraService->playSound(SOUND_SHUTTER); } sp<ICameraClient> c = mCameraClient; if (c != 0) { mLock.unlock(); c->notifyCallback(CAMERA_MSG_SHUTTER, 0, 0); if (!lockIfMessageWanted(CAMERA_MSG_SHUTTER)) return; } disableMsgType(CAMERA_MSG_SHUTTER); mLock.unlock(); }
// picture callback - compressed picture ready void CameraService::Client::handleCompressedPicture(const sp<IMemory>& mem) { if (mburstCnt) mburstCnt--; if (!mburstCnt) { LOG1("mburstCnt = %d", mburstCnt); disableMsgType(CAMERA_MSG_COMPRESSED_IMAGE); if (mFaceDetection) { enableMsgType(CAMERA_MSG_PREVIEW_METADATA); } } sp<ICameraClient> c = mCameraClient; mLock.unlock(); if (c != 0) { c->dataCallback(CAMERA_MSG_COMPRESSED_IMAGE, mem, NULL); } }
/****************************************************************************** * 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); } }
void CameraService::Client::disconnect() { int callingPid = getCallingPid(); LOG1("disconnect E (pid %d)", callingPid); Mutex::Autolock lock(mLock); if (checkPid() != NO_ERROR) { LOGW("different client - don't disconnect"); return; } if (mClientPid <= 0) { LOG1("camera is unlocked (mClientPid = %d), don't tear down hardware", mClientPid); return; } // Make sure disconnect() is done once and once only, whether it is called // from the user directly, or called by the destructor. if (mHardware == 0) return; LOG1("hardware teardown"); // Before destroying mHardware, we must make sure it's in the // idle state. // Turn off all messages. disableMsgType(CAMERA_MSG_ALL_MSGS); mHardware->stopPreview(); mHardware->cancelPicture(); // Release the hardware resources. mHardware->release(); // Release the held overlay resources. if (mUseOverlay) { #ifdef USE_OVERLAY_FORMAT_YCbCr_420_SP /* Release previous overlay handle */ if (mOverlay != NULL) { mOverlay->destroy(); } #endif mOverlayRef = 0; } mHardware.clear(); mCameraService->removeClient(mCameraClient); mCameraService->setCameraFree(mCameraId); LOG1("disconnect X (pid %d)", callingPid); }
// picture callback - raw image ready void CameraService::Client::handleRawPicture(const sp<IMemory>& mem) { disableMsgType(CAMERA_MSG_RAW_IMAGE); ssize_t offset; size_t size; sp<IMemoryHeap> heap = mem->getMemory(&offset, &size); // Put the YUV version of the snapshot in the preview display. if (mSurface != 0 && !mUseOverlay) { mSurface->postBuffer(offset); } sp<ICameraClient> c = mCameraClient; mLock.unlock(); if (c != 0) { c->dataCallback(CAMERA_MSG_RAW_IMAGE, mem); } }
// picture callback - raw image ready void CameraClient::handleRawPicture(const sp<IMemory>& mem) { disableMsgType(CAMERA_MSG_RAW_IMAGE); ssize_t offset; size_t size; sp<IMemoryHeap> heap = mem->getMemory(&offset, &size); sp<ICameraClient> c = mRemoteCallback; //!++ #if 1 #else mLock.unlock(); #endif //!-- if (c != 0) { c->dataCallback(CAMERA_MSG_RAW_IMAGE, mem, NULL); } }
// picture callback - compressed picture ready void CameraClient::handleCompressedPicture(const sp<IMemory>& mem) { #ifdef QCOM_HARDWARE if (mBurstCnt) mBurstCnt--; if (!mBurstCnt) { LOG1("handleCompressedPicture mBurstCnt = %d", mBurstCnt); #endif disableMsgType(CAMERA_MSG_COMPRESSED_IMAGE); #ifdef QCOM_HARDWARE } #endif sp<ICameraClient> c = mRemoteCallback; mLock.unlock(); if (c != 0) { c->dataCallback(CAMERA_MSG_COMPRESSED_IMAGE, mem, NULL); } }
// stop preview mode void CameraService::Client::stopPreview() { LOG1("stopPreview (pid %d)", getCallingPid()); Mutex::Autolock lock(mLock); if (checkPidAndHardware() != NO_ERROR) return; disableMsgType(CAMERA_MSG_PREVIEW_FRAME); mHardware->stopPreview(); if (mSurface != 0 && !mUseOverlay) { mSurface->unregisterBuffers(); #ifdef USE_OVERLAY_FORMAT_YCbCr_420_SP } else { mOverlayW = 0; mOverlayH = 0; #endif } mPreviewBuffer.clear(); }