AndroidCamera2Capabilities.java revision de48004068f8c16f9a56c60b0ed2485a67687b4b
1a0842b40441db5332a5290f941021636b1182761Sol Boucher/* 2a0842b40441db5332a5290f941021636b1182761Sol Boucher * Copyright (C) 2014 The Android Open Source Project 3a0842b40441db5332a5290f941021636b1182761Sol Boucher * 4a0842b40441db5332a5290f941021636b1182761Sol Boucher * Licensed under the Apache License, Version 2.0 (the "License"); 5a0842b40441db5332a5290f941021636b1182761Sol Boucher * you may not use this file except in compliance with the License. 6a0842b40441db5332a5290f941021636b1182761Sol Boucher * You may obtain a copy of the License at 7a0842b40441db5332a5290f941021636b1182761Sol Boucher * 8a0842b40441db5332a5290f941021636b1182761Sol Boucher * http://www.apache.org/licenses/LICENSE-2.0 9a0842b40441db5332a5290f941021636b1182761Sol Boucher * 10a0842b40441db5332a5290f941021636b1182761Sol Boucher * Unless required by applicable law or agreed to in writing, software 11a0842b40441db5332a5290f941021636b1182761Sol Boucher * distributed under the License is distributed on an "AS IS" BASIS, 12a0842b40441db5332a5290f941021636b1182761Sol Boucher * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13a0842b40441db5332a5290f941021636b1182761Sol Boucher * See the License for the specific language governing permissions and 14a0842b40441db5332a5290f941021636b1182761Sol Boucher * limitations under the License. 15a0842b40441db5332a5290f941021636b1182761Sol Boucher */ 16a0842b40441db5332a5290f941021636b1182761Sol Boucher 17a0842b40441db5332a5290f941021636b1182761Sol Boucherpackage com.android.ex.camera2.portability; 18a0842b40441db5332a5290f941021636b1182761Sol Boucher 19a0842b40441db5332a5290f941021636b1182761Sol Boucherimport static android.hardware.camera2.CameraCharacteristics.*; 20a0842b40441db5332a5290f941021636b1182761Sol Boucher 21a0842b40441db5332a5290f941021636b1182761Sol Boucherimport android.graphics.Point; 22a0842b40441db5332a5290f941021636b1182761Sol Boucherimport android.hardware.camera2.CameraCharacteristics; 23a0842b40441db5332a5290f941021636b1182761Sol Boucherimport android.hardware.camera2.params.StreamConfigurationMap; 24a0842b40441db5332a5290f941021636b1182761Sol Boucherimport android.media.ImageReader; 25a0842b40441db5332a5290f941021636b1182761Sol Boucherimport android.media.MediaRecorder; 26a0842b40441db5332a5290f941021636b1182761Sol Boucherimport android.util.Range; 27a0842b40441db5332a5290f941021636b1182761Sol Boucherimport android.util.Rational; 28a0842b40441db5332a5290f941021636b1182761Sol Boucherimport android.view.SurfaceHolder; 29a0842b40441db5332a5290f941021636b1182761Sol Boucher 30a0842b40441db5332a5290f941021636b1182761Sol Boucherimport com.android.ex.camera2.portability.debug.Log; 31a0842b40441db5332a5290f941021636b1182761Sol Boucher 32a0842b40441db5332a5290f941021636b1182761Sol Boucherimport java.util.ArrayList; 33a0842b40441db5332a5290f941021636b1182761Sol Boucherimport java.util.Arrays; 34a0842b40441db5332a5290f941021636b1182761Sol Boucher 35a0842b40441db5332a5290f941021636b1182761Sol Boucher/** 36a0842b40441db5332a5290f941021636b1182761Sol Boucher * The subclass of {@link CameraCapabilities} for Android Camera 2 API. 37a0842b40441db5332a5290f941021636b1182761Sol Boucher */ 38a0842b40441db5332a5290f941021636b1182761Sol Boucherpublic class AndroidCamera2Capabilities extends CameraCapabilities { 39a0842b40441db5332a5290f941021636b1182761Sol Boucher private static Log.Tag TAG = new Log.Tag("AndCam2Capabs"); 40a0842b40441db5332a5290f941021636b1182761Sol Boucher 41a0842b40441db5332a5290f941021636b1182761Sol Boucher AndroidCamera2Capabilities(CameraCharacteristics p) { 42de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher super(new Stringifier()); 43a0842b40441db5332a5290f941021636b1182761Sol Boucher 44a0842b40441db5332a5290f941021636b1182761Sol Boucher StreamConfigurationMap s = p.get(SCALER_STREAM_CONFIGURATION_MAP); 45a0842b40441db5332a5290f941021636b1182761Sol Boucher 46a0842b40441db5332a5290f941021636b1182761Sol Boucher for (Range<Integer> fpsRange : p.get(CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES)) { 47a0842b40441db5332a5290f941021636b1182761Sol Boucher mSupportedPreviewFpsRange.add(new int[] { fpsRange.getLower(), fpsRange.getUpper() }); 48a0842b40441db5332a5290f941021636b1182761Sol Boucher } 49a0842b40441db5332a5290f941021636b1182761Sol Boucher 50a0842b40441db5332a5290f941021636b1182761Sol Boucher // TODO: We only support SurfaceView preview rendering 51a0842b40441db5332a5290f941021636b1182761Sol Boucher mSupportedPreviewSizes.addAll(Size.buildListFromAndroidSizes(Arrays.asList( 52a0842b40441db5332a5290f941021636b1182761Sol Boucher s.getOutputSizes(SurfaceHolder.class)))); 53a0842b40441db5332a5290f941021636b1182761Sol Boucher for (int format : s.getOutputFormats()) { 54a0842b40441db5332a5290f941021636b1182761Sol Boucher mSupportedPreviewFormats.add(format); 55a0842b40441db5332a5290f941021636b1182761Sol Boucher } 56a0842b40441db5332a5290f941021636b1182761Sol Boucher 57a0842b40441db5332a5290f941021636b1182761Sol Boucher // TODO: We only support MediaRecorder videos capture 58a0842b40441db5332a5290f941021636b1182761Sol Boucher mSupportedVideoSizes.addAll(Size.buildListFromAndroidSizes(Arrays.asList( 59a0842b40441db5332a5290f941021636b1182761Sol Boucher s.getOutputSizes(MediaRecorder.class)))); 60a0842b40441db5332a5290f941021636b1182761Sol Boucher 61a0842b40441db5332a5290f941021636b1182761Sol Boucher // TODO: We only support ImageReader image capture 62a0842b40441db5332a5290f941021636b1182761Sol Boucher mSupportedPhotoSizes.addAll(Size.buildListFromAndroidSizes(Arrays.asList( 63a0842b40441db5332a5290f941021636b1182761Sol Boucher s.getOutputSizes(ImageReader.class)))); 64a0842b40441db5332a5290f941021636b1182761Sol Boucher mSupportedPhotoFormats.addAll(mSupportedPreviewFormats); 65a0842b40441db5332a5290f941021636b1182761Sol Boucher 66a0842b40441db5332a5290f941021636b1182761Sol Boucher buildSceneModes(p); 67a0842b40441db5332a5290f941021636b1182761Sol Boucher buildFlashModes(p); 68a0842b40441db5332a5290f941021636b1182761Sol Boucher buildFocusModes(p); 69a0842b40441db5332a5290f941021636b1182761Sol Boucher buildWhiteBalances(p); 70a0842b40441db5332a5290f941021636b1182761Sol Boucher // TODO: Populate mSupportedFeatures 71a0842b40441db5332a5290f941021636b1182761Sol Boucher 72a0842b40441db5332a5290f941021636b1182761Sol Boucher // TODO: Populate mPreferredPreviewSizeForVideo 73a0842b40441db5332a5290f941021636b1182761Sol Boucher 74a0842b40441db5332a5290f941021636b1182761Sol Boucher Range<Integer> ecRange = p.get(CONTROL_AE_COMPENSATION_RANGE); 75a0842b40441db5332a5290f941021636b1182761Sol Boucher mMinExposureCompensation = ecRange.getLower(); 76a0842b40441db5332a5290f941021636b1182761Sol Boucher mMaxExposureCompensation = ecRange.getUpper(); 77a0842b40441db5332a5290f941021636b1182761Sol Boucher 78a0842b40441db5332a5290f941021636b1182761Sol Boucher Rational ecStep = p.get(CONTROL_AE_COMPENSATION_STEP); 79a0842b40441db5332a5290f941021636b1182761Sol Boucher mExposureCompensationStep = (float) ecStep.getNumerator() / ecStep.getDenominator(); 80a0842b40441db5332a5290f941021636b1182761Sol Boucher 81a0842b40441db5332a5290f941021636b1182761Sol Boucher mMaxNumOfFacesSupported = p.get(STATISTICS_INFO_MAX_FACE_COUNT); 82a0842b40441db5332a5290f941021636b1182761Sol Boucher mMaxNumOfMeteringArea = p.get(CONTROL_MAX_REGIONS_AE); 83a0842b40441db5332a5290f941021636b1182761Sol Boucher 84a0842b40441db5332a5290f941021636b1182761Sol Boucher // TODO: Populate mMaxZoomRatio 85a0842b40441db5332a5290f941021636b1182761Sol Boucher // TODO: Populate mHorizontalViewAngle 86a0842b40441db5332a5290f941021636b1182761Sol Boucher // TODO: Populate mVerticalViewAngle 87a0842b40441db5332a5290f941021636b1182761Sol Boucher // TODO: Populate mZoomRatioList 88a0842b40441db5332a5290f941021636b1182761Sol Boucher // TODO: Populate mMaxZoomIndex 89a97b7d1192e246a5f738991adca37cce282e1382Sol Boucher 90a97b7d1192e246a5f738991adca37cce282e1382Sol Boucher if (supports(FocusMode.AUTO)) { 91a97b7d1192e246a5f738991adca37cce282e1382Sol Boucher mMaxNumOfFocusAreas = p.get(CONTROL_MAX_REGIONS_AF); 92a97b7d1192e246a5f738991adca37cce282e1382Sol Boucher if (mMaxNumOfFocusAreas > 0) { 93a97b7d1192e246a5f738991adca37cce282e1382Sol Boucher mSupportedFeatures.add(Feature.FOCUS_AREA); 94a97b7d1192e246a5f738991adca37cce282e1382Sol Boucher } 95a97b7d1192e246a5f738991adca37cce282e1382Sol Boucher } 96a97b7d1192e246a5f738991adca37cce282e1382Sol Boucher if (mMaxNumOfMeteringArea > 0) { 97a97b7d1192e246a5f738991adca37cce282e1382Sol Boucher mSupportedFeatures.add(Feature.METERING_AREA); 98a97b7d1192e246a5f738991adca37cce282e1382Sol Boucher } 99a0842b40441db5332a5290f941021636b1182761Sol Boucher 100de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher // TODO: Detect other features 101a0842b40441db5332a5290f941021636b1182761Sol Boucher } 102a0842b40441db5332a5290f941021636b1182761Sol Boucher 103a0842b40441db5332a5290f941021636b1182761Sol Boucher private void buildSceneModes(CameraCharacteristics p) { 104de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher int[] scenes = p.get(CONTROL_AVAILABLE_SCENE_MODES); 105de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher if (scenes != null) { 106de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher for (int scene : scenes) { 107de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher SceneMode equiv = sceneModeFromInt(scene); 108de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher if (equiv != null) { 109de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher mSupportedSceneModes.add(equiv); 110de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher } 111a0842b40441db5332a5290f941021636b1182761Sol Boucher } 112a0842b40441db5332a5290f941021636b1182761Sol Boucher } 113a0842b40441db5332a5290f941021636b1182761Sol Boucher } 114a0842b40441db5332a5290f941021636b1182761Sol Boucher 115a0842b40441db5332a5290f941021636b1182761Sol Boucher private void buildFlashModes(CameraCharacteristics p) { 116a0842b40441db5332a5290f941021636b1182761Sol Boucher mSupportedFlashModes.add(FlashMode.OFF); 117a0842b40441db5332a5290f941021636b1182761Sol Boucher if (p.get(FLASH_INFO_AVAILABLE)) { 118de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher mSupportedFlashModes.add(FlashMode.AUTO); 119a0842b40441db5332a5290f941021636b1182761Sol Boucher mSupportedFlashModes.add(FlashMode.ON); 120a0842b40441db5332a5290f941021636b1182761Sol Boucher mSupportedFlashModes.add(FlashMode.TORCH); 121de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher for (int expose : p.get(CONTROL_AE_AVAILABLE_MODES)) { 122de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher if (expose == CONTROL_AE_MODE_ON_AUTO_FLASH_REDEYE) { 123de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher mSupportedFlashModes.add(FlashMode.RED_EYE); 124de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher } 125de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher } 126a0842b40441db5332a5290f941021636b1182761Sol Boucher } 127a0842b40441db5332a5290f941021636b1182761Sol Boucher } 128a0842b40441db5332a5290f941021636b1182761Sol Boucher 129a0842b40441db5332a5290f941021636b1182761Sol Boucher private void buildFocusModes(CameraCharacteristics p) { 130de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher int[] focuses = p.get(CONTROL_AF_AVAILABLE_MODES); 131de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher if (focuses != null) { 132de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher for (int focus : focuses) { 133de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher FocusMode equiv = focusModeFromInt(focus); 134de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher if (equiv != null) { 135de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher mSupportedFocusModes.add(equiv); 136de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher } 137a0842b40441db5332a5290f941021636b1182761Sol Boucher } 138a0842b40441db5332a5290f941021636b1182761Sol Boucher } 139a0842b40441db5332a5290f941021636b1182761Sol Boucher } 140a0842b40441db5332a5290f941021636b1182761Sol Boucher 141a0842b40441db5332a5290f941021636b1182761Sol Boucher private void buildWhiteBalances(CameraCharacteristics p) { 142de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher int[] bals = p.get(CONTROL_AWB_AVAILABLE_MODES); 143de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher if (bals != null) { 144de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher for (int bal : bals) { 145de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher WhiteBalance equiv = whiteBalanceFromInt(bal); 146de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher if (equiv != null) { 147de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher mSupportedWhiteBalances.add(equiv); 148de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher } 149a0842b40441db5332a5290f941021636b1182761Sol Boucher } 150a0842b40441db5332a5290f941021636b1182761Sol Boucher } 151a0842b40441db5332a5290f941021636b1182761Sol Boucher } 152a0842b40441db5332a5290f941021636b1182761Sol Boucher 153de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher /** 154de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * Converts the API-related integer representation of the focus mode to the 155de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * abstract representation. 156de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * 157de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * @param fm The integral representation. 158de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * @return The mode represented by the input integer, or {@code null} if it 159de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * cannot be converted. 160de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher */ 161de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher public static FocusMode focusModeFromInt(int fm) { 162de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher switch (fm) { 163de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_AF_MODE_AUTO: 164de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return FocusMode.AUTO; 165de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_AF_MODE_CONTINUOUS_PICTURE: 166de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return FocusMode.CONTINUOUS_PICTURE; 167de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_AF_MODE_CONTINUOUS_VIDEO: 168de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return FocusMode.CONTINUOUS_VIDEO; 169de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_AF_MODE_EDOF: 170de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return FocusMode.EXTENDED_DOF; 171de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_AF_MODE_OFF: 172de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return FocusMode.FIXED; 173de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher // TODO: We cannot support INFINITY 174de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_AF_MODE_MACRO: 175de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return FocusMode.MACRO; 176a0842b40441db5332a5290f941021636b1182761Sol Boucher } 177de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher Log.w(TAG, "Unable to convert from API 2 focus mode: " + fm); 178de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return null; 179de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher } 180a0842b40441db5332a5290f941021636b1182761Sol Boucher 181de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher /** 182de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * Converts the API-related integer representation of the scene mode to the 183de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * abstract representation. 184de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * 185de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * @param sm The integral representation. 186de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * @return The mode represented by the input integer, or {@code null} if it 187de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * cannot be converted. 188de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher */ 189de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher public static SceneMode sceneModeFromInt(int sm) { 190de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher switch (sm) { 191de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_SCENE_MODE_DISABLED: 192de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return SceneMode.AUTO; 193de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_SCENE_MODE_ACTION: 194de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return SceneMode.ACTION; 195de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_SCENE_MODE_BARCODE: 196de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return SceneMode.BARCODE; 197de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_SCENE_MODE_BEACH: 198de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return SceneMode.BEACH; 199de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_SCENE_MODE_CANDLELIGHT: 200de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return SceneMode.CANDLELIGHT; 201de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_SCENE_MODE_FIREWORKS: 202de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return SceneMode.FIREWORKS; 203de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher // TODO: We cannot support HDR 204de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_SCENE_MODE_LANDSCAPE: 205de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return SceneMode.LANDSCAPE; 206de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_SCENE_MODE_NIGHT: 207de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return SceneMode.NIGHT; 208de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher // TODO: We cannot support NIGHT_PORTRAIT 209de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_SCENE_MODE_PARTY: 210de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return SceneMode.PARTY; 211de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_SCENE_MODE_PORTRAIT: 212de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return SceneMode.PORTRAIT; 213de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_SCENE_MODE_SNOW: 214de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return SceneMode.SNOW; 215de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_SCENE_MODE_SPORTS: 216de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return SceneMode.SPORTS; 217de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_SCENE_MODE_STEADYPHOTO: 218de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return SceneMode.STEADYPHOTO; 219de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_SCENE_MODE_SUNSET: 220de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return SceneMode.SUNSET; 221de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_SCENE_MODE_THEATRE: 222de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return SceneMode.THEATRE; 223de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher // TODO: We cannot expose FACE_PRIORITY, or HIGH_SPEED_VIDEO 224a0842b40441db5332a5290f941021636b1182761Sol Boucher } 225de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher Log.w(TAG, "Unable to convert from API 2 scene mode: " + sm); 226de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return null; 227de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher } 228a0842b40441db5332a5290f941021636b1182761Sol Boucher 229de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher /** 230de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * Converts the API-related integer representation of the white balance to 231de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * the abstract representation. 232de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * 233de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * @param wb The integral representation. 234de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * @return The balance represented by the input integer, or {@code null} if 235de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * it cannot be converted. 236de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher */ 237de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher public static WhiteBalance whiteBalanceFromInt(int wb) { 238de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher switch (wb) { 239de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_AWB_MODE_AUTO: 240de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return WhiteBalance.AUTO; 241de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_AWB_MODE_CLOUDY_DAYLIGHT: 242de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return WhiteBalance.CLOUDY_DAYLIGHT; 243de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_AWB_MODE_DAYLIGHT: 244de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return WhiteBalance.DAYLIGHT; 245de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_AWB_MODE_FLUORESCENT: 246de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return WhiteBalance.FLUORESCENT; 247de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_AWB_MODE_INCANDESCENT: 248de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return WhiteBalance.INCANDESCENT; 249de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_AWB_MODE_SHADE: 250de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return WhiteBalance.SHADE; 251de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_AWB_MODE_TWILIGHT: 252de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return WhiteBalance.TWILIGHT; 253de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_AWB_MODE_WARM_FLUORESCENT: 254de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return WhiteBalance.WARM_FLUORESCENT; 255a0842b40441db5332a5290f941021636b1182761Sol Boucher } 256de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher Log.w(TAG, "Unable to convert from API 2 white balance: " + wb); 257de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return null; 258a0842b40441db5332a5290f941021636b1182761Sol Boucher } 259a0842b40441db5332a5290f941021636b1182761Sol Boucher} 260