-
- All Implemented Interfaces:
-
android.media.ImageReader.OnImageAvailableListener,com.otaliastudios.cameraview.engine.action.ActionHolder,com.otaliastudios.cameraview.picture.PictureRecorder.PictureResultListener,com.otaliastudios.cameraview.preview.CameraPreview.SurfaceCallback,com.otaliastudios.cameraview.video.VideoRecorder.VideoResultListener
@RequiresApi(value = Build.VERSION_CODES.LOLLIPOP) public class Camera2Engine extends CameraBaseEngine implements ImageReader.OnImageAvailableListener, ActionHolder
-
-
Constructor Summary
Constructors Constructor Description Camera2Engine(CameraEngine.Callback callback)
-
Method Summary
Modifier and Type Method Description voidonPictureResult(@Nullable() PictureResult.Stub result, @Nullable() Exception error)Picture was taken or there was some error, ifthe result is null. voidonVideoRecordingEnd()When video ends we must stop the recorder and remove the recorder surface fromcamera outputs. voidonVideoResult(@Nullable() VideoResult.Stub result, @Nullable() Exception exception)The operation was completed, either with success or with an error. voidsetFlash(@NonNull() Flash flash)voidsetLocation(@Nullable() Location location)voidsetWhiteBalance(@NonNull() WhiteBalance whiteBalance)voidsetHdr(@NonNull() Hdr hdr)voidsetZoom(float zoom, @Nullable() Array<PointF> points, boolean notify)voidsetExposureCorrection(float EVvalue, @NonNull() Array<float> bounds, @Nullable() Array<PointF> points, boolean notify)voidsetPlaySounds(boolean playSounds)voidsetPreviewFrameRate(float previewFrameRate)voidsetPictureFormat(@NonNull() PictureFormat pictureFormat)voidonImageAvailable(ImageReader reader)voidsetHasFrameProcessors(boolean hasFrameProcessors)voidsetFrameProcessingFormat(int format)voidstartAutoFocus(@Nullable() Gesture gesture, @NonNull() MeteringRegions regions, @NonNull() PointF legacyPoint)voidaddAction(@NonNull() Action action)Adds a new action voidremoveAction(@NonNull() Action action)Removes a previously added action CameraCharacteristicsgetCharacteristics(@NonNull() Action action)Returns the CameraCharacteristics of the currentcamera device. TotalCaptureResultgetLastResult(@NonNull() Action action)Returns the latest TotalCaptureResult. CaptureRequest.BuildergetBuilder(@NonNull() Action action)Returns the current CaptureRequest.Builder so thatactions can apply changes to it and later submit them. voidapplyBuilder(@NonNull() Action source)Applies the current builder (as per getBuilder)as a repeating request on the preview. voidapplyBuilder(@NonNull() Action source, @NonNull() CaptureRequest.Builder builder)Applies the given builder as a single capture request.Callers can catch the exception and choose what to do. -
Methods inherited from class com.otaliastudios.cameraview.engine.CameraBaseEngine
getAngles, getAudio, getAudioBitRate, getAudioCodec, getAutoFocusResetDelay, getCameraOptions, getExposureCorrectionValue, getFacing, getFlash, getFrameManager, getFrameProcessingFormat, getFrameProcessingMaxHeight, getFrameProcessingMaxWidth, getFrameProcessingPoolSize, getHdr, getLocation, getMode, getOverlay, getPictureFormat, getPictureMetering, getPictureSize, getPictureSizeSelector, getPictureSnapshotMetering, getPreview, getPreviewFrameRate, getPreviewFrameRateExact, getPreviewStreamSize, getPreviewStreamSizeSelector, getSnapshotMaxHeight, getSnapshotMaxWidth, getUncroppedSnapshotSize, getVideoBitRate, getVideoCodec, getVideoMaxDuration, getVideoMaxSize, getVideoSize, getVideoSizeSelector, getWhiteBalance, getZoomValue, hasFrameProcessors, isTakingPicture, isTakingVideo, onPictureShutter, onSurfaceChanged, onVideoRecordingStart, setAudio, setAudioBitRate, setAudioCodec, setAutoFocusResetDelay, setFacing, setFrameProcessingMaxHeight, setFrameProcessingMaxWidth, setFrameProcessingPoolSize, setMode, setOverlay, setPictureMetering, setPictureSizeSelector, setPictureSnapshotMetering, setPreview, setPreviewFrameRateExact, setPreviewStreamSizeSelector, setSnapshotMaxHeight, setSnapshotMaxWidth, setVideoBitRate, setVideoCodec, setVideoMaxDuration, setVideoMaxSize, setVideoSizeSelector, stopVideo, takePicture, takePictureSnapshot, takeVideo, takeVideoSnapshot -
Methods inherited from class com.otaliastudios.cameraview.engine.CameraEngine
destroy, getPictureSize, getState, getTargetState, getVideoSize, isChangingState, onSurfaceAvailable, onSurfaceDestroyed, restart, setExposureCorrection, setFlash, setFrameProcessingFormat, setHasFrameProcessors, setPictureFormat, setZoom, start, startAutoFocus, stop, takePicture, takeVideo, takeVideoSnapshot -
Methods inherited from class android.media.ImageReader.OnImageAvailableListener
onImageAvailable -
Methods inherited from class com.otaliastudios.cameraview.engine.action.ActionHolder
addAction, removeAction -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
Camera2Engine
Camera2Engine(CameraEngine.Callback callback)
-
-
Method Detail
-
onPictureResult
void onPictureResult(@Nullable() PictureResult.Stub result, @Nullable() Exception error)
Picture was taken or there was some error, ifthe result is null.
- Parameters:
result- the result or null if there was some errorerror- the error or null if there wasn't any
-
onVideoRecordingEnd
void onVideoRecordingEnd()
When video ends we must stop the recorder and remove the recorder surface fromcamera outputs. This is done in onVideoResult. However, on some devices, order matters.If we stop the recorder and AFTER send camera frames to it, the camera will try to fillthe recorder "abandoned" Surface and on some devices with a poor internal implementation(HW_LEVEL_LEGACY) this crashes. So if the conditions are met, we restore here. Issue #549.
-
onVideoResult
void onVideoResult(@Nullable() VideoResult.Stub result, @Nullable() Exception exception)
The operation was completed, either with success or with an error.
- Parameters:
result- the result or null if errorexception- the error or null if everything went fine
-
setLocation
void setLocation(@Nullable() Location location)
-
setWhiteBalance
void setWhiteBalance(@NonNull() WhiteBalance whiteBalance)
-
setExposureCorrection
void setExposureCorrection(float EVvalue, @NonNull() Array<float> bounds, @Nullable() Array<PointF> points, boolean notify)
-
setPlaySounds
void setPlaySounds(boolean playSounds)
-
setPreviewFrameRate
void setPreviewFrameRate(float previewFrameRate)
-
setPictureFormat
void setPictureFormat(@NonNull() PictureFormat pictureFormat)
-
onImageAvailable
void onImageAvailable(ImageReader reader)
-
setHasFrameProcessors
void setHasFrameProcessors(boolean hasFrameProcessors)
-
setFrameProcessingFormat
void setFrameProcessingFormat(int format)
-
startAutoFocus
void startAutoFocus(@Nullable() Gesture gesture, @NonNull() MeteringRegions regions, @NonNull() PointF legacyPoint)
-
removeAction
void removeAction(@NonNull() Action action)
Removes a previously added action
- Parameters:
action- action
-
getCharacteristics
@NonNull() CameraCharacteristics getCharacteristics(@NonNull() Action action)
Returns the CameraCharacteristics of the currentcamera device.
- Parameters:
action- action
-
getLastResult
@Nullable() TotalCaptureResult getLastResult(@NonNull() Action action)
Returns the latest TotalCaptureResult. Can be usedby actions to start querying the state before receiving theirfirst frame.
- Parameters:
action- action
-
getBuilder
@NonNull() CaptureRequest.Builder getBuilder(@NonNull() Action action)
Returns the current CaptureRequest.Builder so thatactions can apply changes to it and later submit them.
- Parameters:
action- action
-
applyBuilder
void applyBuilder(@NonNull() Action source)
Applies the current builder (as per getBuilder)as a repeating request on the preview.
- Parameters:
source- action
-
applyBuilder
void applyBuilder(@NonNull() Action source, @NonNull() CaptureRequest.Builder builder)
Applies the given builder as a single capture request.Callers can catch the exception and choose what to do.
- Parameters:
source- actionbuilder- builder
-
-
-
-