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 android.hardware.camera2; 18 19 import android.hardware.camera2.CaptureRequest; 20 import android.hardware.camera2.ICameraDeviceCallbacks; 21 import android.hardware.camera2.ICameraOfflineSession; 22 import android.hardware.camera2.impl.CameraMetadataNative; 23 import android.hardware.camera2.params.OutputConfiguration; 24 import android.hardware.camera2.params.SessionConfiguration; 25 import android.hardware.camera2.utils.SubmitInfo; 26 import android.view.Surface; 27 28 /** @hide */ 29 interface ICameraDeviceUser 30 { disconnect()31 void disconnect(); 32 33 const int NO_IN_FLIGHT_REPEATING_FRAMES = -1; 34 submitRequest(in CaptureRequest request, boolean streaming)35 SubmitInfo submitRequest(in CaptureRequest request, boolean streaming); submitRequestList(in CaptureRequest[] requestList, boolean streaming)36 SubmitInfo submitRequestList(in CaptureRequest[] requestList, boolean streaming); 37 38 /** 39 * Cancel the repeating request specified by requestId 40 * Returns the frame number of the last frame that will be produced from this 41 * repeating request, or NO_IN_FLIGHT_REPEATING_FRAMES if no frames were produced 42 * by this repeating request. 43 * 44 * Repeating request may be stopped by camera device due to an error. Canceling a stopped 45 * repeating request will trigger ERROR_ILLEGAL_ARGUMENT. 46 */ cancelRequest(int requestId)47 long cancelRequest(int requestId); 48 49 /** 50 * Begin the device configuration. 51 * 52 * <p> 53 * beginConfigure must be called before any call to deleteStream, createStream, 54 * or endConfigure. It is not valid to call this when the device is not idle. 55 * <p> 56 */ beginConfigure()57 void beginConfigure(); 58 59 /** 60 * The standard operating mode for a camera device; all API guarantees are in force 61 */ 62 const int NORMAL_MODE = 0; 63 64 /** 65 * High-speed recording mode; only two outputs targeting preview and video recording may be 66 * used, and requests must be batched. 67 */ 68 const int CONSTRAINED_HIGH_SPEED_MODE = 1; 69 70 /** 71 * Start of custom vendor modes 72 */ 73 const int VENDOR_MODE_START = 0x8000; 74 75 /** 76 * End the device configuration. 77 * 78 * <p> 79 * endConfigure must be called after stream configuration is complete (i.e. after 80 * a call to beginConfigure and subsequent createStream/deleteStream calls). This 81 * must be called before any requests can be submitted. 82 * <p> 83 * @param operatingMode The kind of session to create; either NORMAL_MODE or 84 * CONSTRAINED_HIGH_SPEED_MODE. Must be a non-negative value. 85 * @param sessionParams Session wide camera parameters 86 * @return a list of stream ids that can be used in offline mode via "switchToOffline" 87 */ endConfigure(int operatingMode, in CameraMetadataNative sessionParams)88 int[] endConfigure(int operatingMode, in CameraMetadataNative sessionParams); 89 90 /** 91 * Check whether a particular session configuration has camera device 92 * support. 93 * 94 * @param sessionConfiguration Specific session configuration to be verified. 95 * @return true - in case the stream combination is supported. 96 * false - in case there is no device support. 97 */ isSessionConfigurationSupported(in SessionConfiguration sessionConfiguration)98 boolean isSessionConfigurationSupported(in SessionConfiguration sessionConfiguration); 99 deleteStream(int streamId)100 void deleteStream(int streamId); 101 102 /** 103 * Create an output stream 104 * 105 * <p>Create an output stream based on the given output configuration</p> 106 * 107 * @param outputConfiguration size, format, and other parameters for the stream 108 * @return new stream ID 109 */ createStream(in OutputConfiguration outputConfiguration)110 int createStream(in OutputConfiguration outputConfiguration); 111 112 /** 113 * Create an input stream 114 * 115 * <p>Create an input stream of width, height, and format</p> 116 * 117 * @param width Width of the input buffers 118 * @param height Height of the input buffers 119 * @param format Format of the input buffers. One of HAL_PIXEL_FORMAT_*. 120 * 121 * @return new stream ID 122 */ createInputStream(int width, int height, int format)123 int createInputStream(int width, int height, int format); 124 125 /** 126 * Get the surface of the input stream. 127 * 128 * <p>It's valid to call this method only after a stream configuration is completed 129 * successfully and the stream configuration includes a input stream.</p> 130 * 131 * @param surface An output argument for the surface of the input stream buffer queue. 132 */ getInputSurface()133 Surface getInputSurface(); 134 135 // Keep in sync with public API in 136 // frameworks/base/core/java/android/hardware/camera2/CameraDevice.java 137 const int TEMPLATE_PREVIEW = 1; 138 const int TEMPLATE_STILL_CAPTURE = 2; 139 const int TEMPLATE_RECORD = 3; 140 const int TEMPLATE_VIDEO_SNAPSHOT = 4; 141 const int TEMPLATE_ZERO_SHUTTER_LAG = 5; 142 const int TEMPLATE_MANUAL = 6; 143 createDefaultRequest(int templateId)144 CameraMetadataNative createDefaultRequest(int templateId); 145 getCameraInfo()146 CameraMetadataNative getCameraInfo(); 147 waitUntilIdle()148 void waitUntilIdle(); 149 flush()150 long flush(); 151 prepare(int streamId)152 void prepare(int streamId); 153 tearDown(int streamId)154 void tearDown(int streamId); 155 prepare2(int maxCount, int streamId)156 void prepare2(int maxCount, int streamId); 157 updateOutputConfiguration(int streamId, in OutputConfiguration outputConfiguration)158 void updateOutputConfiguration(int streamId, in OutputConfiguration outputConfiguration); 159 finalizeOutputConfigurations(int streamId, in OutputConfiguration outputConfiguration)160 void finalizeOutputConfigurations(int streamId, in OutputConfiguration outputConfiguration); 161 162 163 // Keep in sync with public API in 164 // frameworks/base/core/java/android/hardware/camera2/CameraDevice.java 165 const int AUDIO_RESTRICTION_NONE = 0; 166 const int AUDIO_RESTRICTION_VIBRATION = 1; 167 const int AUDIO_RESTRICTION_VIBRATION_SOUND = 3; 168 169 /** 170 * Set audio restriction mode for this camera device. 171 * 172 * @param mode the audio restriction mode ID as above 173 * 174 */ setCameraAudioRestriction(int mode)175 void setCameraAudioRestriction(int mode); 176 177 /** 178 * Get global audio restriction mode for all camera clients. 179 * 180 * @return the currently applied system-wide audio restriction mode 181 */ getGlobalAudioRestriction()182 int getGlobalAudioRestriction(); 183 184 /** 185 * Offline processing main entry point 186 * 187 * @param callbacks Object that will receive callbacks from offline session 188 * @param offlineOutputIds The ID of streams that needs to be preserved in offline session 189 * 190 * @return Offline session object. 191 */ switchToOffline(in ICameraDeviceCallbacks callbacks, in int[] offlineOutputIds)192 ICameraOfflineSession switchToOffline(in ICameraDeviceCallbacks callbacks, 193 in int[] offlineOutputIds); 194 } 195