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. *

    • Constructor Detail

    • Method Detail

      • 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 recording
        recorder - 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 recording
        recorder - 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 recording
        recorder - the MediaRecorder to be configured
      • 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 degrees
        width - width of the available preview space
        height - height of the available preview space
        parameters - 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 degrees
        width - width of the available preview space
        height - height of the available preview space
        parameters - the current camera parameters
        deviceHint - the size that the device itself thinks should be used for video, which sometimes is ridiculously low
      • 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
      • 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.
      • 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