Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 1 | /* |
Shuzhen Wang | c28189a | 2017-11-27 23:05:10 -0800 | [diff] [blame] | 2 | * Copyright (C) 2013-2018 The Android Open Source Project |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 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 | #ifndef ANDROID_SERVERS_CAMERA_CAMERADEVICEBASE_H |
| 18 | #define ANDROID_SERVERS_CAMERA_CAMERADEVICEBASE_H |
| 19 | |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 20 | #include <list> |
| 21 | |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 22 | #include <utils/RefBase.h> |
| 23 | #include <utils/String8.h> |
| 24 | #include <utils/String16.h> |
| 25 | #include <utils/Vector.h> |
Emilian Peev | 40ead60 | 2017-09-26 15:46:36 +0100 | [diff] [blame] | 26 | #include <utils/KeyedVector.h> |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 27 | #include <utils/Timers.h> |
Jianing Wei | 90e59c9 | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 28 | #include <utils/List.h> |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 29 | |
| 30 | #include "hardware/camera2.h" |
Zhijun He | 0ea8fa4 | 2014-07-07 17:05:38 -0700 | [diff] [blame] | 31 | #include "hardware/camera3.h" |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 32 | #include "camera/CameraMetadata.h" |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 33 | #include "camera/CaptureResult.h" |
Chien-Yu Chen | 618ff8a | 2015-03-13 11:27:17 -0700 | [diff] [blame] | 34 | #include "gui/IGraphicBufferProducer.h" |
Zhijun He | 125684a | 2015-12-26 15:07:30 -0800 | [diff] [blame] | 35 | #include "device3/Camera3StreamInterface.h" |
Shuzhen Wang | e867578 | 2019-12-05 09:12:14 -0800 | [diff] [blame] | 36 | #include "device3/StatusTracker.h" |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 37 | #include "binder/Status.h" |
Emilian Peev | faa4bde | 2020-01-23 12:19:37 -0800 | [diff] [blame] | 38 | #include "FrameProducer.h" |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 39 | |
Yin-Chia Yeh | b978c38 | 2019-10-30 00:22:37 -0700 | [diff] [blame] | 40 | #include "CameraOfflineSessionBase.h" |
| 41 | |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 42 | namespace android { |
| 43 | |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 44 | class CameraProviderManager; |
| 45 | |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 46 | // Mapping of output stream index to surface ids |
| 47 | typedef std::unordered_map<int, std::vector<size_t> > SurfaceMap; |
| 48 | |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 49 | /** |
| 50 | * Base interface for version >= 2 camera device classes, which interface to |
| 51 | * camera HAL device versions >= 2. |
| 52 | */ |
Emilian Peev | faa4bde | 2020-01-23 12:19:37 -0800 | [diff] [blame] | 53 | class CameraDeviceBase : public virtual FrameProducer { |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 54 | public: |
| 55 | virtual ~CameraDeviceBase(); |
| 56 | |
Igor Murashkin | 7138105 | 2013-03-04 14:53:08 -0800 | [diff] [blame] | 57 | /** |
Emilian Peev | 00420d2 | 2018-02-05 21:33:13 +0000 | [diff] [blame] | 58 | * The device vendor tag ID |
| 59 | */ |
| 60 | virtual metadata_vendor_id_t getVendorTagId() const = 0; |
| 61 | |
Emilian Peev | bd8c503 | 2018-02-14 23:05:40 +0000 | [diff] [blame] | 62 | virtual status_t initialize(sp<CameraProviderManager> manager, const String8& monitorTags) = 0; |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 63 | virtual status_t disconnect() = 0; |
| 64 | |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 65 | virtual status_t dump(int fd, const Vector<String16> &args) = 0; |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 66 | |
| 67 | /** |
Shuzhen Wang | 2e7f58f | 2018-07-11 14:00:29 -0700 | [diff] [blame] | 68 | * The physical camera device's static characteristics metadata buffer |
| 69 | */ |
Emilian Peev | faa4bde | 2020-01-23 12:19:37 -0800 | [diff] [blame] | 70 | virtual const CameraMetadata& infoPhysical(const String8& physicalId) const = 0; |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 71 | |
Emilian Peev | aebbe41 | 2018-01-15 13:53:24 +0000 | [diff] [blame] | 72 | struct PhysicalCameraSettings { |
| 73 | std::string cameraId; |
| 74 | CameraMetadata metadata; |
| 75 | }; |
| 76 | typedef List<PhysicalCameraSettings> PhysicalCameraSettingsList; |
| 77 | |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 78 | /** |
| 79 | * Submit request for capture. The CameraDevice takes ownership of the |
| 80 | * passed-in buffer. |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 81 | * Output lastFrameNumber is the expected frame number of this request. |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 82 | */ |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 83 | virtual status_t capture(CameraMetadata &request, int64_t *lastFrameNumber = NULL) = 0; |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 84 | |
| 85 | /** |
Jianing Wei | 90e59c9 | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 86 | * Submit a list of requests. |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 87 | * Output lastFrameNumber is the expected last frame number of the list of requests. |
Jianing Wei | 90e59c9 | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 88 | */ |
Emilian Peev | aebbe41 | 2018-01-15 13:53:24 +0000 | [diff] [blame] | 89 | virtual status_t captureList(const List<const PhysicalCameraSettingsList> &requests, |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 90 | const std::list<const SurfaceMap> &surfaceMaps, |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 91 | int64_t *lastFrameNumber = NULL) = 0; |
Jianing Wei | 90e59c9 | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 92 | |
| 93 | /** |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 94 | * Submit request for streaming. The CameraDevice makes a copy of the |
| 95 | * passed-in buffer and the caller retains ownership. |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 96 | * Output lastFrameNumber is the last frame number of the previous streaming request. |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 97 | */ |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 98 | virtual status_t setStreamingRequest(const CameraMetadata &request, |
| 99 | int64_t *lastFrameNumber = NULL) = 0; |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 100 | |
| 101 | /** |
Jianing Wei | 90e59c9 | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 102 | * Submit a list of requests for streaming. |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 103 | * Output lastFrameNumber is the last frame number of the previous streaming request. |
Jianing Wei | 90e59c9 | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 104 | */ |
Emilian Peev | aebbe41 | 2018-01-15 13:53:24 +0000 | [diff] [blame] | 105 | virtual status_t setStreamingRequestList(const List<const PhysicalCameraSettingsList> &requests, |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 106 | const std::list<const SurfaceMap> &surfaceMaps, |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 107 | int64_t *lastFrameNumber = NULL) = 0; |
Jianing Wei | 90e59c9 | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 108 | |
| 109 | /** |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 110 | * Clear the streaming request slot. |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 111 | * Output lastFrameNumber is the last frame number of the previous streaming request. |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 112 | */ |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 113 | virtual status_t clearStreamingRequest(int64_t *lastFrameNumber = NULL) = 0; |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 114 | |
| 115 | /** |
| 116 | * Wait until a request with the given ID has been dequeued by the |
| 117 | * HAL. Returns TIMED_OUT if the timeout duration is reached. Returns |
| 118 | * immediately if the latest request received by the HAL has this id. |
| 119 | */ |
| 120 | virtual status_t waitUntilRequestReceived(int32_t requestId, |
| 121 | nsecs_t timeout) = 0; |
| 122 | |
| 123 | /** |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 124 | * Create an output stream of the requested size, format, rotation and dataspace |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 125 | * |
Eino-Ville Talvala | 3d82c0d | 2015-02-23 15:19:19 -0800 | [diff] [blame] | 126 | * For HAL_PIXEL_FORMAT_BLOB formats, the width and height should be the |
| 127 | * logical dimensions of the buffer, not the number of bytes. |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 128 | */ |
Eino-Ville Talvala | 727d172 | 2015-06-09 13:44:19 -0700 | [diff] [blame] | 129 | virtual status_t createStream(sp<Surface> consumer, |
Eino-Ville Talvala | 3d82c0d | 2015-02-23 15:19:19 -0800 | [diff] [blame] | 130 | uint32_t width, uint32_t height, int format, |
Zhijun He | 125684a | 2015-12-26 15:07:30 -0800 | [diff] [blame] | 131 | android_dataspace dataSpace, camera3_stream_rotation_t rotation, int *id, |
Shuzhen Wang | c28189a | 2017-11-27 23:05:10 -0800 | [diff] [blame] | 132 | const String8& physicalCameraId, |
Emilian Peev | 40ead60 | 2017-09-26 15:46:36 +0100 | [diff] [blame] | 133 | std::vector<int> *surfaceIds = nullptr, |
Zhijun He | 5d677d1 | 2016-05-29 16:52:39 -0700 | [diff] [blame] | 134 | int streamSetId = camera3::CAMERA3_STREAM_SET_ID_INVALID, |
Emilian Peev | 050f5dc | 2017-05-18 14:43:56 +0100 | [diff] [blame] | 135 | bool isShared = false, uint64_t consumerUsage = 0) = 0; |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 136 | |
| 137 | /** |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 138 | * Create an output stream of the requested size, format, rotation and |
| 139 | * dataspace with a number of consumers. |
| 140 | * |
| 141 | * For HAL_PIXEL_FORMAT_BLOB formats, the width and height should be the |
| 142 | * logical dimensions of the buffer, not the number of bytes. |
| 143 | */ |
| 144 | virtual status_t createStream(const std::vector<sp<Surface>>& consumers, |
| 145 | bool hasDeferredConsumer, uint32_t width, uint32_t height, int format, |
| 146 | android_dataspace dataSpace, camera3_stream_rotation_t rotation, int *id, |
Shuzhen Wang | c28189a | 2017-11-27 23:05:10 -0800 | [diff] [blame] | 147 | const String8& physicalCameraId, |
Emilian Peev | 40ead60 | 2017-09-26 15:46:36 +0100 | [diff] [blame] | 148 | std::vector<int> *surfaceIds = nullptr, |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 149 | int streamSetId = camera3::CAMERA3_STREAM_SET_ID_INVALID, |
Emilian Peev | 050f5dc | 2017-05-18 14:43:56 +0100 | [diff] [blame] | 150 | bool isShared = false, uint64_t consumerUsage = 0) = 0; |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 151 | |
| 152 | /** |
Chien-Yu Chen | 618ff8a | 2015-03-13 11:27:17 -0700 | [diff] [blame] | 153 | * Create an input stream of width, height, and format. |
| 154 | * |
| 155 | * Return value is the stream ID if non-negative and an error if negative. |
| 156 | */ |
| 157 | virtual status_t createInputStream(uint32_t width, uint32_t height, |
| 158 | int32_t format, /*out*/ int32_t *id) = 0; |
| 159 | |
Emilian Peev | 710c142 | 2017-08-30 11:19:38 +0100 | [diff] [blame] | 160 | struct StreamInfo { |
| 161 | uint32_t width; |
| 162 | uint32_t height; |
Eino-Ville Talvala | 91cd3f8 | 2017-08-21 16:12:50 -0700 | [diff] [blame] | 163 | |
Emilian Peev | 710c142 | 2017-08-30 11:19:38 +0100 | [diff] [blame] | 164 | uint32_t format; |
| 165 | bool formatOverridden; |
| 166 | uint32_t originalFormat; |
Eino-Ville Talvala | 91cd3f8 | 2017-08-21 16:12:50 -0700 | [diff] [blame] | 167 | |
Emilian Peev | 710c142 | 2017-08-30 11:19:38 +0100 | [diff] [blame] | 168 | android_dataspace dataSpace; |
Eino-Ville Talvala | 91cd3f8 | 2017-08-21 16:12:50 -0700 | [diff] [blame] | 169 | bool dataSpaceOverridden; |
| 170 | android_dataspace originalDataSpace; |
| 171 | |
Emilian Peev | 710c142 | 2017-08-30 11:19:38 +0100 | [diff] [blame] | 172 | StreamInfo() : width(0), height(0), format(0), formatOverridden(false), originalFormat(0), |
Eino-Ville Talvala | 91cd3f8 | 2017-08-21 16:12:50 -0700 | [diff] [blame] | 173 | dataSpace(HAL_DATASPACE_UNKNOWN), dataSpaceOverridden(false), |
| 174 | originalDataSpace(HAL_DATASPACE_UNKNOWN) {} |
Emilian Peev | 710c142 | 2017-08-30 11:19:38 +0100 | [diff] [blame] | 175 | /** |
| 176 | * Check whether the format matches the current or the original one in case |
| 177 | * it got overridden. |
| 178 | */ |
Eino-Ville Talvala | 91cd3f8 | 2017-08-21 16:12:50 -0700 | [diff] [blame] | 179 | bool matchFormat(uint32_t clientFormat) const { |
Emilian Peev | 710c142 | 2017-08-30 11:19:38 +0100 | [diff] [blame] | 180 | if ((formatOverridden && (originalFormat == clientFormat)) || |
| 181 | (format == clientFormat)) { |
| 182 | return true; |
| 183 | } |
| 184 | return false; |
| 185 | } |
Eino-Ville Talvala | 91cd3f8 | 2017-08-21 16:12:50 -0700 | [diff] [blame] | 186 | |
| 187 | /** |
| 188 | * Check whether the dataspace matches the current or the original one in case |
| 189 | * it got overridden. |
| 190 | */ |
| 191 | bool matchDataSpace(android_dataspace clientDataSpace) const { |
| 192 | if ((dataSpaceOverridden && (originalDataSpace == clientDataSpace)) || |
| 193 | (dataSpace == clientDataSpace)) { |
| 194 | return true; |
| 195 | } |
| 196 | return false; |
| 197 | } |
| 198 | |
Emilian Peev | 710c142 | 2017-08-30 11:19:38 +0100 | [diff] [blame] | 199 | }; |
| 200 | |
Chien-Yu Chen | 618ff8a | 2015-03-13 11:27:17 -0700 | [diff] [blame] | 201 | /** |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 202 | * Get information about a given stream. |
| 203 | */ |
Emilian Peev | 710c142 | 2017-08-30 11:19:38 +0100 | [diff] [blame] | 204 | virtual status_t getStreamInfo(int id, StreamInfo *streamInfo) = 0; |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 205 | |
| 206 | /** |
| 207 | * Set stream gralloc buffer transform |
| 208 | */ |
| 209 | virtual status_t setStreamTransform(int id, int transform) = 0; |
| 210 | |
| 211 | /** |
| 212 | * Delete stream. Must not be called if there are requests in flight which |
| 213 | * reference that stream. |
| 214 | */ |
| 215 | virtual status_t deleteStream(int id) = 0; |
| 216 | |
| 217 | /** |
Igor Murashkin | e2d167e | 2014-08-19 16:19:59 -0700 | [diff] [blame] | 218 | * Take the currently-defined set of streams and configure the HAL to use |
| 219 | * them. This is a long-running operation (may be several hundered ms). |
| 220 | * |
| 221 | * The device must be idle (see waitUntilDrained) before calling this. |
| 222 | * |
| 223 | * Returns OK on success; otherwise on error: |
| 224 | * - BAD_VALUE if the set of streams was invalid (e.g. fmts or sizes) |
| 225 | * - INVALID_OPERATION if the device was in the wrong state |
| 226 | */ |
Emilian Peev | 5fbe0ba | 2017-10-20 15:45:45 +0100 | [diff] [blame] | 227 | virtual status_t configureStreams(const CameraMetadata& sessionParams, |
| 228 | int operatingMode = 0) = 0; |
Igor Murashkin | e2d167e | 2014-08-19 16:19:59 -0700 | [diff] [blame] | 229 | |
Emilian Peev | cc0b795 | 2020-01-07 13:54:47 -0800 | [diff] [blame] | 230 | /** |
| 231 | * Retrieve a list of all stream ids that were advertised as capable of |
| 232 | * supporting offline processing mode by Hal after the last stream configuration. |
| 233 | */ |
| 234 | virtual void getOfflineStreamIds(std::vector<int> *offlineStreamIds) = 0; |
| 235 | |
Chien-Yu Chen | 618ff8a | 2015-03-13 11:27:17 -0700 | [diff] [blame] | 236 | // get the buffer producer of the input stream |
| 237 | virtual status_t getInputBufferProducer( |
| 238 | sp<IGraphicBufferProducer> *producer) = 0; |
| 239 | |
Igor Murashkin | e2d167e | 2014-08-19 16:19:59 -0700 | [diff] [blame] | 240 | /** |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 241 | * Create a metadata buffer with fields that the HAL device believes are |
| 242 | * best for the given use case |
| 243 | */ |
| 244 | virtual status_t createDefaultRequest(int templateId, |
| 245 | CameraMetadata *request) = 0; |
| 246 | |
| 247 | /** |
| 248 | * Wait until all requests have been processed. Returns INVALID_OPERATION if |
| 249 | * the streaming slot is not empty, or TIMED_OUT if the requests haven't |
| 250 | * finished processing in 10 seconds. |
| 251 | */ |
| 252 | virtual status_t waitUntilDrained() = 0; |
| 253 | |
| 254 | /** |
Zhijun He | 28c9b6f | 2014-08-08 12:00:47 -0700 | [diff] [blame] | 255 | * Get Jpeg buffer size for a given jpeg resolution. |
| 256 | * Negative values are error codes. |
| 257 | */ |
| 258 | virtual ssize_t getJpegBufferSize(uint32_t width, uint32_t height) const = 0; |
| 259 | |
| 260 | /** |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 261 | * Connect HAL notifications to a listener. Overwrites previous |
| 262 | * listener. Set to NULL to stop receiving notifications. |
| 263 | */ |
Yin-Chia Yeh | e1c8063 | 2016-08-08 14:48:05 -0700 | [diff] [blame] | 264 | virtual status_t setNotifyCallback(wp<NotificationListener> listener) = 0; |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 265 | |
| 266 | /** |
Eino-Ville Talvala | 46910bd | 2013-07-18 19:15:17 -0700 | [diff] [blame] | 267 | * Whether the device supports calling notifyAutofocus, notifyAutoExposure, |
| 268 | * and notifyAutoWhitebalance; if this returns false, the client must |
| 269 | * synthesize these notifications from received frame metadata. |
| 270 | */ |
| 271 | virtual bool willNotify3A() = 0; |
| 272 | |
| 273 | /** |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 274 | * Trigger auto-focus. The latest ID used in a trigger autofocus or cancel |
| 275 | * autofocus call will be returned by the HAL in all subsequent AF |
| 276 | * notifications. |
| 277 | */ |
| 278 | virtual status_t triggerAutofocus(uint32_t id) = 0; |
| 279 | |
| 280 | /** |
| 281 | * Cancel auto-focus. The latest ID used in a trigger autofocus/cancel |
| 282 | * autofocus call will be returned by the HAL in all subsequent AF |
| 283 | * notifications. |
| 284 | */ |
| 285 | virtual status_t triggerCancelAutofocus(uint32_t id) = 0; |
| 286 | |
| 287 | /** |
| 288 | * Trigger pre-capture metering. The latest ID used in a trigger pre-capture |
| 289 | * call will be returned by the HAL in all subsequent AE and AWB |
| 290 | * notifications. |
| 291 | */ |
| 292 | virtual status_t triggerPrecaptureMetering(uint32_t id) = 0; |
| 293 | |
| 294 | /** |
Eino-Ville Talvala | abaa51d | 2013-08-14 11:37:00 -0700 | [diff] [blame] | 295 | * Flush all pending and in-flight requests. Blocks until flush is |
| 296 | * complete. |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 297 | * Output lastFrameNumber is the last frame number of the previous streaming request. |
Eino-Ville Talvala | abaa51d | 2013-08-14 11:37:00 -0700 | [diff] [blame] | 298 | */ |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 299 | virtual status_t flush(int64_t *lastFrameNumber = NULL) = 0; |
Eino-Ville Talvala | abaa51d | 2013-08-14 11:37:00 -0700 | [diff] [blame] | 300 | |
Zhijun He | 204e329 | 2014-07-14 17:09:23 -0700 | [diff] [blame] | 301 | /** |
Eino-Ville Talvala | 4d44cad | 2015-04-11 13:15:45 -0700 | [diff] [blame] | 302 | * Prepare stream by preallocating buffers for it asynchronously. |
| 303 | * Calls notifyPrepared() once allocation is complete. |
| 304 | */ |
| 305 | virtual status_t prepare(int streamId) = 0; |
| 306 | |
| 307 | /** |
Eino-Ville Talvala | b25e3c8 | 2015-07-15 16:04:27 -0700 | [diff] [blame] | 308 | * Free stream resources by dumping its unused gralloc buffers. |
| 309 | */ |
| 310 | virtual status_t tearDown(int streamId) = 0; |
| 311 | |
| 312 | /** |
Shuzhen Wang | b0fdc1e | 2016-03-20 23:21:39 -0700 | [diff] [blame] | 313 | * Add buffer listener for a particular stream in the device. |
| 314 | */ |
| 315 | virtual status_t addBufferListenerForStream(int streamId, |
| 316 | wp<camera3::Camera3StreamBufferListener> listener) = 0; |
| 317 | |
| 318 | /** |
Ruben Brunk | c78ac26 | 2015-08-13 17:58:46 -0700 | [diff] [blame] | 319 | * Prepare stream by preallocating up to maxCount buffers for it asynchronously. |
| 320 | * Calls notifyPrepared() once allocation is complete. |
| 321 | */ |
| 322 | virtual status_t prepare(int maxCount, int streamId) = 0; |
| 323 | |
| 324 | /** |
Zhijun He | 5d677d1 | 2016-05-29 16:52:39 -0700 | [diff] [blame] | 325 | * Set the deferred consumer surface and finish the rest of the stream configuration. |
| 326 | */ |
Shuzhen Wang | 758c215 | 2017-01-10 18:26:18 -0800 | [diff] [blame] | 327 | virtual status_t setConsumerSurfaces(int streamId, |
Emilian Peev | 40ead60 | 2017-09-26 15:46:36 +0100 | [diff] [blame] | 328 | const std::vector<sp<Surface>>& consumers, std::vector<int> *surfaceIds /*out*/) = 0; |
Zhijun He | 5d677d1 | 2016-05-29 16:52:39 -0700 | [diff] [blame] | 329 | |
Emilian Peev | 40ead60 | 2017-09-26 15:46:36 +0100 | [diff] [blame] | 330 | /** |
| 331 | * Update a given stream. |
| 332 | */ |
| 333 | virtual status_t updateStream(int streamId, const std::vector<sp<Surface>> &newSurfaces, |
| 334 | const std::vector<android::camera3::OutputStreamInfo> &outputInfo, |
| 335 | const std::vector<size_t> &removedSurfaceIds, |
| 336 | KeyedVector<sp<Surface>, size_t> *outputMap/*out*/) = 0; |
Chien-Yu Chen | a936ac2 | 2017-10-23 15:59:49 -0700 | [diff] [blame] | 337 | |
| 338 | /** |
| 339 | * Drop buffers for stream of streamId if dropping is true. If dropping is false, do not |
| 340 | * drop buffers for stream of streamId. |
| 341 | */ |
| 342 | virtual status_t dropStreamBuffers(bool /*dropping*/, int /*streamId*/) = 0; |
Emilian Peev | 2a8e283 | 2019-08-23 13:00:31 -0700 | [diff] [blame] | 343 | |
| 344 | /** |
| 345 | * Returns the maximum expected time it'll take for all currently in-flight |
| 346 | * requests to complete, based on their settings |
| 347 | */ |
| 348 | virtual nsecs_t getExpectedInFlightDuration() = 0; |
Yin-Chia Yeh | b978c38 | 2019-10-30 00:22:37 -0700 | [diff] [blame] | 349 | |
| 350 | /** |
| 351 | * switch to offline session |
| 352 | */ |
| 353 | virtual status_t switchToOffline( |
| 354 | const std::vector<int32_t>& streamsToKeep, |
| 355 | /*out*/ sp<CameraOfflineSessionBase>* session) = 0; |
Eino-Ville Talvala | f2e3709 | 2020-01-07 15:32:32 -0800 | [diff] [blame] | 356 | |
| 357 | /** |
| 358 | * Set the current behavior for the ROTATE_AND_CROP control when in AUTO. |
| 359 | * |
| 360 | * The value must be one of the ROTATE_AND_CROP_* values besides AUTO, |
| 361 | * and defaults to NONE. |
| 362 | */ |
| 363 | virtual status_t setRotateAndCropAutoBehavior( |
| 364 | camera_metadata_enum_android_scaler_rotate_and_crop_t rotateAndCropValue) = 0; |
| 365 | |
Shuzhen Wang | e867578 | 2019-12-05 09:12:14 -0800 | [diff] [blame] | 366 | /** |
| 367 | * Get the status tracker of the camera device |
| 368 | */ |
| 369 | virtual wp<camera3::StatusTracker> getStatusTracker() = 0; |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 370 | }; |
| 371 | |
| 372 | }; // namespace android |
| 373 | |
| 374 | #endif |