Class SimpleCameraHost
-
- All Implemented Interfaces:
-
android.hardware.Camera.AutoFocusCallback
,com.commonsware.cwac.camera.CameraHost
public class SimpleCameraHost implements CameraHost
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public class
SimpleCameraHost.Builder
-
Field Summary
Fields Modifier and Type Field Description public int
cameraId
public CameraHost.RecordingHint
recordingHint
-
Constructor Summary
Constructors Constructor Description SimpleCameraHost(Context _ctxt)
-
Method Summary
Modifier and Type Method Description int
getCameraId()
CameraHost.RecordingHint
getRecordingHint()
Camera.Parameters
adjustPictureParameters(PictureTransaction xact, Camera.Parameters parameters)
Implement this to configure the Camera.Parameters just prior to taking a photo. Camera.Parameters
adjustPreviewParameters(Camera.Parameters parameters)
Implement this to configure the Camera.Parameters for the purposes of the preview. 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. 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. 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. DeviceProfile
getDeviceProfile()
Camera.Size
getPictureSize(PictureTransaction xact, Camera.Parameters parameters)
Called to allow you to be able to indicate what size photo should be taken. Camera.Size
getPreviewSize(int displayOrientation, int width, int height, Camera.Parameters parameters)
Called to allow you to indicate what size preview should be used 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 Camera.ShutterCallback
getShutterCallback()
void
handleException(Exception e)
Called when something blows up in CameraView, to allow you to alert the user as you see fit boolean
mirrorFFC()
void
saveImage(PictureTransaction xact, Bitmap bitmap)
Called when a picture has been taken. void
saveImage(PictureTransaction xact, Array<byte> image, int imageOrientation)
Called when a picture has been taken. void
onAutoFocus(boolean success, Camera camera)
boolean
useSingleShotMode()
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. 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. 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 boolean
useFullBleedPreview()
float
maxPictureCleanupHeapUsage()
-
-
Constructor Detail
-
SimpleCameraHost
SimpleCameraHost(Context _ctxt)
-
-
Method Detail
-
getCameraId
int getCameraId()
-
getRecordingHint
CameraHost.RecordingHint getRecordingHint()
-
adjustPictureParameters
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
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.
-
configureRecorderAudio
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
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
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
-
getDeviceProfile
DeviceProfile getDeviceProfile()
-
getPictureSize
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
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
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
Camera.ShutterCallback getShutterCallback()
-
handleException
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
boolean mirrorFFC()
-
saveImage
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
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.
-
onAutoFocus
void onAutoFocus(boolean success, Camera camera)
-
useSingleShotMode
boolean useSingleShotMode()
-
autoFocusAvailable
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
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.
-
onCameraFail
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
boolean useFullBleedPreview()
-
maxPictureCleanupHeapUsage
float maxPictureCleanupHeapUsage()
-
-
-
-