diff options
author | Jianing Wei <jianingwei@google.com> | 2014-03-22 00:04:19 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-03-22 00:04:20 +0000 |
commit | cfe09079608d78a0a358f01bb49f279859e38664 (patch) | |
tree | 9a1b044149726ec242d3a5e948029d71803aaf7e /services/camera/libcameraservice/device3 | |
parent | 55d15957bc44d11052e1cb3eea3340ec00f70bae (diff) | |
parent | 90e59c98c343e941b1a75307ffa4b4b5f1eb50d6 (diff) | |
download | frameworks_av-cfe09079608d78a0a358f01bb49f279859e38664.zip frameworks_av-cfe09079608d78a0a358f01bb49f279859e38664.tar.gz frameworks_av-cfe09079608d78a0a358f01bb49f279859e38664.tar.bz2 |
Merge "CameraService: Add support for burst capture and repeating burst."
Diffstat (limited to 'services/camera/libcameraservice/device3')
-rw-r--r-- | services/camera/libcameraservice/device3/Camera3Device.cpp | 106 | ||||
-rw-r--r-- | services/camera/libcameraservice/device3/Camera3Device.h | 12 |
2 files changed, 118 insertions, 0 deletions
diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp index 08e03ce..e5ac037 100644 --- a/services/camera/libcameraservice/device3/Camera3Device.cpp +++ b/services/camera/libcameraservice/device3/Camera3Device.cpp @@ -370,6 +370,45 @@ const CameraMetadata& Camera3Device::info() const { return mDeviceInfo; } +status_t Camera3Device::checkStatusOkToCaptureLocked() { + switch (mStatus) { + case STATUS_ERROR: + CLOGE("Device has encountered a serious error"); + return INVALID_OPERATION; + case STATUS_UNINITIALIZED: + CLOGE("Device not initialized"); + return INVALID_OPERATION; + case STATUS_UNCONFIGURED: + case STATUS_CONFIGURED: + case STATUS_ACTIVE: + // OK + break; + default: + SET_ERR_L("Unexpected status: %d", mStatus); + return INVALID_OPERATION; + } + return OK; +} + +status_t Camera3Device::convertMetadataListToRequestListLocked( + const List<const CameraMetadata> &metadataList, RequestList *requestList) { + if (requestList == NULL) { + CLOGE("requestList cannot be NULL."); + return BAD_VALUE; + } + + for (List<const CameraMetadata>::const_iterator it = metadataList.begin(); + it != metadataList.end(); ++it) { + sp<CaptureRequest> newRequest = setUpRequestLocked(*it); + if (newRequest == 0) { + CLOGE("Can't create capture request"); + return BAD_VALUE; + } + requestList->push_back(newRequest); + } + return OK; +} + status_t Camera3Device::capture(CameraMetadata &request) { ATRACE_CALL(); status_t res; @@ -410,10 +449,59 @@ status_t Camera3Device::capture(CameraMetadata &request) { kActiveTimeout/1e9); } ALOGV("Camera %d: Capture request enqueued", mId); + } else { + CLOGE("Cannot queue request. Impossible."); // queueRequest always returns OK. + return BAD_VALUE; } return res; } +status_t Camera3Device::submitRequestsHelper( + const List<const CameraMetadata> &requests, bool repeating) { + ATRACE_CALL(); + Mutex::Autolock il(mInterfaceLock); + Mutex::Autolock l(mLock); + + status_t res = checkStatusOkToCaptureLocked(); + if (res != OK) { + // error logged by previous call + return res; + } + + RequestList requestList; + + res = convertMetadataListToRequestListLocked(requests, /*out*/&requestList); + if (res != OK) { + // error logged by previous call + return res; + } + + if (repeating) { + res = mRequestThread->setRepeatingRequests(requestList); + } else { + res = mRequestThread->queueRequestList(requestList); + } + + if (res == OK) { + waitUntilStateThenRelock(/*active*/true, kActiveTimeout); + if (res != OK) { + SET_ERR_L("Can't transition to active in %f seconds!", + kActiveTimeout/1e9); + } + ALOGV("Camera %d: Capture request enqueued", mId); + } else { + CLOGE("Cannot queue request. Impossible."); + return BAD_VALUE; + } + + return res; +} + +status_t Camera3Device::captureList(const List<const CameraMetadata> &requests) { + ATRACE_CALL(); + + return submitRequestsHelper(requests, /*repeating*/false); +} status_t Camera3Device::setStreamingRequest(const CameraMetadata &request) { ATRACE_CALL(); @@ -460,6 +548,11 @@ status_t Camera3Device::setStreamingRequest(const CameraMetadata &request) { return res; } +status_t Camera3Device::setStreamingRequestList(const List<const CameraMetadata> &requests) { + ATRACE_CALL(); + + return submitRequestsHelper(requests, /*repeating*/true); +} sp<Camera3Device::CaptureRequest> Camera3Device::setUpRequestLocked( const CameraMetadata &request) { @@ -1895,6 +1988,19 @@ status_t Camera3Device::RequestThread::queueRequest( return OK; } +status_t Camera3Device::RequestThread::queueRequestList( + List<sp<CaptureRequest> > &requests) { + Mutex::Autolock l(mRequestLock); + for (List<sp<CaptureRequest> >::iterator it = requests.begin(); it != requests.end(); + ++it) { + mRequestQueue.push_back(*it); + } + + unpauseForNewRequests(); + + return OK; +} + status_t Camera3Device::RequestThread::queueTrigger( RequestTrigger trigger[], diff --git a/services/camera/libcameraservice/device3/Camera3Device.h b/services/camera/libcameraservice/device3/Camera3Device.h index 9007a9b..44c6260 100644 --- a/services/camera/libcameraservice/device3/Camera3Device.h +++ b/services/camera/libcameraservice/device3/Camera3Device.h @@ -79,7 +79,9 @@ class Camera3Device : // Capture and setStreamingRequest will configure streams if currently in // idle state virtual status_t capture(CameraMetadata &request); + virtual status_t captureList(const List<const CameraMetadata> &requests); virtual status_t setStreamingRequest(const CameraMetadata &request); + virtual status_t setStreamingRequestList(const List<const CameraMetadata> &requests); virtual status_t clearStreamingRequest(); virtual status_t waitUntilRequestReceived(int32_t requestId, nsecs_t timeout); @@ -201,6 +203,14 @@ class Camera3Device : }; typedef List<sp<CaptureRequest> > RequestList; + status_t checkStatusOkToCaptureLocked(); + + status_t convertMetadataListToRequestListLocked( + const List<const CameraMetadata> &metadataList, + /*out*/RequestList *requestList); + + status_t submitRequestsHelper(const List<const CameraMetadata> &requests, bool repeating); + /** * Get the last request submitted to the hal by the request thread. * @@ -312,6 +322,8 @@ class Camera3Device : status_t queueRequest(sp<CaptureRequest> request); + status_t queueRequestList(List<sp<CaptureRequest> > &requests); + /** * Remove all queued and repeating requests, and pending triggers */ |