Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d860b094 authored by Shuzhen Wang's avatar Shuzhen Wang Committed by Bruno Martins
Browse files

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
parent f501f106
Loading
Loading
Loading
Loading
+31 −2
Original line number Diff line number Diff line
@@ -55,6 +55,9 @@ CameraClient::CameraClient(const sp<CameraService>& cameraService,
    mPreviewCallbackFlag = CAMERA_FRAME_CALLBACK_FLAG_NOOP;
    mOrientation = getOrientation(0, mCameraFacing == CAMERA_FACING_FRONT);
    mPlayShutterSound = true;

    mLongshotEnabled = false;
    mBurstCnt = 0;
    LOG1("CameraClient::CameraClient X (pid %d, id %d)", callingPid, cameraId);
}

@@ -672,6 +675,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();
}
@@ -755,6 +762,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);
@@ -954,7 +975,9 @@ void CameraClient::handleShutter(void) {
        c->notifyCallback(CAMERA_MSG_SHUTTER, 0, 0);
        if (!lockIfMessageWanted(CAMERA_MSG_SHUTTER)) return;
    }
    if ( !mLongshotEnabled ) {
        disableMsgType(CAMERA_MSG_SHUTTER);
    }

    // Shutters only happen in response to takePicture, so mark device as
    // idle now, until preview is restarted
@@ -1040,7 +1063,13 @@ void CameraClient::handleRawPicture(const sp<IMemory>& mem) {

// picture callback - compressed picture ready
void CameraClient::handleCompressedPicture(const sp<IMemory>& mem) {
    if (mBurstCnt)
        mBurstCnt--;

    if (!mBurstCnt && !mLongshotEnabled) {
        LOG1("handleCompressedPicture mBurstCnt = %d", mBurstCnt);
        disableMsgType(CAMERA_MSG_COMPRESSED_IMAGE);
    }

    sp<hardware::ICameraClient> c = mRemoteCallback;
    mLock.unlock();
+3 −0
Original line number Diff line number Diff line
@@ -183,6 +183,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;
};

}