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 
17 package com.android.camera.one.v2.initialization;
18 
19 import android.view.Surface;
20 
21 import com.android.camera.async.Lifetime;
22 import com.android.camera.async.Observable;
23 import com.android.camera.async.Updatable;
24 import com.android.camera.one.v2.autofocus.ManualAutoFocus;
25 import com.android.camera.one.v2.camera2proxy.CameraCaptureSessionProxy;
26 import com.android.camera.one.v2.camera2proxy.TotalCaptureResultProxy;
27 import com.android.camera.one.v2.photo.PictureTaker;
28 
29 /**
30  * Starts a camera after initialization (e.g. of the preview Surface and
31  * CameraCaptureSession) is already done.
32  * <p>
33  * Device-specific features should typically be wired together here.
34  */
35 public interface CameraStarter {
36     public static class CameraControls {
37         private final PictureTaker mPictureTaker;
38         private final ManualAutoFocus mManualAutoFocus;
39 
CameraControls(PictureTaker pictureTaker, ManualAutoFocus manualAutoFocus)40         public CameraControls(PictureTaker pictureTaker, ManualAutoFocus manualAutoFocus) {
41             mPictureTaker = pictureTaker;
42             mManualAutoFocus = manualAutoFocus;
43         }
44 
getPictureTaker()45         public PictureTaker getPictureTaker() {
46             return mPictureTaker;
47         }
48 
getManualAutoFocus()49         public ManualAutoFocus getManualAutoFocus() {
50             return mManualAutoFocus;
51         }
52     }
53 
54     /**
55      * Implementations should start a preview and return controls for taking
56      * pictures and triggering focus.
57      * <p>
58      * They should also react to changes to zoom and invoke callbacks for the
59      * auto focus state, ready state, and preview-start success state.
60      *
61      * @param cameraLifetime The lifetime of all resources to be created.
62      */
startCamera( Lifetime cameraLifetime, CameraCaptureSessionProxy cameraCaptureSession, Surface previewSurface, Observable<Float> zoomState, Updatable<TotalCaptureResultProxy> metadataCallback, Updatable<Boolean> readyStateCallback)63     public CameraControls startCamera(
64             Lifetime cameraLifetime,
65             CameraCaptureSessionProxy cameraCaptureSession,
66             Surface previewSurface,
67             Observable<Float> zoomState,
68             Updatable<TotalCaptureResultProxy> metadataCallback,
69             Updatable<Boolean> readyStateCallback);
70 }
71