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 21c6344faeff899655abd60b3bf4cd638e58bcc3d7Sol Boucherimport android.graphics.ImageFormat; 22a0842b40441db5332a5290f941021636b1182761Sol Boucherimport android.graphics.Point; 23c6344faeff899655abd60b3bf4cd638e58bcc3d7Sol Boucherimport android.graphics.SurfaceTexture; 24a0842b40441db5332a5290f941021636b1182761Sol Boucherimport android.hardware.camera2.CameraCharacteristics; 25a0842b40441db5332a5290f941021636b1182761Sol Boucherimport android.hardware.camera2.params.StreamConfigurationMap; 26a0842b40441db5332a5290f941021636b1182761Sol Boucherimport android.media.MediaRecorder; 27a0842b40441db5332a5290f941021636b1182761Sol Boucherimport android.util.Range; 28a0842b40441db5332a5290f941021636b1182761Sol Boucherimport android.util.Rational; 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 50c6344faeff899655abd60b3bf4cd638e58bcc3d7Sol Boucher // TODO: We only support TextureView preview rendering 51a0842b40441db5332a5290f941021636b1182761Sol Boucher mSupportedPreviewSizes.addAll(Size.buildListFromAndroidSizes(Arrays.asList( 52c6344faeff899655abd60b3bf4cd638e58bcc3d7Sol Boucher s.getOutputSizes(SurfaceTexture.class)))); 53a0842b40441db5332a5290f941021636b1182761Sol Boucher for (int format : s.getOutputFormats()) { 54a0842b40441db5332a5290f941021636b1182761Sol Boucher mSupportedPreviewFormats.add(format); 55a0842b40441db5332a5290f941021636b1182761Sol Boucher } 56a0842b40441db5332a5290f941021636b1182761Sol Boucher 57c6344faeff899655abd60b3bf4cd638e58bcc3d7Sol Boucher // TODO: We only support MediaRecorder video capture 58a0842b40441db5332a5290f941021636b1182761Sol Boucher mSupportedVideoSizes.addAll(Size.buildListFromAndroidSizes(Arrays.asList( 59a0842b40441db5332a5290f941021636b1182761Sol Boucher s.getOutputSizes(MediaRecorder.class)))); 60a0842b40441db5332a5290f941021636b1182761Sol Boucher 61c6344faeff899655abd60b3bf4cd638e58bcc3d7Sol Boucher // TODO: We only support JPEG image capture 62a0842b40441db5332a5290f941021636b1182761Sol Boucher mSupportedPhotoSizes.addAll(Size.buildListFromAndroidSizes(Arrays.asList( 63c6344faeff899655abd60b3bf4cd638e58bcc3d7Sol Boucher s.getOutputSizes(ImageFormat.JPEG)))); 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 849d8668449376fa47bc6528c7a61b04d6a0f691b3Sol Boucher mMaxZoomRatio = p.get(SCALER_AVAILABLE_MAX_DIGITAL_ZOOM); 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 1009d8668449376fa47bc6528c7a61b04d6a0f691b3Sol Boucher if (mMaxZoomRatio > CameraCapabilities.ZOOM_RATIO_UNZOOMED) { 1019d8668449376fa47bc6528c7a61b04d6a0f691b3Sol Boucher mSupportedFeatures.add(Feature.ZOOM); 1029d8668449376fa47bc6528c7a61b04d6a0f691b3Sol Boucher } 1039d8668449376fa47bc6528c7a61b04d6a0f691b3Sol Boucher 104de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher // TODO: Detect other features 105a0842b40441db5332a5290f941021636b1182761Sol Boucher } 106a0842b40441db5332a5290f941021636b1182761Sol Boucher 107a0842b40441db5332a5290f941021636b1182761Sol Boucher private void buildSceneModes(CameraCharacteristics p) { 108de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher int[] scenes = p.get(CONTROL_AVAILABLE_SCENE_MODES); 109de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher if (scenes != null) { 110de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher for (int scene : scenes) { 111de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher SceneMode equiv = sceneModeFromInt(scene); 112de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher if (equiv != null) { 113de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher mSupportedSceneModes.add(equiv); 114de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher } 115a0842b40441db5332a5290f941021636b1182761Sol Boucher } 116a0842b40441db5332a5290f941021636b1182761Sol Boucher } 117a0842b40441db5332a5290f941021636b1182761Sol Boucher } 118a0842b40441db5332a5290f941021636b1182761Sol Boucher 119a0842b40441db5332a5290f941021636b1182761Sol Boucher private void buildFlashModes(CameraCharacteristics p) { 120a0842b40441db5332a5290f941021636b1182761Sol Boucher mSupportedFlashModes.add(FlashMode.OFF); 121a0842b40441db5332a5290f941021636b1182761Sol Boucher if (p.get(FLASH_INFO_AVAILABLE)) { 122de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher mSupportedFlashModes.add(FlashMode.AUTO); 123a0842b40441db5332a5290f941021636b1182761Sol Boucher mSupportedFlashModes.add(FlashMode.ON); 124a0842b40441db5332a5290f941021636b1182761Sol Boucher mSupportedFlashModes.add(FlashMode.TORCH); 125de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher for (int expose : p.get(CONTROL_AE_AVAILABLE_MODES)) { 126de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher if (expose == CONTROL_AE_MODE_ON_AUTO_FLASH_REDEYE) { 127de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher mSupportedFlashModes.add(FlashMode.RED_EYE); 128de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher } 129de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher } 130a0842b40441db5332a5290f941021636b1182761Sol Boucher } 131a0842b40441db5332a5290f941021636b1182761Sol Boucher } 132a0842b40441db5332a5290f941021636b1182761Sol Boucher 133a0842b40441db5332a5290f941021636b1182761Sol Boucher private void buildFocusModes(CameraCharacteristics p) { 134de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher int[] focuses = p.get(CONTROL_AF_AVAILABLE_MODES); 135de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher if (focuses != null) { 136de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher for (int focus : focuses) { 137de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher FocusMode equiv = focusModeFromInt(focus); 138de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher if (equiv != null) { 139de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher mSupportedFocusModes.add(equiv); 140de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher } 141a0842b40441db5332a5290f941021636b1182761Sol Boucher } 142a0842b40441db5332a5290f941021636b1182761Sol Boucher } 143a0842b40441db5332a5290f941021636b1182761Sol Boucher } 144a0842b40441db5332a5290f941021636b1182761Sol Boucher 145a0842b40441db5332a5290f941021636b1182761Sol Boucher private void buildWhiteBalances(CameraCharacteristics p) { 146de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher int[] bals = p.get(CONTROL_AWB_AVAILABLE_MODES); 147de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher if (bals != null) { 148de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher for (int bal : bals) { 149de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher WhiteBalance equiv = whiteBalanceFromInt(bal); 150de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher if (equiv != null) { 151de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher mSupportedWhiteBalances.add(equiv); 152de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher } 153a0842b40441db5332a5290f941021636b1182761Sol Boucher } 154a0842b40441db5332a5290f941021636b1182761Sol Boucher } 155a0842b40441db5332a5290f941021636b1182761Sol Boucher } 156a0842b40441db5332a5290f941021636b1182761Sol Boucher 157de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher /** 158de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * Converts the API-related integer representation of the focus mode to the 159de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * abstract representation. 160de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * 161de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * @param fm The integral representation. 162de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * @return The mode represented by the input integer, or {@code null} if it 163de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * cannot be converted. 164de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher */ 165de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher public static FocusMode focusModeFromInt(int fm) { 166de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher switch (fm) { 167de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_AF_MODE_AUTO: 168de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return FocusMode.AUTO; 169de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_AF_MODE_CONTINUOUS_PICTURE: 170de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return FocusMode.CONTINUOUS_PICTURE; 171de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_AF_MODE_CONTINUOUS_VIDEO: 172de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return FocusMode.CONTINUOUS_VIDEO; 173de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_AF_MODE_EDOF: 174de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return FocusMode.EXTENDED_DOF; 175de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_AF_MODE_OFF: 176de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return FocusMode.FIXED; 177de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher // TODO: We cannot support INFINITY 178de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_AF_MODE_MACRO: 179de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return FocusMode.MACRO; 180a0842b40441db5332a5290f941021636b1182761Sol Boucher } 181de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher Log.w(TAG, "Unable to convert from API 2 focus mode: " + fm); 182de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return null; 183de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher } 184a0842b40441db5332a5290f941021636b1182761Sol Boucher 185de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher /** 186de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * Converts the API-related integer representation of the scene mode to the 187de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * abstract representation. 188de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * 189de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * @param sm The integral representation. 190de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * @return The mode represented by the input integer, or {@code null} if it 191de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * cannot be converted. 192de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher */ 193de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher public static SceneMode sceneModeFromInt(int sm) { 194de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher switch (sm) { 195de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_SCENE_MODE_DISABLED: 196de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return SceneMode.AUTO; 197de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_SCENE_MODE_ACTION: 198de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return SceneMode.ACTION; 199de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_SCENE_MODE_BARCODE: 200de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return SceneMode.BARCODE; 201de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_SCENE_MODE_BEACH: 202de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return SceneMode.BEACH; 203de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_SCENE_MODE_CANDLELIGHT: 204de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return SceneMode.CANDLELIGHT; 205de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_SCENE_MODE_FIREWORKS: 206de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return SceneMode.FIREWORKS; 207de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_SCENE_MODE_LANDSCAPE: 208de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return SceneMode.LANDSCAPE; 209de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_SCENE_MODE_NIGHT: 210de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return SceneMode.NIGHT; 211de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher // TODO: We cannot support NIGHT_PORTRAIT 212de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_SCENE_MODE_PARTY: 213de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return SceneMode.PARTY; 214de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_SCENE_MODE_PORTRAIT: 215de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return SceneMode.PORTRAIT; 216de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_SCENE_MODE_SNOW: 217de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return SceneMode.SNOW; 218de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_SCENE_MODE_SPORTS: 219de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return SceneMode.SPORTS; 220de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_SCENE_MODE_STEADYPHOTO: 221de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return SceneMode.STEADYPHOTO; 222de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_SCENE_MODE_SUNSET: 223de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return SceneMode.SUNSET; 224de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_SCENE_MODE_THEATRE: 225de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return SceneMode.THEATRE; 226de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher // TODO: We cannot expose FACE_PRIORITY, or HIGH_SPEED_VIDEO 227a0842b40441db5332a5290f941021636b1182761Sol Boucher } 22854c8f898815a233ba6478630940432ddafdb4314Ruben Brunk 22954c8f898815a233ba6478630940432ddafdb4314Ruben Brunk if (sm == LegacyVendorTags.CONTROL_SCENE_MODE_HDR) { 23054c8f898815a233ba6478630940432ddafdb4314Ruben Brunk return SceneMode.HDR; 23154c8f898815a233ba6478630940432ddafdb4314Ruben Brunk } 23254c8f898815a233ba6478630940432ddafdb4314Ruben Brunk 233de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher Log.w(TAG, "Unable to convert from API 2 scene mode: " + sm); 234de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return null; 235de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher } 236a0842b40441db5332a5290f941021636b1182761Sol Boucher 237de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher /** 238de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * Converts the API-related integer representation of the white balance to 239de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * the abstract representation. 240de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * 241de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * @param wb The integral representation. 242de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * @return The balance represented by the input integer, or {@code null} if 243de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher * it cannot be converted. 244de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher */ 245de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher public static WhiteBalance whiteBalanceFromInt(int wb) { 246de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher switch (wb) { 247de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_AWB_MODE_AUTO: 248de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return WhiteBalance.AUTO; 249de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_AWB_MODE_CLOUDY_DAYLIGHT: 250de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return WhiteBalance.CLOUDY_DAYLIGHT; 251de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_AWB_MODE_DAYLIGHT: 252de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return WhiteBalance.DAYLIGHT; 253de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_AWB_MODE_FLUORESCENT: 254de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return WhiteBalance.FLUORESCENT; 255de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_AWB_MODE_INCANDESCENT: 256de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return WhiteBalance.INCANDESCENT; 257de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_AWB_MODE_SHADE: 258de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return WhiteBalance.SHADE; 259de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_AWB_MODE_TWILIGHT: 260de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return WhiteBalance.TWILIGHT; 261de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher case CONTROL_AWB_MODE_WARM_FLUORESCENT: 262de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return WhiteBalance.WARM_FLUORESCENT; 263a0842b40441db5332a5290f941021636b1182761Sol Boucher } 264de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher Log.w(TAG, "Unable to convert from API 2 white balance: " + wb); 265de48004068f8c16f9a56c60b0ed2485a67687b4bSol Boucher return null; 266a0842b40441db5332a5290f941021636b1182761Sol Boucher } 267a0842b40441db5332a5290f941021636b1182761Sol Boucher} 268