diff options
author | Benny Wong <Benny.Wong@motorola.com> | 2009-08-12 12:01:27 -0500 |
---|---|---|
committer | James Dong <jdong@google.com> | 2009-08-13 10:46:28 -0700 |
commit | 4c8fb0a184e51c3f561fff26ba84ceb5ec75be24 (patch) | |
tree | bf62fcd39b8ddce9c5a9104bad23244cc747a15b /include | |
parent | 1689746b118fbf3a3a3e23f2ce7e2ab104d2ecfc (diff) | |
download | frameworks_native-4c8fb0a184e51c3f561fff26ba84ceb5ec75be24.zip frameworks_native-4c8fb0a184e51c3f561fff26ba84ceb5ec75be24.tar.gz frameworks_native-4c8fb0a184e51c3f561fff26ba84ceb5ec75be24.tar.bz2 |
Modified the camera HAL interface to use the same generic callback architecture as camera services
Diffstat (limited to 'include')
-rw-r--r-- | include/ui/Camera.h | 19 | ||||
-rw-r--r-- | include/ui/CameraHardwareInterface.h | 137 |
2 files changed, 82 insertions, 74 deletions
diff --git a/include/ui/Camera.h b/include/ui/Camera.h index afb07b5..ae6e255 100644 --- a/include/ui/Camera.h +++ b/include/ui/Camera.h @@ -66,15 +66,16 @@ namespace android { // msgType in notifyCallback and dataCallback functions enum { - CAMERA_MSG_ERROR = 0, - CAMERA_MSG_SHUTTER, - CAMERA_MSG_FOCUS, - CAMERA_MSG_ZOOM, - CAMERA_MSG_PREVIEW_FRAME, - CAMERA_MSG_VIDEO_FRAME, - CAMERA_MSG_POSTVIEW_FRAME, - CAMERA_MSG_RAW_IMAGE, - CAMERA_MSG_COMPRESSED_IMAGE + CAMERA_MSG_ERROR = 0x001, + CAMERA_MSG_SHUTTER = 0x002, + CAMERA_MSG_FOCUS = 0x004, + CAMERA_MSG_ZOOM = 0x008, + CAMERA_MSG_PREVIEW_FRAME = 0x010, + CAMERA_MSG_VIDEO_FRAME = 0x020, + CAMERA_MSG_POSTVIEW_FRAME = 0x040, + CAMERA_MSG_RAW_IMAGE = 0x080, + CAMERA_MSG_COMPRESSED_IMAGE = 0x100, + CAMERA_MSG_ALL_MSGS = 0x1FF }; // camera fatal errors diff --git a/include/ui/CameraHardwareInterface.h b/include/ui/CameraHardwareInterface.h index c703f5e..535f70e 100644 --- a/include/ui/CameraHardwareInterface.h +++ b/include/ui/CameraHardwareInterface.h @@ -19,28 +19,26 @@ #include <binder/IMemory.h> #include <utils/RefBase.h> +#include <ui/ISurface.h> +#include <ui/Camera.h> #include <ui/CameraParameters.h> #include <ui/Overlay.h> namespace android { -/** Callback for startPreview() */ -typedef void (*preview_callback)(const sp<IMemory>& mem, void* user); +typedef void (*notify_callback)(int32_t msgType, + int32_t ext1, + int32_t ext2, + void* user); -/** Callback for startRecord() */ -typedef void (*recording_callback)(nsecs_t timestamp, const sp<IMemory>& mem, void* user); +typedef void (*data_callback)(int32_t msgType, + const sp<IMemory>& dataPtr, + void* user); -/** Callback for takePicture() */ -typedef void (*shutter_callback)(void* user); - -/** Callback for takePicture() */ -typedef void (*raw_callback)(const sp<IMemory>& mem, void* user); - -/** Callback for takePicture() */ -typedef void (*jpeg_callback)(const sp<IMemory>& mem, void* user); - -/** Callback for autoFocus() */ -typedef void (*autofocus_callback)(bool focused, void* user); +typedef void (*data_callback_timestamp)(nsecs_t timestamp, + int32_t msgType, + const sp<IMemory>& dataPtr, + void* user); /** * CameraHardwareInterface.h defines the interface to the @@ -57,28 +55,21 @@ typedef void (*autofocus_callback)(bool focused, void* user); * CameraService calls getPreviewHeap() to establish access to the * preview heap so it can be registered with SurfaceFlinger for * efficient display updating while in preview mode. - * -# startPreview() is called, which is passed a preview_callback() - * function and a user parameter. The camera instance then periodically - * calls preview_callback() each time a new preview frame is available. - * The callback routine has two parameters: the first is a pointer to - * the IMemory containing the frame and the second a user parameter. If - * the preview_callback code needs to use this memory after returning, - * it must copy the data. + * -# startPreview() is called. The camera instance then periodically + * sends the message CAMERA_MSG_PREVIEW_FRAME (if enabled) each time + * a new preview frame is available. If data callback code needs to use + * this memory after returning, it must copy the data. * - * Prior to taking a picture, CameraService calls autofocus() with - * autofocus_callback() and a user parameter. When auto focusing has - * completed, the camera instance calls autofocus_callback(), which informs - * the application whether focusing was successful. The camera instance - * only calls autofocus_callback() once and it is up to the application to - * call autoFocus() again if refocusing is desired. + * Prior to taking a picture, CameraService calls autofocus(). When auto + * focusing has completed, the camera instance sends a CAMERA_MSG_FOCUS notification, + * which informs the application whether focusing was successful. The camera instance + * only sends this message once and it is up to the application to call autoFocus() + * again if refocusing is desired. * * CameraService calls takePicture() to request the camera instance take a - * picture. This method has two callbacks: raw_callback() and jpeg_callback(). - * When the raw image is available, raw_callback() is called with a pointer - * to the IMemory containing the raw image. When the jpeg image is available, - * jpeg_callback() is called with a pointer to the IMemory containing the - * jpeg image. As with preview_callback(), the memory must be copied if it's - * needed after returning. + * picture. At this point, if a shutter, postview, raw, and/or compressed callback + * is desired, the corresponding message must be enabled. As with CAMERA_MSG_PREVIEW_FRAME, + * any memory provided in a data callback must be copied if it's needed after returning. */ class CameraHardwareInterface : public virtual RefBase { public: @@ -90,17 +81,45 @@ public: /** Return the IMemoryHeap for the raw image heap */ virtual sp<IMemoryHeap> getRawHeap() const = 0; + /** Set the notification and data callbacks */ + virtual void setCallbacks(notify_callback notify_cb, + data_callback data_cb, + data_callback_timestamp data_cb_timestamp, + void* user) = 0; + /** - * Start preview mode. When a preview image is available - * preview_callback is called with the user parameter. The - * call back parameter may be null. + * The following three functions all take a msgtype, + * which is a bitmask of the messages defined in + * include/ui/Camera.h */ - virtual status_t startPreview(preview_callback cb, void* user) = 0; + + /** + * Enable a message, or set of messages. + */ + virtual void enableMsgType(int32_t msgType) = 0; + + /** + * Disable a message, or a set of messages. + */ + virtual void disableMsgType(int32_t msgType) = 0; + + /** + * Query whether a message, or a set of messages, is enabled. + * Note that this is operates as an AND, if any of the messages + * queried are off, this will return false. + */ + virtual bool msgTypeEnabled(int32_t msgType) = 0; + + /** + * Start preview mode. + */ + virtual status_t startPreview() = 0; + /** * Only used if overlays are used for camera preview. */ - virtual bool useOverlay() {return false;} - virtual status_t setOverlay(const sp<Overlay> &overlay) {return BAD_VALUE;} + virtual bool useOverlay() {return false;} + virtual status_t setOverlay(const sp<Overlay> &overlay) {return BAD_VALUE;} /** * Stop a previously started preview. @@ -113,11 +132,11 @@ public: virtual bool previewEnabled() = 0; /** - * Start record mode. When a record image is available recording_callback() - * is called with the user parameter. Every record frame must be released + * Start record mode. When a record image is available a CAMERA_MSG_VIDEO_FRAME + * message is sent with the corresponding frame. Every record frame must be released * by calling releaseRecordingFrame(). */ - virtual status_t startRecording(recording_callback cb, void* user) = 0; + virtual status_t startRecording() = 0; /** * Stop a previously started recording. @@ -130,39 +149,27 @@ public: virtual bool recordingEnabled() = 0; /** - * Release a record frame previously returned by the recording_callback() - * passed to startRecord(). + * Release a record frame previously returned by CAMERA_MSG_VIDEO_FRAME. */ virtual void releaseRecordingFrame(const sp<IMemory>& mem) = 0; /** - * Start auto focus, the callback routine is called - * once when focusing is complete. autoFocus() will - * be called again if another auto focus is needed. + * Start auto focus, the notification callback routine is called + * with CAMERA_MSG_FOCUS once when focusing is complete. autoFocus() + * will be called again if another auto focus is needed. */ - virtual status_t autoFocus(autofocus_callback, - void* user) = 0; + virtual status_t autoFocus() = 0; /** - * Take a picture. The raw_callback is called when - * the uncompressed image is available. The jpeg_callback - * is called when the compressed image is available. These - * call backs may be null. The user parameter is passed - * to each of the call back routines. + * Take a picture. */ - virtual status_t takePicture(shutter_callback, - raw_callback, - jpeg_callback, - void* user) = 0; + virtual status_t takePicture() = 0; /** - * Cancel a picture that was started with takePicture. You may cancel any - * of the shutter, raw, or jpeg callbacks. Calling this method when no - * picture is being taken is a no-op. + * Cancel a picture that was started with takePicture. Calling this + * method when no picture is being taken is a no-op. */ - virtual status_t cancelPicture(bool cancel_shutter, - bool cancel_raw, - bool cancel_jpeg) = 0; + virtual status_t cancelPicture() = 0; /** Set the camera parameters. */ virtual status_t setParameters(const CameraParameters& params) = 0; |