Interface CameraHost
-
- All Implemented Interfaces:
-
android.hardware.Camera.AutoFocusCallback
public interface CameraHost implements Camera.AutoFocusCallback
Specification of a CameraHost, which is the primary way by which an app will interact with the library. This allows for a single code base supporting those using CameraView directly, CameraFragment, the CameraFragment for the Android Support package's backport of fragments, and who knows what else in the future. A concrete implementation of this class, SimpleCameraHost, provides reasonable defaults for all of the functionality. Hence, you can either extend SimpleCameraHost and override where needed, or implement your own CameraHost from scratch. *
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enum
CameraHost.RecordingHint
Indication of what purpose we plan to put the camera towards. If your use of the camera is single-purpose, return STILL_ONLY (for photos) or VIDEO_ONLY (for videos). If you support both (all the time or via some sort of user-selectable mode), use ANY. NONE indicates that something else should be making this decision (for internal use only).
public enum
CameraHost.FailureReason
Indication of why we were unable to open up a camera. NO_CAMERAS_REPORTED will be used if getCameraId() returns a negative number. Exceptions raised when the camera is opened will return UNKNOWN.
-
Method Summary
Modifier and Type Method Description abstract Camera.Parameters
adjustPictureParameters(PictureTransaction xact, Camera.Parameters parameters)
Implement this to configure the Camera.Parameters just prior to taking a photo. abstract Camera.Parameters
adjustPreviewParameters(Camera.Parameters parameters)
Implement this to configure the Camera.Parameters for the purposes of the preview. abstract void
autoFocusAvailable()
This will be called by the library to let you know that auto-focus is available for your use, so you can update your UI accordingly. abstract void
autoFocusUnavailable()
This will be called by the library to let you know that auto-focus is not available for your use, so you can update your UI accordingly. abstract void
configureRecorderAudio(int cameraId, MediaRecorder recorder)
This will be called by the library to give you a chance to configure the audio of the MediaRecorder, just prior to beginning to record a video. abstract void
configureRecorderOutput(int cameraId, MediaRecorder recorder)
This will be called by the library to give you a chance to configure the output of the MediaRecorder, just prior to beginning to record a video. abstract void
configureRecorderProfile(int cameraId, MediaRecorder recorder)
This will be called by the library to give you a chance to configure the profile of the MediaRecorder, just prior to beginning to record a video. abstract int
getCameraId()
abstract DeviceProfile
getDeviceProfile()
abstract Camera.Size
getPictureSize(PictureTransaction xact, Camera.Parameters parameters)
Called to allow you to be able to indicate what size photo should be taken. abstract Camera.Size
getPreviewSize(int displayOrientation, int width, int height, Camera.Parameters parameters)
Called to allow you to indicate what size preview should be used abstract Camera.Size
getPreferredPreviewSizeForVideo(int displayOrientation, int width, int height, Camera.Parameters parameters, Camera.Size deviceHint)
Same as getPreviewSize(), but called when we anticipate taking videos, as some devices may work better with lower-resolution previews, to reduce CPU load abstract Camera.ShutterCallback
getShutterCallback()
abstract void
handleException(Exception e)
Called when something blows up in CameraView, to allow you to alert the user as you see fit abstract boolean
mirrorFFC()
abstract void
saveImage(PictureTransaction xact, Bitmap bitmap)
Called when a picture has been taken. abstract void
saveImage(PictureTransaction xact, Array<byte> image, int imageOrientation)
Called when a picture has been taken. abstract boolean
useSingleShotMode()
abstract CameraHost.RecordingHint
getRecordingHint()
abstract void
onCameraFail(CameraHost.FailureReason reason)
Called when we failed to open the camera for one reason or another, so you can let the user know abstract boolean
useFullBleedPreview()
abstract float
maxPictureCleanupHeapUsage()
-
-
Method Detail
-
adjustPictureParameters
abstract Camera.Parameters adjustPictureParameters(PictureTransaction xact, Camera.Parameters parameters)
Implement this to configure the Camera.Parameters just prior to taking a photo.
- Parameters:
parameters
- the Camera.
-
adjustPreviewParameters
abstract Camera.Parameters adjustPreviewParameters(Camera.Parameters parameters)
Implement this to configure the Camera.Parameters for the purposes of the preview. Note that you will have another chance to configure the Camera.Parameters for a specific photo via adjustPictureParameters().
- Parameters:
parameters
- the Camera.
-
autoFocusAvailable
abstract void autoFocusAvailable()
This will be called by the library to let you know that auto-focus is available for your use, so you can update your UI accordingly.
-
autoFocusUnavailable
abstract void autoFocusUnavailable()
This will be called by the library to let you know that auto-focus is not available for your use, so you can update your UI accordingly.
-
configureRecorderAudio
abstract void configureRecorderAudio(int cameraId, MediaRecorder recorder)
This will be called by the library to give you a chance to configure the audio of the MediaRecorder, just prior to beginning to record a video. Please ONLY configure audio here.
- Parameters:
cameraId
- the camera that will be used for recordingrecorder
- the MediaRecorder to be configured
-
configureRecorderOutput
abstract void configureRecorderOutput(int cameraId, MediaRecorder recorder)
This will be called by the library to give you a chance to configure the output of the MediaRecorder, just prior to beginning to record a video. Please ONLY configure output here.
- Parameters:
cameraId
- the camera that will be used for recordingrecorder
- the MediaRecorder to be configured
-
configureRecorderProfile
abstract void configureRecorderProfile(int cameraId, MediaRecorder recorder)
This will be called by the library to give you a chance to configure the profile of the MediaRecorder, just prior to beginning to record a video. Please ONLY configure profile here.
- Parameters:
cameraId
- the camera that will be used for recordingrecorder
- the MediaRecorder to be configured
-
getCameraId
abstract int getCameraId()
-
getDeviceProfile
abstract DeviceProfile getDeviceProfile()
-
getPictureSize
abstract Camera.Size getPictureSize(PictureTransaction xact, Camera.Parameters parameters)
Called to allow you to be able to indicate what size photo should be taken.
- Parameters:
parameters
- the current camera parameters
-
getPreviewSize
abstract Camera.Size getPreviewSize(int displayOrientation, int width, int height, Camera.Parameters parameters)
Called to allow you to indicate what size preview should be used
- Parameters:
displayOrientation
- orientation of the display in degreeswidth
- width of the available preview spaceheight
- height of the available preview spaceparameters
- the current camera parameters
-
getPreferredPreviewSizeForVideo
abstract Camera.Size getPreferredPreviewSizeForVideo(int displayOrientation, int width, int height, Camera.Parameters parameters, Camera.Size deviceHint)
Same as getPreviewSize(), but called when we anticipate taking videos, as some devices may work better with lower-resolution previews, to reduce CPU load
- Parameters:
displayOrientation
- orientation of the display in degreeswidth
- width of the available preview spaceheight
- height of the available preview spaceparameters
- the current camera parametersdeviceHint
- the size that the device itself thinks should be used for video, which sometimes is ridiculously low
-
getShutterCallback
abstract Camera.ShutterCallback getShutterCallback()
-
handleException
abstract void handleException(Exception e)
Called when something blows up in CameraView, to allow you to alert the user as you see fit
- Parameters:
e
- an Exception indicating what went wrong
-
mirrorFFC
abstract boolean mirrorFFC()
-
saveImage
abstract void saveImage(PictureTransaction xact, Bitmap bitmap)
Called when a picture has been taken. This will be called on a background thread.
- Parameters:
bitmap
- Bitmap of the picture
-
saveImage
abstract void saveImage(PictureTransaction xact, Array<byte> image, int imageOrientation)
Called when a picture has been taken. This will be called on a background thread. passes image orientation
- Parameters:
image
- byte array of the picture data (e.g.
-
useSingleShotMode
abstract boolean useSingleShotMode()
-
getRecordingHint
abstract CameraHost.RecordingHint getRecordingHint()
-
onCameraFail
abstract void onCameraFail(CameraHost.FailureReason reason)
Called when we failed to open the camera for one reason or another, so you can let the user know
- Parameters:
reason
- a FailureReason indicating what went wrong
-
useFullBleedPreview
abstract boolean useFullBleedPreview()
-
maxPictureCleanupHeapUsage
abstract float maxPictureCleanupHeapUsage()
-
-
-
-