public abstract static class CameraAgent.CameraProxy extends Object
Constructor and Description |
---|
CameraProxy() |
Modifier and Type | Method and Description |
---|---|
void |
addCallbackBuffer(byte[] callbackBuffer)
Adds buffer for the preview callback.
|
abstract boolean |
applySettings(CameraSettings settings)
Applies the settings to the camera device.
|
protected boolean |
applySettingsHelper(CameraSettings settings,
int statesToAwait)
Default implementation of
applySettings(CameraSettings)
that is only missing the set of states it needs to wait for
before applying the settings. |
abstract void |
autoFocus(Handler handler,
CameraAgent.CameraAFCallback cb)
Starts the auto-focus process.
|
void |
cancelAutoFocus()
Cancels the auto-focus process.
|
abstract String |
dumpDeviceSettings()
Dumps the current settings of the camera device.
|
void |
enableShutterSound(boolean enable)
Enables/Disables the camera shutter sound.
|
abstract CameraAgent |
getAgent() |
abstract Camera |
getCamera()
Deprecated.
|
abstract Handler |
getCameraHandler() |
abstract int |
getCameraId() |
abstract CameraStateHolder |
getCameraState() |
abstract CameraCapabilities |
getCapabilities() |
abstract CameraDeviceInfo.Characteristics |
getCharacteristics() |
abstract DispatchThread |
getDispatchThread() |
abstract Camera.Parameters |
getParameters()
Deprecated.
|
abstract CameraSettings |
getSettings()
Gets the current camera settings synchronously.
|
void |
lock()
Locks the camera device.
|
void |
reconnect(Handler handler,
CameraAgent.CameraOpenCallback cb)
Reconnects to the camera device.
|
void |
refreshSettings()
Forces
CameraProxy to update the cached version of the camera
settings regardless of the dirty bit. |
abstract void |
setAutoFocusMoveCallback(Handler handler,
CameraAgent.CameraAFMoveCallback cb)
Sets the auto-focus callback
|
void |
setDisplayOrientation(int degrees)
Sets the display orientation for camera to adjust the preview and JPEG orientation.
|
void |
setDisplayOrientation(int degrees,
boolean capture)
Sets the display orientation for camera to adjust the preview—and, optionally,
JPEG—orientations.
|
abstract void |
setFaceDetectionCallback(Handler handler,
CameraAgent.CameraFaceDetectionCallback callback)
Sets the face detection listener.
|
void |
setJpegOrientation(int degrees) |
abstract void |
setOneShotPreviewCallback(Handler handler,
CameraAgent.CameraPreviewDataCallback cb)
Sets the one-time callback for preview data.
|
abstract void |
setParameters(Camera.Parameters params)
Deprecated.
|
abstract void |
setPreviewDataCallback(Handler handler,
CameraAgent.CameraPreviewDataCallback cb)
Sets the callback for preview data.
|
abstract void |
setPreviewDataCallbackWithBuffer(Handler handler,
CameraAgent.CameraPreviewDataCallback cb)
Sets the callback for preview data.
|
void |
setPreviewDisplay(SurfaceHolder surfaceHolder)
Sets the
SurfaceHolder for preview. |
void |
setPreviewTexture(SurfaceTexture surfaceTexture)
Sets the
SurfaceTexture for preview. |
void |
setPreviewTextureSync(SurfaceTexture surfaceTexture)
Blocks until a
SurfaceTexture has been set
for preview. |
abstract void |
setZoomChangeListener(Camera.OnZoomChangeListener listener)
Sets the listener for zoom change.
|
void |
startFaceDetection()
Starts the face detection.
|
void |
startPreview()
Starts the camera preview.
|
void |
startPreviewWithCallback(Handler h,
CameraAgent.CameraStartPreviewCallback cb)
Starts the camera preview and executes a callback on a handler once
the preview starts.
|
void |
stopFaceDetection()
Stops the face detection.
|
void |
stopPreview()
Stops the camera preview synchronously.
|
abstract void |
takePicture(Handler handler,
CameraAgent.CameraShutterCallback shutter,
CameraAgent.CameraPictureCallback raw,
CameraAgent.CameraPictureCallback postview,
CameraAgent.CameraPictureCallback jpeg)
Instrument the camera to take a picture.
|
void |
unlock()
Unlocks the camera device.
|
@Deprecated public abstract Camera getCamera()
Camera
object used
by this proxy. This method should only be used when handing the
camera device over to MediaRecorder
for
recording.public abstract int getCameraId()
CameraAgent.CameraProxy
.public abstract CameraDeviceInfo.Characteristics getCharacteristics()
public abstract CameraCapabilities getCapabilities()
public abstract CameraAgent getAgent()
public void reconnect(Handler handler, CameraAgent.CameraOpenCallback cb)
.CameraOpenCallback#onCameraOpened(com.android.camera.cameradevice.CameraAgent
.CameraProxy)
.handler
- The Handler
in which the callback
was handled.cb
- The callback when any error happens.Camera.reconnect()
public void unlock()
Camera.unlock()
public void lock()
Camera.lock()
public void setPreviewTexture(SurfaceTexture surfaceTexture)
SurfaceTexture
for preview.
Note that, once this operation has been performed, it is no longer
possible to change the preview or photo sizes in the
CameraSettings
instance for this camera, and the mutators for
these fields are allowed to ignore all further invocations until the
preview is stopped with stopPreview()
.
surfaceTexture
- The SurfaceTexture
for preview.CameraSettings.setPhotoSize(com.android.ex.camera2.portability.Size)
,
CameraSettings.setPreviewSize(com.android.ex.camera2.portability.Size)
public void setPreviewTextureSync(SurfaceTexture surfaceTexture)
SurfaceTexture
has been set
for preview.
Note that, once this operation has been performed, it is no longer
possible to change the preview or photo sizes in the
CameraSettings
instance for this camera, and the mutators for
these fields are allowed to ignore all further invocations.
surfaceTexture
- The SurfaceTexture
for preview.CameraSettings.setPhotoSize(com.android.ex.camera2.portability.Size)
,
CameraSettings.setPreviewSize(com.android.ex.camera2.portability.Size)
public void setPreviewDisplay(SurfaceHolder surfaceHolder)
SurfaceHolder
for preview.surfaceHolder
- The SurfaceHolder
for preview.public void startPreview()
public void startPreviewWithCallback(Handler h, CameraAgent.CameraStartPreviewCallback cb)
public void stopPreview()
stopPreview()
must be synchronous to ensure that the caller can
continues to release resources related to camera preview.public abstract void setPreviewDataCallback(Handler handler, CameraAgent.CameraPreviewDataCallback cb)
handler
- The Handler
in which the callback was handled.cb
- The callback to be invoked when the preview data is available.Camera.setPreviewCallback(android.hardware.Camera.PreviewCallback)
public abstract void setOneShotPreviewCallback(Handler handler, CameraAgent.CameraPreviewDataCallback cb)
handler
- The Handler
in which the callback was handled.cb
- The callback to be invoked when the preview data for
next frame is available.Camera.setPreviewCallback(android.hardware.Camera.PreviewCallback)
public abstract void setPreviewDataCallbackWithBuffer(Handler handler, CameraAgent.CameraPreviewDataCallback cb)
handler
- The handler in which the callback will be invoked.cb
- The callback to be invoked when the preview data is available.Camera.setPreviewCallbackWithBuffer(android.hardware.Camera.PreviewCallback)
public void addCallbackBuffer(byte[] callbackBuffer)
callbackBuffer
- The buffer allocated for the preview data.public abstract void autoFocus(Handler handler, CameraAgent.CameraAFCallback cb)
handler
- The handler in which the callback will be invoked.cb
- The auto-focus callback.public void cancelAutoFocus()
This action has the highest priority and will get processed before anything else that is pending. Moreover, any pending auto-focuses that haven't yet began will also be ignored.
public abstract void setAutoFocusMoveCallback(Handler handler, CameraAgent.CameraAFMoveCallback cb)
handler
- The handler in which the callback will be invoked.cb
- The callback to be invoked when the preview data is available.public abstract void takePicture(Handler handler, CameraAgent.CameraShutterCallback shutter, CameraAgent.CameraPictureCallback raw, CameraAgent.CameraPictureCallback postview, CameraAgent.CameraPictureCallback jpeg)
handler
- The handler in which the callback will be invoked.shutter
- The callback for shutter action, may be null.raw
- The callback for uncompressed data, may be null.postview
- The callback for postview image data, may be null.jpeg
- The callback for jpeg image data, may be null.Camera.takePicture(
android.hardware.Camera.ShutterCallback,
android.hardware.Camera.PictureCallback,
android.hardware.Camera.PictureCallback)
public void setDisplayOrientation(int degrees)
degrees
- The counterclockwise rotation in degrees, relative to the device's natural
orientation. Should be 0, 90, 180 or 270.public void setDisplayOrientation(int degrees, boolean capture)
If capture rotation is not requested, future captures will be returned in the sensor's physical rotation, which does not necessarily match the device's natural orientation.
degrees
- The counterclockwise rotation in degrees, relative to the device's natural
orientation. Should be 0, 90, 180 or 270.capture
- Whether to adjust the JPEG capture orientation as well as the preview one.public void setJpegOrientation(int degrees)
public abstract void setZoomChangeListener(Camera.OnZoomChangeListener listener)
listener
- The listener.public abstract void setFaceDetectionCallback(Handler handler, CameraAgent.CameraFaceDetectionCallback callback)
handler
- The handler in which the callback will be invoked.callback
- The callback for face detection results.public void startFaceDetection()
public void stopFaceDetection()
@Deprecated public abstract void setParameters(Camera.Parameters params)
params
- The camera parameters to use.@Deprecated public abstract Camera.Parameters getParameters()
public abstract CameraSettings getSettings()
This method is synchronous since the caller has to wait for the camera to return the parameters. If the parameters are already cached, it returns immediately.
protected boolean applySettingsHelper(CameraSettings settings, int statesToAwait)
applySettings(CameraSettings)
that is only missing the set of states it needs to wait for
before applying the settings.settings
- The settings to use on the device.statesToAwait
- Bitwise OR of the required camera states.public abstract boolean applySettings(CameraSettings settings)
If the camera is either focusing or capturing; settings applications will be (asynchronously) deferred until those operations complete.
settings
- The settings to use on the device.public void refreshSettings()
CameraProxy
to update the cached version of the camera
settings regardless of the dirty bit.public void enableShutterSound(boolean enable)
enable
- true
to enable the shutter sound,
false
to disable it.public abstract String dumpDeviceSettings()
The content varies based on the underlying camera API settings implementation.
public abstract Handler getCameraHandler()
public abstract DispatchThread getDispatchThread()
public abstract CameraStateHolder getCameraState()