From cb0652e5a850b2fcd919e977247e87239efaf70e Mon Sep 17 00:00:00 2001 From: Jianing Wei Date: Wed, 12 Mar 2014 18:29:36 -0700 Subject: CameraService: trigger appropriate callbacks for burst capture. * Instead of tracking CameraMetadata only, now we track both CameraMetadata and CaptureResultExtras, which is not part of the HAL metadata. This will enable the correct callback of onCaptureStarted and onResultReceived given burst requests. * Get last frame number in reply when submitting requests, canceling requests, and flushing device. For repeating requests, this frame number is the last frame number of the previous request. For non-repeating requests, this frame number is the expected last frame number of the current request. The goal is provide frame number to Java side in order to trigger onCaptureSequenceCompleted correctly. * Fix notifyError so that onDeviceError can be called correctly. Bug: 10749500 Change-Id: I2f3dda6c530090055d4a2ff9f0f087bbbe8d9257 --- include/camera/CaptureResult.h | 90 +++++++++++++++++++++++++ include/camera/camera2/ICameraDeviceCallbacks.h | 12 ++-- include/camera/camera2/ICameraDeviceUser.h | 38 +++++++++-- 3 files changed, 132 insertions(+), 8 deletions(-) create mode 100644 include/camera/CaptureResult.h (limited to 'include') diff --git a/include/camera/CaptureResult.h b/include/camera/CaptureResult.h new file mode 100644 index 0000000..6e47a16 --- /dev/null +++ b/include/camera/CaptureResult.h @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_HARDWARE_CAPTURERESULT_H +#define ANDROID_HARDWARE_CAPTURERESULT_H + +#include +#include + +namespace android { + +/** + * CaptureResultExtras is a structure to encapsulate various indices for a capture result. + * These indices are framework-internal and not sent to the HAL. + */ +struct CaptureResultExtras { + /** + * An integer to index the request sequence that this result belongs to. + */ + int32_t requestId; + + /** + * An integer to index this result inside a request sequence, starting from 0. + */ + int32_t burstId; + + /** + * TODO: Add documentation for this field. + */ + int32_t afTriggerId; + + /** + * TODO: Add documentation for this field. + */ + int32_t precaptureTriggerId; + + /** + * A 64bit integer to index the frame number associated with this result. + */ + int64_t frameNumber; + + /** + * Constructor initializes object as invalid by setting requestId to be -1. + */ + CaptureResultExtras() + : requestId(-1), + burstId(0), + afTriggerId(0), + precaptureTriggerId(0), + frameNumber(0) { + } + + /** + * This function returns true if it's a valid CaptureResultExtras object. + * Otherwise, returns false. It is valid only when requestId is non-negative. + */ + bool isValid(); + + status_t readFromParcel(Parcel* parcel); + status_t writeToParcel(Parcel* parcel) const; +}; + +struct CaptureResult : public virtual LightRefBase { + CameraMetadata mMetadata; + CaptureResultExtras mResultExtras; + + CaptureResult(); + + CaptureResult(const CaptureResult& otherResult); + + status_t readFromParcel(Parcel* parcel); + status_t writeToParcel(Parcel* parcel) const; +}; + +} + +#endif /* ANDROID_HARDWARE_CAPTURERESULT_H */ diff --git a/include/camera/camera2/ICameraDeviceCallbacks.h b/include/camera/camera2/ICameraDeviceCallbacks.h index 8dac4f2..f059b3d 100644 --- a/include/camera/camera2/ICameraDeviceCallbacks.h +++ b/include/camera/camera2/ICameraDeviceCallbacks.h @@ -24,9 +24,12 @@ #include #include +#include + namespace android { class CameraMetadata; + class ICameraDeviceCallbacks : public IInterface { /** @@ -45,18 +48,19 @@ public: }; // One way - virtual void onDeviceError(CameraErrorCode errorCode) = 0; + virtual void onDeviceError(CameraErrorCode errorCode, + const CaptureResultExtras& resultExtras) = 0; // One way virtual void onDeviceIdle() = 0; // One way - virtual void onCaptureStarted(int32_t requestId, + virtual void onCaptureStarted(const CaptureResultExtras& resultExtras, int64_t timestamp) = 0; // One way - virtual void onResultReceived(int32_t requestId, - const CameraMetadata& result) = 0; + virtual void onResultReceived(const CameraMetadata& metadata, + const CaptureResultExtras& resultExtras) = 0; }; // ---------------------------------------------------------------------------- diff --git a/include/camera/camera2/ICameraDeviceUser.h b/include/camera/camera2/ICameraDeviceUser.h index f71f302..49daf69 100644 --- a/include/camera/camera2/ICameraDeviceUser.h +++ b/include/camera/camera2/ICameraDeviceUser.h @@ -19,6 +19,7 @@ #include #include +#include struct camera_metadata; @@ -44,9 +45,34 @@ public: * Request Handling **/ + /** + * For streaming requests, output lastFrameNumber is the last frame number + * of the previous repeating request. + * For non-streaming requests, output lastFrameNumber is the expected last + * frame number of the current request. + */ virtual int submitRequest(sp request, - bool streaming = false) = 0; - virtual status_t cancelRequest(int requestId) = 0; + bool streaming = false, + /*out*/ + int64_t* lastFrameNumber = NULL) = 0; + + /** + * For streaming requests, output lastFrameNumber is the last frame number + * of the previous repeating request. + * For non-streaming requests, output lastFrameNumber is the expected last + * frame number of the current request. + */ + virtual int submitRequestList(List > requestList, + bool streaming = false, + /*out*/ + int64_t* lastFrameNumber = NULL) = 0; + + /** + * Output lastFrameNumber is the last frame number of the previous repeating request. + */ + virtual status_t cancelRequest(int requestId, + /*out*/ + int64_t* lastFrameNumber = NULL) = 0; virtual status_t deleteStream(int streamId) = 0; virtual status_t createStream( @@ -64,8 +90,12 @@ public: // Wait until all the submitted requests have finished processing virtual status_t waitUntilIdle() = 0; - // Flush all pending and in-progress work as quickly as possible. - virtual status_t flush() = 0; + /** + * Flush all pending and in-progress work as quickly as possible. + * Output lastFrameNumber is the last frame number of the previous repeating request. + */ + virtual status_t flush(/*out*/ + int64_t* lastFrameNumber = NULL) = 0; }; // ---------------------------------------------------------------------------- -- cgit v1.1