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