summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorIgor Murashkin <iam@google.com>2013-02-20 19:29:53 -0800
committerIgor Murashkin <iam@google.com>2013-02-22 10:50:15 -0800
commit5835cc46a2f06dbfa5fbdab70e091896ef2fb438 (patch)
treef303abd135f649d5beb940a238b906b4027564f5 /include
parent76f8b43909817179b317880202360863b8f976d0 (diff)
downloadframeworks_av-5835cc46a2f06dbfa5fbdab70e091896ef2fb438.zip
frameworks_av-5835cc46a2f06dbfa5fbdab70e091896ef2fb438.tar.gz
frameworks_av-5835cc46a2f06dbfa5fbdab70e091896ef2fb438.tar.bz2
Camera: ProCamera - add createStreamCpu and unit test
Change-Id: I468172dbfdd78510b273bf9d119c950cbeda7ea3
Diffstat (limited to 'include')
-rw-r--r--include/camera/ProCamera.h86
1 files changed, 74 insertions, 12 deletions
diff --git a/include/camera/ProCamera.h b/include/camera/ProCamera.h
index 9b763a3..4dda533 100644
--- a/include/camera/ProCamera.h
+++ b/include/camera/ProCamera.h
@@ -18,17 +18,20 @@
#define ANDROID_HARDWARE_PRO_CAMERA_H
#include <utils/Timers.h>
+#include <utils/KeyedVector.h>
#include <gui/IGraphicBufferProducer.h>
#include <system/camera.h>
#include <camera/IProCameraCallbacks.h>
#include <camera/IProCameraUser.h>
#include <camera/Camera.h>
+#include <gui/CpuConsumer.h>
struct camera_metadata;
namespace android {
-// ref-counted object for callbacks
+// All callbacks on this class are concurrent
+// (they come from separate threads)
class ProCameraListener : public CameraListener
{
public:
@@ -42,6 +45,21 @@ public:
// Lock free.
virtual void onTriggerNotify(int32_t msgType, int32_t ext1, int32_t ext2)
= 0;
+
+ // OnBufferReceived and OnRequestReceived can come in with any order,
+ // use android.sensor.timestamp and LockedBuffer.timestamp to correlate them
+
+ // TODO: implement in IProCameraCallbacks, ProCamera2Client
+
+ // A new frame buffer has been received for this stream.
+ // -- This callback only fires for createStreamCpu streams
+ // -- The buffer must not be accessed after this function call completes
+ virtual void onBufferReceived(int streamId,
+ const CpuConsumer::LockedBuffer& buf) = 0;
+ // A new metadata buffer has been received.
+ // -- Ownership of request passes on to the callee,
+ // free with free_camera_metadata.
+ virtual void onRequestReceived(camera_metadata* request) = 0;
};
class ProCamera : public BnProCameraCallbacks, public IBinder::DeathRecipient
@@ -109,22 +127,15 @@ public:
* Lock free. Service maintains counter of streams.
*/
status_t requestStream(int streamId);
- /**
- * Ask for a stream to be disabled.
- * Lock free. Service maintains counter of streams.
- * Errors: BAD_VALUE if unknown stream ID.
- */
// TODO: remove requestStream, its useless.
-// TODO: rename cancelStream to deleteStream
-// can probably do it with a grep/sed
-
/**
- * Ask for a stream to be disabled.
- * Lock free. Service maintains counter of streams.
+ * Delete a stream.
+ * Lock free.
* Errors: BAD_VALUE if unknown stream ID.
+ * PERMISSION_DENIED if the stream wasn't yours
*/
- status_t cancelStream(int streamId);
+ status_t deleteStream(int streamId);
/**
* Create a new HW stream, whose sink will be the window.
@@ -145,6 +156,10 @@ public:
const sp<IGraphicBufferProducer>& bufferProducer,
/*out*/
int* streamId);
+ status_t createStreamCpu(int width, int height, int format,
+ int heapCount,
+ /*out*/
+ int* streamId);
// Create a request object from a template.
status_t createDefaultRequest(int templateId,
@@ -203,6 +218,53 @@ private:
static Mutex mLock;
static sp<ICameraService> mCameraService;
+ class ProFrameListener : public CpuConsumer::FrameAvailableListener {
+ public:
+ ProFrameListener(wp<ProCamera> camera, int streamID) {
+ mCamera = camera;
+ mStreamId = streamID;
+ }
+
+ protected:
+ virtual void onFrameAvailable() {
+ sp<ProCamera> c = mCamera.promote();
+ if (c.get() != NULL) {
+ c->onFrameAvailable(mStreamId);
+ }
+ }
+
+ private:
+ wp<ProCamera> mCamera;
+ int mStreamId;
+ };
+ friend class ProFrameListener;
+
+ struct StreamInfo
+ {
+ StreamInfo(int streamId) {
+ this->streamID = streamId;
+ cpuStream = false;
+ }
+
+ StreamInfo() {
+ streamID = -1;
+ cpuStream = false;
+ }
+
+ int streamID;
+ bool cpuStream;
+ sp<CpuConsumer> cpuConsumer;
+ sp<ProFrameListener> frameAvailableListener;
+ sp<Surface> stc;
+ };
+
+ KeyedVector<int, StreamInfo> mStreams;
+
+
+ void onFrameAvailable(int streamId);
+
+ StreamInfo& getStreamInfo(int streamId);
+
};