blob: cfc41c33d3aead12133870acc0f03900fbf8f2a0 [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>
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -080023#include <utils/String16.h>
24#include <utils/Vector.h>
Emilian Peev40ead602017-09-26 15:46:36 +010025#include <utils/KeyedVector.h>
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -080026#include <utils/Timers.h>
Jianing Wei90e59c92014-03-12 18:29:36 -070027#include <utils/List.h>
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -080028
29#include "hardware/camera2.h"
30#include "camera/CameraMetadata.h"
Jianing Weicb0652e2014-03-12 18:29:36 -070031#include "camera/CaptureResult.h"
Chien-Yu Chen618ff8a2015-03-13 11:27:17 -070032#include "gui/IGraphicBufferProducer.h"
Zhijun He125684a2015-12-26 15:07:30 -080033#include "device3/Camera3StreamInterface.h"
Shuzhen Wange8675782019-12-05 09:12:14 -080034#include "device3/StatusTracker.h"
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080035#include "binder/Status.h"
Emilian Peevfaa4bde2020-01-23 12:19:37 -080036#include "FrameProducer.h"
Jayant Chowdharyc67af1b2022-04-07 18:05:04 +000037#include "utils/IPCTransport.h"
Shuzhen Wang045be6c2023-10-12 10:01:10 -070038#include "utils/SessionConfigurationUtils.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
Emilian Peevf4816702020-04-03 15:44:51 -070046typedef enum camera_stream_configuration_mode {
47 CAMERA_STREAM_CONFIGURATION_NORMAL_MODE = 0,
48 CAMERA_STREAM_CONFIGURATION_CONSTRAINED_HIGH_SPEED_MODE = 1,
49 CAMERA_VENDOR_STREAM_CONFIGURATION_MODE_START = 0x8000
50} camera_stream_configuration_mode_t;
51
Jayant Chowdharyc67af1b2022-04-07 18:05:04 +000052// Matches definition of camera3_jpeg_blob in camera3.h and HIDL definition
53// device@3.2:types.hal, needs to stay around till HIDL support is removed (for
54// HIDL -> AIDL cameraBlob translation)
Emilian Peevf4816702020-04-03 15:44:51 -070055typedef struct camera_jpeg_blob {
56 uint16_t jpeg_blob_id;
57 uint32_t jpeg_size;
58} camera_jpeg_blob_t;
59
60enum {
61 CAMERA_JPEG_BLOB_ID = 0x00FF,
62 CAMERA_JPEG_APP_SEGMENTS_BLOB_ID = 0x0100,
63};
64
65} // namespace camera3
66
67using camera3::camera_request_template_t;;
68using camera3::camera_stream_configuration_mode_t;
69using camera3::camera_stream_rotation_t;
70
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -080071class CameraProviderManager;
72
Shuzhen Wang0129d522016-10-30 22:43:41 -070073// Mapping of output stream index to surface ids
74typedef std::unordered_map<int, std::vector<size_t> > SurfaceMap;
75
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -080076/**
77 * Base interface for version >= 2 camera device classes, which interface to
78 * camera HAL device versions >= 2.
79 */
Emilian Peevfaa4bde2020-01-23 12:19:37 -080080class CameraDeviceBase : public virtual FrameProducer {
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -080081 public:
82 virtual ~CameraDeviceBase();
83
Jayant Chowdharyc67af1b2022-04-07 18:05:04 +000084 virtual IPCTransport getTransportType() const = 0;
85
Igor Murashkin71381052013-03-04 14:53:08 -080086 /**
Emilian Peev00420d22018-02-05 21:33:13 +000087 * The device vendor tag ID
88 */
89 virtual metadata_vendor_id_t getVendorTagId() const = 0;
90
Austin Borgered99f642023-06-01 16:51:35 -070091 virtual status_t initialize(sp<CameraProviderManager> manager,
92 const std::string& monitorTags) = 0;
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -080093 virtual status_t disconnect() = 0;
94
Jianing Weicb0652e2014-03-12 18:29:36 -070095 virtual status_t dump(int fd, const Vector<String16> &args) = 0;
Austin Borgered99f642023-06-01 16:51:35 -070096 virtual status_t startWatchingTags(const std::string &tags) = 0;
Avichal Rakesh7e53cad2021-10-05 13:46:30 -070097 virtual status_t stopWatchingTags() = 0;
98 virtual status_t dumpWatchedEventsToVector(std::vector<std::string> &out) = 0;
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -080099
100 /**
Jayant Chowdhary6a6d3a82021-11-17 16:54:34 -0800101 * The physical camera device's static characteristics metadata buffer, or
102 * the logical camera's static characteristics if physical id is empty.
Shuzhen Wang2e7f58f2018-07-11 14:00:29 -0700103 */
Austin Borgered99f642023-06-01 16:51:35 -0700104 virtual const CameraMetadata& infoPhysical(const std::string& physicalId) const = 0;
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800105
Emilian Peev15230142023-04-27 20:22:54 +0000106 virtual bool isCompositeJpegRDisabled() const { return false; };
Emilian Peeve579d8b2023-02-28 14:16:08 -0800107
Emilian Peevaebbe412018-01-15 13:53:24 +0000108 struct PhysicalCameraSettings {
109 std::string cameraId;
110 CameraMetadata metadata;
Shuzhen Wang911c6a32021-10-27 13:36:03 -0700111
112 // Whether the physical camera supports testPatternMode/testPatternData
113 bool mHasTestPatternModeTag = true;
114 bool mHasTestPatternDataTag = true;
115
116 // Original value of TEST_PATTERN_MODE and DATA so that they can be
117 // restored when sensor muting is turned off
118 int32_t mOriginalTestPatternMode = 0;
119 int32_t mOriginalTestPatternData[4] = {};
120
Shuzhen Wangaf22e912023-04-11 16:03:17 -0700121 // Original value of SETTINGS_OVERRIDE so that they can be restored if
122 // camera service isn't overwriting the app value.
123 int32_t mOriginalSettingsOverride = ANDROID_CONTROL_SETTINGS_OVERRIDE_OFF;
Emilian Peevaebbe412018-01-15 13:53:24 +0000124 };
125 typedef List<PhysicalCameraSettings> PhysicalCameraSettingsList;
126
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800127 /**
128 * Submit request for capture. The CameraDevice takes ownership of the
129 * passed-in buffer.
Jianing Weicb0652e2014-03-12 18:29:36 -0700130 * Output lastFrameNumber is the expected frame number of this request.
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800131 */
Jianing Weicb0652e2014-03-12 18:29:36 -0700132 virtual status_t capture(CameraMetadata &request, int64_t *lastFrameNumber = NULL) = 0;
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800133
134 /**
Jianing Wei90e59c92014-03-12 18:29:36 -0700135 * Submit a list of requests.
Jianing Weicb0652e2014-03-12 18:29:36 -0700136 * Output lastFrameNumber is the expected last frame number of the list of requests.
Jianing Wei90e59c92014-03-12 18:29:36 -0700137 */
Emilian Peevaebbe412018-01-15 13:53:24 +0000138 virtual status_t captureList(const List<const PhysicalCameraSettingsList> &requests,
Shuzhen Wang0129d522016-10-30 22:43:41 -0700139 const std::list<const SurfaceMap> &surfaceMaps,
Jianing Weicb0652e2014-03-12 18:29:36 -0700140 int64_t *lastFrameNumber = NULL) = 0;
Jianing Wei90e59c92014-03-12 18:29:36 -0700141
142 /**
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800143 * Submit request for streaming. The CameraDevice makes a copy of the
144 * passed-in buffer and the caller retains ownership.
Jianing Weicb0652e2014-03-12 18:29:36 -0700145 * Output lastFrameNumber is the last frame number of the previous streaming request.
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800146 */
Jianing Weicb0652e2014-03-12 18:29:36 -0700147 virtual status_t setStreamingRequest(const CameraMetadata &request,
148 int64_t *lastFrameNumber = NULL) = 0;
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800149
150 /**
Jianing Wei90e59c92014-03-12 18:29:36 -0700151 * Submit a list of requests for streaming.
Jianing Weicb0652e2014-03-12 18:29:36 -0700152 * Output lastFrameNumber is the last frame number of the previous streaming request.
Jianing Wei90e59c92014-03-12 18:29:36 -0700153 */
Emilian Peevaebbe412018-01-15 13:53:24 +0000154 virtual status_t setStreamingRequestList(const List<const PhysicalCameraSettingsList> &requests,
Shuzhen Wang0129d522016-10-30 22:43:41 -0700155 const std::list<const SurfaceMap> &surfaceMaps,
Jianing Weicb0652e2014-03-12 18:29:36 -0700156 int64_t *lastFrameNumber = NULL) = 0;
Jianing Wei90e59c92014-03-12 18:29:36 -0700157
158 /**
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800159 * Clear the streaming request slot.
Jianing Weicb0652e2014-03-12 18:29:36 -0700160 * Output lastFrameNumber is the last frame number of the previous streaming request.
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800161 */
Jianing Weicb0652e2014-03-12 18:29:36 -0700162 virtual status_t clearStreamingRequest(int64_t *lastFrameNumber = NULL) = 0;
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800163
164 /**
165 * Wait until a request with the given ID has been dequeued by the
166 * HAL. Returns TIMED_OUT if the timeout duration is reached. Returns
167 * immediately if the latest request received by the HAL has this id.
168 */
169 virtual status_t waitUntilRequestReceived(int32_t requestId,
170 nsecs_t timeout) = 0;
171
172 /**
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700173 * Create an output stream of the requested size, format, rotation and dataspace
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800174 *
Eino-Ville Talvala3d82c0d2015-02-23 15:19:19 -0800175 * For HAL_PIXEL_FORMAT_BLOB formats, the width and height should be the
176 * logical dimensions of the buffer, not the number of bytes.
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800177 */
Eino-Ville Talvala727d1722015-06-09 13:44:19 -0700178 virtual status_t createStream(sp<Surface> consumer,
Eino-Ville Talvala3d82c0d2015-02-23 15:19:19 -0800179 uint32_t width, uint32_t height, int format,
Emilian Peevf4816702020-04-03 15:44:51 -0700180 android_dataspace dataSpace, camera_stream_rotation_t rotation, int *id,
Austin Borgered99f642023-06-01 16:51:35 -0700181 const std::string& physicalCameraId,
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800182 const std::unordered_set<int32_t> &sensorPixelModesUsed,
Emilian Peev40ead602017-09-26 15:46:36 +0100183 std::vector<int> *surfaceIds = nullptr,
Zhijun He5d677d12016-05-29 16:52:39 -0700184 int streamSetId = camera3::CAMERA3_STREAM_SET_ID_INVALID,
Shuzhen Wang83bff122020-11-20 15:51:39 -0800185 bool isShared = false, bool isMultiResolution = false,
Emilian Peev2295df72021-11-12 18:14:10 -0800186 uint64_t consumerUsage = 0,
Emilian Peevc81a7592022-02-14 17:38:18 -0800187 int64_t dynamicProfile = ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_STANDARD,
Shuzhen Wang8ed1e872022-03-08 16:34:33 -0800188 int64_t streamUseCase = ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT,
Shuzhen Wang610d7b82022-02-08 14:37:22 -0800189 int timestampBase = OutputConfiguration::TIMESTAMP_BASE_DEFAULT,
Austin Borger9e2b27c2022-07-15 11:27:24 -0700190 int mirrorMode = OutputConfiguration::MIRROR_MODE_AUTO,
Shuzhen Wangbce53db2022-12-03 00:38:20 +0000191 int32_t colorSpace = ANDROID_REQUEST_AVAILABLE_COLOR_SPACE_PROFILES_MAP_UNSPECIFIED,
192 bool useReadoutTimestamp = false)
Austin Borger9e2b27c2022-07-15 11:27:24 -0700193 = 0;
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800194
195 /**
Shuzhen Wang0129d522016-10-30 22:43:41 -0700196 * Create an output stream of the requested size, format, rotation and
197 * dataspace with a number of consumers.
198 *
199 * For HAL_PIXEL_FORMAT_BLOB formats, the width and height should be the
200 * logical dimensions of the buffer, not the number of bytes.
201 */
202 virtual status_t createStream(const std::vector<sp<Surface>>& consumers,
203 bool hasDeferredConsumer, uint32_t width, uint32_t height, int format,
Emilian Peevf4816702020-04-03 15:44:51 -0700204 android_dataspace dataSpace, camera_stream_rotation_t rotation, int *id,
Austin Borgered99f642023-06-01 16:51:35 -0700205 const std::string& physicalCameraId,
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800206 const std::unordered_set<int32_t> &sensorPixelModesUsed,
Emilian Peev40ead602017-09-26 15:46:36 +0100207 std::vector<int> *surfaceIds = nullptr,
Shuzhen Wang0129d522016-10-30 22:43:41 -0700208 int streamSetId = camera3::CAMERA3_STREAM_SET_ID_INVALID,
Shuzhen Wang83bff122020-11-20 15:51:39 -0800209 bool isShared = false, bool isMultiResolution = false,
Emilian Peev2295df72021-11-12 18:14:10 -0800210 uint64_t consumerUsage = 0,
Emilian Peevc81a7592022-02-14 17:38:18 -0800211 int64_t dynamicProfile = ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_STANDARD,
Shuzhen Wang8ed1e872022-03-08 16:34:33 -0800212 int64_t streamUseCase = ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT,
Shuzhen Wang610d7b82022-02-08 14:37:22 -0800213 int timestampBase = OutputConfiguration::TIMESTAMP_BASE_DEFAULT,
Austin Borger9e2b27c2022-07-15 11:27:24 -0700214 int mirrorMode = OutputConfiguration::MIRROR_MODE_AUTO,
Shuzhen Wangbce53db2022-12-03 00:38:20 +0000215 int32_t colorSpace = ANDROID_REQUEST_AVAILABLE_COLOR_SPACE_PROFILES_MAP_UNSPECIFIED,
216 bool useReadoutTimestamp = false)
Austin Borger9e2b27c2022-07-15 11:27:24 -0700217 = 0;
Shuzhen Wang0129d522016-10-30 22:43:41 -0700218
219 /**
Chien-Yu Chen618ff8a2015-03-13 11:27:17 -0700220 * Create an input stream of width, height, and format.
221 *
222 * Return value is the stream ID if non-negative and an error if negative.
223 */
224 virtual status_t createInputStream(uint32_t width, uint32_t height,
Shuzhen Wang83bff122020-11-20 15:51:39 -0800225 int32_t format, bool multiResolution, /*out*/ int32_t *id) = 0;
Chien-Yu Chen618ff8a2015-03-13 11:27:17 -0700226
Emilian Peev710c1422017-08-30 11:19:38 +0100227 struct StreamInfo {
228 uint32_t width;
229 uint32_t height;
Eino-Ville Talvala91cd3f82017-08-21 16:12:50 -0700230
Emilian Peev710c1422017-08-30 11:19:38 +0100231 uint32_t format;
232 bool formatOverridden;
233 uint32_t originalFormat;
Eino-Ville Talvala91cd3f82017-08-21 16:12:50 -0700234
Emilian Peev710c1422017-08-30 11:19:38 +0100235 android_dataspace dataSpace;
Eino-Ville Talvala91cd3f82017-08-21 16:12:50 -0700236 bool dataSpaceOverridden;
237 android_dataspace originalDataSpace;
Emilian Peevc81a7592022-02-14 17:38:18 -0800238 int64_t dynamicRangeProfile;
Austin Borger9e2b27c2022-07-15 11:27:24 -0700239 int32_t colorSpace;
Eino-Ville Talvala91cd3f82017-08-21 16:12:50 -0700240
Emilian Peev710c1422017-08-30 11:19:38 +0100241 StreamInfo() : width(0), height(0), format(0), formatOverridden(false), originalFormat(0),
Eino-Ville Talvala91cd3f82017-08-21 16:12:50 -0700242 dataSpace(HAL_DATASPACE_UNKNOWN), dataSpaceOverridden(false),
Emilian Peev2295df72021-11-12 18:14:10 -0800243 originalDataSpace(HAL_DATASPACE_UNKNOWN),
Austin Borger9e2b27c2022-07-15 11:27:24 -0700244 dynamicRangeProfile(ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_STANDARD),
245 colorSpace(ANDROID_REQUEST_AVAILABLE_COLOR_SPACE_PROFILES_MAP_UNSPECIFIED) {}
Emilian Peev710c1422017-08-30 11:19:38 +0100246 /**
247 * Check whether the format matches the current or the original one in case
248 * it got overridden.
249 */
Eino-Ville Talvala91cd3f82017-08-21 16:12:50 -0700250 bool matchFormat(uint32_t clientFormat) const {
Emilian Peev710c1422017-08-30 11:19:38 +0100251 if ((formatOverridden && (originalFormat == clientFormat)) ||
252 (format == clientFormat)) {
253 return true;
254 }
255 return false;
256 }
Eino-Ville Talvala91cd3f82017-08-21 16:12:50 -0700257
258 /**
259 * Check whether the dataspace matches the current or the original one in case
260 * it got overridden.
261 */
262 bool matchDataSpace(android_dataspace clientDataSpace) const {
263 if ((dataSpaceOverridden && (originalDataSpace == clientDataSpace)) ||
264 (dataSpace == clientDataSpace)) {
265 return true;
266 }
267 return false;
268 }
269
Emilian Peev710c1422017-08-30 11:19:38 +0100270 };
271
Chien-Yu Chen618ff8a2015-03-13 11:27:17 -0700272 /**
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800273 * Get information about a given stream.
274 */
Emilian Peev710c1422017-08-30 11:19:38 +0100275 virtual status_t getStreamInfo(int id, StreamInfo *streamInfo) = 0;
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800276
277 /**
278 * Set stream gralloc buffer transform
279 */
280 virtual status_t setStreamTransform(int id, int transform) = 0;
281
282 /**
283 * Delete stream. Must not be called if there are requests in flight which
284 * reference that stream.
285 */
286 virtual status_t deleteStream(int id) = 0;
287
288 /**
Igor Murashkine2d167e2014-08-19 16:19:59 -0700289 * Take the currently-defined set of streams and configure the HAL to use
290 * them. This is a long-running operation (may be several hundered ms).
291 *
292 * The device must be idle (see waitUntilDrained) before calling this.
293 *
294 * Returns OK on success; otherwise on error:
295 * - BAD_VALUE if the set of streams was invalid (e.g. fmts or sizes)
296 * - INVALID_OPERATION if the device was in the wrong state
297 */
Emilian Peev5fbe0ba2017-10-20 15:45:45 +0100298 virtual status_t configureStreams(const CameraMetadata& sessionParams,
Emilian Peevf4816702020-04-03 15:44:51 -0700299 int operatingMode =
300 camera_stream_configuration_mode_t::CAMERA_STREAM_CONFIGURATION_NORMAL_MODE) = 0;
Igor Murashkine2d167e2014-08-19 16:19:59 -0700301
Emilian Peevcc0b7952020-01-07 13:54:47 -0800302 /**
303 * Retrieve a list of all stream ids that were advertised as capable of
304 * supporting offline processing mode by Hal after the last stream configuration.
305 */
306 virtual void getOfflineStreamIds(std::vector<int> *offlineStreamIds) = 0;
307
Chien-Yu Chen618ff8a2015-03-13 11:27:17 -0700308 // get the buffer producer of the input stream
309 virtual status_t getInputBufferProducer(
310 sp<IGraphicBufferProducer> *producer) = 0;
311
Igor Murashkine2d167e2014-08-19 16:19:59 -0700312 /**
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800313 * Create a metadata buffer with fields that the HAL device believes are
314 * best for the given use case
315 */
Emilian Peevf4816702020-04-03 15:44:51 -0700316 virtual status_t createDefaultRequest(camera_request_template_t templateId,
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800317 CameraMetadata *request) = 0;
318
319 /**
320 * Wait until all requests have been processed. Returns INVALID_OPERATION if
321 * the streaming slot is not empty, or TIMED_OUT if the requests haven't
322 * finished processing in 10 seconds.
323 */
324 virtual status_t waitUntilDrained() = 0;
325
326 /**
Zhijun He28c9b6f2014-08-08 12:00:47 -0700327 * Get Jpeg buffer size for a given jpeg resolution.
328 * Negative values are error codes.
329 */
Jayant Chowdhary6a6d3a82021-11-17 16:54:34 -0800330 virtual ssize_t getJpegBufferSize(const CameraMetadata &info, uint32_t width,
331 uint32_t height) const = 0;
Zhijun He28c9b6f2014-08-08 12:00:47 -0700332
333 /**
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800334 * Connect HAL notifications to a listener. Overwrites previous
335 * listener. Set to NULL to stop receiving notifications.
336 */
Yin-Chia Yehe1c80632016-08-08 14:48:05 -0700337 virtual status_t setNotifyCallback(wp<NotificationListener> listener) = 0;
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800338
339 /**
Eino-Ville Talvala46910bd2013-07-18 19:15:17 -0700340 * Whether the device supports calling notifyAutofocus, notifyAutoExposure,
341 * and notifyAutoWhitebalance; if this returns false, the client must
342 * synthesize these notifications from received frame metadata.
343 */
344 virtual bool willNotify3A() = 0;
345
346 /**
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800347 * Trigger auto-focus. The latest ID used in a trigger autofocus or cancel
348 * autofocus call will be returned by the HAL in all subsequent AF
349 * notifications.
350 */
351 virtual status_t triggerAutofocus(uint32_t id) = 0;
352
353 /**
354 * Cancel auto-focus. The latest ID used in a trigger autofocus/cancel
355 * autofocus call will be returned by the HAL in all subsequent AF
356 * notifications.
357 */
358 virtual status_t triggerCancelAutofocus(uint32_t id) = 0;
359
360 /**
361 * Trigger pre-capture metering. The latest ID used in a trigger pre-capture
362 * call will be returned by the HAL in all subsequent AE and AWB
363 * notifications.
364 */
365 virtual status_t triggerPrecaptureMetering(uint32_t id) = 0;
366
367 /**
Eino-Ville Talvalaabaa51d2013-08-14 11:37:00 -0700368 * Flush all pending and in-flight requests. Blocks until flush is
369 * complete.
Jianing Weicb0652e2014-03-12 18:29:36 -0700370 * Output lastFrameNumber is the last frame number of the previous streaming request.
Eino-Ville Talvalaabaa51d2013-08-14 11:37:00 -0700371 */
Jianing Weicb0652e2014-03-12 18:29:36 -0700372 virtual status_t flush(int64_t *lastFrameNumber = NULL) = 0;
Eino-Ville Talvalaabaa51d2013-08-14 11:37:00 -0700373
Zhijun He204e3292014-07-14 17:09:23 -0700374 /**
Eino-Ville Talvala4d44cad2015-04-11 13:15:45 -0700375 * Prepare stream by preallocating buffers for it asynchronously.
376 * Calls notifyPrepared() once allocation is complete.
377 */
378 virtual status_t prepare(int streamId) = 0;
379
380 /**
Eino-Ville Talvalab25e3c82015-07-15 16:04:27 -0700381 * Free stream resources by dumping its unused gralloc buffers.
382 */
383 virtual status_t tearDown(int streamId) = 0;
384
385 /**
Shuzhen Wangb0fdc1e2016-03-20 23:21:39 -0700386 * Add buffer listener for a particular stream in the device.
387 */
388 virtual status_t addBufferListenerForStream(int streamId,
389 wp<camera3::Camera3StreamBufferListener> listener) = 0;
390
391 /**
Ruben Brunkc78ac262015-08-13 17:58:46 -0700392 * Prepare stream by preallocating up to maxCount buffers for it asynchronously.
393 * Calls notifyPrepared() once allocation is complete.
394 */
395 virtual status_t prepare(int maxCount, int streamId) = 0;
396
397 /**
Zhijun He5d677d12016-05-29 16:52:39 -0700398 * Set the deferred consumer surface and finish the rest of the stream configuration.
399 */
Shuzhen Wang758c2152017-01-10 18:26:18 -0800400 virtual status_t setConsumerSurfaces(int streamId,
Emilian Peev40ead602017-09-26 15:46:36 +0100401 const std::vector<sp<Surface>>& consumers, std::vector<int> *surfaceIds /*out*/) = 0;
Zhijun He5d677d12016-05-29 16:52:39 -0700402
Emilian Peev40ead602017-09-26 15:46:36 +0100403 /**
404 * Update a given stream.
405 */
406 virtual status_t updateStream(int streamId, const std::vector<sp<Surface>> &newSurfaces,
407 const std::vector<android::camera3::OutputStreamInfo> &outputInfo,
408 const std::vector<size_t> &removedSurfaceIds,
409 KeyedVector<sp<Surface>, size_t> *outputMap/*out*/) = 0;
Chien-Yu Chena936ac22017-10-23 15:59:49 -0700410
411 /**
412 * Drop buffers for stream of streamId if dropping is true. If dropping is false, do not
413 * drop buffers for stream of streamId.
414 */
415 virtual status_t dropStreamBuffers(bool /*dropping*/, int /*streamId*/) = 0;
Emilian Peev2a8e2832019-08-23 13:00:31 -0700416
417 /**
418 * Returns the maximum expected time it'll take for all currently in-flight
419 * requests to complete, based on their settings
420 */
421 virtual nsecs_t getExpectedInFlightDuration() = 0;
Yin-Chia Yehb978c382019-10-30 00:22:37 -0700422
423 /**
424 * switch to offline session
425 */
426 virtual status_t switchToOffline(
427 const std::vector<int32_t>& streamsToKeep,
428 /*out*/ sp<CameraOfflineSessionBase>* session) = 0;
Eino-Ville Talvalaf2e37092020-01-07 15:32:32 -0800429
430 /**
431 * Set the current behavior for the ROTATE_AND_CROP control when in AUTO.
432 *
433 * The value must be one of the ROTATE_AND_CROP_* values besides AUTO,
434 * and defaults to NONE.
435 */
436 virtual status_t setRotateAndCropAutoBehavior(
Jayant Chowdhary44d5f622023-09-20 03:11:41 +0000437 camera_metadata_enum_android_scaler_rotate_and_crop_t rotateAndCropValue,
438 bool fromHal = false) = 0;
Eino-Ville Talvalaf2e37092020-01-07 15:32:32 -0800439
Shuzhen Wange8675782019-12-05 09:12:14 -0800440 /**
Bharatt Kukreja7146ced2022-10-25 15:45:29 +0000441 * Set the current behavior for the AUTOFRAMING control when in AUTO.
442 *
443 * The value must be one of the AUTOFRAMING_* values besides AUTO.
444 */
445 virtual status_t setAutoframingAutoBehavior(
446 camera_metadata_enum_android_control_autoframing_t autoframingValue) = 0;
447
448 /**
Eino-Ville Talvala305cec62020-11-12 14:18:17 -0800449 * Whether camera muting (producing black-only output) is supported.
450 *
451 * Calling setCameraMute(true) when this returns false will return an
452 * INVALID_OPERATION error.
453 */
454 virtual bool supportsCameraMute() = 0;
455
456 /**
457 * Mute the camera.
458 *
459 * When muted, black image data is output on all output streams.
460 */
461 virtual status_t setCameraMute(bool enabled) = 0;
462
463 /**
Shuzhen Wangaf22e912023-04-11 16:03:17 -0700464 * Whether the camera device supports zoom override.
465 */
466 virtual bool supportsZoomOverride() = 0;
467
468 // Set/reset zoom override
469 virtual status_t setZoomOverride(int32_t zoomOverride) = 0;
470
471 /**
Ravneetaeb20dc2022-03-30 05:33:03 +0000472 * Enable/disable camera service watchdog
473 */
474 virtual status_t setCameraServiceWatchdog(bool enabled) = 0;
475
476 /**
Shuzhen Wange8675782019-12-05 09:12:14 -0800477 * Get the status tracker of the camera device
478 */
479 virtual wp<camera3::StatusTracker> getStatusTracker() = 0;
Shuzhen Wangabbcb6b2020-12-09 22:32:44 -0800480
481 /**
Shuzhen Wang03fe6232023-02-05 12:41:15 -0800482 * If the device is in eror state
483 */
484 virtual bool hasDeviceError() = 0;
485
486 /**
Shuzhen Wangabbcb6b2020-12-09 22:32:44 -0800487 * Set bitmask for image dump flag
488 */
489 void setImageDumpMask(int mask) { mImageDumpMask = mask; }
490
Cliff Wud3a05312021-04-26 23:07:31 +0800491 /**
Shuzhen Wang16610a62022-12-15 22:38:07 -0800492 * Set stream use case overrides
493 */
494 void setStreamUseCaseOverrides(const std::vector<int64_t>& useCaseOverrides) {
495 mStreamUseCaseOverrides = useCaseOverrides;
496 }
497
498 void clearStreamUseCaseOverrides() {}
499
500 /**
Cliff Wud3a05312021-04-26 23:07:31 +0800501 * The injection camera session to replace the internal camera
502 * session.
503 */
Austin Borgered99f642023-06-01 16:51:35 -0700504 virtual status_t injectCamera(const std::string& injectedCamId,
Cliff Wud3a05312021-04-26 23:07:31 +0800505 sp<CameraProviderManager> manager) = 0;
506
507 /**
508 * Stop the injection camera and restore to internal camera session.
509 */
510 virtual status_t stopInjection() = 0;
511
malikakash22af94c2023-12-04 18:13:14 +0000512 // Inject session parameters into an existing client.
513 virtual status_t injectSessionParams(
514 const CameraMetadata& sessionParams) = 0;
515
Shuzhen Wangabbcb6b2020-12-09 22:32:44 -0800516protected:
517 bool mImageDumpMask = 0;
Shuzhen Wang16610a62022-12-15 22:38:07 -0800518 std::vector<int64_t> mStreamUseCaseOverrides;
Eino-Ville Talvala7fa43f32013-02-06 17:20:07 -0800519};
520
521}; // namespace android
522
523#endif