Igor Murashkin | ae500e5 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 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 | #ifndef ANDROID_SERVERS_CAMERA3_STREAM_INTERFACE_H |
| 18 | #define ANDROID_SERVERS_CAMERA3_STREAM_INTERFACE_H |
| 19 | |
| 20 | #include <utils/RefBase.h> |
Shuzhen Wang | 68ac7ad | 2019-01-30 14:03:28 -0800 | [diff] [blame] | 21 | |
| 22 | #include <camera/CameraMetadata.h> |
Igor Murashkin | ae500e5 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 23 | #include "Camera3StreamBufferListener.h" |
Yin-Chia Yeh | be83fa7 | 2017-03-30 13:35:36 -0700 | [diff] [blame] | 24 | #include "Camera3StreamBufferFreedListener.h" |
Igor Murashkin | ae500e5 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 25 | |
Igor Murashkin | ae500e5 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 26 | namespace android { |
| 27 | |
| 28 | namespace camera3 { |
| 29 | |
Emilian Peev | f481670 | 2020-04-03 15:44:51 -0700 | [diff] [blame] | 30 | typedef enum camera_buffer_status { |
| 31 | CAMERA_BUFFER_STATUS_OK = 0, |
| 32 | CAMERA_BUFFER_STATUS_ERROR = 1 |
| 33 | } camera_buffer_status_t; |
| 34 | |
| 35 | typedef enum camera_stream_type { |
| 36 | CAMERA_STREAM_OUTPUT = 0, |
| 37 | CAMERA_STREAM_INPUT = 1, |
| 38 | CAMERA_NUM_STREAM_TYPES |
| 39 | } camera_stream_type_t; |
| 40 | |
| 41 | typedef enum camera_stream_rotation { |
| 42 | /* No rotation */ |
| 43 | CAMERA_STREAM_ROTATION_0 = 0, |
| 44 | |
| 45 | /* Rotate by 90 degree counterclockwise */ |
| 46 | CAMERA_STREAM_ROTATION_90 = 1, |
| 47 | |
| 48 | /* Rotate by 180 degree counterclockwise */ |
| 49 | CAMERA_STREAM_ROTATION_180 = 2, |
| 50 | |
| 51 | /* Rotate by 270 degree counterclockwise */ |
| 52 | CAMERA_STREAM_ROTATION_270 = 3 |
| 53 | } camera_stream_rotation_t; |
| 54 | |
| 55 | typedef struct camera_stream { |
| 56 | camera_stream_type_t stream_type; |
| 57 | uint32_t width; |
| 58 | uint32_t height; |
| 59 | int format; |
| 60 | uint32_t usage; |
| 61 | uint32_t max_buffers; |
| 62 | android_dataspace_t data_space; |
| 63 | camera_stream_rotation_t rotation; |
| 64 | const char* physical_camera_id; |
| 65 | } camera_stream_t; |
| 66 | |
| 67 | typedef struct camera_stream_buffer { |
| 68 | camera_stream_t *stream; |
| 69 | buffer_handle_t *buffer; |
| 70 | camera_buffer_status_t status; |
| 71 | int acquire_fence; |
| 72 | int release_fence; |
| 73 | } camera_stream_buffer_t; |
| 74 | |
Zhijun He | 125684a | 2015-12-26 15:07:30 -0800 | [diff] [blame] | 75 | enum { |
| 76 | /** |
| 77 | * This stream set ID indicates that the set ID is invalid, and this stream doesn't intend to |
| 78 | * share buffers with any other stream. It is illegal to register this kind of stream to |
| 79 | * Camera3BufferManager. |
| 80 | */ |
| 81 | CAMERA3_STREAM_SET_ID_INVALID = -1, |
| 82 | |
| 83 | /** |
| 84 | * Invalid output stream ID. |
| 85 | */ |
| 86 | CAMERA3_STREAM_ID_INVALID = -1, |
| 87 | }; |
| 88 | |
Eino-Ville Talvala | f1e98d8 | 2013-09-06 09:32:43 -0700 | [diff] [blame] | 89 | class StatusTracker; |
| 90 | |
Emilian Peev | 40ead60 | 2017-09-26 15:46:36 +0100 | [diff] [blame] | 91 | // OutputStreamInfo describes the property of a camera stream. |
| 92 | class OutputStreamInfo { |
| 93 | public: |
| 94 | int width; |
| 95 | int height; |
| 96 | int format; |
| 97 | android_dataspace dataSpace; |
| 98 | uint64_t consumerUsage; |
| 99 | bool finalized = false; |
Emilian Peev | cc0b795 | 2020-01-07 13:54:47 -0800 | [diff] [blame] | 100 | bool supportsOffline = false; |
Emilian Peev | 40ead60 | 2017-09-26 15:46:36 +0100 | [diff] [blame] | 101 | OutputStreamInfo() : |
| 102 | width(-1), height(-1), format(-1), dataSpace(HAL_DATASPACE_UNKNOWN), |
| 103 | consumerUsage(0) {} |
| 104 | OutputStreamInfo(int _width, int _height, int _format, android_dataspace _dataSpace, |
| 105 | uint64_t _consumerUsage) : |
| 106 | width(_width), height(_height), format(_format), |
| 107 | dataSpace(_dataSpace), consumerUsage(_consumerUsage) {} |
| 108 | }; |
| 109 | |
Igor Murashkin | ae500e5 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 110 | /** |
| 111 | * An interface for managing a single stream of input and/or output data from |
| 112 | * the camera device. |
| 113 | */ |
| 114 | class Camera3StreamInterface : public virtual RefBase { |
| 115 | public: |
Ruben Brunk | c78ac26 | 2015-08-13 17:58:46 -0700 | [diff] [blame] | 116 | |
| 117 | enum { |
| 118 | ALLOCATE_PIPELINE_MAX = 0, // Allocate max buffers used by a given surface |
| 119 | }; |
| 120 | |
Igor Murashkin | ae500e5 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 121 | /** |
| 122 | * Get the stream's ID |
| 123 | */ |
| 124 | virtual int getId() const = 0; |
| 125 | |
| 126 | /** |
Zhijun He | 125684a | 2015-12-26 15:07:30 -0800 | [diff] [blame] | 127 | * Get the output stream set id. |
| 128 | */ |
| 129 | virtual int getStreamSetId() const = 0; |
| 130 | |
| 131 | /** |
Igor Murashkin | ae500e5 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 132 | * Get the stream's dimensions and format |
| 133 | */ |
| 134 | virtual uint32_t getWidth() const = 0; |
| 135 | virtual uint32_t getHeight() const = 0; |
| 136 | virtual int getFormat() const = 0; |
Eino-Ville Talvala | d46a6b9 | 2015-05-14 17:26:24 -0700 | [diff] [blame] | 137 | virtual android_dataspace getDataSpace() const = 0; |
Emilian Peev | 710c142 | 2017-08-30 11:19:38 +0100 | [diff] [blame] | 138 | virtual void setFormatOverride(bool formatOverriden) = 0; |
Eino-Ville Talvala | 91cd3f8 | 2017-08-21 16:12:50 -0700 | [diff] [blame] | 139 | virtual bool isFormatOverridden() const = 0; |
| 140 | virtual int getOriginalFormat() const = 0; |
| 141 | virtual void setDataSpaceOverride(bool dataSpaceOverriden) = 0; |
| 142 | virtual bool isDataSpaceOverridden() const = 0; |
| 143 | virtual android_dataspace getOriginalDataSpace() const = 0; |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 144 | virtual int getMaxHalBuffers() const = 0; |
| 145 | virtual int getMaxTotalBuffers() const = 0; |
Igor Murashkin | ae500e5 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 146 | |
| 147 | /** |
Yin-Chia Yeh | 5fd603e | 2019-11-20 11:22:27 -0800 | [diff] [blame] | 148 | * Offline processing |
| 149 | */ |
| 150 | virtual void setOfflineProcessingSupport(bool support) = 0; |
| 151 | virtual bool getOfflineProcessingSupport() const = 0; |
| 152 | |
| 153 | /** |
Emilian Peev | f481670 | 2020-04-03 15:44:51 -0700 | [diff] [blame] | 154 | * Get a handle for the stream, without starting stream configuration. |
Eino-Ville Talvala | 0b1cb14 | 2016-12-19 16:29:17 -0800 | [diff] [blame] | 155 | */ |
Emilian Peev | f481670 | 2020-04-03 15:44:51 -0700 | [diff] [blame] | 156 | virtual camera_stream* asHalStream() = 0; |
Eino-Ville Talvala | 0b1cb14 | 2016-12-19 16:29:17 -0800 | [diff] [blame] | 157 | |
| 158 | /** |
Igor Murashkin | ae500e5 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 159 | * Start the stream configuration process. Returns a handle to the stream's |
Emilian Peev | f481670 | 2020-04-03 15:44:51 -0700 | [diff] [blame] | 160 | * information to be passed into the device's configure_streams call. |
Igor Murashkin | ae500e5 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 161 | * |
| 162 | * Until finishConfiguration() is called, no other methods on the stream may |
Emilian Peev | f481670 | 2020-04-03 15:44:51 -0700 | [diff] [blame] | 163 | * be called. The usage and max_buffers fields of camera_stream may be |
Igor Murashkin | ae500e5 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 164 | * modified between start/finishConfiguration, but may not be changed after |
Emilian Peev | f481670 | 2020-04-03 15:44:51 -0700 | [diff] [blame] | 165 | * that. The priv field of camera_stream may be modified at any time after |
Igor Murashkin | ae500e5 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 166 | * startConfiguration. |
| 167 | * |
| 168 | * Returns NULL in case of error starting configuration. |
| 169 | */ |
Emilian Peev | f481670 | 2020-04-03 15:44:51 -0700 | [diff] [blame] | 170 | virtual camera_stream* startConfiguration() = 0; |
Igor Murashkin | ae500e5 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 171 | |
| 172 | /** |
| 173 | * Check if the stream is mid-configuration (start has been called, but not |
| 174 | * finish). Used for lazy completion of configuration. |
| 175 | */ |
| 176 | virtual bool isConfiguring() const = 0; |
| 177 | |
| 178 | /** |
| 179 | * Completes the stream configuration process. During this call, the stream |
| 180 | * may call the device's register_stream_buffers() method. The stream |
| 181 | * information structure returned by startConfiguration() may no longer be |
| 182 | * modified after this call, but can still be read until the destruction of |
| 183 | * the stream. |
| 184 | * |
Yin-Chia Yeh | 573a270 | 2019-04-17 10:08:55 -0700 | [diff] [blame] | 185 | * streamReconfigured: set to true when a stream is being reconfigured. |
| 186 | * |
Igor Murashkin | ae500e5 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 187 | * Returns: |
| 188 | * OK on a successful configuration |
| 189 | * NO_INIT in case of a serious error from the HAL device |
| 190 | * NO_MEMORY in case of an error registering buffers |
| 191 | * INVALID_OPERATION in case connecting to the consumer failed |
| 192 | */ |
Yin-Chia Yeh | 573a270 | 2019-04-17 10:08:55 -0700 | [diff] [blame] | 193 | virtual status_t finishConfiguration(/*out*/bool* streamReconfigured = nullptr) = 0; |
Igor Murashkin | ae500e5 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 194 | |
| 195 | /** |
Eino-Ville Talvala | 1754351 | 2014-08-06 14:32:02 -0700 | [diff] [blame] | 196 | * Cancels the stream configuration process. This returns the stream to the |
| 197 | * initial state, allowing it to be configured again later. |
| 198 | * This is done if the HAL rejects the proposed combined stream configuration |
| 199 | */ |
| 200 | virtual status_t cancelConfiguration() = 0; |
| 201 | |
| 202 | /** |
Eino-Ville Talvala | 4d44cad | 2015-04-11 13:15:45 -0700 | [diff] [blame] | 203 | * Determine whether the stream has already become in-use (has received |
| 204 | * a valid filled buffer), which determines if a stream can still have |
| 205 | * prepareNextBuffer called on it. |
| 206 | */ |
| 207 | virtual bool isUnpreparable() = 0; |
| 208 | |
| 209 | /** |
Emilian Peev | f0348ae | 2021-01-13 13:39:45 -0800 | [diff] [blame] | 210 | * Mark the stream as unpreparable. |
| 211 | */ |
| 212 | virtual void markUnpreparable() = 0; |
| 213 | |
| 214 | /** |
Eino-Ville Talvala | 4d44cad | 2015-04-11 13:15:45 -0700 | [diff] [blame] | 215 | * Start stream preparation. May only be called in the CONFIGURED state, |
Ruben Brunk | c78ac26 | 2015-08-13 17:58:46 -0700 | [diff] [blame] | 216 | * when no valid buffers have yet been returned to this stream. Prepares |
| 217 | * up to maxCount buffers, or the maximum number of buffers needed by the |
| 218 | * pipeline if maxCount is ALLOCATE_PIPELINE_MAX. |
Eino-Ville Talvala | 4d44cad | 2015-04-11 13:15:45 -0700 | [diff] [blame] | 219 | * |
| 220 | * If no prepartion is necessary, returns OK and does not transition to |
| 221 | * PREPARING state. Otherwise, returns NOT_ENOUGH_DATA and transitions |
| 222 | * to PREPARING. |
| 223 | * |
Shuzhen Wang | b3a0fb5 | 2018-09-13 17:24:08 -0700 | [diff] [blame] | 224 | * blockRequest specifies whether prepare will block upcoming capture |
| 225 | * request. This flag should only be set to false if the caller guarantees |
| 226 | * the whole buffer preparation process is done before capture request |
| 227 | * comes in. |
| 228 | * |
Eino-Ville Talvala | 4d44cad | 2015-04-11 13:15:45 -0700 | [diff] [blame] | 229 | * Returns: |
| 230 | * OK if no more buffers need to be preallocated |
| 231 | * NOT_ENOUGH_DATA if calls to prepareNextBuffer are needed to finish |
| 232 | * buffer pre-allocation, and transitions to the PREPARING state. |
| 233 | * NO_INIT in case of a serious error from the HAL device |
| 234 | * INVALID_OPERATION if called when not in CONFIGURED state, or a |
| 235 | * valid buffer has already been returned to this stream. |
| 236 | */ |
Shuzhen Wang | b3a0fb5 | 2018-09-13 17:24:08 -0700 | [diff] [blame] | 237 | virtual status_t startPrepare(int maxCount, bool blockRequest) = 0; |
Eino-Ville Talvala | 4d44cad | 2015-04-11 13:15:45 -0700 | [diff] [blame] | 238 | |
| 239 | /** |
Shuzhen Wang | b3a0fb5 | 2018-09-13 17:24:08 -0700 | [diff] [blame] | 240 | * Check if the request on a stream is blocked by prepare. |
Eino-Ville Talvala | 4d44cad | 2015-04-11 13:15:45 -0700 | [diff] [blame] | 241 | */ |
Shuzhen Wang | b3a0fb5 | 2018-09-13 17:24:08 -0700 | [diff] [blame] | 242 | virtual bool isBlockedByPrepare() const = 0; |
Eino-Ville Talvala | 4d44cad | 2015-04-11 13:15:45 -0700 | [diff] [blame] | 243 | |
| 244 | /** |
| 245 | * Continue stream buffer preparation by allocating the next |
| 246 | * buffer for this stream. May only be called in the PREPARED state. |
| 247 | * |
| 248 | * Returns OK and transitions to the CONFIGURED state if all buffers |
| 249 | * are allocated after the call concludes. Otherwise returns NOT_ENOUGH_DATA. |
| 250 | * |
| 251 | * Returns: |
| 252 | * OK if no more buffers need to be preallocated, and transitions |
| 253 | * to the CONFIGURED state. |
| 254 | * NOT_ENOUGH_DATA if more calls to prepareNextBuffer are needed to finish |
| 255 | * buffer pre-allocation. |
| 256 | * NO_INIT in case of a serious error from the HAL device |
| 257 | * INVALID_OPERATION if called when not in CONFIGURED state, or a |
| 258 | * valid buffer has already been returned to this stream. |
| 259 | */ |
| 260 | virtual status_t prepareNextBuffer() = 0; |
| 261 | |
| 262 | /** |
| 263 | * Cancel stream preparation early. In case allocation needs to be |
| 264 | * stopped, this method transitions the stream back to the CONFIGURED state. |
| 265 | * Buffers that have been allocated with prepareNextBuffer remain that way, |
| 266 | * but a later use of prepareNextBuffer will require just as many |
| 267 | * calls as if the earlier prepare attempt had not existed. |
| 268 | * |
| 269 | * Returns: |
| 270 | * OK if cancellation succeeded, and transitions to the CONFIGURED state |
| 271 | * INVALID_OPERATION if not in the PREPARING state |
| 272 | * NO_INIT in case of a serious error from the HAL device |
| 273 | */ |
| 274 | virtual status_t cancelPrepare() = 0; |
| 275 | |
| 276 | /** |
Eino-Ville Talvala | b25e3c8 | 2015-07-15 16:04:27 -0700 | [diff] [blame] | 277 | * Tear down memory for this stream. This frees all unused gralloc buffers |
| 278 | * allocated for this stream, but leaves it ready for operation afterward. |
| 279 | * |
| 280 | * May only be called in the CONFIGURED state, and keeps the stream in |
| 281 | * the CONFIGURED state. |
| 282 | * |
| 283 | * Returns: |
| 284 | * OK if teardown succeeded. |
| 285 | * INVALID_OPERATION if not in the CONFIGURED state |
| 286 | * NO_INIT in case of a serious error from the HAL device |
| 287 | */ |
| 288 | virtual status_t tearDown() = 0; |
| 289 | |
| 290 | /** |
Emilian Peev | f481670 | 2020-04-03 15:44:51 -0700 | [diff] [blame] | 291 | * Fill in the camera_stream_buffer with the next valid buffer for this |
Igor Murashkin | ae500e5 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 292 | * stream, to hand over to the HAL. |
| 293 | * |
Shuzhen Wang | bee0f0a | 2017-01-24 14:51:37 -0800 | [diff] [blame] | 294 | * Multiple surfaces could share the same HAL stream, but a request may |
| 295 | * be only for a subset of surfaces. In this case, the |
| 296 | * Camera3StreamInterface object needs the surface ID information to acquire |
| 297 | * buffers for those surfaces. For the case of single surface for a HAL |
| 298 | * stream, surface_ids parameter has no effect. |
| 299 | * |
Igor Murashkin | ae500e5 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 300 | * This method may only be called once finishConfiguration has been called. |
| 301 | * For bidirectional streams, this method applies to the output-side |
| 302 | * buffers. |
| 303 | * |
| 304 | */ |
Emilian Peev | f481670 | 2020-04-03 15:44:51 -0700 | [diff] [blame] | 305 | virtual status_t getBuffer(camera_stream_buffer *buffer, |
Yin-Chia Yeh | b3a80b1 | 2018-09-04 12:13:05 -0700 | [diff] [blame] | 306 | nsecs_t waitBufferTimeout, |
Shuzhen Wang | bee0f0a | 2017-01-24 14:51:37 -0800 | [diff] [blame] | 307 | const std::vector<size_t>& surface_ids = std::vector<size_t>()) = 0; |
Igor Murashkin | ae500e5 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 308 | |
Yin-Chia Yeh | 14ef48d | 2020-02-10 15:06:37 -0800 | [diff] [blame] | 309 | struct OutstandingBuffer { |
| 310 | camera_stream_buffer* outBuffer; |
| 311 | |
| 312 | /** |
| 313 | * Multiple surfaces could share the same HAL stream, but a request may |
| 314 | * be only for a subset of surfaces. In this case, the |
| 315 | * Camera3StreamInterface object needs the surface ID information to acquire |
| 316 | * buffers for those surfaces. For the case of single surface for a HAL |
| 317 | * stream, surface_ids parameter has no effect. |
| 318 | */ |
| 319 | std::vector<size_t> surface_ids; |
| 320 | }; |
| 321 | /** |
| 322 | * Similar to getBuffer() except this method fills multiple buffers. |
| 323 | */ |
| 324 | virtual status_t getBuffers(std::vector<OutstandingBuffer>* buffers, |
| 325 | nsecs_t waitBufferTimeout) = 0; |
| 326 | |
Igor Murashkin | ae500e5 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 327 | /** |
| 328 | * Return a buffer to the stream after use by the HAL. |
| 329 | * |
Yin-Chia Yeh | 58b1b4e | 2018-10-15 12:18:36 -0700 | [diff] [blame] | 330 | * Multiple surfaces could share the same HAL stream, but a request may |
| 331 | * be only for a subset of surfaces. In this case, the |
| 332 | * Camera3StreamInterface object needs the surface ID information to attach |
| 333 | * buffers for those surfaces. For the case of single surface for a HAL |
| 334 | * stream, surface_ids parameter has no effect. |
| 335 | * |
Igor Murashkin | ae500e5 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 336 | * This method may only be called for buffers provided by getBuffer(). |
| 337 | * For bidirectional streams, this method applies to the output-side buffers |
| 338 | */ |
Emilian Peev | f481670 | 2020-04-03 15:44:51 -0700 | [diff] [blame] | 339 | virtual status_t returnBuffer(const camera_stream_buffer &buffer, |
Yin-Chia Yeh | 58b1b4e | 2018-10-15 12:18:36 -0700 | [diff] [blame] | 340 | nsecs_t timestamp, bool timestampIncreasing = true, |
Emilian Peev | 538c90e | 2018-12-17 18:03:19 +0000 | [diff] [blame] | 341 | const std::vector<size_t>& surface_ids = std::vector<size_t>(), |
| 342 | uint64_t frameNumber = 0) = 0; |
Igor Murashkin | ae500e5 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 343 | |
| 344 | /** |
Emilian Peev | f481670 | 2020-04-03 15:44:51 -0700 | [diff] [blame] | 345 | * Fill in the camera_stream_buffer with the next valid buffer for this |
Igor Murashkin | ae500e5 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 346 | * stream, to hand over to the HAL. |
| 347 | * |
| 348 | * This method may only be called once finishConfiguration has been called. |
| 349 | * For bidirectional streams, this method applies to the input-side |
| 350 | * buffers. |
| 351 | * |
Eino-Ville Talvala | ba43525 | 2017-06-21 16:07:25 -0700 | [diff] [blame] | 352 | * Normally this call will block until the handed out buffer count is less than the stream |
| 353 | * max buffer count; if respectHalLimit is set to false, this is ignored. |
Igor Murashkin | ae500e5 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 354 | */ |
Emilian Peev | f481670 | 2020-04-03 15:44:51 -0700 | [diff] [blame] | 355 | virtual status_t getInputBuffer(camera_stream_buffer *buffer, bool respectHalLimit = true) = 0; |
Igor Murashkin | ae500e5 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 356 | |
| 357 | /** |
| 358 | * Return a buffer to the stream after use by the HAL. |
| 359 | * |
| 360 | * This method may only be called for buffers provided by getBuffer(). |
| 361 | * For bidirectional streams, this method applies to the input-side buffers |
| 362 | */ |
Emilian Peev | f481670 | 2020-04-03 15:44:51 -0700 | [diff] [blame] | 363 | virtual status_t returnInputBuffer(const camera_stream_buffer &buffer) = 0; |
Igor Murashkin | ae500e5 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 364 | |
| 365 | /** |
Chien-Yu Chen | 618ff8a | 2015-03-13 11:27:17 -0700 | [diff] [blame] | 366 | * Get the buffer producer of the input buffer queue. |
| 367 | * |
| 368 | * This method only applies to input streams. |
| 369 | */ |
| 370 | virtual status_t getInputBufferProducer(sp<IGraphicBufferProducer> *producer) = 0; |
| 371 | |
| 372 | /** |
Igor Murashkin | ae500e5 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 373 | * Whether any of the stream's buffers are currently in use by the HAL, |
| 374 | * including buffers that have been returned but not yet had their |
| 375 | * release fence signaled. |
| 376 | */ |
| 377 | virtual bool hasOutstandingBuffers() const = 0; |
| 378 | |
Yin-Chia Yeh | d5cd5ff | 2018-10-01 14:43:04 -0700 | [diff] [blame] | 379 | /** |
| 380 | * Get number of buffers currently handed out to HAL |
| 381 | */ |
| 382 | virtual size_t getOutstandingBuffersCount() const = 0; |
| 383 | |
Igor Murashkin | ae500e5 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 384 | enum { |
| 385 | TIMEOUT_NEVER = -1 |
| 386 | }; |
Eino-Ville Talvala | f1e98d8 | 2013-09-06 09:32:43 -0700 | [diff] [blame] | 387 | |
Igor Murashkin | ae500e5 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 388 | /** |
Eino-Ville Talvala | f1e98d8 | 2013-09-06 09:32:43 -0700 | [diff] [blame] | 389 | * Set the state tracker to use for signaling idle transitions. |
Igor Murashkin | ae500e5 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 390 | */ |
Eino-Ville Talvala | f1e98d8 | 2013-09-06 09:32:43 -0700 | [diff] [blame] | 391 | virtual status_t setStatusTracker(sp<StatusTracker> statusTracker) = 0; |
Igor Murashkin | ae500e5 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 392 | |
| 393 | /** |
| 394 | * Disconnect stream from its non-HAL endpoint. After this, |
| 395 | * start/finishConfiguration must be called before the stream can be used |
| 396 | * again. This cannot be called if the stream has outstanding dequeued |
| 397 | * buffers. |
| 398 | */ |
| 399 | virtual status_t disconnect() = 0; |
| 400 | |
| 401 | /** |
Chien-Yu Chen | e8c535e | 2016-04-14 12:18:26 -0700 | [diff] [blame] | 402 | * Return if the buffer queue of the stream is abandoned. |
| 403 | */ |
| 404 | virtual bool isAbandoned() const = 0; |
| 405 | |
| 406 | /** |
Igor Murashkin | ae500e5 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 407 | * Debug dump of the stream's state. |
| 408 | */ |
| 409 | virtual void dump(int fd, const Vector<String16> &args) const = 0; |
| 410 | |
| 411 | virtual void addBufferListener( |
| 412 | wp<Camera3StreamBufferListener> listener) = 0; |
| 413 | virtual void removeBufferListener( |
| 414 | const sp<Camera3StreamBufferListener>& listener) = 0; |
Yin-Chia Yeh | be83fa7 | 2017-03-30 13:35:36 -0700 | [diff] [blame] | 415 | |
| 416 | /** |
| 417 | * Setting listner will remove previous listener (if exists) |
| 418 | * Only allow set listener during stream configuration because stream is guaranteed to be IDLE |
| 419 | * at this state, so setBufferFreedListener won't collide with onBufferFreed callbacks. |
| 420 | * Client is responsible to keep the listener object alive throughout the lifecycle of this |
| 421 | * Camera3Stream. |
| 422 | */ |
Yin-Chia Yeh | db1e864 | 2017-07-14 15:19:30 -0700 | [diff] [blame] | 423 | virtual void setBufferFreedListener(wp<Camera3StreamBufferFreedListener> listener) = 0; |
Emilian Peev | 538c90e | 2018-12-17 18:03:19 +0000 | [diff] [blame] | 424 | |
| 425 | /** |
| 426 | * Notify buffer stream listeners about incoming request with particular frame number. |
| 427 | */ |
Shuzhen Wang | 68ac7ad | 2019-01-30 14:03:28 -0800 | [diff] [blame] | 428 | virtual void fireBufferRequestForFrameNumber(uint64_t frameNumber, |
| 429 | const CameraMetadata& settings) = 0; |
Igor Murashkin | ae500e5 | 2013-04-22 14:03:54 -0700 | [diff] [blame] | 430 | }; |
| 431 | |
| 432 | } // namespace camera3 |
| 433 | |
| 434 | } // namespace android |
| 435 | |
| 436 | #endif |