CameraProvider.java revision 1d84d7107686aa428ee2eeb1a8caf0ea3e43b1df
1/*
2 * Copyright (C) 2013 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.camera.app;
18
19import com.android.camera.device.CameraId;
20import com.android.ex.camera2.portability.CameraDeviceInfo.Characteristics;
21import com.android.ex.camera2.portability.CameraExceptionHandler;
22
23/**
24 * An interface which defines the camera provider.
25 */
26public interface CameraProvider {
27
28    /**
29     * Requests the camera device. If the camera device of the same ID is
30     * already requested, then no-op here.
31     *
32     * @param id The ID of the requested camera device.
33     */
34    public void requestCamera(int id);
35
36    /**
37     * Requests the camera device. If the camera device of the same ID is
38     * already requested, then no-op here.
39     *
40     * @param id The ID of the requested camera device.
41     * @param useNewApi Whether to use the new API if this platform provides it.
42     */
43    public void requestCamera(int id, boolean useNewApi);
44
45    public boolean waitingForCamera();
46
47    /**
48     * Releases the camera device.
49     *
50     * @param id The camera ID.
51     */
52    public void releaseCamera(int id);
53
54    /**
55     * Sets a callback for handling camera api runtime exceptions on
56     * a handler.
57     */
58    public void setCameraExceptionHandler(CameraExceptionHandler exceptionHandler);
59
60    /**
61     * Get the {@link Characteristics} of the given camera.
62     *
63     * @param cameraId Which camera.
64     * @return The static characteristics of that camera.
65     */
66    public Characteristics getCharacteristics(int cameraId);
67
68    /**
69     * @returns The current camera id.
70     */
71    public CameraId getCurrentCameraId();
72
73    /**
74     * Returns the total number of cameras available on the device.
75     */
76    public int getNumberOfCameras();
77
78    /**
79     * @returns The lowest ID of the back camera or -1 if not available.
80     */
81    public int getFirstBackCameraId();
82
83    /**
84     * @return The lowest ID of the front camera or -1 if not available.
85     */
86    public int getFirstFrontCameraId();
87
88    /**
89     * @returns Whether the camera is facing front.
90     */
91    public boolean isFrontFacingCamera(int id);
92
93    /**
94     * @returns Whether the camera is facing back.
95     */
96    public boolean isBackFacingCamera(int id);
97}
98