summaryrefslogtreecommitdiffstats
path: root/include/camera
diff options
context:
space:
mode:
Diffstat (limited to 'include/camera')
-rw-r--r--include/camera/Camera.h118
-rw-r--r--include/camera/CameraBase.h118
-rw-r--r--include/camera/CameraMetadata.h232
-rw-r--r--include/camera/CameraParameters.h10
-rw-r--r--include/camera/ICamera.h27
-rw-r--r--include/camera/ICameraClient.h3
-rw-r--r--include/camera/ICameraService.h70
-rw-r--r--include/camera/ICameraServiceListener.h87
-rw-r--r--include/camera/IProCameraCallbacks.h71
-rw-r--r--include/camera/IProCameraUser.h100
-rw-r--r--include/camera/ProCamera.h319
-rw-r--r--include/camera/camera2/CaptureRequest.h42
-rw-r--r--include/camera/camera2/ICameraDeviceCallbacks.h75
-rw-r--r--include/camera/camera2/ICameraDeviceUser.h84
14 files changed, 1268 insertions, 88 deletions
diff --git a/include/camera/Camera.h b/include/camera/Camera.h
index 234e165..79682b8 100644
--- a/include/camera/Camera.h
+++ b/include/camera/Camera.h
@@ -18,41 +18,20 @@
#define ANDROID_HARDWARE_CAMERA_H
#include <utils/Timers.h>
-#include <gui/ISurfaceTexture.h>
+#include <gui/IGraphicBufferProducer.h>
#include <system/camera.h>
#include <camera/ICameraClient.h>
#include <camera/ICameraRecordingProxy.h>
#include <camera/ICameraRecordingProxyListener.h>
+#include <camera/ICameraService.h>
+#include <camera/ICamera.h>
+#include <camera/CameraBase.h>
namespace android {
-struct CameraInfo {
- /**
- * The direction that the camera faces to. It should be CAMERA_FACING_BACK
- * or CAMERA_FACING_FRONT.
- */
- int facing;
-
- /**
- * The orientation of the camera image. The value is the angle that the
- * camera image needs to be rotated clockwise so it shows correctly on the
- * display in its natural orientation. It should be 0, 90, 180, or 270.
- *
- * For example, suppose a device has a naturally tall screen. The
- * back-facing camera sensor is mounted in landscape. You are looking at
- * the screen. If the top side of the camera sensor is aligned with the
- * right edge of the screen in natural orientation, the value should be
- * 90. If the top side of a front-facing camera sensor is aligned with the
- * right of the screen, the value should be 270.
- */
- int orientation;
-};
-
-class ICameraService;
-class ICamera;
class Surface;
-class Mutex;
class String8;
+class String16;
// ref-counted object for callbacks
class CameraListener: virtual public RefBase
@@ -64,32 +43,47 @@ public:
virtual void postDataTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr) = 0;
};
-class Camera : public BnCameraClient, public IBinder::DeathRecipient
+class Camera;
+
+template <>
+struct CameraTraits<Camera>
+{
+ typedef CameraListener TCamListener;
+ typedef ICamera TCamUser;
+ typedef ICameraClient TCamCallbacks;
+ typedef status_t (ICameraService::*TCamConnectService)(const sp<ICameraClient>&,
+ int, const String16&, int,
+ /*out*/
+ sp<ICamera>&);
+ static TCamConnectService fnConnectService;
+};
+
+
+class Camera :
+ public CameraBase<Camera>,
+ public BnCameraClient
{
public:
+ enum {
+ USE_CALLING_UID = ICameraService::USE_CALLING_UID
+ };
+
// construct a camera client from an existing remote
static sp<Camera> create(const sp<ICamera>& camera);
- static int32_t getNumberOfCameras();
- static status_t getCameraInfo(int cameraId,
- struct CameraInfo* cameraInfo);
- static sp<Camera> connect(int cameraId);
+ static sp<Camera> connect(int cameraId,
+ const String16& clientPackageName,
+ int clientUid);
+
virtual ~Camera();
- void init();
status_t reconnect();
- void disconnect();
status_t lock();
status_t unlock();
- status_t getStatus() { return mStatus; }
+ // pass the buffered IGraphicBufferProducer to the camera service
+ status_t setPreviewTarget(const sp<IGraphicBufferProducer>& bufferProducer);
- // pass the buffered Surface to the camera service
- status_t setPreviewDisplay(const sp<Surface>& surface);
-
- // pass the buffered ISurfaceTexture to the camera service
- status_t setPreviewTexture(const sp<ISurfaceTexture>& surfaceTexture);
-
- // start preview mode, must call setPreviewDisplay first
+ // start preview mode, must call setPreviewTarget first
status_t startPreview();
// stop preview mode
@@ -98,7 +92,7 @@ public:
// get preview state
bool previewEnabled();
- // start recording mode, must call setPreviewDisplay first
+ // start recording mode, must call setPreviewTarget first
status_t startRecording();
// stop recording mode
@@ -133,7 +127,15 @@ public:
void setListener(const sp<CameraListener>& listener);
void setRecordingProxyListener(const sp<ICameraRecordingProxyListener>& listener);
+
+ // Configure preview callbacks to app. Only one of the older
+ // callbacks or the callback surface can be active at the same time;
+ // enabling one will disable the other if active. Flags can be
+ // disabled by calling it with CAMERA_FRAME_CALLBACK_FLAG_NOOP, and
+ // Target by calling it with a NULL interface.
void setPreviewCallbackFlags(int preview_callback_flag);
+ status_t setPreviewCallbackTarget(
+ const sp<IGraphicBufferProducer>& callbackProducer);
sp<ICameraRecordingProxy> getRecordingProxy();
@@ -143,8 +145,6 @@ public:
camera_frame_metadata_t *metadata);
virtual void dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr);
- sp<ICamera> remote();
-
class RecordingProxy : public BnCameraRecordingProxy
{
public:
@@ -159,36 +159,14 @@ public:
sp<Camera> mCamera;
};
-private:
- Camera();
+protected:
+ Camera(int cameraId);
Camera(const Camera&);
Camera& operator=(const Camera);
- virtual void binderDied(const wp<IBinder>& who);
-
- class DeathNotifier: public IBinder::DeathRecipient
- {
- public:
- DeathNotifier() {
- }
-
- virtual void binderDied(const wp<IBinder>& who);
- };
-
- static sp<DeathNotifier> mDeathNotifier;
-
- // helper function to obtain camera service handle
- static const sp<ICameraService>& getCameraService();
-
- sp<ICamera> mCamera;
- status_t mStatus;
-
- sp<CameraListener> mListener;
- sp<ICameraRecordingProxyListener> mRecordingProxyListener;
- friend class DeathNotifier;
+ sp<ICameraRecordingProxyListener> mRecordingProxyListener;
- static Mutex mLock;
- static sp<ICameraService> mCameraService;
+ friend class CameraBase;
};
}; // namespace android
diff --git a/include/camera/CameraBase.h b/include/camera/CameraBase.h
new file mode 100644
index 0000000..1b93157
--- /dev/null
+++ b/include/camera/CameraBase.h
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2013 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_CAMERA_BASE_H
+#define ANDROID_HARDWARE_CAMERA_BASE_H
+
+#include <utils/Mutex.h>
+#include <camera/ICameraService.h>
+
+struct camera_frame_metadata;
+
+namespace android {
+
+struct CameraInfo {
+ /**
+ * The direction that the camera faces to. It should be CAMERA_FACING_BACK
+ * or CAMERA_FACING_FRONT.
+ */
+ int facing;
+
+ /**
+ * The orientation of the camera image. The value is the angle that the
+ * camera image needs to be rotated clockwise so it shows correctly on the
+ * display in its natural orientation. It should be 0, 90, 180, or 270.
+ *
+ * For example, suppose a device has a naturally tall screen. The
+ * back-facing camera sensor is mounted in landscape. You are looking at
+ * the screen. If the top side of the camera sensor is aligned with the
+ * right edge of the screen in natural orientation, the value should be
+ * 90. If the top side of a front-facing camera sensor is aligned with the
+ * right of the screen, the value should be 270.
+ */
+ int orientation;
+};
+
+template <typename TCam>
+struct CameraTraits {
+};
+
+template <typename TCam, typename TCamTraits = CameraTraits<TCam> >
+class CameraBase : public IBinder::DeathRecipient
+{
+public:
+ typedef typename TCamTraits::TCamListener TCamListener;
+ typedef typename TCamTraits::TCamUser TCamUser;
+ typedef typename TCamTraits::TCamCallbacks TCamCallbacks;
+ typedef typename TCamTraits::TCamConnectService TCamConnectService;
+
+ static sp<TCam> connect(int cameraId,
+ const String16& clientPackageName,
+ int clientUid);
+ virtual void disconnect();
+
+ void setListener(const sp<TCamListener>& listener);
+
+ static int getNumberOfCameras();
+
+ static status_t getCameraInfo(int cameraId,
+ /*out*/
+ struct CameraInfo* cameraInfo);
+
+ static status_t addServiceListener(
+ const sp<ICameraServiceListener>& listener);
+
+ static status_t removeServiceListener(
+ const sp<ICameraServiceListener>& listener);
+
+ sp<TCamUser> remote();
+
+ // Status is set to 'UNKNOWN_ERROR' after successful (re)connection
+ status_t getStatus();
+
+protected:
+ CameraBase(int cameraId);
+ virtual ~CameraBase();
+
+ ////////////////////////////////////////////////////////
+ // TCamCallbacks implementation
+ ////////////////////////////////////////////////////////
+ virtual void notifyCallback(int32_t msgType, int32_t ext,
+ int32_t ext2);
+
+ ////////////////////////////////////////////////////////
+ // Common instance variables
+ ////////////////////////////////////////////////////////
+ Mutex mLock;
+
+ virtual void binderDied(const wp<IBinder>& who);
+
+ // helper function to obtain camera service handle
+ static const sp<ICameraService>& getCameraService();
+
+ sp<TCamUser> mCamera;
+ status_t mStatus;
+
+ sp<TCamListener> mListener;
+
+ const int mCameraId;
+
+ typedef CameraBase<TCam> CameraBaseT;
+};
+
+}; // namespace android
+
+#endif
diff --git a/include/camera/CameraMetadata.h b/include/camera/CameraMetadata.h
new file mode 100644
index 0000000..1254d3c
--- /dev/null
+++ b/include/camera/CameraMetadata.h
@@ -0,0 +1,232 @@
+/*
+ * Copyright (C) 2012 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_CLIENT_CAMERA2_CAMERAMETADATA_CPP
+#define ANDROID_CLIENT_CAMERA2_CAMERAMETADATA_CPP
+
+#include "system/camera_metadata.h"
+#include <utils/String8.h>
+#include <utils/Vector.h>
+
+namespace android {
+class Parcel;
+
+/**
+ * A convenience wrapper around the C-based camera_metadata_t library.
+ */
+class CameraMetadata {
+ public:
+ /** Creates an empty object; best used when expecting to acquire contents
+ * from elsewhere */
+ CameraMetadata();
+ /** Creates an object with space for entryCapacity entries, with
+ * dataCapacity extra storage */
+ CameraMetadata(size_t entryCapacity, size_t dataCapacity = 10);
+
+ ~CameraMetadata();
+
+ /** Takes ownership of passed-in buffer */
+ CameraMetadata(camera_metadata_t *buffer);
+ /** Clones the metadata */
+ CameraMetadata(const CameraMetadata &other);
+
+ /**
+ * Assignment clones metadata buffer.
+ */
+ CameraMetadata &operator=(const CameraMetadata &other);
+ CameraMetadata &operator=(const camera_metadata_t *buffer);
+
+ /**
+ * Get reference to the underlying metadata buffer. Ownership remains with
+ * the CameraMetadata object, but non-const CameraMetadata methods will not
+ * work until unlock() is called. Note that the lock has nothing to do with
+ * thread-safety, it simply prevents the camera_metadata_t pointer returned
+ * here from being accidentally invalidated by CameraMetadata operations.
+ */
+ const camera_metadata_t* getAndLock();
+
+ /**
+ * Unlock the CameraMetadata for use again. After this unlock, the pointer
+ * given from getAndLock() may no longer be used. The pointer passed out
+ * from getAndLock must be provided to guarantee that the right object is
+ * being unlocked.
+ */
+ status_t unlock(const camera_metadata_t *buffer);
+
+ /**
+ * Release a raw metadata buffer to the caller. After this call,
+ * CameraMetadata no longer references the buffer, and the caller takes
+ * responsibility for freeing the raw metadata buffer (using
+ * free_camera_metadata()), or for handing it to another CameraMetadata
+ * instance.
+ */
+ camera_metadata_t* release();
+
+ /**
+ * Clear the metadata buffer and free all storage used by it
+ */
+ void clear();
+
+ /**
+ * Acquire a raw metadata buffer from the caller. After this call,
+ * the caller no longer owns the raw buffer, and must not free or manipulate it.
+ * If CameraMetadata already contains metadata, it is freed.
+ */
+ void acquire(camera_metadata_t* buffer);
+
+ /**
+ * Acquires raw buffer from other CameraMetadata object. After the call, the argument
+ * object no longer has any metadata.
+ */
+ void acquire(CameraMetadata &other);
+
+ /**
+ * Append metadata from another CameraMetadata object.
+ */
+ status_t append(const CameraMetadata &other);
+
+ /**
+ * Append metadata from a raw camera_metadata buffer
+ */
+ status_t append(const camera_metadata* other);
+
+ /**
+ * Number of metadata entries.
+ */
+ size_t entryCount() const;
+
+ /**
+ * Is the buffer empty (no entires)
+ */
+ bool isEmpty() const;
+
+ /**
+ * Sort metadata buffer for faster find
+ */
+ status_t sort();
+
+ /**
+ * Update metadata entry. Will create entry if it doesn't exist already, and
+ * will reallocate the buffer if insufficient space exists. Overloaded for
+ * the various types of valid data.
+ */
+ status_t update(uint32_t tag,
+ const uint8_t *data, size_t data_count);
+ status_t update(uint32_t tag,
+ const int32_t *data, size_t data_count);
+ status_t update(uint32_t tag,
+ const float *data, size_t data_count);
+ status_t update(uint32_t tag,
+ const int64_t *data, size_t data_count);
+ status_t update(uint32_t tag,
+ const double *data, size_t data_count);
+ status_t update(uint32_t tag,
+ const camera_metadata_rational_t *data, size_t data_count);
+ status_t update(uint32_t tag,
+ const String8 &string);
+
+ template<typename T>
+ status_t update(uint32_t tag, Vector<T> data) {
+ return update(tag, data.array(), data.size());
+ }
+
+ /**
+ * Check if a metadata entry exists for a given tag id
+ *
+ */
+ bool exists(uint32_t tag) const;
+
+ /**
+ * Get metadata entry by tag id
+ */
+ camera_metadata_entry find(uint32_t tag);
+
+ /**
+ * Get metadata entry by tag id, with no editing
+ */
+ camera_metadata_ro_entry find(uint32_t tag) const;
+
+ /**
+ * Delete metadata entry by tag
+ */
+ status_t erase(uint32_t tag);
+
+ /**
+ * Swap the underlying camera metadata between this and the other
+ * metadata object.
+ */
+ void swap(CameraMetadata &other);
+
+ /**
+ * Dump contents into FD for debugging. The verbosity levels are
+ * 0: Tag entry information only, no data values
+ * 1: Level 0 plus at most 16 data values per entry
+ * 2: All information
+ *
+ * The indentation parameter sets the number of spaces to add to the start
+ * each line of output.
+ */
+ void dump(int fd, int verbosity = 1, int indentation = 0) const;
+
+ /**
+ * Serialization over Binder
+ */
+
+ // Metadata object is unchanged when reading from parcel fails.
+ status_t readFromParcel(Parcel *parcel);
+ status_t writeToParcel(Parcel *parcel) const;
+
+ /**
+ * Caller becomes the owner of the new metadata
+ * 'const Parcel' doesnt prevent us from calling the read functions.
+ * which is interesting since it changes the internal state
+ *
+ * NULL can be returned when no metadata was sent, OR if there was an issue
+ * unpacking the serialized data (i.e. bad parcel or invalid structure).
+ */
+ static status_t readFromParcel(const Parcel &parcel,
+ camera_metadata_t** out);
+ /**
+ * Caller retains ownership of metadata
+ * - Write 2 (int32 + blob) args in the current position
+ */
+ static status_t writeToParcel(Parcel &parcel,
+ const camera_metadata_t* metadata);
+
+ private:
+ camera_metadata_t *mBuffer;
+ bool mLocked;
+
+ /**
+ * Check if tag has a given type
+ */
+ status_t checkType(uint32_t tag, uint8_t expectedType);
+
+ /**
+ * Base update entry method
+ */
+ status_t updateImpl(uint32_t tag, const void *data, size_t data_count);
+
+ /**
+ * Resize metadata buffer if needed by reallocating it and copying it over.
+ */
+ status_t resizeIfNeeded(size_t extraEntries, size_t extraData);
+
+};
+
+}; // namespace android
+
+#endif
diff --git a/include/camera/CameraParameters.h b/include/camera/CameraParameters.h
index 5540d32..d521543 100644
--- a/include/camera/CameraParameters.h
+++ b/include/camera/CameraParameters.h
@@ -525,6 +525,10 @@ public:
// stream and record stabilized videos.
static const char KEY_VIDEO_STABILIZATION_SUPPORTED[];
+ // Supported modes for special effects with light.
+ // Example values: "lowlight,hdr".
+ static const char KEY_LIGHTFX[];
+
// Value for KEY_ZOOM_SUPPORTED or KEY_SMOOTH_ZOOM_SUPPORTED.
static const char TRUE[];
static const char FALSE[];
@@ -664,6 +668,12 @@ public:
// other modes.
static const char FOCUS_MODE_CONTINUOUS_PICTURE[];
+ // Values for light special effects
+ // Low-light enhancement mode
+ static const char LIGHTFX_LOWLIGHT[];
+ // High-dynamic range mode
+ static const char LIGHTFX_HDR[];
+
private:
DefaultKeyedVector<String8,String8> mMap;
};
diff --git a/include/camera/ICamera.h b/include/camera/ICamera.h
index 3d18837..b025735 100644
--- a/include/camera/ICamera.h
+++ b/include/camera/ICamera.h
@@ -27,11 +27,14 @@
namespace android {
class ICameraClient;
-class ISurfaceTexture;
+class IGraphicBufferProducer;
class Surface;
class ICamera: public IInterface
{
+ /**
+ * Keep up-to-date with ICamera.aidl in frameworks/base
+ */
public:
DECLARE_META_INTERFACE(Camera);
@@ -46,18 +49,22 @@ public:
// allow other processes to use this ICamera interface
virtual status_t unlock() = 0;
- // pass the buffered Surface to the camera service
- virtual status_t setPreviewDisplay(const sp<Surface>& surface) = 0;
-
- // pass the buffered ISurfaceTexture to the camera service
- virtual status_t setPreviewTexture(
- const sp<ISurfaceTexture>& surfaceTexture) = 0;
+ // pass the buffered IGraphicBufferProducer to the camera service
+ virtual status_t setPreviewTarget(
+ const sp<IGraphicBufferProducer>& bufferProducer) = 0;
// set the preview callback flag to affect how the received frames from
- // preview are handled.
+ // preview are handled. Enabling preview callback flags disables any active
+ // preview callback surface set by setPreviewCallbackTarget().
virtual void setPreviewCallbackFlag(int flag) = 0;
-
- // start preview mode, must call setPreviewDisplay first
+ // set a buffer interface to use for client-received preview frames instead
+ // of preview callback buffers. Passing a valid interface here disables any
+ // active preview callbacks set by setPreviewCallbackFlag(). Passing NULL
+ // disables the use of the callback target.
+ virtual status_t setPreviewCallbackTarget(
+ const sp<IGraphicBufferProducer>& callbackProducer) = 0;
+
+ // start preview mode, must call setPreviewTarget first
virtual status_t startPreview() = 0;
// stop preview mode
diff --git a/include/camera/ICameraClient.h b/include/camera/ICameraClient.h
index b30aa7a..1584dba 100644
--- a/include/camera/ICameraClient.h
+++ b/include/camera/ICameraClient.h
@@ -28,6 +28,9 @@ namespace android {
class ICameraClient: public IInterface
{
+ /**
+ * Keep up-to-date with ICameraClient.aidl in frameworks/base
+ */
public:
DECLARE_META_INTERFACE(CameraClient);
diff --git a/include/camera/ICameraService.h b/include/camera/ICameraService.h
index 7d70c1e..f342122 100644
--- a/include/camera/ICameraService.h
+++ b/include/camera/ICameraService.h
@@ -21,28 +21,82 @@
#include <binder/IInterface.h>
#include <binder/Parcel.h>
-#include <camera/ICameraClient.h>
-#include <camera/ICamera.h>
-
namespace android {
+class ICamera;
+class ICameraClient;
+class IProCameraUser;
+class IProCameraCallbacks;
+class ICameraServiceListener;
+class ICameraDeviceUser;
+class ICameraDeviceCallbacks;
+class CameraMetadata;
+
class ICameraService : public IInterface
{
public:
+ /**
+ * Keep up-to-date with ICameraService.aidl in frameworks/base
+ */
enum {
GET_NUMBER_OF_CAMERAS = IBinder::FIRST_CALL_TRANSACTION,
GET_CAMERA_INFO,
- CONNECT
+ CONNECT,
+ CONNECT_PRO,
+ CONNECT_DEVICE,
+ ADD_LISTENER,
+ REMOVE_LISTENER,
+ GET_CAMERA_CHARACTERISTICS,
+ };
+
+ enum {
+ USE_CALLING_UID = -1
};
public:
DECLARE_META_INTERFACE(CameraService);
- virtual int32_t getNumberOfCameras() = 0;
- virtual status_t getCameraInfo(int cameraId,
+ virtual int32_t getNumberOfCameras() = 0;
+ virtual status_t getCameraInfo(int cameraId,
struct CameraInfo* cameraInfo) = 0;
- virtual sp<ICamera> connect(const sp<ICameraClient>& cameraClient,
- int cameraId) = 0;
+
+ virtual status_t getCameraCharacteristics(int cameraId,
+ CameraMetadata* cameraInfo) = 0;
+
+ // Returns 'OK' if operation succeeded
+ // - Errors: ALREADY_EXISTS if the listener was already added
+ virtual status_t addListener(const sp<ICameraServiceListener>& listener)
+ = 0;
+ // Returns 'OK' if operation succeeded
+ // - Errors: BAD_VALUE if specified listener was not in the listener list
+ virtual status_t removeListener(const sp<ICameraServiceListener>& listener)
+ = 0;
+ /**
+ * clientPackageName and clientUid are used for permissions checking. if
+ * clientUid == USE_CALLING_UID, then the calling UID is used instead. Only
+ * trusted callers can set a clientUid other than USE_CALLING_UID.
+ */
+ virtual status_t connect(const sp<ICameraClient>& cameraClient,
+ int cameraId,
+ const String16& clientPackageName,
+ int clientUid,
+ /*out*/
+ sp<ICamera>& device) = 0;
+
+ virtual status_t connectPro(const sp<IProCameraCallbacks>& cameraCb,
+ int cameraId,
+ const String16& clientPackageName,
+ int clientUid,
+ /*out*/
+ sp<IProCameraUser>& device) = 0;
+
+ virtual status_t connectDevice(
+ const sp<ICameraDeviceCallbacks>& cameraCb,
+ int cameraId,
+ const String16& clientPackageName,
+ int clientUid,
+ /*out*/
+ sp<ICameraDeviceUser>& device) = 0;
};
// ----------------------------------------------------------------------------
diff --git a/include/camera/ICameraServiceListener.h b/include/camera/ICameraServiceListener.h
new file mode 100644
index 0000000..0a0e43a
--- /dev/null
+++ b/include/camera/ICameraServiceListener.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2013 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_ICAMERASERVICE_LISTENER_H
+#define ANDROID_HARDWARE_ICAMERASERVICE_LISTENER_H
+
+#include <utils/RefBase.h>
+#include <binder/IInterface.h>
+#include <binder/Parcel.h>
+#include <hardware/camera_common.h>
+
+namespace android {
+
+class ICameraServiceListener : public IInterface
+{
+ /**
+ * Keep up-to-date with ICameraServiceListener.aidl in frameworks/base
+ */
+public:
+
+ /**
+ * Initial status will be transmitted with onStatusChange immediately
+ * after this listener is added to the service listener list.
+ *
+ * Allowed transitions:
+ *
+ * (Any) -> NOT_PRESENT
+ * NOT_PRESENT -> PRESENT
+ * NOT_PRESENT -> ENUMERATING
+ * ENUMERATING -> PRESENT
+ * PRESENT -> NOT_AVAILABLE
+ * NOT_AVAILABLE -> PRESENT
+ *
+ * A state will never immediately transition back to itself.
+ */
+ enum Status {
+ // Device physically unplugged
+ STATUS_NOT_PRESENT = CAMERA_DEVICE_STATUS_NOT_PRESENT,
+ // Device physically has been plugged in
+ // and the camera can be used exlusively
+ STATUS_PRESENT = CAMERA_DEVICE_STATUS_PRESENT,
+ // Device physically has been plugged in
+ // but it will not be connect-able until enumeration is complete
+ STATUS_ENUMERATING = CAMERA_DEVICE_STATUS_ENUMERATING,
+
+ // Camera can be used exclusively
+ STATUS_AVAILABLE = STATUS_PRESENT, // deprecated, will be removed
+
+ // Camera is in use by another app and cannot be used exclusively
+ STATUS_NOT_AVAILABLE = 0x80000000,
+
+ // Use to initialize variables only
+ STATUS_UNKNOWN = 0xFFFFFFFF,
+ };
+
+ DECLARE_META_INTERFACE(CameraServiceListener);
+
+ virtual void onStatusChanged(Status status, int32_t cameraId) = 0;
+};
+
+// ----------------------------------------------------------------------------
+
+class BnCameraServiceListener : public BnInterface<ICameraServiceListener>
+{
+public:
+ virtual status_t onTransact( uint32_t code,
+ const Parcel& data,
+ Parcel* reply,
+ uint32_t flags = 0);
+};
+
+}; // namespace android
+
+#endif
diff --git a/include/camera/IProCameraCallbacks.h b/include/camera/IProCameraCallbacks.h
new file mode 100644
index 0000000..e8abb89
--- /dev/null
+++ b/include/camera/IProCameraCallbacks.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2013 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_IPROCAMERA_CALLBACKS_H
+#define ANDROID_HARDWARE_IPROCAMERA_CALLBACKS_H
+
+#include <utils/RefBase.h>
+#include <binder/IInterface.h>
+#include <binder/Parcel.h>
+#include <binder/IMemory.h>
+#include <utils/Timers.h>
+#include <system/camera.h>
+
+struct camera_metadata;
+
+namespace android {
+
+class IProCameraCallbacks : public IInterface
+{
+ /**
+ * Keep up-to-date with IProCameraCallbacks.aidl in frameworks/base
+ */
+public:
+ DECLARE_META_INTERFACE(ProCameraCallbacks);
+
+ virtual void notifyCallback(int32_t msgType,
+ int32_t ext1,
+ int32_t ext2) = 0;
+
+ enum LockStatus {
+ LOCK_ACQUIRED,
+ LOCK_RELEASED,
+ LOCK_STOLEN,
+ };
+
+ virtual void onLockStatusChanged(LockStatus newLockStatus) = 0;
+
+ /** Missing by design: implementation is client-side in ProCamera.cpp **/
+ // virtual void onBufferReceived(int streamId,
+ // const CpuConsumer::LockedBufer& buf);
+ virtual void onResultReceived(int32_t requestId,
+ camera_metadata* result) = 0;
+};
+
+// ----------------------------------------------------------------------------
+
+class BnProCameraCallbacks : public BnInterface<IProCameraCallbacks>
+{
+public:
+ virtual status_t onTransact( uint32_t code,
+ const Parcel& data,
+ Parcel* reply,
+ uint32_t flags = 0);
+};
+
+}; // namespace android
+
+#endif
diff --git a/include/camera/IProCameraUser.h b/include/camera/IProCameraUser.h
new file mode 100644
index 0000000..2ccc4d2
--- /dev/null
+++ b/include/camera/IProCameraUser.h
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2013 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_IPROCAMERAUSER_H
+#define ANDROID_HARDWARE_IPROCAMERAUSER_H
+
+#include <utils/RefBase.h>
+#include <binder/IInterface.h>
+#include <binder/Parcel.h>
+#include <binder/IMemory.h>
+#include <utils/String8.h>
+#include <camera/IProCameraCallbacks.h>
+
+struct camera_metadata;
+
+namespace android {
+
+class IProCameraUserClient;
+class IGraphicBufferProducer;
+class Surface;
+
+class IProCameraUser: public IInterface
+{
+ /**
+ * Keep up-to-date with IProCameraUser.aidl in frameworks/base
+ */
+public:
+ DECLARE_META_INTERFACE(ProCameraUser);
+
+ virtual void disconnect() = 0;
+
+ // connect to the service, given a callbacks listener
+ virtual status_t connect(const sp<IProCameraCallbacks>& callbacks)
+ = 0;
+
+ /**
+ * Locking
+ **/
+ virtual status_t exclusiveTryLock() = 0;
+ virtual status_t exclusiveLock() = 0;
+ virtual status_t exclusiveUnlock() = 0;
+
+ virtual bool hasExclusiveLock() = 0;
+
+ /**
+ * Request Handling
+ **/
+
+ // Note that the callee gets a copy of the metadata.
+ virtual int submitRequest(struct camera_metadata* metadata,
+ bool streaming = false) = 0;
+ virtual status_t cancelRequest(int requestId) = 0;
+
+ virtual status_t deleteStream(int streamId) = 0;
+ virtual status_t createStream(
+ int width, int height, int format,
+ const sp<IGraphicBufferProducer>& bufferProducer,
+ /*out*/
+ int* streamId) = 0;
+
+ // Create a request object from a template.
+ virtual status_t createDefaultRequest(int templateId,
+ /*out*/
+ camera_metadata** request)
+ = 0;
+
+ // Get static camera metadata
+ virtual status_t getCameraInfo(int cameraId,
+ /*out*/
+ camera_metadata** info) = 0;
+
+};
+
+// ----------------------------------------------------------------------------
+
+class BnProCameraUser: public BnInterface<IProCameraUser>
+{
+public:
+ virtual status_t onTransact( uint32_t code,
+ const Parcel& data,
+ Parcel* reply,
+ uint32_t flags = 0);
+};
+
+}; // namespace android
+
+#endif
diff --git a/include/camera/ProCamera.h b/include/camera/ProCamera.h
new file mode 100644
index 0000000..83a3028
--- /dev/null
+++ b/include/camera/ProCamera.h
@@ -0,0 +1,319 @@
+/*
+ * Copyright (C) 2013 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_PRO_CAMERA_H
+#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 <camera/CameraMetadata.h>
+#include <camera/ICameraService.h>
+#include <gui/CpuConsumer.h>
+
+#include <gui/Surface.h>
+
+#include <utils/Condition.h>
+#include <utils/Mutex.h>
+
+#include <camera/CameraBase.h>
+
+struct camera_metadata;
+
+namespace android {
+
+// All callbacks on this class are concurrent
+// (they come from separate threads)
+class ProCameraListener : virtual public RefBase
+{
+public:
+ virtual void notify(int32_t msgType, int32_t ext1, int32_t ext2) = 0;
+
+ // Lock has been acquired. Write operations now available.
+ virtual void onLockAcquired() = 0;
+ // Lock has been released with exclusiveUnlock.
+ virtual void onLockReleased() = 0;
+ // Lock has been stolen by another client.
+ virtual void onLockStolen() = 0;
+
+ // Lock free.
+ virtual void onTriggerNotify(int32_t msgType, int32_t ext1, int32_t ext2)
+ = 0;
+ // onFrameAvailable and OnResultReceived can come in with any order,
+ // use android.sensor.timestamp and LockedBuffer.timestamp to correlate them
+
+ /**
+ * A new metadata buffer has been received.
+ * -- Ownership of request passes on to the callee, free with
+ * free_camera_metadata.
+ */
+ virtual void onResultReceived(int32_t frameId, camera_metadata* result) = 0;
+
+ // TODO: make onFrameAvailable pure virtual
+
+ // A new frame buffer has been received for this stream.
+ // -- This callback only fires for createStreamCpu streams
+ // -- A buffer may be obtained by calling cpuConsumer->lockNextBuffer
+ // -- Use buf.timestamp to correlate with result's android.sensor.timestamp
+ // -- The buffer should be accessed with CpuConsumer::lockNextBuffer
+ // and CpuConsumer::unlockBuffer
+ virtual void onFrameAvailable(int /*streamId*/,
+ const sp<CpuConsumer>& /*cpuConsumer*/) {
+ }
+
+};
+
+class ProCamera;
+
+template <>
+struct CameraTraits<ProCamera>
+{
+ typedef ProCameraListener TCamListener;
+ typedef IProCameraUser TCamUser;
+ typedef IProCameraCallbacks TCamCallbacks;
+ typedef status_t (ICameraService::*TCamConnectService)(const sp<IProCameraCallbacks>&,
+ int, const String16&, int,
+ /*out*/
+ sp<IProCameraUser>&);
+ static TCamConnectService fnConnectService;
+};
+
+
+class ProCamera :
+ public CameraBase<ProCamera>,
+ public BnProCameraCallbacks
+{
+public:
+ /**
+ * Connect a shared camera. By default access is restricted to read only
+ * (Lock free) operations. To be able to submit custom requests a lock needs
+ * to be acquired with exclusive[Try]Lock.
+ */
+ static sp<ProCamera> connect(int cameraId);
+ virtual ~ProCamera();
+
+ /**
+ * Exclusive Locks:
+ * - We may request exclusive access to a camera if no other
+ * clients are using the camera. This works as a traditional
+ * client, writing/reading any camera state.
+ * - An application opening the camera (a regular 'Camera') will
+ * always steal away the exclusive lock from a ProCamera,
+ * this will call onLockReleased.
+ * - onLockAcquired will be called again once it is possible
+ * to again exclusively lock the camera.
+ *
+ */
+
+ /**
+ * All exclusiveLock/unlock functions are asynchronous. The remote endpoint
+ * shall not block while waiting to acquire the lock. Instead the lock
+ * notifications will come in asynchronously on the listener.
+ */
+
+ /**
+ * Attempt to acquire the lock instantly (non-blocking)
+ * - If this succeeds, you do not need to wait for onLockAcquired
+ * but the event will still be fired
+ *
+ * Returns -EBUSY if already locked. 0 on success.
+ */
+ status_t exclusiveTryLock();
+ // always returns 0. wait for onLockAcquired before lock is acquired.
+ status_t exclusiveLock();
+ // release a lock if we have one, or cancel the lock request.
+ status_t exclusiveUnlock();
+
+ // exclusive lock = do whatever we want. no lock = read only.
+ bool hasExclusiveLock();
+
+ /**
+ * < 0 error, >= 0 the request ID. streaming to have the request repeat
+ * until cancelled.
+ * The request queue is flushed when a lock is released or stolen
+ * if not locked will return PERMISSION_DENIED
+ */
+ int submitRequest(const struct camera_metadata* metadata,
+ bool streaming = false);
+ // if not locked will return PERMISSION_DENIED, BAD_VALUE if requestId bad
+ status_t cancelRequest(int requestId);
+
+ /**
+ * Ask for a stream to be enabled.
+ * Lock free. Service maintains counter of streams.
+ */
+ status_t requestStream(int streamId);
+// TODO: remove requestStream, its useless.
+
+ /**
+ * Delete a stream.
+ * Lock free.
+ *
+ * NOTE: As a side effect this cancels ALL streaming requests.
+ *
+ * Errors: BAD_VALUE if unknown stream ID.
+ * PERMISSION_DENIED if the stream wasn't yours
+ */
+ status_t deleteStream(int streamId);
+
+ /**
+ * Create a new HW stream, whose sink will be the window.
+ * Lock free. Service maintains counter of streams.
+ * Errors: -EBUSY if too many streams created
+ */
+ status_t createStream(int width, int height, int format,
+ const sp<Surface>& surface,
+ /*out*/
+ int* streamId);
+
+ /**
+ * Create a new HW stream, whose sink will be the SurfaceTexture.
+ * Lock free. Service maintains counter of streams.
+ * Errors: -EBUSY if too many streams created
+ */
+ status_t createStream(int width, int height, int format,
+ const sp<IGraphicBufferProducer>& bufferProducer,
+ /*out*/
+ int* streamId);
+ status_t createStreamCpu(int width, int height, int format,
+ int heapCount,
+ /*out*/
+ sp<CpuConsumer>* cpuConsumer,
+ int* streamId);
+ status_t createStreamCpu(int width, int height, int format,
+ int heapCount,
+ bool synchronousMode,
+ /*out*/
+ sp<CpuConsumer>* cpuConsumer,
+ int* streamId);
+
+ // Create a request object from a template.
+ status_t createDefaultRequest(int templateId,
+ /*out*/
+ camera_metadata** request) const;
+
+ // 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
+ // Return value:
+ // - >0 - number of frames available to be locked
+ // - <0 - error (refer to error codes)
+ // Error codes:
+ // -ETIMEDOUT if it took too long to get a frame
+ int 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();
+
+ // Convenience method to drop frame buffers (CPU streams only)
+ // Return values:
+ // >=0 - number of frames dropped (up to count)
+ // <0 - error code
+ // Error codes:
+ // BAD_VALUE - invalid streamId or count passed
+ int dropFrameBuffer(int streamId, int count);
+
+protected:
+ ////////////////////////////////////////////////////////
+ // IProCameraCallbacks implementation
+ ////////////////////////////////////////////////////////
+ virtual void notifyCallback(int32_t msgType,
+ int32_t ext,
+ int32_t ext2);
+
+ virtual void onLockStatusChanged(
+ IProCameraCallbacks::LockStatus newLockStatus);
+
+ virtual void onResultReceived(int32_t requestId,
+ camera_metadata* result);
+private:
+ ProCamera(int cameraId);
+
+ 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;
+ frameReady = 0;
+ }
+
+ StreamInfo() {
+ streamID = -1;
+ cpuStream = false;
+ }
+
+ int streamID;
+ bool cpuStream;
+ sp<CpuConsumer> cpuConsumer;
+ bool synchronousMode;
+ sp<ProFrameListener> frameAvailableListener;
+ sp<Surface> stc;
+ int frameReady;
+ };
+
+ Condition mWaitCondition;
+ Mutex mWaitMutex;
+ static const nsecs_t mWaitTimeout = 1000000000; // 1sec
+ KeyedVector<int, StreamInfo> mStreams;
+ bool mMetadataReady;
+ CameraMetadata mLatestMetadata;
+
+ void onFrameAvailable(int streamId);
+
+ StreamInfo& getStreamInfo(int streamId);
+
+ friend class CameraBase;
+};
+
+}; // namespace android
+
+#endif
diff --git a/include/camera/camera2/CaptureRequest.h b/include/camera/camera2/CaptureRequest.h
new file mode 100644
index 0000000..e56d61f
--- /dev/null
+++ b/include/camera/camera2/CaptureRequest.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2013 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_PHOTOGRAPHY_CAPTUREREQUEST_H
+#define ANDROID_HARDWARE_PHOTOGRAPHY_CAPTUREREQUEST_H
+
+#include <utils/RefBase.h>
+#include <utils/Vector.h>
+#include <camera/CameraMetadata.h>
+
+namespace android {
+
+class Surface;
+
+struct CaptureRequest : public virtual RefBase {
+public:
+
+ CameraMetadata mMetadata;
+ Vector<sp<Surface> > mSurfaceList;
+
+ /**
+ * Keep impl up-to-date with CaptureRequest.java in frameworks/base
+ */
+ status_t readFromParcel(Parcel* parcel);
+ status_t writeToParcel(Parcel* parcel) const;
+};
+}; // namespace android
+
+#endif
diff --git a/include/camera/camera2/ICameraDeviceCallbacks.h b/include/camera/camera2/ICameraDeviceCallbacks.h
new file mode 100644
index 0000000..8dac4f2
--- /dev/null
+++ b/include/camera/camera2/ICameraDeviceCallbacks.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2013 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_PHOTOGRAPHY_CALLBACKS_H
+#define ANDROID_HARDWARE_PHOTOGRAPHY_CALLBACKS_H
+
+#include <utils/RefBase.h>
+#include <binder/IInterface.h>
+#include <binder/Parcel.h>
+#include <binder/IMemory.h>
+#include <utils/Timers.h>
+#include <system/camera.h>
+
+namespace android {
+class CameraMetadata;
+
+class ICameraDeviceCallbacks : public IInterface
+{
+ /**
+ * Keep up-to-date with ICameraDeviceCallbacks.aidl in frameworks/base
+ */
+public:
+ DECLARE_META_INTERFACE(CameraDeviceCallbacks);
+
+ /**
+ * Error codes for CAMERA_MSG_ERROR
+ */
+ enum CameraErrorCode {
+ ERROR_CAMERA_DISCONNECTED = 0,
+ ERROR_CAMERA_DEVICE = 1,
+ ERROR_CAMERA_SERVICE = 2
+ };
+
+ // One way
+ virtual void onDeviceError(CameraErrorCode errorCode) = 0;
+
+ // One way
+ virtual void onDeviceIdle() = 0;
+
+ // One way
+ virtual void onCaptureStarted(int32_t requestId,
+ int64_t timestamp) = 0;
+
+ // One way
+ virtual void onResultReceived(int32_t requestId,
+ const CameraMetadata& result) = 0;
+};
+
+// ----------------------------------------------------------------------------
+
+class BnCameraDeviceCallbacks : public BnInterface<ICameraDeviceCallbacks>
+{
+public:
+ virtual status_t onTransact( uint32_t code,
+ const Parcel& data,
+ Parcel* reply,
+ uint32_t flags = 0);
+};
+
+}; // namespace android
+
+#endif
diff --git a/include/camera/camera2/ICameraDeviceUser.h b/include/camera/camera2/ICameraDeviceUser.h
new file mode 100644
index 0000000..f71f302
--- /dev/null
+++ b/include/camera/camera2/ICameraDeviceUser.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2013 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_PHOTOGRAPHY_ICAMERADEVICEUSER_H
+#define ANDROID_HARDWARE_PHOTOGRAPHY_ICAMERADEVICEUSER_H
+
+#include <binder/IInterface.h>
+#include <binder/Parcel.h>
+
+struct camera_metadata;
+
+namespace android {
+
+class ICameraDeviceUserClient;
+class IGraphicBufferProducer;
+class Surface;
+class CaptureRequest;
+class CameraMetadata;
+
+class ICameraDeviceUser : public IInterface
+{
+ /**
+ * Keep up-to-date with ICameraDeviceUser.aidl in frameworks/base
+ */
+public:
+ DECLARE_META_INTERFACE(CameraDeviceUser);
+
+ virtual void disconnect() = 0;
+
+ /**
+ * Request Handling
+ **/
+
+ virtual int submitRequest(sp<CaptureRequest> request,
+ bool streaming = false) = 0;
+ virtual status_t cancelRequest(int requestId) = 0;
+
+ virtual status_t deleteStream(int streamId) = 0;
+ virtual status_t createStream(
+ int width, int height, int format,
+ const sp<IGraphicBufferProducer>& bufferProducer) = 0;
+
+ // Create a request object from a template.
+ virtual status_t createDefaultRequest(int templateId,
+ /*out*/
+ CameraMetadata* request) = 0;
+ // Get static camera metadata
+ virtual status_t getCameraInfo(/*out*/
+ CameraMetadata* info) = 0;
+
+ // 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;
+};
+
+// ----------------------------------------------------------------------------
+
+class BnCameraDeviceUser: public BnInterface<ICameraDeviceUser>
+{
+public:
+ virtual status_t onTransact( uint32_t code,
+ const Parcel& data,
+ Parcel* reply,
+ uint32_t flags = 0);
+};
+
+}; // namespace android
+
+#endif