Skip to content
com.iristick.smartglass.core.camera

Interface CameraDevice.Listener

Enclosing class:
CameraDevice

public static interface CameraDevice.Listener

Listener interface for receiving updates about the state of a camera device.

An instance must be provided to the Headset.openCamera method to open a camera session.

The state updates include notifications about the camera completing startup, about device disconnection or closure, and about unexpected errors.

Events about the progress of specific CaptureRequests are provided through CaptureListeners given to the capture or captureBurst methods.

See Also:
Headset.openCamera(String, CameraDevice.Listener, Handler)

Field Summary

Modifier and Type Field and Description
static int ERROR_CAMERA_DEVICE
An error code indicating that the camera has encountered a fatal error.
static int ERROR_CAMERA_DISABLED
An error code indicating that the session could not be opened due to a policy.
static int ERROR_CAMERA_IN_USE
An error code that can be reported by onError(CameraDevice, int) indicating that the camera device is in use already.
static int ERROR_CAMERA_SERVICE
An error code indicating that the camera service has encountered a fatal error.
static int ERROR_MAX_CAMERAS_IN_USE
An error code indicating that the session could not be opened because there are too many other open devices.

Method Summary

Modifier and Type Method and Description
void onClosed(CameraDevice device)
Called when a camera device has been completely closed.
void onDisconnected(CameraDevice device)
Called when the camera is no longer available for use.
void onError(CameraDevice device, int error)
Called when the camera has encountered a serious error.
void onOpened(CameraDevice device)
Called when a camera has finished opening.

Field Detail

ERROR_CAMERA_IN_USE

static final int ERROR_CAMERA_IN_USE

An error code that can be reported by onError(CameraDevice, int) indicating that the camera device is in use already.

This error can be produced when opening the session fails due to the camera being used by a higher-priority camera API client.

See Also:
onError(com.iristick.smartglass.core.camera.CameraDevice, int)

ERROR_MAX_CAMERAS_IN_USE

static final int ERROR_MAX_CAMERAS_IN_USE

An error code indicating that the session could not be opened because there are too many other open devices.

The system-wide limit for number of open camera sessions has been reached, and more sessions cannot be opened until previous instances are closed.

See Also:
onError(com.iristick.smartglass.core.camera.CameraDevice, int)

ERROR_CAMERA_DISABLED

static final int ERROR_CAMERA_DISABLED
An error code indicating that the session could not be opened due to a policy.
See Also:
onError(com.iristick.smartglass.core.camera.CameraDevice, int)

ERROR_CAMERA_DEVICE

static final int ERROR_CAMERA_DEVICE

An error code indicating that the camera has encountered a fatal error.

The camera needs to be re-opened to be used again.

See Also:
onError(com.iristick.smartglass.core.camera.CameraDevice, int)

ERROR_CAMERA_SERVICE

static final int ERROR_CAMERA_SERVICE

An error code indicating that the camera service has encountered a fatal error.

The headset may need to be unplugged and replugged, and the Iristick service forcefully stopped and restarted, to restore camera function, or there may be a persistent hardware problem.

An attempt at recovery may be possible by closing the unbinding from the service, and trying to acquire all resources again from scratch.

See Also:
onError(com.iristick.smartglass.core.camera.CameraDevice, int)

Method Detail

onOpened

void onOpened(@NonNull
              CameraDevice device)

Called when a camera has finished opening.

At this point, the camera is ready to use, and createCaptureSession can be called to set up the first capture session.

Parameters:
device - The camera device that has become opened.

onClosed

void onClosed(@NonNull
              CameraDevice device)

Called when a camera device has been completely closed.

This can happen either because the session has been closed explicitly with CameraDevice.close(), or because the headset was disconnected or encountered a fatal error. In the latter case, onDisconnected or onError will be called first.

No further callbacks (of this interface and of CaptureListener) will be invoked after this method is done.

Parameters:
device - The camera device that has become closed.

onDisconnected

void onDisconnected(@NonNull
                    CameraDevice device)

Called when the camera is no longer available for use.

This callback may be called instead of onOpened if the headset has been disconnected. It may also be called after the session has been opened, when the headset is disconnected or a higher-priority session API client requests the camera.

There may still be capture callbacks that are invoked after this method is called, or new image buffers that are delivered to active outputs. The onClosed callback will be called last.

Parameters:
device - The camera device that has been disconnected.

onError

void onError(@NonNull
             CameraDevice device,
             int error)

Called when the camera has encountered a serious error.

This callback may be called instead of onOpened if opening the session fails. It may also be called after the session has been opened if a serious error is encountered.

There may still be capture callbacks that will be called after this error is received. The onClosed callback will be called last.

Parameters:
device - The camera device reporting the error
error - The error code, one of the ERROR_* values.
See Also:
ERROR_CAMERA_IN_USE, ERROR_MAX_CAMERAS_IN_USE, ERROR_CAMERA_DISABLED, ERROR_CAMERA_DEVICE, ERROR_CAMERA_SERVICE