summaryrefslogtreecommitdiffstats
path: root/include/camera
diff options
context:
space:
mode:
authorIgor Murashkin <iam@google.com>2013-02-21 14:45:03 -0800
committerIgor Murashkin <iam@google.com>2013-02-22 10:50:15 -0800
commita140a6efea1db7837984b3578755cfa4eaa8d92d (patch)
treed7ce2fa02ae78e0ca1fedf453290787ce5cd2be3 /include/camera
parentdcb07d51e307019731147751946774f45321edfb (diff)
downloadframeworks_av-a140a6efea1db7837984b3578755cfa4eaa8d92d.zip
frameworks_av-a140a6efea1db7837984b3578755cfa4eaa8d92d.tar.gz
frameworks_av-a140a6efea1db7837984b3578755cfa4eaa8d92d.tar.bz2
ProCamera: add waitForFrameBuffer/waitForFrameResult blocking calls
Change-Id: I851d41aeecaa15245d5b9d622132e8706d6e292c
Diffstat (limited to 'include/camera')
-rw-r--r--include/camera/ProCamera.h45
1 files changed, 44 insertions, 1 deletions
diff --git a/include/camera/ProCamera.h b/include/camera/ProCamera.h
index 11904f9..f813c1c 100644
--- a/include/camera/ProCamera.h
+++ b/include/camera/ProCamera.h
@@ -24,8 +24,12 @@
#include <camera/IProCameraCallbacks.h>
#include <camera/IProCameraUser.h>
#include <camera/Camera.h>
+#include <camera/CameraMetadata.h>
#include <gui/CpuConsumer.h>
+#include <utils/Condition.h>
+#include <utils/Mutex.h>
+
struct camera_metadata;
namespace android {
@@ -62,6 +66,20 @@ public:
* free_camera_metadata.
*/
virtual void onResultReceived(int32_t frameId, camera_metadata* result) = 0;
+
+
+ // A new frame buffer has been received for this stream.
+ // -- This callback only fires for createStreamCpu streams
+ // -- Use buf.timestamp to correlate with metadata's android.sensor.timestamp
+ // -- The buffer should be accessed with CpuConsumer::lockNextBuffer
+ // and CpuConsumer::unlockBuffer
+ virtual void onFrameAvailable(int streamId,
+ const sp<CpuConsumer>& cpuConsumer) {
+ }
+
+ virtual bool useOnFrameAvailable() {
+ return false;
+ }
};
class ProCamera : public BnProCameraCallbacks, public IBinder::DeathRecipient
@@ -161,6 +179,7 @@ public:
status_t createStreamCpu(int width, int height, int format,
int heapCount,
/*out*/
+ sp<CpuConsumer>* cpuConsumer,
int* streamId);
// Create a request object from a template.
@@ -174,6 +193,24 @@ public:
// Get static camera metadata
camera_metadata* getCameraInfo(int cameraId);
+ // Blocks until a frame is available (CPU streams only)
+ // - Obtain the frame data by calling CpuConsumer::lockNextBuffer
+ // - Release the frame data after use with CpuConsumer::unlockBuffer
+ // Error codes:
+ // -ETIMEDOUT if it took too long to get a frame
+ status_t waitForFrameBuffer(int streamId);
+
+ // Blocks until a metadata result is available
+ // - Obtain the metadata by calling consumeFrameMetadata()
+ // Error codes:
+ // -ETIMEDOUT if it took too long to get a frame
+ status_t waitForFrameMetadata();
+
+ // Get the latest metadata. This is destructive.
+ // - Calling this repeatedly will produce empty metadata objects.
+ // - Use waitForFrameMetadata to sync until new data is available.
+ CameraMetadata consumeFrameMetadata();
+
sp<IProCameraUser> remote();
protected:
@@ -249,6 +286,7 @@ private:
StreamInfo(int streamId) {
this->streamID = streamId;
cpuStream = false;
+ frameReady = false;
}
StreamInfo() {
@@ -261,10 +299,15 @@ private:
sp<CpuConsumer> cpuConsumer;
sp<ProFrameListener> frameAvailableListener;
sp<Surface> stc;
+ bool frameReady;
};
+ Condition mWaitCondition;
+ Mutex mWaitMutex;
+ static const nsecs_t mWaitTimeout = 1000000000; // 1sec
KeyedVector<int, StreamInfo> mStreams;
-
+ bool mMetadataReady;
+ CameraMetadata mLatestMetadata;
void onFrameAvailable(int streamId);