public static interface Camera.StateCallback
android.hardware.camera2.CameraDevice.StateCallback
Modifier and Type | Method and Description |
---|---|
void |
onClosed(Camera camera)
The method called when a camera device has been closed with
Camera.close() . |
void |
onError(Camera camera,
Camera.Error error)
The method called when a camera device has encountered a serious error.
|
void |
onOpened(Camera camera)
The method called when a camera device has finished successfully opening.
|
void |
onOpenFailed(CameraName cameraName,
Camera.OpenFailure reason)
A request to open a camera has failed.
|
void onOpened(Camera camera)
At this point, the camera device is ready to use, and Camera.createCaptureSession(org.firstinspires.ftc.robotcore.external.function.Continuation<? extends org.firstinspires.ftc.robotcore.external.hardware.camera.CameraCaptureSession.StateCallback>)
can be called to set up a capture session.
Important: once this method is invoked, callee is responsible for calling
Camera.close()
when they are finished using the camera device.
camera
- the camera device that has become openedCameraManager.asyncOpenCameraAssumingPermission(org.firstinspires.ftc.robotcore.external.hardware.camera.CameraName, org.firstinspires.ftc.robotcore.external.function.Continuation<? extends org.firstinspires.ftc.robotcore.external.hardware.camera.Camera.StateCallback>, long, java.util.concurrent.TimeUnit)
void onOpenFailed(CameraName cameraName, Camera.OpenFailure reason)
cameraName
- The identity of the camera that failed to open.CameraManager.asyncOpenCameraAssumingPermission(org.firstinspires.ftc.robotcore.external.hardware.camera.CameraName, org.firstinspires.ftc.robotcore.external.function.Continuation<? extends org.firstinspires.ftc.robotcore.external.hardware.camera.Camera.StateCallback>, long, java.util.concurrent.TimeUnit)
void onClosed(Camera camera)
Camera.close()
.
Any attempt to call methods on this Camera in the
future will likely throw a RuntimeException
.
camera
- the camera device that has become closedvoid onError(Camera camera, Camera.Error error)
This indicates a failure of the camera device or camera service in
some way. Any attempt to call methods on this Camera in the
future will likely throw a CameraException
There may still be capture completion or camera stream callbacks that will be called after this error is received.
You should clean up the camera with Camera.close()
after
this happens. Further attempts at recovery are error-code specific.
camera
- The device reporting the errorerror
- The error code