• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.camera.one;
18 
19 import com.android.camera.async.Observable;
20 import com.android.camera.async.Observables;
21 import com.android.camera.device.CameraId;
22 import com.android.camera.hardware.HardwareSpec;
23 import com.android.camera.one.OneCamera.Facing;
24 import com.android.camera.settings.Keys;
25 import com.android.camera.settings.ResolutionSetting;
26 import com.android.camera.settings.SettingObserver;
27 import com.android.camera.settings.SettingsManager;
28 import com.android.camera.util.Size;
29 import com.google.common.base.Function;
30 
31 /**
32  * Contains related settings to configure a camera for a particular type of
33  * capture.
34  */
35 public class OneCameraCaptureSetting {
36     private final Size mCaptureSize;
37     private final Observable<OneCamera.PhotoCaptureParameters.Flash> mFlashSetting;
38     private final Observable<Integer> mExposureSetting;
39     private final Observable<Boolean> mHdrSceneSetting;
40     private final boolean mIsHdrPlusEnabled;
41 
create( Size pictureSize, SettingsManager settingsManager, final HardwareSpec hardwareSpec, String cameraSettingScope, boolean isHdrPlusEnabled)42     public static OneCameraCaptureSetting create(
43             Size pictureSize,
44             SettingsManager settingsManager,
45             final HardwareSpec hardwareSpec,
46             String cameraSettingScope,
47             boolean isHdrPlusEnabled) {
48         Observable<OneCamera.PhotoCaptureParameters.Flash> flashSetting;
49         if (hardwareSpec.isFlashSupported()) {
50             flashSetting = new FlashSetting(SettingObserver.ofString(
51                         settingsManager, cameraSettingScope, Keys.KEY_FLASH_MODE));
52         } else {
53             flashSetting = new FlashSetting(Observables.of("off"));
54         }
55         Observable<Integer> exposureSetting = SettingObserver.ofInteger(
56                 settingsManager, cameraSettingScope, Keys.KEY_EXPOSURE);
57         Observable<Boolean> hdrSceneSetting;
58         if (hardwareSpec.isHdrSupported()) {
59             hdrSceneSetting = SettingObserver.ofBoolean(settingsManager,
60                     SettingsManager.SCOPE_GLOBAL, Keys.KEY_CAMERA_HDR);
61         } else {
62             hdrSceneSetting = Observables.of(false);
63         }
64         return new OneCameraCaptureSetting(
65                 pictureSize,
66                 flashSetting,
67                 exposureSetting,
68                 hdrSceneSetting,
69                 isHdrPlusEnabled);
70     }
71 
OneCameraCaptureSetting( Size captureSize, Observable<OneCamera.PhotoCaptureParameters.Flash> flashSetting, Observable<Integer> exposureSetting, Observable<Boolean> hdrSceneSetting, boolean isHdrPlusEnabled)72     private OneCameraCaptureSetting(
73             Size captureSize,
74             Observable<OneCamera.PhotoCaptureParameters.Flash> flashSetting,
75             Observable<Integer> exposureSetting,
76             Observable<Boolean> hdrSceneSetting,
77             boolean isHdrPlusEnabled) {
78         mCaptureSize = captureSize;
79         mFlashSetting = flashSetting;
80         mExposureSetting = exposureSetting;
81         mHdrSceneSetting = hdrSceneSetting;
82         mIsHdrPlusEnabled = isHdrPlusEnabled;
83     }
84 
getCaptureSize()85     public Size getCaptureSize() {
86         return mCaptureSize;
87     }
88 
getFlashSetting()89     public Observable<OneCamera.PhotoCaptureParameters.Flash> getFlashSetting() {
90         return mFlashSetting;
91     }
92 
getExposureSetting()93     public Observable<Integer> getExposureSetting() {
94         return mExposureSetting;
95     }
96 
getHdrSceneSetting()97     public Observable<Boolean> getHdrSceneSetting() {
98         return mHdrSceneSetting;
99     }
100 
isHdrPlusEnabled()101     public boolean isHdrPlusEnabled() {
102         return mIsHdrPlusEnabled;
103     }
104 }
105