AndroidCamera2Settings.java revision a0842b40441db5332a5290f941021636b1182761
1/*
2 * Copyright (C) 2014 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
17package com.android.ex.camera2.portability;
18
19import android.hardware.camera2.CaptureRequest;
20
21/**
22 * The subclass of {@link CameraSettings} for Android Camera 2 API.
23 */
24public class AndroidCamera2Settings extends CameraSettings {
25    // TODO: Implement more completely
26    public AndroidCamera2Settings(AndroidCamera2Capabilities capabilities,
27                                  CaptureRequest.Builder request,
28                                  Size preview, Size photo) {
29        // TODO: Support zoom
30        setZoomRatio(1.0f);
31        setZoomIndex(0);
32
33        // TODO: Set exposure compensation
34
35        AndroidCamera2Capabilities.IntegralStringifier stringifier =
36                capabilities.getIntegralStringifier();
37        setFocusMode(stringifier.focusModeFromInt(request.get(CaptureRequest.CONTROL_AF_MODE)));
38        setFlashMode(stringifier.flashModeFromInt(request.get(CaptureRequest.FLASH_MODE)));
39        setSceneMode(stringifier.sceneModeFromInt(request.get(CaptureRequest.CONTROL_SCENE_MODE)));
40
41        // This is mutability-safe because those setters copy the Size objects
42        setPreviewSize(preview);
43        setPhotoSize(photo);
44
45        // TODO: Initialize formats, too
46    }
47}
48