blob: 89a2af828330633d3dbeef88d2210e996d92dbd7 [file] [log] [blame]
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -08001/*
Shuzhen Wangc28189a2017-11-27 23:05:10 -08002 * Copyright (C) 2013-2018 The Android Open Source Project
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -08003 *
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#ifndef ANDROID_SERVERS_CAMERA_CAMERADEVICEBASE_H
18#define ANDROID_SERVERS_CAMERA_CAMERADEVICEBASE_H
19
Shuzhen Wang0129d522016-10-30 22:43:41 -070020#include <list>
21
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -080022#include <utils/RefBase.h>
23#include <utils/String8.h>
24#include <utils/String16.h>
25#include <utils/Vector.h>
Emilian Peev40ead602017-09-26 15:46:36 +010026#include <utils/KeyedVector.h>
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -080027#include <utils/Timers.h>
Jianing Wei90e59c92014-03-12 18:29:36 -070028#include <utils/List.h>
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -080029
30#include "hardware/camera2.h"
31#include "camera/CameraMetadata.h"
Jianing Weicb0652e2014-03-12 18:29:36 -070032#include "camera/CaptureResult.h"
Chien-Yu Chen618ff8a2015-03-13 11:27:17 -070033#include "gui/IGraphicBufferProducer.h"
Zhijun He125684a2015-12-26 15:07:30 -080034#include "device3/Camera3StreamInterface.h"
Shuzhen Wange8675782019-12-05 09:12:14 -080035#include "device3/StatusTracker.h"
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080036#include "binder/Status.h"
Emilian Peevfaa4bde2020-01-23 12:19:37 -080037#include "FrameProducer.h"
Jayant Chowdharyc67af1b2022-04-07 18:05:04 +000038#include "utils/IPCTransport.h"
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -080039
Yin-Chia Yehb978c382019-10-30 00:22:37 -070040#include "CameraOfflineSessionBase.h"
41
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -080042namespace android {
43
Emilian Peevf4816702020-04-03 15:44:51 -070044namespace camera3 {
45
46typedef enum camera_request_template {
47 CAMERA_TEMPLATE_PREVIEW = 1,
48 CAMERA_TEMPLATE_STILL_CAPTURE = 2,
49 CAMERA_TEMPLATE_VIDEO_RECORD = 3,
50 CAMERA_TEMPLATE_VIDEO_SNAPSHOT = 4,
51 CAMERA_TEMPLATE_ZERO_SHUTTER_LAG = 5,
52 CAMERA_TEMPLATE_MANUAL = 6,
53 CAMERA_TEMPLATE_COUNT,
54 CAMERA_VENDOR_TEMPLATE_START = 0x40000000
55} camera_request_template_t;
56
57typedef enum camera_stream_configuration_mode {
58 CAMERA_STREAM_CONFIGURATION_NORMAL_MODE = 0,
59 CAMERA_STREAM_CONFIGURATION_CONSTRAINED_HIGH_SPEED_MODE = 1,
60 CAMERA_VENDOR_STREAM_CONFIGURATION_MODE_START = 0x8000
61} camera_stream_configuration_mode_t;
62
Jayant Chowdharyc67af1b2022-04-07 18:05:04 +000063// Matches definition of camera3_jpeg_blob in camera3.h and HIDL definition
64// device@3.2:types.hal, needs to stay around till HIDL support is removed (for
65// HIDL -> AIDL cameraBlob translation)
Emilian Peevf4816702020-04-03 15:44:51 -070066typedef struct camera_jpeg_blob {
67 uint16_t jpeg_blob_id;
68 uint32_t jpeg_size;
69} camera_jpeg_blob_t;
70
71enum {
72 CAMERA_JPEG_BLOB_ID = 0x00FF,
73 CAMERA_JPEG_APP_SEGMENTS_BLOB_ID = 0x0100,
74};
75
76} // namespace camera3
77
78using camera3::camera_request_template_t;;
79using camera3::camera_stream_configuration_mode_t;
80using camera3::camera_stream_rotation_t;
81
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -080082class CameraProviderManager;
83
Shuzhen Wang0129d522016-10-30 22:43:41 -070084// Mapping of output stream index to surface ids
85typedef std::unordered_map<int, std::vector<size_t> > SurfaceMap;
86
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -080087/**
88 * Base interface for version >= 2 camera device classes, which interface to
89 * camera HAL device versions >= 2.
90 */
Emilian Peevfaa4bde2020-01-23 12:19:37 -080091class CameraDeviceBase : public virtual FrameProducer {
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -080092 public:
93 virtual ~CameraDeviceBase();
94
Jayant Chowdharyc67af1b2022-04-07 18:05:04 +000095 virtual IPCTransport getTransportType() const = 0;
96
Igor Murashkin71381052013-03-04 14:53:08 -080097 /**
Emilian Peev00420d22018-02-05 21:33:13 +000098 * The device vendor tag ID
99 */
100 virtual metadata_vendor_id_t getVendorTagId() const = 0;
101
Emilian Peevbd8c5032018-02-14 23:05:40 +0000102 virtual status_t initialize(sp<CameraProviderManager> manager, const String8& monitorTags) = 0;
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800103 virtual status_t disconnect() = 0;
104
Jianing Weicb0652e2014-03-12 18:29:36 -0700105 virtual status_t dump(int fd, const Vector<String16> &args) = 0;
Avichal Rakesh7e53cad2021-10-05 13:46:30 -0700106 virtual status_t startWatchingTags(const String8 &tags) = 0;
107 virtual status_t stopWatchingTags() = 0;
108 virtual status_t dumpWatchedEventsToVector(std::vector<std::string> &out) = 0;
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800109
110 /**
Jayant Chowdhary6a6d3a82021-11-17 16:54:34 -0800111 * The physical camera device's static characteristics metadata buffer, or
112 * the logical camera's static characteristics if physical id is empty.
Shuzhen Wang2e7f58f2018-07-11 14:00:29 -0700113 */
Emilian Peevfaa4bde2020-01-23 12:19:37 -0800114 virtual const CameraMetadata& infoPhysical(const String8& physicalId) const = 0;
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800115
Emilian Peevaebbe412018-01-15 13:53:24 +0000116 struct PhysicalCameraSettings {
117 std::string cameraId;
118 CameraMetadata metadata;
Shuzhen Wang911c6a32021-10-27 13:36:03 -0700119
120 // Whether the physical camera supports testPatternMode/testPatternData
121 bool mHasTestPatternModeTag = true;
122 bool mHasTestPatternDataTag = true;
123
124 // Original value of TEST_PATTERN_MODE and DATA so that they can be
125 // restored when sensor muting is turned off
126 int32_t mOriginalTestPatternMode = 0;
127 int32_t mOriginalTestPatternData[4] = {};
128
Emilian Peevaebbe412018-01-15 13:53:24 +0000129 };
130 typedef List<PhysicalCameraSettings> PhysicalCameraSettingsList;
131
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800132 /**
133 * Submit request for capture. The CameraDevice takes ownership of the
134 * passed-in buffer.
Jianing Weicb0652e2014-03-12 18:29:36 -0700135 * Output lastFrameNumber is the expected frame number of this request.
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800136 */
Jianing Weicb0652e2014-03-12 18:29:36 -0700137 virtual status_t capture(CameraMetadata &request, int64_t *lastFrameNumber = NULL) = 0;
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800138
139 /**
Jianing Wei90e59c92014-03-12 18:29:36 -0700140 * Submit a list of requests.
Jianing Weicb0652e2014-03-12 18:29:36 -0700141 * Output lastFrameNumber is the expected last frame number of the list of requests.
Jianing Wei90e59c92014-03-12 18:29:36 -0700142 */
Emilian Peevaebbe412018-01-15 13:53:24 +0000143 virtual status_t captureList(const List<const PhysicalCameraSettingsList> &requests,
Shuzhen Wang0129d522016-10-30 22:43:41 -0700144 const std::list<const SurfaceMap> &surfaceMaps,
Jianing Weicb0652e2014-03-12 18:29:36 -0700145 int64_t *lastFrameNumber = NULL) = 0;
Jianing Wei90e59c92014-03-12 18:29:36 -0700146
147 /**
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800148 * Submit request for streaming. The CameraDevice makes a copy of the
149 * passed-in buffer and the caller retains ownership.
Jianing Weicb0652e2014-03-12 18:29:36 -0700150 * Output lastFrameNumber is the last frame number of the previous streaming request.
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800151 */
Jianing Weicb0652e2014-03-12 18:29:36 -0700152 virtual status_t setStreamingRequest(const CameraMetadata &request,
153 int64_t *lastFrameNumber = NULL) = 0;
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800154
155 /**
Jianing Wei90e59c92014-03-12 18:29:36 -0700156 * Submit a list of requests for streaming.
Jianing Weicb0652e2014-03-12 18:29:36 -0700157 * Output lastFrameNumber is the last frame number of the previous streaming request.
Jianing Wei90e59c92014-03-12 18:29:36 -0700158 */
Emilian Peevaebbe412018-01-15 13:53:24 +0000159 virtual status_t setStreamingRequestList(const List<const PhysicalCameraSettingsList> &requests,
Shuzhen Wang0129d522016-10-30 22:43:41 -0700160 const std::list<const SurfaceMap> &surfaceMaps,
Jianing Weicb0652e2014-03-12 18:29:36 -0700161 int64_t *lastFrameNumber = NULL) = 0;
Jianing Wei90e59c92014-03-12 18:29:36 -0700162
163 /**
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800164 * Clear the streaming request slot.
Jianing Weicb0652e2014-03-12 18:29:36 -0700165 * Output lastFrameNumber is the last frame number of the previous streaming request.
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800166 */
Jianing Weicb0652e2014-03-12 18:29:36 -0700167 virtual status_t clearStreamingRequest(int64_t *lastFrameNumber = NULL) = 0;
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800168
169 /**
170 * Wait until a request with the given ID has been dequeued by the
171 * HAL. Returns TIMED_OUT if the timeout duration is reached. Returns
172 * immediately if the latest request received by the HAL has this id.
173 */
174 virtual status_t waitUntilRequestReceived(int32_t requestId,
175 nsecs_t timeout) = 0;
176
177 /**
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700178 * Create an output stream of the requested size, format, rotation and dataspace
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800179 *
Eino-Ville Talvala3d82c0d2015-02-23 15:19:19 -0800180 * For HAL_PIXEL_FORMAT_BLOB formats, the width and height should be the
181 * logical dimensions of the buffer, not the number of bytes.
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800182 */
Eino-Ville Talvala727d1722015-06-09 13:44:19 -0700183 virtual status_t createStream(sp<Surface> consumer,
Eino-Ville Talvala3d82c0d2015-02-23 15:19:19 -0800184 uint32_t width, uint32_t height, int format,
Emilian Peevf4816702020-04-03 15:44:51 -0700185 android_dataspace dataSpace, camera_stream_rotation_t rotation, int *id,
Shuzhen Wangc28189a2017-11-27 23:05:10 -0800186 const String8& physicalCameraId,
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800187 const std::unordered_set<int32_t> &sensorPixelModesUsed,
Emilian Peev40ead602017-09-26 15:46:36 +0100188 std::vector<int> *surfaceIds = nullptr,
Zhijun He5d677d12016-05-29 16:52:39 -0700189 int streamSetId = camera3::CAMERA3_STREAM_SET_ID_INVALID,
Shuzhen Wang83bff122020-11-20 15:51:39 -0800190 bool isShared = false, bool isMultiResolution = false,
Emilian Peev2295df72021-11-12 18:14:10 -0800191 uint64_t consumerUsage = 0,
Emilian Peevc81a7592022-02-14 17:38:18 -0800192 int64_t dynamicProfile = ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_STANDARD,
Shuzhen Wang8ed1e872022-03-08 16:34:33 -0800193 int64_t streamUseCase = ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT,
Shuzhen Wang610d7b82022-02-08 14:37:22 -0800194 int timestampBase = OutputConfiguration::TIMESTAMP_BASE_DEFAULT,
Austin Borger9e2b27c2022-07-15 11:27:24 -0700195 int mirrorMode = OutputConfiguration::MIRROR_MODE_AUTO,
196 int32_t colorSpace = ANDROID_REQUEST_AVAILABLE_COLOR_SPACE_PROFILES_MAP_UNSPECIFIED)
197 = 0;
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800198
199 /**
Shuzhen Wang0129d522016-10-30 22:43:41 -0700200 * Create an output stream of the requested size, format, rotation and
201 * dataspace with a number of consumers.
202 *
203 * For HAL_PIXEL_FORMAT_BLOB formats, the width and height should be the
204 * logical dimensions of the buffer, not the number of bytes.
205 */
206 virtual status_t createStream(const std::vector<sp<Surface>>& consumers,
207 bool hasDeferredConsumer, uint32_t width, uint32_t height, int format,
Emilian Peevf4816702020-04-03 15:44:51 -0700208 android_dataspace dataSpace, camera_stream_rotation_t rotation, int *id,
Shuzhen Wangc28189a2017-11-27 23:05:10 -0800209 const String8& physicalCameraId,
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800210 const std::unordered_set<int32_t> &sensorPixelModesUsed,
Emilian Peev40ead602017-09-26 15:46:36 +0100211 std::vector<int> *surfaceIds = nullptr,
Shuzhen Wang0129d522016-10-30 22:43:41 -0700212 int streamSetId = camera3::CAMERA3_STREAM_SET_ID_INVALID,
Shuzhen Wang83bff122020-11-20 15:51:39 -0800213 bool isShared = false, bool isMultiResolution = false,
Emilian Peev2295df72021-11-12 18:14:10 -0800214 uint64_t consumerUsage = 0,
Emilian Peevc81a7592022-02-14 17:38:18 -0800215 int64_t dynamicProfile = ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_STANDARD,
Shuzhen Wang8ed1e872022-03-08 16:34:33 -0800216 int64_t streamUseCase = ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT,
Shuzhen Wang610d7b82022-02-08 14:37:22 -0800217 int timestampBase = OutputConfiguration::TIMESTAMP_BASE_DEFAULT,
Austin Borger9e2b27c2022-07-15 11:27:24 -0700218 int mirrorMode = OutputConfiguration::MIRROR_MODE_AUTO,
219 int32_t colorSpace = ANDROID_REQUEST_AVAILABLE_COLOR_SPACE_PROFILES_MAP_UNSPECIFIED)
220 = 0;
Shuzhen Wang0129d522016-10-30 22:43:41 -0700221
222 /**
Chien-Yu Chen618ff8a2015-03-13 11:27:17 -0700223 * Create an input stream of width, height, and format.
224 *
225 * Return value is the stream ID if non-negative and an error if negative.
226 */
227 virtual status_t createInputStream(uint32_t width, uint32_t height,
Shuzhen Wang83bff122020-11-20 15:51:39 -0800228 int32_t format, bool multiResolution, /*out*/ int32_t *id) = 0;
Chien-Yu Chen618ff8a2015-03-13 11:27:17 -0700229
Emilian Peev710c1422017-08-30 11:19:38 +0100230 struct StreamInfo {
231 uint32_t width;
232 uint32_t height;
Eino-Ville Talvala91cd3f82017-08-21 16:12:50 -0700233
Emilian Peev710c1422017-08-30 11:19:38 +0100234 uint32_t format;
235 bool formatOverridden;
236 uint32_t originalFormat;
Eino-Ville Talvala91cd3f82017-08-21 16:12:50 -0700237
Emilian Peev710c1422017-08-30 11:19:38 +0100238 android_dataspace dataSpace;
Eino-Ville Talvala91cd3f82017-08-21 16:12:50 -0700239 bool dataSpaceOverridden;
240 android_dataspace originalDataSpace;
Emilian Peevc81a7592022-02-14 17:38:18 -0800241 int64_t dynamicRangeProfile;
Austin Borger9e2b27c2022-07-15 11:27:24 -0700242 int32_t colorSpace;
Eino-Ville Talvala91cd3f82017-08-21 16:12:50 -0700243
Emilian Peev710c1422017-08-30 11:19:38 +0100244 StreamInfo() : width(0), height(0), format(0), formatOverridden(false), originalFormat(0),
Eino-Ville Talvala91cd3f82017-08-21 16:12:50 -0700245 dataSpace(HAL_DATASPACE_UNKNOWN), dataSpaceOverridden(false),
Emilian Peev2295df72021-11-12 18:14:10 -0800246 originalDataSpace(HAL_DATASPACE_UNKNOWN),
Austin Borger9e2b27c2022-07-15 11:27:24 -0700247 dynamicRangeProfile(ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_STANDARD),
248 colorSpace(ANDROID_REQUEST_AVAILABLE_COLOR_SPACE_PROFILES_MAP_UNSPECIFIED) {}
Emilian Peev710c1422017-08-30 11:19:38 +0100249 /**
250 * Check whether the format matches the current or the original one in case
251 * it got overridden.
252 */
Eino-Ville Talvala91cd3f82017-08-21 16:12:50 -0700253 bool matchFormat(uint32_t clientFormat) const {
Emilian Peev710c1422017-08-30 11:19:38 +0100254 if ((formatOverridden && (originalFormat == clientFormat)) ||
255 (format == clientFormat)) {
256 return true;
257 }
258 return false;
259 }
Eino-Ville Talvala91cd3f82017-08-21 16:12:50 -0700260
261 /**
262 * Check whether the dataspace matches the current or the original one in case
263 * it got overridden.
264 */
265 bool matchDataSpace(android_dataspace clientDataSpace) const {
266 if ((dataSpaceOverridden && (originalDataSpace == clientDataSpace)) ||
267 (dataSpace == clientDataSpace)) {
268 return true;
269 }
270 return false;
271 }
272
Emilian Peev710c1422017-08-30 11:19:38 +0100273 };
274
Chien-Yu Chen618ff8a2015-03-13 11:27:17 -0700275 /**
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800276 * Get information about a given stream.
277 */
Emilian Peev710c1422017-08-30 11:19:38 +0100278 virtual status_t getStreamInfo(int id, StreamInfo *streamInfo) = 0;
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800279
280 /**
281 * Set stream gralloc buffer transform
282 */
283 virtual status_t setStreamTransform(int id, int transform) = 0;
284
285 /**
286 * Delete stream. Must not be called if there are requests in flight which
287 * reference that stream.
288 */
289 virtual status_t deleteStream(int id) = 0;
290
291 /**
Igor Murashkine2d167e2014-08-19 16:19:59 -0700292 * Take the currently-defined set of streams and configure the HAL to use
293 * them. This is a long-running operation (may be several hundered ms).
294 *
295 * The device must be idle (see waitUntilDrained) before calling this.
296 *
297 * Returns OK on success; otherwise on error:
298 * - BAD_VALUE if the set of streams was invalid (e.g. fmts or sizes)
299 * - INVALID_OPERATION if the device was in the wrong state
300 */
Emilian Peev5fbe0ba2017-10-20 15:45:45 +0100301 virtual status_t configureStreams(const CameraMetadata& sessionParams,
Emilian Peevf4816702020-04-03 15:44:51 -0700302 int operatingMode =
303 camera_stream_configuration_mode_t::CAMERA_STREAM_CONFIGURATION_NORMAL_MODE) = 0;
Igor Murashkine2d167e2014-08-19 16:19:59 -0700304
Emilian Peevcc0b7952020-01-07 13:54:47 -0800305 /**
306 * Retrieve a list of all stream ids that were advertised as capable of
307 * supporting offline processing mode by Hal after the last stream configuration.
308 */
309 virtual void getOfflineStreamIds(std::vector<int> *offlineStreamIds) = 0;
310
Chien-Yu Chen618ff8a2015-03-13 11:27:17 -0700311 // get the buffer producer of the input stream
312 virtual status_t getInputBufferProducer(
313 sp<IGraphicBufferProducer> *producer) = 0;
314
Igor Murashkine2d167e2014-08-19 16:19:59 -0700315 /**
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800316 * Create a metadata buffer with fields that the HAL device believes are
317 * best for the given use case
318 */
Emilian Peevf4816702020-04-03 15:44:51 -0700319 virtual status_t createDefaultRequest(camera_request_template_t templateId,
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800320 CameraMetadata *request) = 0;
321
322 /**
323 * Wait until all requests have been processed. Returns INVALID_OPERATION if
324 * the streaming slot is not empty, or TIMED_OUT if the requests haven't
325 * finished processing in 10 seconds.
326 */
327 virtual status_t waitUntilDrained() = 0;
328
329 /**
Zhijun He28c9b6f2014-08-08 12:00:47 -0700330 * Get Jpeg buffer size for a given jpeg resolution.
331 * Negative values are error codes.
332 */
Jayant Chowdhary6a6d3a82021-11-17 16:54:34 -0800333 virtual ssize_t getJpegBufferSize(const CameraMetadata &info, uint32_t width,
334 uint32_t height) const = 0;
Zhijun He28c9b6f2014-08-08 12:00:47 -0700335
336 /**
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800337 * Connect HAL notifications to a listener. Overwrites previous
338 * listener. Set to NULL to stop receiving notifications.
339 */
Yin-Chia Yehe1c80632016-08-08 14:48:05 -0700340 virtual status_t setNotifyCallback(wp<NotificationListener> listener) = 0;
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800341
342 /**
Eino-Ville Talvala46910bd2013-07-18 19:15:17 -0700343 * Whether the device supports calling notifyAutofocus, notifyAutoExposure,
344 * and notifyAutoWhitebalance; if this returns false, the client must
345 * synthesize these notifications from received frame metadata.
346 */
347 virtual bool willNotify3A() = 0;
348
349 /**
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800350 * Trigger auto-focus. The latest ID used in a trigger autofocus or cancel
351 * autofocus call will be returned by the HAL in all subsequent AF
352 * notifications.
353 */
354 virtual status_t triggerAutofocus(uint32_t id) = 0;
355
356 /**
357 * Cancel auto-focus. The latest ID used in a trigger autofocus/cancel
358 * autofocus call will be returned by the HAL in all subsequent AF
359 * notifications.
360 */
361 virtual status_t triggerCancelAutofocus(uint32_t id) = 0;
362
363 /**
364 * Trigger pre-capture metering. The latest ID used in a trigger pre-capture
365 * call will be returned by the HAL in all subsequent AE and AWB
366 * notifications.
367 */
368 virtual status_t triggerPrecaptureMetering(uint32_t id) = 0;
369
370 /**
Eino-Ville Talvalaabaa51d2013-08-14 11:37:00 -0700371 * Flush all pending and in-flight requests. Blocks until flush is
372 * complete.
Jianing Weicb0652e2014-03-12 18:29:36 -0700373 * Output lastFrameNumber is the last frame number of the previous streaming request.
Eino-Ville Talvalaabaa51d2013-08-14 11:37:00 -0700374 */
Jianing Weicb0652e2014-03-12 18:29:36 -0700375 virtual status_t flush(int64_t *lastFrameNumber = NULL) = 0;
Eino-Ville Talvalaabaa51d2013-08-14 11:37:00 -0700376
Zhijun He204e3292014-07-14 17:09:23 -0700377 /**
Eino-Ville Talvala4d44cad2015-04-11 13:15:45 -0700378 * Prepare stream by preallocating buffers for it asynchronously.
379 * Calls notifyPrepared() once allocation is complete.
380 */
381 virtual status_t prepare(int streamId) = 0;
382
383 /**
Eino-Ville Talvalab25e3c82015-07-15 16:04:27 -0700384 * Free stream resources by dumping its unused gralloc buffers.
385 */
386 virtual status_t tearDown(int streamId) = 0;
387
388 /**
Shuzhen Wangb0fdc1e2016-03-20 23:21:39 -0700389 * Add buffer listener for a particular stream in the device.
390 */
391 virtual status_t addBufferListenerForStream(int streamId,
392 wp<camera3::Camera3StreamBufferListener> listener) = 0;
393
394 /**
Ruben Brunkc78ac262015-08-13 17:58:46 -0700395 * Prepare stream by preallocating up to maxCount buffers for it asynchronously.
396 * Calls notifyPrepared() once allocation is complete.
397 */
398 virtual status_t prepare(int maxCount, int streamId) = 0;
399
400 /**
Zhijun He5d677d12016-05-29 16:52:39 -0700401 * Set the deferred consumer surface and finish the rest of the stream configuration.
402 */
Shuzhen Wang758c2152017-01-10 18:26:18 -0800403 virtual status_t setConsumerSurfaces(int streamId,
Emilian Peev40ead602017-09-26 15:46:36 +0100404 const std::vector<sp<Surface>>& consumers, std::vector<int> *surfaceIds /*out*/) = 0;
Zhijun He5d677d12016-05-29 16:52:39 -0700405
Emilian Peev40ead602017-09-26 15:46:36 +0100406 /**
407 * Update a given stream.
408 */
409 virtual status_t updateStream(int streamId, const std::vector<sp<Surface>> &newSurfaces,
410 const std::vector<android::camera3::OutputStreamInfo> &outputInfo,
411 const std::vector<size_t> &removedSurfaceIds,
412 KeyedVector<sp<Surface>, size_t> *outputMap/*out*/) = 0;
Chien-Yu Chena936ac22017-10-23 15:59:49 -0700413
414 /**
415 * Drop buffers for stream of streamId if dropping is true. If dropping is false, do not
416 * drop buffers for stream of streamId.
417 */
418 virtual status_t dropStreamBuffers(bool /*dropping*/, int /*streamId*/) = 0;
Emilian Peev2a8e2832019-08-23 13:00:31 -0700419
420 /**
421 * Returns the maximum expected time it'll take for all currently in-flight
422 * requests to complete, based on their settings
423 */
424 virtual nsecs_t getExpectedInFlightDuration() = 0;
Yin-Chia Yehb978c382019-10-30 00:22:37 -0700425
426 /**
427 * switch to offline session
428 */
429 virtual status_t switchToOffline(
430 const std::vector<int32_t>& streamsToKeep,
431 /*out*/ sp<CameraOfflineSessionBase>* session) = 0;
Eino-Ville Talvalaf2e37092020-01-07 15:32:32 -0800432
433 /**
434 * Set the current behavior for the ROTATE_AND_CROP control when in AUTO.
435 *
436 * The value must be one of the ROTATE_AND_CROP_* values besides AUTO,
437 * and defaults to NONE.
438 */
439 virtual status_t setRotateAndCropAutoBehavior(
440 camera_metadata_enum_android_scaler_rotate_and_crop_t rotateAndCropValue) = 0;
441
Shuzhen Wange8675782019-12-05 09:12:14 -0800442 /**
Eino-Ville Talvala305cec62020-11-12 14:18:17 -0800443 * Whether camera muting (producing black-only output) is supported.
444 *
445 * Calling setCameraMute(true) when this returns false will return an
446 * INVALID_OPERATION error.
447 */
448 virtual bool supportsCameraMute() = 0;
449
450 /**
451 * Mute the camera.
452 *
453 * When muted, black image data is output on all output streams.
454 */
455 virtual status_t setCameraMute(bool enabled) = 0;
456
457 /**
Ravneetaeb20dc2022-03-30 05:33:03 +0000458 * Enable/disable camera service watchdog
459 */
460 virtual status_t setCameraServiceWatchdog(bool enabled) = 0;
461
462 /**
Shuzhen Wange8675782019-12-05 09:12:14 -0800463 * Get the status tracker of the camera device
464 */
465 virtual wp<camera3::StatusTracker> getStatusTracker() = 0;
Shuzhen Wangabbcb6b2020-12-09 22:32:44 -0800466
467 /**
468 * Set bitmask for image dump flag
469 */
470 void setImageDumpMask(int mask) { mImageDumpMask = mask; }
471
Cliff Wud3a05312021-04-26 23:07:31 +0800472 /**
473 * The injection camera session to replace the internal camera
474 * session.
475 */
476 virtual status_t injectCamera(const String8& injectedCamId,
477 sp<CameraProviderManager> manager) = 0;
478
479 /**
480 * Stop the injection camera and restore to internal camera session.
481 */
482 virtual status_t stopInjection() = 0;
483
Shuzhen Wangabbcb6b2020-12-09 22:32:44 -0800484protected:
485 bool mImageDumpMask = 0;
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800486};
487
488}; // namespace android
489
490#endif