Public Member Functions
android::CameraHardwareInterface Class Referenceabstract

CameraHardwareInterface.h defines the interface to the camera hardware abstraction layer, used for setting and getting parameters, live previewing, and taking pictures. More...

Inherits RefBase.

Public Member Functions

virtual status_t autoFocus ()=0
 Start auto focus, the notification callback routine is called with CAMERA_MSG_FOCUS once when focusing is complete. More...
 
virtual status_t cancelAutoFocus ()=0
 Cancels auto-focus function. More...
 
virtual status_t cancelPicture ()=0
 Cancel a picture that was started with takePicture. More...
 
virtual void disableMsgType (int32_t msgType)=0
 Disable a message, or a set of messages. More...
 
virtual status_t dump (int fd, const Vector< String16 > &args) const =0
 Dump state of the camera hardware. More...
 
virtual void enableMsgType (int32_t msgType)=0
 The following three functions all take a msgtype, which is a bitmask of the messages defined in include/ui/Camera.h. More...
 
virtual CameraParameters getParameters () const =0
 Return the camera parameters. More...
 
virtual sp< IMemoryHeap > getPreviewHeap () const =0
 Return the IMemoryHeap for the preview image heap. More...
 
virtual sp< IMemoryHeap > getRawHeap () const =0
 Return the IMemoryHeap for the raw image heap. More...
 
virtual bool msgTypeEnabled (int32_t msgType)=0
 Query whether a message, or a set of messages, is enabled. More...
 
virtual bool previewEnabled ()=0
 Returns true if preview is enabled. More...
 
virtual bool recordingEnabled ()=0
 Returns true if recording is enabled. More...
 
virtual void release ()=0
 Release the hardware resources owned by this object. More...
 
virtual void releaseRecordingFrame (const sp< IMemory > &mem)=0
 Release a record frame previously returned by CAMERA_MSG_VIDEO_FRAME. More...
 
virtual status_t sendCommand (int32_t cmd, int32_t arg1, int32_t arg2)=0
 Send command to camera driver. More...
 
virtual void setCallbacks (notify_callback notify_cb, data_callback data_cb, data_callback_timestamp data_cb_timestamp, void *user)=0
 Set the notification and data callbacks. More...
 
virtual status_t setOverlay (const sp< Overlay > &overlay)
 
virtual status_t setParameters (const CameraParameters &params)=0
 Set the camera parameters. More...
 
virtual status_t startPreview ()=0
 Start preview mode. More...
 
virtual status_t startRecording ()=0
 Start record mode. More...
 
virtual void stopPreview ()=0
 Stop a previously started preview. More...
 
virtual void stopRecording ()=0
 Stop a previously started recording. More...
 
virtual status_t takePicture ()=0
 Take a picture. More...
 
virtual bool useOverlay ()
 Only used if overlays are used for camera preview. More...
 
virtual ~CameraHardwareInterface ()
 

Detailed Description

CameraHardwareInterface.h defines the interface to the camera hardware abstraction layer, used for setting and getting parameters, live previewing, and taking pictures.

It is a referenced counted interface with RefBase as its base class. CameraService calls openCameraHardware() to retrieve a strong pointer to the instance of this interface and may be called multiple times. The following steps describe a typical sequence:

  1. After CameraService calls openCameraHardware(), getParameters() and setParameters() are used to initialize the camera instance. 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.
  2. 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(). 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. 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.

Definition at line 75 of file CameraHardwareInterface.h.

Constructor & Destructor Documentation

virtual android::CameraHardwareInterface::~CameraHardwareInterface ( )
inlinevirtual

Definition at line 77 of file CameraHardwareInterface.h.

Member Function Documentation

virtual status_t android::CameraHardwareInterface::autoFocus ( )
pure virtual

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 android::CameraHardwareInterface::cancelAutoFocus ( )
pure virtual

Cancels auto-focus function.

If the auto-focus is still in progress, this function will cancel it. Whether the auto-focus is in progress or not, this function will return the focus position to the default. If the camera does not support auto-focus, this is a no-op.

virtual status_t android::CameraHardwareInterface::cancelPicture ( )
pure virtual

Cancel a picture that was started with takePicture.

Calling this method when no picture is being taken is a no-op.

virtual void android::CameraHardwareInterface::disableMsgType ( int32_t  msgType)
pure virtual

Disable a message, or a set of messages.

virtual status_t android::CameraHardwareInterface::dump ( int  fd,
const Vector< String16 > &  args 
) const
pure virtual

Dump state of the camera hardware.

virtual void android::CameraHardwareInterface::enableMsgType ( int32_t  msgType)
pure virtual

The following three functions all take a msgtype, which is a bitmask of the messages defined in include/ui/Camera.h.

Enable a message, or set of messages.

virtual CameraParameters android::CameraHardwareInterface::getParameters ( ) const
pure virtual

Return the camera parameters.

virtual sp<IMemoryHeap> android::CameraHardwareInterface::getPreviewHeap ( ) const
pure virtual

Return the IMemoryHeap for the preview image heap.

virtual sp<IMemoryHeap> android::CameraHardwareInterface::getRawHeap ( ) const
pure virtual

Return the IMemoryHeap for the raw image heap.

virtual bool android::CameraHardwareInterface::msgTypeEnabled ( int32_t  msgType)
pure virtual

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 android::CameraHardwareInterface::previewEnabled ( )
pure virtual

Returns true if preview is enabled.

virtual bool android::CameraHardwareInterface::recordingEnabled ( )
pure virtual

Returns true if recording is enabled.

virtual void android::CameraHardwareInterface::release ( )
pure virtual

Release the hardware resources owned by this object.

Note that this is not done in the destructor.

virtual void android::CameraHardwareInterface::releaseRecordingFrame ( const sp< IMemory > &  mem)
pure virtual

Release a record frame previously returned by CAMERA_MSG_VIDEO_FRAME.

virtual status_t android::CameraHardwareInterface::sendCommand ( int32_t  cmd,
int32_t  arg1,
int32_t  arg2 
)
pure virtual

Send command to camera driver.

virtual void android::CameraHardwareInterface::setCallbacks ( notify_callback  notify_cb,
data_callback  data_cb,
data_callback_timestamp  data_cb_timestamp,
void *  user 
)
pure virtual

Set the notification and data callbacks.

virtual status_t android::CameraHardwareInterface::setOverlay ( const sp< Overlay > &  overlay)
inlinevirtual

Definition at line 114 of file CameraHardwareInterface.h.

virtual status_t android::CameraHardwareInterface::setParameters ( const CameraParameters &  params)
pure virtual

Set the camera parameters.

This returns BAD_VALUE if any parameter is invalid or not supported.

virtual status_t android::CameraHardwareInterface::startPreview ( )
pure virtual

Start preview mode.

virtual status_t android::CameraHardwareInterface::startRecording ( )
pure virtual

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 void android::CameraHardwareInterface::stopPreview ( )
pure virtual

Stop a previously started preview.

virtual void android::CameraHardwareInterface::stopRecording ( )
pure virtual

Stop a previously started recording.

virtual status_t android::CameraHardwareInterface::takePicture ( )
pure virtual

Take a picture.

virtual bool android::CameraHardwareInterface::useOverlay ( )
inlinevirtual

Only used if overlays are used for camera preview.

Definition at line 113 of file CameraHardwareInterface.h.