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