FileDocCategorySizeDatePackage
CameraSettings.javaAPI DocAndroid 5.1 API15826Thu Mar 12 22:22:48 GMT 2015com.android.ex.camera2.portability

CameraSettings

public abstract class CameraSettings extends Object
A class which stores the camera settings.

Fields Summary
private static final Log.Tag
TAG
private static final int
MIN_JPEG_COMPRESSION_QUALITY
private static final int
MAX_JPEG_COMPRESSION_QUALITY
protected final Map
mGeneralSetting
protected final List
mMeteringAreas
protected final List
mFocusAreas
protected boolean
mSizesLocked
protected int
mPreviewFpsRangeMin
protected int
mPreviewFpsRangeMax
protected int
mPreviewFrameRate
protected Size
mCurrentPreviewSize
private int
mCurrentPreviewFormat
protected Size
mCurrentPhotoSize
protected byte
mJpegCompressQuality
protected int
mCurrentPhotoFormat
protected float
mCurrentZoomRatio
protected int
mExposureCompensationIndex
protected CameraCapabilities.FlashMode
mCurrentFlashMode
protected CameraCapabilities.FocusMode
mCurrentFocusMode
protected CameraCapabilities.SceneMode
mCurrentSceneMode
protected CameraCapabilities.WhiteBalance
mWhiteBalance
protected boolean
mVideoStabilizationEnabled
protected boolean
mAutoExposureLocked
protected boolean
mAutoWhiteBalanceLocked
protected boolean
mRecordingHintEnabled
protected GpsData
mGpsData
protected Size
mExifThumbnailSize
Constructors Summary
protected CameraSettings()

    
protected CameraSettings(CameraSettings src)
Copy constructor.

param
src The source settings.
return
The copy of the source.

        mGeneralSetting.putAll(src.mGeneralSetting);
        mMeteringAreas.addAll(src.mMeteringAreas);
        mFocusAreas.addAll(src.mFocusAreas);
        mSizesLocked = src.mSizesLocked;
        mPreviewFpsRangeMin = src.mPreviewFpsRangeMin;
        mPreviewFpsRangeMax = src.mPreviewFpsRangeMax;
        mPreviewFrameRate = src.mPreviewFrameRate;
        mCurrentPreviewSize =
                (src.mCurrentPreviewSize == null ? null : new Size(src.mCurrentPreviewSize));
        mCurrentPreviewFormat = src.mCurrentPreviewFormat;
        mCurrentPhotoSize =
                (src.mCurrentPhotoSize == null ? null : new Size(src.mCurrentPhotoSize));
        mJpegCompressQuality = src.mJpegCompressQuality;
        mCurrentPhotoFormat = src.mCurrentPhotoFormat;
        mCurrentZoomRatio = src.mCurrentZoomRatio;
        mExposureCompensationIndex = src.mExposureCompensationIndex;
        mCurrentFlashMode = src.mCurrentFlashMode;
        mCurrentFocusMode = src.mCurrentFocusMode;
        mCurrentSceneMode = src.mCurrentSceneMode;
        mWhiteBalance = src.mWhiteBalance;
        mVideoStabilizationEnabled = src.mVideoStabilizationEnabled;
        mAutoExposureLocked = src.mAutoExposureLocked;
        mAutoWhiteBalanceLocked = src.mAutoWhiteBalanceLocked;
        mRecordingHintEnabled = src.mRecordingHintEnabled;
        mGpsData = src.mGpsData;
        mExifThumbnailSize = src.mExifThumbnailSize;
    
Methods Summary
public voidclearGpsData()

        mGpsData = null;
    
public abstract com.android.ex.camera2.portability.CameraSettingscopy()

return
A copy of this object, as an instance of the implementing class.

public CameraCapabilities.FlashModegetCurrentFlashMode()
Flash

        return mCurrentFlashMode;
    
public CameraCapabilities.FocusModegetCurrentFocusMode()

return
The current focus mode.

        return mCurrentFocusMode;
    
public intgetCurrentPhotoFormat()

return
The format for the photos taken.
see
{@link android.graphics.ImageFormat}.

        return mCurrentPhotoFormat;
    
public SizegetCurrentPhotoSize()

return
The current photo size.

        return new Size(mCurrentPhotoSize);
    
public intgetCurrentPreviewFormat()

return
The preview format.
see
{@link android.graphics.ImageFormat}.

        return mCurrentPreviewFormat;
    
public SizegetCurrentPreviewSize()

return
The current preview size.

        return new Size(mCurrentPreviewSize);
    
public CameraCapabilities.SceneModegetCurrentSceneMode()

return
The current scene mode.

        return mCurrentSceneMode;
    
public floatgetCurrentZoomRatio()

return
The current zoom ratio. The min is 1.0f.

        return mCurrentZoomRatio;
    
public SizegetExifThumbnailSize()
Gets the size of the thumbnail in EXIF header.

return
desired thumbnail size, or null if no size was set

        return (mExifThumbnailSize == null) ? null : new Size(mExifThumbnailSize);
    
public intgetExposureCompensationIndex()

return
The exposure compensation, with 0 meaning unadjusted.

        return mExposureCompensationIndex;
    
public java.util.ListgetFocusAreas()

        return new ArrayList<Camera.Area>(mFocusAreas);
    
public com.android.ex.camera2.portability.CameraSettings$GpsDatagetGpsData()

        return (mGpsData == null ? null : new GpsData(mGpsData));
    
public java.util.ListgetMeteringAreas()

        return new ArrayList<Camera.Area>(mMeteringAreas);
    
public intgetPhotoJpegCompressionQuality()

        return mJpegCompressQuality;
    
public intgetPreviewFpsRangeMax()

return
The max of the preview FPS range.

        return mPreviewFpsRangeMax;
    
public intgetPreviewFpsRangeMin()

return
The min of the preview FPS range.

        return mPreviewFpsRangeMin;
    
public intgetPreviewFrameRate()

        return mPreviewFrameRate;
    
public CameraCapabilities.WhiteBalancegetWhiteBalance()

        return mWhiteBalance;
    
public booleanisAutoExposureLocked()

        return mAutoExposureLocked;
    
public booleanisAutoWhiteBalanceLocked()

        return mAutoWhiteBalanceLocked;
    
public booleanisRecordingHintEnabled()

        return mRecordingHintEnabled;
    
public booleanisVideoStabilizationEnabled()

        return mVideoStabilizationEnabled;
    
public voidsetAutoExposureLock(boolean locked)

        mAutoExposureLocked = locked;
    
public voidsetAutoWhiteBalanceLock(boolean locked)

        mAutoWhiteBalanceLocked = locked;
    
public voidsetExifThumbnailSize(Size s)
Sets the size of the thumbnail in EXIF header. To suppress thumbnail generation, set a size of (0,0).

param
s The size for the thumbnail. If {@code null}, agent will not set a thumbnail size.

        mExifThumbnailSize = s;
    
public voidsetExposureCompensationIndex(int index)
Exposure

        mExposureCompensationIndex = index;
    
public voidsetFlashMode(CameraCapabilities.FlashMode flashMode)

        mCurrentFlashMode = flashMode;
    
public voidsetFocusAreas(java.util.List areas)

param
areas The areas to focus. The coordinate system has domain and range [-1000,1000], measured relative to the visible preview image, with orientation matching that of the sensor. This means the coordinates must be transformed to account for the devices rotation---but not the zoom level---before being passed into this method.

        mFocusAreas.clear();
        if (areas != null) {
            mFocusAreas.addAll(areas);
        }
    
public voidsetFocusMode(CameraCapabilities.FocusMode focusMode)
Sets the focus mode.

param
focusMode The focus mode to use.

        mCurrentFocusMode = focusMode;
    
public voidsetGpsData(com.android.ex.camera2.portability.CameraSettings$GpsData data)

        mGpsData = new GpsData(data);
    
public voidsetMeteringAreas(java.util.List areas)

param
areas The areas for autoexposure. The coordinate system has domain and range [-1000,1000], measured relative to the visible preview image, with orientation matching that of the sensor. This means the coordinates must be transformed to account for the devices rotation---but not the zoom level---before being passed into this method.

        mMeteringAreas.clear();
        if (areas != null) {
            mMeteringAreas.addAll(areas);
        }
    
public voidsetPhotoFormat(int format)
Sets the format for the photo.

param
format The format for the photos taken.
see
{@link android.graphics.ImageFormat}.

        mCurrentPhotoFormat = format;
    
public voidsetPhotoJpegCompressionQuality(int quality)
Sets the JPEG compression quality.

param
quality The quality for JPEG.

        if (quality < MIN_JPEG_COMPRESSION_QUALITY || quality > MAX_JPEG_COMPRESSION_QUALITY) {
            Log.w(TAG, "Ignoring JPEG quality that falls outside the expected range");
            return;
        }
        // This is safe because the positive numbers go up to 127.
        mJpegCompressQuality = (byte) quality;
    
public booleansetPhotoSize(Size photoSize)

param
photoSize The size to use for preview.
return
Whether the operation was allowed (i.e. the sizes are unlocked).

        if (mSizesLocked) {
            Log.w(TAG, "Attempt to change photo size while locked");
            return false;
        }

        mCurrentPhotoSize = new Size(photoSize);
        return true;
    
public voidsetPreviewFormat(int format)
Sets the preview format.

param
format
see
{@link android.graphics.ImageFormat}.

        mCurrentPreviewFormat = format;
    
public voidsetPreviewFpsRange(int min, int max)
Sets the preview FPS range. This call will invalidate prior calls to {@link #setPreviewFrameRate(int)}.

param
min The min FPS.
param
max The max FPS.

        if (min > max) {
            int temp = max;
            max = min;
            min = temp;
        }
        mPreviewFpsRangeMax = max;
        mPreviewFpsRangeMin = min;
        mPreviewFrameRate = -1;
    
public voidsetPreviewFrameRate(int frameRate)
Sets the preview FPS. This call will invalidate prior calls to {@link #setPreviewFpsRange(int, int)}.

param
frameRate The target frame rate.

        if (frameRate > 0) {
            mPreviewFrameRate = frameRate;
            mPreviewFpsRangeMax = frameRate;
            mPreviewFpsRangeMin = frameRate;
        }
    
public booleansetPreviewSize(Size previewSize)

param
previewSize The size to use for preview.
return
Whether the operation was allowed (i.e. the sizes are unlocked).

        if (mSizesLocked) {
            Log.w(TAG, "Attempt to change preview size while locked");
            return false;
        }

        mCurrentPreviewSize = new Size(previewSize);
        return true;
    
public voidsetRecordingHintEnabled(boolean hintEnabled)

        mRecordingHintEnabled = hintEnabled;
    
public voidsetSceneMode(CameraCapabilities.SceneMode sceneMode)
Sets the scene mode for capturing.

param
sceneMode The scene mode to use.
throws
java.lang.UnsupportedOperationException if it's not supported.

        mCurrentSceneMode = sceneMode;
    
public voidsetSetting(java.lang.String key, java.lang.String value)
General setting

        mGeneralSetting.put(key, value);
    
voidsetSizesLocked(boolean locked)
Changes whether classes outside this class are allowed to set the preview and photo capture sizes.

param
locked Whether to prevent changes to these fields.
see
#setPhotoSize
see
#setPreviewSize

        mSizesLocked = locked;
    
public voidsetVideoStabilization(boolean enabled)
Other Features

        mVideoStabilizationEnabled = enabled;
    
public voidsetWhiteBalance(CameraCapabilities.WhiteBalance whiteBalance)
White balance

        mWhiteBalance = whiteBalance;
    
public voidsetZoomRatio(float ratio)
Sets the zoom ratio.

param
ratio The new zoom ratio. Should be in the range between 1.0 to the value returned from {@link com.android.camera.cameradevice.CameraCapabilities#getMaxZoomRatio()}.
throws
java.lang.UnsupportedOperationException if the ratio is not supported.

        mCurrentZoomRatio = ratio;