• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.hardware.common.fmq.MQDescriptor;
27 import android.hardware.common.fmq.SynchronizedReadWrite;
28 import android.view.Surface;
29 
30 /** @hide */
31 interface ICameraDeviceUser
32 {
disconnect()33     void disconnect();
34 
35     const int NO_IN_FLIGHT_REPEATING_FRAMES = -1;
36 
submitRequest(in CaptureRequest request, boolean streaming)37     SubmitInfo submitRequest(in CaptureRequest request, boolean streaming);
submitRequestList(in CaptureRequest[] requestList, boolean streaming)38     SubmitInfo submitRequestList(in CaptureRequest[] requestList, boolean streaming);
39     /**
40      * When a camera device is opened in shared mode, only the primary client can change capture
41      * parameters and submit capture requests. Secondary clients can use the startStreaming API to
42      * provide the stream and surface IDs they want to stream on. If the primary client has an
43      * ongoing repeating request, camera service will attach these surfaces to it. Otherwise,
44      * camera service will create a default capture request with a preview template.
45      *
46      * @param streamIdxArray stream ids of the target surfaces
47      * @param surfaceIdxArray surface ids of the target surfaces
48      * @return SubmitInfo data structure containing the request id of the capture request and the
49      *         frame number of the last request, of the previous batch of repeating requests, if
50      *         any. If there is no previous  batch, the frame number returned will be -1.
51      */
startStreaming(in int[] streamIdxArray, in int[] surfaceIdxArray)52     SubmitInfo startStreaming(in int[] streamIdxArray, in int[] surfaceIdxArray);
53 
54     /**
55      * Cancel the repeating request specified by requestId
56      * Returns the frame number of the last frame that will be produced from this
57      * repeating request, or NO_IN_FLIGHT_REPEATING_FRAMES if no frames were produced
58      * by this repeating request.
59      *
60      * Repeating request may be stopped by camera device due to an error. Canceling a stopped
61      * repeating request will trigger ERROR_ILLEGAL_ARGUMENT.
62      */
cancelRequest(int requestId)63     long cancelRequest(int requestId);
64 
65     /**
66      * Begin the device configuration.
67      *
68      * <p>
69      * beginConfigure must be called before any call to deleteStream, createStream,
70      * or endConfigure.  It is not valid to call this when the device is not idle.
71      * <p>
72      */
beginConfigure()73     void beginConfigure();
74 
75     /**
76      * The standard operating mode for a camera device; all API guarantees are in force
77      */
78     const int NORMAL_MODE = 0;
79 
80     /**
81      * High-speed recording mode; only two outputs targeting preview and video recording may be
82      * used, and requests must be batched.
83      */
84     const int CONSTRAINED_HIGH_SPEED_MODE = 1;
85 
86     /**
87      * The shared operating mode for a camera device.
88      *
89      * <p>
90      * When in shared mode, the camera device can be opened and accessed by multiple applications
91      * simultaneously.
92      * </p>
93      *
94      */
95     const int SHARED_MODE = 2;
96 
97     /**
98      * Start of custom vendor modes
99      */
100     const int VENDOR_MODE_START = 0x8000;
101 
102     /**
103      * End the device configuration.
104      *
105      * <p>
106      * endConfigure must be called after stream configuration is complete (i.e. after
107      * a call to beginConfigure and subsequent createStream/deleteStream calls).  This
108      * must be called before any requests can be submitted.
109      * <p>
110      * @param operatingMode The kind of session to create; either NORMAL_MODE or
111      *     CONSTRAINED_HIGH_SPEED_MODE. Must be a non-negative value.
112      * @param sessionParams Session wide camera parameters
113      * @param startTimeMs The timestamp of session creation start, measured by
114      *                    SystemClock.uptimeMillis.
115      * @return a list of stream ids that can be used in offline mode via "switchToOffline"
116      */
endConfigure(int operatingMode, in CameraMetadataNative sessionParams, long startTimeMs)117     int[] endConfigure(int operatingMode, in CameraMetadataNative sessionParams, long startTimeMs);
118 
119     /**
120       * Check whether a particular session configuration has camera device
121       * support.
122       *
123       * @param sessionConfiguration Specific session configuration to be verified.
124       * @return true  - in case the stream combination is supported.
125       *         false - in case there is no device support.
126       */
isSessionConfigurationSupported(in SessionConfiguration sessionConfiguration)127     boolean isSessionConfigurationSupported(in SessionConfiguration sessionConfiguration);
128 
deleteStream(int streamId)129     void deleteStream(int streamId);
130 
131     /**
132      * Create an output stream
133      *
134      * <p>Create an output stream based on the given output configuration</p>
135      *
136      * @param outputConfiguration size, format, and other parameters for the stream
137      * @return new stream ID
138      */
createStream(in OutputConfiguration outputConfiguration)139     int createStream(in OutputConfiguration outputConfiguration);
140 
141     /**
142      * Create an input stream
143      *
144      * <p>Create an input stream of width, height, and format</p>
145      *
146      * @param width Width of the input buffers
147      * @param height Height of the input buffers
148      * @param format Format of the input buffers. One of HAL_PIXEL_FORMAT_*.
149      * @param isMultiResolution Whether the input stream supports variable resolution image.
150      *
151      * @return new stream ID
152      */
createInputStream(int width, int height, int format, boolean isMultiResolution)153     int createInputStream(int width, int height, int format, boolean isMultiResolution);
154 
155     /**
156      * Get the surface of the input stream.
157      *
158      * <p>It's valid to call this method only after a stream configuration is completed
159      * successfully and the stream configuration includes a input stream.</p>
160      *
161      * @param surface An output argument for the surface of the input stream buffer queue.
162      */
getInputSurface()163     Surface getInputSurface();
164 
165     // Keep in sync with public API in
166     // frameworks/base/core/java/android/hardware/camera2/CameraDevice.java
167     const int TEMPLATE_PREVIEW = 1;
168     const int TEMPLATE_STILL_CAPTURE = 2;
169     const int TEMPLATE_RECORD = 3;
170     const int TEMPLATE_VIDEO_SNAPSHOT = 4;
171     const int TEMPLATE_ZERO_SHUTTER_LAG = 5;
172     const int TEMPLATE_MANUAL = 6;
173 
createDefaultRequest(int templateId)174     CameraMetadataNative createDefaultRequest(int templateId);
175 
getCameraInfo()176     CameraMetadataNative getCameraInfo();
177 
waitUntilIdle()178     void waitUntilIdle();
179 
flush()180     long flush();
181 
prepare(int streamId)182     void prepare(int streamId);
183 
tearDown(int streamId)184     void tearDown(int streamId);
185 
prepare2(int maxCount, int streamId)186     void prepare2(int maxCount, int streamId);
187 
updateOutputConfiguration(int streamId, in OutputConfiguration outputConfiguration)188     void updateOutputConfiguration(int streamId, in OutputConfiguration outputConfiguration);
189 
finalizeOutputConfigurations(int streamId, in OutputConfiguration outputConfiguration)190     void finalizeOutputConfigurations(int streamId, in OutputConfiguration outputConfiguration);
191 
getCaptureResultMetadataQueue()192     MQDescriptor<byte, SynchronizedReadWrite> getCaptureResultMetadataQueue();
193 
194     // Keep in sync with public API in
195     // frameworks/base/core/java/android/hardware/camera2/CameraDevice.java
196     const int AUDIO_RESTRICTION_NONE = 0;
197     const int AUDIO_RESTRICTION_VIBRATION = 1;
198     const int AUDIO_RESTRICTION_VIBRATION_SOUND = 3;
199 
200     /**
201       * Set audio restriction mode for this camera device.
202       *
203       * @param mode the audio restriction mode ID as above
204       *
205       */
setCameraAudioRestriction(int mode)206     void setCameraAudioRestriction(int mode);
207 
208     /**
209       * Get global audio restriction mode for all camera clients.
210       *
211       * @return the currently applied system-wide audio restriction mode
212       */
getGlobalAudioRestriction()213     int getGlobalAudioRestriction();
214 
215     /**
216      * Offline processing main entry point
217      *
218      * @param callbacks Object that will receive callbacks from offline session
219      * @param offlineOutputIds The ID of streams that needs to be preserved in offline session
220      *
221      * @return Offline session object.
222      */
switchToOffline(in ICameraDeviceCallbacks callbacks, in int[] offlineOutputIds)223     ICameraOfflineSession switchToOffline(in ICameraDeviceCallbacks callbacks,
224             in int[] offlineOutputIds);
225 
226     /**
227      * Get the client status as primary or secondary when camera is opened in shared mode.
228      *
229      * @return true if this is primary client when camera is opened in shared mode.
230      *         false if another higher priority client with primary access is also using the camera.
231      */
isPrimaryClient()232     boolean isPrimaryClient();
233 }
234