From f462de9dac6a858ab42447a67ba5077e3effb04e Mon Sep 17 00:00:00 2001 From: Shuzhen Wang Date: Wed, 8 Jul 2015 15:47:46 -0700 Subject: Camera: Add extensions to CameraClient This change includes the following gerrits: # This is a combination of 4 commits. # The first commit's message is: Camera: Enable Histogram feature. Link the histogram enable/disable commands from application to the HAL layer. Change-Id: I510c4e1798285ed1315bfb0d234fa76090659ba2 # This is the 2nd commit message: Camera: Add support for ZSL burst mode. Added ability to set number of snapshots in burst mode. Change-Id: Ie0e7c8c0117b7adc985cfc92df79747ee6a5ea51 # This is the 3rd commit message: CameraService: Adds support for longshot mode - This change introduces additional functionality inside CameraClient for supporting continuous compressed data callbacks. This is needed for 'Burst/Long shot' mode where we could have indefinite number of callbacks after capture is triggered. (cherrypicked from commit e4f502aa7cbe8875e8a1589024cdcf227c228a2b) Change-Id: Ia18ca9bdda7736c679db557e510870115089537a # This is the 4th commit message: CameraClient: Enables meta data notifications. Adds the needed functionality for enabling/disabling metadata messages depending on the camera client commands. Change-Id: I39d632b4742e83df5db5f86b12742aefc2480dfc Cherrypicked from 25bd97f5ec30e7942c3b1fdc96115da6028736f0 Change-Id: Ie930d20c962593e40a0767f9cf7d4385df8e2561 --- .../camera/libcameraservice/api1/CameraClient.cpp | 33 ++++++++++++++++++++-- .../camera/libcameraservice/api1/CameraClient.h | 3 ++ 2 files changed, 34 insertions(+), 2 deletions(-) (limited to 'services') diff --git a/services/camera/libcameraservice/api1/CameraClient.cpp b/services/camera/libcameraservice/api1/CameraClient.cpp index e552633..f3a7988 100644 --- a/services/camera/libcameraservice/api1/CameraClient.cpp +++ b/services/camera/libcameraservice/api1/CameraClient.cpp @@ -56,6 +56,9 @@ CameraClient::CameraClient(const sp& cameraService, mOrientation = getOrientation(0, mCameraFacing == CAMERA_FACING_FRONT); mLegacyMode = legacyMode; mPlayShutterSound = true; + + mLongshotEnabled = false; + mBurstCnt = 0; LOG1("CameraClient::CameraClient X (pid %d, id %d)", callingPid, cameraId); } @@ -544,6 +547,10 @@ status_t CameraClient::takePicture(int msgType) { CAMERA_MSG_COMPRESSED_IMAGE); enableMsgType(picMsgType); + mBurstCnt = mHardware->getParameters().getInt("num-snaps-per-shutter"); + if(mBurstCnt <= 0) + mBurstCnt = 1; + LOG1("mBurstCnt = %d", mBurstCnt); return mHardware->takePicture(); } @@ -646,6 +653,20 @@ status_t CameraClient::sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) { } else if (cmd == CAMERA_CMD_PING) { // If mHardware is 0, checkPidAndHardware will return error. return OK; + } 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); } return mHardware->sendCommand(cmd, arg1, arg2); @@ -788,7 +809,9 @@ void CameraClient::handleShutter(void) { c->notifyCallback(CAMERA_MSG_SHUTTER, 0, 0); if (!lockIfMessageWanted(CAMERA_MSG_SHUTTER)) return; } - disableMsgType(CAMERA_MSG_SHUTTER); + if ( !mLongshotEnabled ) { + disableMsgType(CAMERA_MSG_SHUTTER); + } mLock.unlock(); } @@ -867,7 +890,13 @@ void CameraClient::handleRawPicture(const sp& mem) { // picture callback - compressed picture ready void CameraClient::handleCompressedPicture(const sp& mem) { - disableMsgType(CAMERA_MSG_COMPRESSED_IMAGE); + if (mBurstCnt) + mBurstCnt--; + + if (!mBurstCnt && !mLongshotEnabled) { + LOG1("handleCompressedPicture mBurstCnt = %d", mBurstCnt); + disableMsgType(CAMERA_MSG_COMPRESSED_IMAGE); + } sp c = mRemoteCallback; mLock.unlock(); diff --git a/services/camera/libcameraservice/api1/CameraClient.h b/services/camera/libcameraservice/api1/CameraClient.h index 95616b2..9d2d02f 100644 --- a/services/camera/libcameraservice/api1/CameraClient.h +++ b/services/camera/libcameraservice/api1/CameraClient.h @@ -162,6 +162,9 @@ private: // This function keeps trying to grab mLock, or give up if the message // is found to be disabled. It returns true if mLock is grabbed. bool lockIfMessageWanted(int32_t msgType); + + bool mLongshotEnabled; + int mBurstCnt; }; } -- cgit v1.1