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