-
- All Implemented Interfaces:
-
com.otaliastudios.cameraview.picture.PictureRecorder.PictureResultListener,com.otaliastudios.cameraview.preview.CameraPreview.SurfaceCallback,com.otaliastudios.cameraview.video.VideoRecorder.VideoResultListener
public abstract class CameraBaseEngine extends CameraEngine
Abstract implementation of CameraEngine that helps in common tasks.
-
-
Method Summary
Modifier and Type Method Description final AnglesgetAngles()FrameManagergetFrameManager()final CameraOptionsgetCameraOptions()final voidsetPreview(@NonNull() CameraPreview cameraPreview)final CameraPreviewgetPreview()final voidsetOverlay(@Nullable() Overlay overlay)final OverlaygetOverlay()final voidsetPreviewStreamSizeSelector(@Nullable() SizeSelector selector)final SizeSelectorgetPreviewStreamSizeSelector()final voidsetPictureSizeSelector(@NonNull() SizeSelector selector)final SizeSelectorgetPictureSizeSelector()final voidsetVideoSizeSelector(@NonNull() SizeSelector selector)final SizeSelectorgetVideoSizeSelector()final voidsetVideoMaxSize(long videoMaxSizeBytes)final longgetVideoMaxSize()final voidsetVideoMaxDuration(int videoMaxDurationMillis)final intgetVideoMaxDuration()final voidsetVideoCodec(@NonNull() VideoCodec codec)final VideoCodecgetVideoCodec()final voidsetVideoBitRate(int videoBitRate)final intgetVideoBitRate()final voidsetAudioCodec(@NonNull() AudioCodec codec)final AudioCodecgetAudioCodec()final voidsetAudioBitRate(int audioBitRate)final intgetAudioBitRate()final voidsetSnapshotMaxWidth(int maxWidth)final intgetSnapshotMaxWidth()final voidsetSnapshotMaxHeight(int maxHeight)final intgetSnapshotMaxHeight()final voidsetFrameProcessingMaxWidth(int maxWidth)final intgetFrameProcessingMaxWidth()final voidsetFrameProcessingMaxHeight(int maxHeight)final intgetFrameProcessingMaxHeight()final intgetFrameProcessingFormat()final voidsetFrameProcessingPoolSize(int poolSize)final intgetFrameProcessingPoolSize()final voidsetAutoFocusResetDelay(long delayMillis)final longgetAutoFocusResetDelay()final voidsetFacing(@NonNull() Facing facing)Sets a new facing value. final FacinggetFacing()final voidsetAudio(@NonNull() Audio audio)Sets a new audio value that will be used for video recordings. final AudiogetAudio()final voidsetMode(@NonNull() Mode mode)Sets the desired mode (either picture or video). final ModegetMode()final floatgetZoomValue()final floatgetExposureCorrectionValue()final FlashgetFlash()final WhiteBalancegetWhiteBalance()final HdrgetHdr()final LocationgetLocation()final PictureFormatgetPictureFormat()final voidsetPreviewFrameRateExact(boolean previewFrameRateExact)final booleangetPreviewFrameRateExact()final floatgetPreviewFrameRate()final booleanhasFrameProcessors()final voidsetPictureMetering(boolean enable)final booleangetPictureMetering()final voidsetPictureSnapshotMetering(boolean enable)final booleangetPictureSnapshotMetering()final booleanisTakingPicture()voidtakePicture(@NonNull() PictureResult.Stub stub)voidtakePictureSnapshot(@NonNull() PictureResult.Stub stub)The snapshot size is the getPreviewStreamSize, but cropped based on theview/surface aspect ratio. voidonPictureShutter(boolean didPlaySound)The shutter was activated. voidonPictureResult(@Nullable() PictureResult.Stub result, @Nullable() Exception error)Picture was taken or there was some error, ifthe result is null. final booleanisTakingVideo()final voidtakeVideo(@NonNull() VideoResult.Stub stub, @Nullable() File file, @Nullable() FileDescriptor fileDescriptor)final voidtakeVideoSnapshot(@NonNull() VideoResult.Stub stub, @NonNull() File file)final voidstopVideo()voidonVideoResult(@Nullable() VideoResult.Stub result, @Nullable() Exception exception)The operation was completed, either with success or with an error. voidonVideoRecordingStart()The callback for the actual video recording starting. voidonVideoRecordingEnd()Video recording has ended. final voidonSurfaceChanged()Called when the surface has changed. final SizegetPictureSize(@NonNull() Reference reference)final SizegetVideoSize(@NonNull() Reference reference)final SizegetPreviewStreamSize(@NonNull() Reference reference)final SizegetUncroppedSnapshotSize(@NonNull() Reference reference)Returns the snapshot size, but not cropped with the view dimensions, whichis what we will do before creating the snapshot. -
Methods inherited from class com.otaliastudios.cameraview.engine.CameraEngine
destroy, getPictureSize, getState, getTargetState, getVideoSize, isChangingState, onSurfaceAvailable, onSurfaceDestroyed, restart, setExposureCorrection, setFlash, setFrameProcessingFormat, setHasFrameProcessors, setHdr, setLocation, setPictureFormat, setPlaySounds, setPreviewFrameRate, setWhiteBalance, setZoom, start, startAutoFocus, stop, takePicture, takeVideo, takeVideoSnapshot -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getFrameManager
@NonNull() FrameManager getFrameManager()
-
getCameraOptions
@Nullable() final CameraOptions getCameraOptions()
-
setPreview
final void setPreview(@NonNull() CameraPreview cameraPreview)
-
getPreview
@NonNull() final CameraPreview getPreview()
-
setOverlay
final void setOverlay(@Nullable() Overlay overlay)
-
getOverlay
@Nullable() final Overlay getOverlay()
-
setPreviewStreamSizeSelector
final void setPreviewStreamSizeSelector(@Nullable() SizeSelector selector)
-
getPreviewStreamSizeSelector
@Nullable() final SizeSelector getPreviewStreamSizeSelector()
-
setPictureSizeSelector
final void setPictureSizeSelector(@NonNull() SizeSelector selector)
-
getPictureSizeSelector
@NonNull() final SizeSelector getPictureSizeSelector()
-
setVideoSizeSelector
final void setVideoSizeSelector(@NonNull() SizeSelector selector)
-
getVideoSizeSelector
@NonNull() final SizeSelector getVideoSizeSelector()
-
setVideoMaxSize
final void setVideoMaxSize(long videoMaxSizeBytes)
-
getVideoMaxSize
final long getVideoMaxSize()
-
setVideoMaxDuration
final void setVideoMaxDuration(int videoMaxDurationMillis)
-
getVideoMaxDuration
final int getVideoMaxDuration()
-
setVideoCodec
final void setVideoCodec(@NonNull() VideoCodec codec)
-
getVideoCodec
@NonNull() final VideoCodec getVideoCodec()
-
setVideoBitRate
final void setVideoBitRate(int videoBitRate)
-
getVideoBitRate
final int getVideoBitRate()
-
setAudioCodec
final void setAudioCodec(@NonNull() AudioCodec codec)
-
getAudioCodec
@NonNull() final AudioCodec getAudioCodec()
-
setAudioBitRate
final void setAudioBitRate(int audioBitRate)
-
getAudioBitRate
final int getAudioBitRate()
-
setSnapshotMaxWidth
final void setSnapshotMaxWidth(int maxWidth)
-
getSnapshotMaxWidth
final int getSnapshotMaxWidth()
-
setSnapshotMaxHeight
final void setSnapshotMaxHeight(int maxHeight)
-
getSnapshotMaxHeight
final int getSnapshotMaxHeight()
-
setFrameProcessingMaxWidth
final void setFrameProcessingMaxWidth(int maxWidth)
-
getFrameProcessingMaxWidth
final int getFrameProcessingMaxWidth()
-
setFrameProcessingMaxHeight
final void setFrameProcessingMaxHeight(int maxHeight)
-
getFrameProcessingMaxHeight
final int getFrameProcessingMaxHeight()
-
getFrameProcessingFormat
final int getFrameProcessingFormat()
-
setFrameProcessingPoolSize
final void setFrameProcessingPoolSize(int poolSize)
-
getFrameProcessingPoolSize
final int getFrameProcessingPoolSize()
-
setAutoFocusResetDelay
final void setAutoFocusResetDelay(long delayMillis)
-
getAutoFocusResetDelay
final long getAutoFocusResetDelay()
-
setFacing
final void setFacing(@NonNull() Facing facing)
Sets a new facing value. This will restart the engine session (if there's any)so that we can open the new facing camera.
- Parameters:
facing- facing
-
setAudio
final void setAudio(@NonNull() Audio audio)
Sets a new audio value that will be used for video recordings.
- Parameters:
audio- desired audio
-
setMode
final void setMode(@NonNull() Mode mode)
Sets the desired mode (either picture or video).
- Parameters:
mode- desired mode.
-
getZoomValue
final float getZoomValue()
-
getExposureCorrectionValue
final float getExposureCorrectionValue()
-
getWhiteBalance
@NonNull() final WhiteBalance getWhiteBalance()
-
getLocation
@Nullable() final Location getLocation()
-
getPictureFormat
@NonNull() final PictureFormat getPictureFormat()
-
setPreviewFrameRateExact
final void setPreviewFrameRateExact(boolean previewFrameRateExact)
-
getPreviewFrameRateExact
final boolean getPreviewFrameRateExact()
-
getPreviewFrameRate
final float getPreviewFrameRate()
-
hasFrameProcessors
final boolean hasFrameProcessors()
-
setPictureMetering
final void setPictureMetering(boolean enable)
-
getPictureMetering
final boolean getPictureMetering()
-
setPictureSnapshotMetering
final void setPictureSnapshotMetering(boolean enable)
-
getPictureSnapshotMetering
final boolean getPictureSnapshotMetering()
-
isTakingPicture
final boolean isTakingPicture()
-
takePicture
void takePicture(@NonNull() PictureResult.Stub stub)
-
takePictureSnapshot
void takePictureSnapshot(@NonNull() PictureResult.Stub stub)
The snapshot size is the getPreviewStreamSize, but cropped based on theview/surface aspect ratio.
- Parameters:
stub- a picture stub
-
onPictureShutter
void onPictureShutter(boolean didPlaySound)
The shutter was activated.
- Parameters:
didPlaySound- whether a sound was played
-
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
-
isTakingVideo
final boolean isTakingVideo()
-
takeVideo
final void takeVideo(@NonNull() VideoResult.Stub stub, @Nullable() File file, @Nullable() FileDescriptor fileDescriptor)
-
takeVideoSnapshot
final void takeVideoSnapshot(@NonNull() VideoResult.Stub stub, @NonNull() File file)
- Parameters:
stub- a video stubfile- the output file
-
stopVideo
final void stopVideo()
-
onVideoResult
@CallSuper() 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
-
onVideoRecordingStart
void onVideoRecordingStart()
The callback for the actual video recording starting.
-
onVideoRecordingEnd
void onVideoRecordingEnd()
Video recording has ended. We will finish processing the fileand soon onVideoResult will be called.
-
onSurfaceChanged
final void onSurfaceChanged()
Called when the surface has changed.
-
getPictureSize
@Nullable() final Size getPictureSize(@NonNull() Reference reference)
-
getVideoSize
@Nullable() final Size getVideoSize(@NonNull() Reference reference)
-
getPreviewStreamSize
@Nullable() final Size getPreviewStreamSize(@NonNull() Reference reference)
-
getUncroppedSnapshotSize
@Nullable() final Size getUncroppedSnapshotSize(@NonNull() Reference reference)
Returns the snapshot size, but not cropped with the view dimensions, whichis what we will do before creating the snapshot. However, cropping is done at variouslevels so we don't want to perform the op here.The base snapshot size is based on PreviewStreamSize (later cropped with view ratio). Why?One might be tempted to say that it's the SurfaceSize (which already matches the view ratio).The camera sensor will capture preview frames with PreviewStreamSize and that's it. Then theyare hardware-scaled by the preview surface, but this does not affect the snapshot, as thesnapshot recorder simply creates another surface.Done tests to ensure that this is true, by using1. small SurfaceSize and biggest() PreviewStreamSize: output is not low quality2. big SurfaceSize and smallest() PreviewStreamSize: output is low qualityIn both cases the result.size here was set to the biggest of the two.I could not find the same evidence for videos, but I would say that the same things shouldapply, despite the capturing mechanism being different.
- Parameters:
reference- the reference system
-
-
-
-