Package: android.hardware.camera.device@1.0

ICameraDevice

interface ICameraDevice

Camera device HAL, legacy version

DEPRECATED.New devices are strongly recommended to use Camera HAL v3.2 or newer.

Supports the android.hardware.Camera API, and the android.hardware.camera2 API in LEGACY mode only.

Will be removed in the Android P release.

Methods

getResourceCost

getResourceCost ()
generates (Status status, CameraResourceCost resourceCost)

Get camera device resource cost information.

This method may be called at any time, including before open()

Details
Generates
status
Status code for the operation, one of:OK:On success.INTERNAL_ERROR:An unexpected internal camera HAL error occurred, and the resource cost is not available.CAMERA_DISCONNECTED:An external camera device has been disconnected, and is no longer available.This camera device interface is now stale, and a new instance must be acquired if the device is reconnected.All subsequent calls on this interface must return CAMERA_DISCONNECTED.
resourceCost
The resources required to open this camera device, or unspecified values if status is not OK.

getCameraInfo

getCameraInfo ()
generates (Status status, CameraInfo info)

Get basic camera information.

This method may be called at any time, including before open()

Details
Generates
status
Status code for the operation, one of:OK:On success.INTERNAL_ERROR:An unexpected internal camera HAL error occurred, and the camera information is not available.CAMERA_DISCONNECTED:An external camera device has been disconnected, and is no longer available.This camera device interface is now stale, and a new instance must be acquired if the device is reconnected.All subsequent calls on this interface must return CAMERA_DISCONNECTED.
info
Basic information about this camera device, or unspecified values if status is not OK.

setTorchMode

setTorchMode (TorchMode mode)
generates (Status status)

setTorchMode:

Turn on or off the torch mode of the flash unit associated with a given camera ID.If the operation is successful, HAL must notify the framework torch state by invoking ICameraProviderCallback::torchModeStatusChange() with the new state.

The camera device has a higher priority accessing the flash unit.When there are any resource conflicts, such as when open() is called to fully activate a camera device, the provider must notify the framework through ICameraProviderCallback::torchModeStatusChange() that the torch mode has been turned off and the torch mode state has become TORCH_MODE_STATUS_NOT_AVAILABLE.When resources to turn on torch mode become available again, the provider must notify the framework through ICameraProviderCallback::torchModeStatusChange() that the torch mode state has become TORCH_MODE_STATUS_AVAILABLE_OFF for set_torch_mode() to be called.

When the framework calls setTorchMode() to turn on the torch mode of a flash unit, if HAL cannot keep multiple torch modes on simultaneously, HAL must turn off the torch mode that was turned on by a previous setTorchMode() call and notify the framework that the torch mode state of that flash unit has become TORCH_MODE_STATUS_AVAILABLE_OFF.

Details
Parameters
mode
Generates
status
Status code for the operation, one of:OK:On a successful change to the torch state.INTERNAL_ERROR:The flash unit cannot be operated due to an unexpected internal error.ILLEGAL_ARGUMENT:The camera ID is unknown.CAMERA_IN_USE:This camera device has been opened, so the torch cannot be controlled until it is closed.MAX_CAMERAS_IN_USE:Due to other camera devices being open, or due to other resource constraints, the torch cannot be controlled currently.METHOD_NOT_SUPPORTED:This provider does not support direct operation of flashlight torch mode.The framework must open the camera device and turn the torch on through the device interface.OPERATION_NOT_SUPPORTED:This camera device does not have a flash unit.This must be returned if and only if parameter key flash-mode-values is not present.CAMERA_DISCONNECTED:An external camera device has been disconnected, and is no longer available.This camera device interface is now stale, and a new instance must be acquired if the device is reconnected.All subsequent calls on this interface must return CAMERA_DISCONNECTED.

dumpState

dumpState (handle fd)
generates (Status status)

Dump state of the camera hardware.

This must be callable at any time, whether the device is open or not.

Details
Parameters
fd
A native handle with one valid file descriptor.The descriptor must be able to be used with dprintf() or equivalent to dump the state of this camera device into the camera service dumpsys output.
Generates
status
The status code for this operation.

open

open (ICameraDeviceCallback callback)
generates (Status status)

Open the camera device for active use.

All methods besides getResourceCost(), getCameraInfo(), setTorchMode(), and dump() must not be called unless open() has been called successfully, and close() has not yet been called.

Details
Parameters
callback
Interface to invoke by the HAL for device callbacks.
Generates
status
Status code for the operation, one of:OK:On a successful open of the camera device.INTERNAL_ERROR:The camera device cannot be opened due to an internal error.ILLEGAL_ARGUMENT:The callback handle is invalid(for example, it is null). CAMERA_IN_USE:This camera device is already open.MAX_CAMERAS_IN_USE:The maximal number of camera devices that can be opened concurrently were opened already.CAMERA_DISCONNECTED:This external camera device has been disconnected, and is no longer available.This interface is now stale, and a new instance must be acquired if the device is reconnected.All subsequent calls on this interface must return CAMERA_DISCONNECTED.

setPreviewWindow

setPreviewWindow (ICameraDevicePreviewCallback window)
generates (Status status)

Set the callback interface through which preview frames are sent

Details
Parameters
window
Generates
status

enableMsgType

enableMsgType (FrameCallbackFlags msgType)

Enable a message, or set of messages.

Details
Parameters
msgType
The bitfield of messages to enable.

disableMsgType

disableMsgType (FrameCallbackFlags msgType)

Disable a message, or a set of messages.

Once received a call to disableMsgType(CAMERA_MSG_VIDEO_FRAME), camera HAL must not rely on its client to call releaseRecordingFrame() to release video recording frames sent out by the cameral HAL before and after the disableMsgType(CAMERA_MSG_VIDEO_FRAME)call.Camera HAL clients must not modify/access any video recording frame after calling disableMsgType(CAMERA_MSG_VIDEO_FRAME).

Details
Parameters
msgType
The bitfield of messages to disable.

msgTypeEnabled

msgTypeEnabled (FrameCallbackFlags msgType)
generates (bool enabled)

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 must return false.

Details
Parameters
msgType
The bitfield of messages to query.
Generates
enabled
Whether all the specified flags are enabled.

startPreview

startPreview ()
generates (Status status)

Start preview mode.

Details
Generates
status
The status code for this operation.

stopPreview

stopPreview ()

Stop a previously started preview.

Details

previewEnabled

previewEnabled ()
generates (bool enabled)

Returns true if preview is enabled.

Details
Generates
enabled
Whether preview is currently enabled.

storeMetaDataInBuffers

storeMetaDataInBuffers (bool enable)
generates (Status status)

Request the camera HAL to store meta data or real YUV data in the video buffers sent out via CAMERA_MSG_VIDEO_FRAME for a recording session.If it is not called, the default camera HAL behavior is to store real YUV data in the video buffers.

This method must be called before startRecording() in order to be effective.

If meta data is stored in the video buffers, it is up to the receiver of the video buffers to interpret the contents and to find the actual frame data with the help of the meta data in the buffer.How this is done is outside of the scope of this method.

Some camera HALs may not support storing meta data in the video buffers, but all camera HALs must support storing real YUV data in the video buffers.If the camera HAL does not support storing the meta data in the video buffers when it is requested to do do, INVALID_OPERATION must be returned.It is very useful for the camera HAL to pass meta data rather than the actual frame data directly to the video encoder, since the amount of the uncompressed frame data can be very large if video size is large.

Details
Parameters
enable
Set to true to instruct the camera HAL to store meta data in the video buffers;false to instruct the camera HAL to store real YUV data in the video buffers.
Generates
status
OK on success.

startRecording

startRecording ()
generates (Status status)

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 a camera HAL client via releaseRecordingFrame() before the client calls disableMsgType(CAMERA_MSG_VIDEO_FRAME). After the client calls disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's responsibility to manage the life-cycle of the video recording frames, and the client must not modify/access any video recording frames.

Details
Generates
status
The status code for the operation.

stopRecording

stopRecording ()

Stop a previously started recording.

Details

recordingEnabled

recordingEnabled ()
generates (bool enabled)

Returns true if recording is enabled.

Details
Generates
enabled
True if recording is currently active.

releaseRecordingFrame

releaseRecordingFrame (MemoryId memId, uint32_t bufferIndex)

Release a record frame previously returned by CAMERA_MSG_VIDEO_FRAME in dataCallbackTimestamp.

It is camera HAL client's responsibility to release video recording frames sent out by the camera HAL before the camera HAL receives a call to disableMsgType(CAMERA_MSG_VIDEO_FRAME). After it receives the call to disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's responsibility to manage the life-cycle of the video recording frames.

Details
Parameters
memId
The memory buffer to release a recording frame from.
bufferIndex
The specific buffer index to return to the HAL.

releaseRecordingFrameHandle

releaseRecordingFrameHandle (MemoryId memId, uint32_t bufferIndex, handle frame)

Release a record frame previously returned by CAMERA_MSG_VIDEO_FRAME in handleCallbackTimestamp.

It is camera HAL client's responsibility to release video recording frames sent out by the camera HAL before the camera HAL receives a call to disableMsgType(CAMERA_MSG_VIDEO_FRAME). After it receives the call to disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's responsibility to manage the life-cycle of the video recording frames.

Details
Parameters
memId
The memory buffer to release a recording frame from.
bufferIndex
The specific buffer index to return to the HAL.
frame
The handle for a released video frame

releaseRecordingFrameHandleBatch

releaseRecordingFrameHandleBatch (vec<VideoFrameMessage> batch)

Release a batch of record frames previously returned by CAMERA_MSG_VIDEO_FRAME in handleCallbackTimestampBatch.

It is camera HAL client's responsibility to release video recording frames sent out by the camera HAL before the camera HAL receives a call to disableMsgType(CAMERA_MSG_VIDEO_FRAME). After it receives the call to disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's responsibility to manage the life-cycle of the video recording frames.

Details
Parameters
batch
A batch of recording frames to be released by camera HAL.

autoFocus

autoFocus ()
generates (Status status)

Start auto focus.

The notification callback routine is called with CAMERA_MSG_FOCUS once when focusing is complete.autoFocus() can be called again after that if another auto focus is needed.

Details
Generates
status
The status code for this operation.

cancelAutoFocus

cancelAutoFocus ()
generates (Status status)

Cancels auto-focus function.

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

Details
Generates
status
The status code for this operation.

takePicture

takePicture ()
generates (Status status)

Take a picture.

Details
Generates
status
The status code for this operation.

cancelPicture

cancelPicture ()
generates (Status status)

Cancel a picture that was started with takePicture.Calling this method when no picture is being taken is a no-op.

Details
Generates
status
The status code for this operation.

setParameters

setParameters (string params)
generates (Status status)

Set the camera parameters.

Details
Parameters
params
The parameter string, consisting of '<key1 >=<value1>;...;<keyN >=<valueN>'.
Generates
status
The status code for this operation:OK:Parameter update was successful ILLEGAL_ARGUMENT:At least one parameter was invalid or not supported

getParameters

getParameters ()
generates (string parms)

Retrieve the camera parameters.

Details
Generates
parms

sendCommand

sendCommand (CommandType cmd, int32_t arg1, int32_t arg2)
generates (Status status)

Send command to camera driver.The meaning of the arguments is defined by the value of cmd, documented in the CommandType definition.

Details
Parameters
cmd
The command to invoke.
arg1
The first argument for the command, if needed.
arg2
The second argument for the command, if needed.
Generates
status
The status code for this operation.

close

close ()

Release the hardware resources owned by this object, shutting down the camera device.

Details