Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [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_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> |
| 26 | #include <utils/Timers.h> |
Jianing Wei | 90e59c9 | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 27 | #include <utils/List.h> |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 28 | |
| 29 | #include "hardware/camera2.h" |
Zhijun He | 0ea8fa4 | 2014-07-07 17:05:38 -0700 | [diff] [blame] | 30 | #include "hardware/camera3.h" |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 31 | #include "camera/CameraMetadata.h" |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 32 | #include "camera/CaptureResult.h" |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 33 | #include "common/CameraModule.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" |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 36 | #include "binder/Status.h" |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 37 | |
| 38 | namespace android { |
| 39 | |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 40 | class CameraProviderManager; |
| 41 | |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 42 | // Mapping of output stream index to surface ids |
| 43 | typedef std::unordered_map<int, std::vector<size_t> > SurfaceMap; |
| 44 | |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 45 | /** |
| 46 | * Base interface for version >= 2 camera device classes, which interface to |
| 47 | * camera HAL device versions >= 2. |
| 48 | */ |
| 49 | class CameraDeviceBase : public virtual RefBase { |
| 50 | public: |
| 51 | virtual ~CameraDeviceBase(); |
| 52 | |
Igor Murashkin | 7138105 | 2013-03-04 14:53:08 -0800 | [diff] [blame] | 53 | /** |
| 54 | * The device's camera ID |
| 55 | */ |
Eino-Ville Talvala | 0b1cb14 | 2016-12-19 16:29:17 -0800 | [diff] [blame] | 56 | virtual const String8& getId() const = 0; |
Igor Murashkin | 7138105 | 2013-03-04 14:53:08 -0800 | [diff] [blame] | 57 | |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 58 | virtual status_t initialize(CameraModule *module) = 0; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 59 | virtual status_t initialize(sp<CameraProviderManager> manager) = 0; |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 60 | virtual status_t disconnect() = 0; |
| 61 | |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 62 | virtual status_t dump(int fd, const Vector<String16> &args) = 0; |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 63 | |
| 64 | /** |
| 65 | * The device's static characteristics metadata buffer |
| 66 | */ |
| 67 | virtual const CameraMetadata& info() const = 0; |
| 68 | |
| 69 | /** |
| 70 | * Submit request for capture. The CameraDevice takes ownership of the |
| 71 | * passed-in buffer. |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 72 | * Output lastFrameNumber is the expected frame number of this request. |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 73 | */ |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 74 | virtual status_t capture(CameraMetadata &request, int64_t *lastFrameNumber = NULL) = 0; |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 75 | |
| 76 | /** |
Jianing Wei | 90e59c9 | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 77 | * Submit a list of requests. |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 78 | * 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] | 79 | */ |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 80 | virtual status_t captureList(const List<const CameraMetadata> &requests, |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 81 | const std::list<const SurfaceMap> &surfaceMaps, |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 82 | int64_t *lastFrameNumber = NULL) = 0; |
Jianing Wei | 90e59c9 | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 83 | |
| 84 | /** |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 85 | * Submit request for streaming. The CameraDevice makes a copy of the |
| 86 | * passed-in buffer and the caller retains ownership. |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 87 | * 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] | 88 | */ |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 89 | virtual status_t setStreamingRequest(const CameraMetadata &request, |
| 90 | int64_t *lastFrameNumber = NULL) = 0; |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 91 | |
| 92 | /** |
Jianing Wei | 90e59c9 | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 93 | * Submit a list of requests for streaming. |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 94 | * Output lastFrameNumber is the last frame number of the previous streaming request. |
Jianing Wei | 90e59c9 | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 95 | */ |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 96 | virtual status_t setStreamingRequestList(const List<const CameraMetadata> &requests, |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 97 | const std::list<const SurfaceMap> &surfaceMaps, |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 98 | int64_t *lastFrameNumber = NULL) = 0; |
Jianing Wei | 90e59c9 | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 99 | |
| 100 | /** |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 101 | * Clear the streaming request slot. |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 102 | * 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] | 103 | */ |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 104 | virtual status_t clearStreamingRequest(int64_t *lastFrameNumber = NULL) = 0; |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 105 | |
| 106 | /** |
| 107 | * Wait until a request with the given ID has been dequeued by the |
| 108 | * HAL. Returns TIMED_OUT if the timeout duration is reached. Returns |
| 109 | * immediately if the latest request received by the HAL has this id. |
| 110 | */ |
| 111 | virtual status_t waitUntilRequestReceived(int32_t requestId, |
| 112 | nsecs_t timeout) = 0; |
| 113 | |
| 114 | /** |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 115 | * 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] | 116 | * |
Eino-Ville Talvala | 3d82c0d | 2015-02-23 15:19:19 -0800 | [diff] [blame] | 117 | * For HAL_PIXEL_FORMAT_BLOB formats, the width and height should be the |
| 118 | * logical dimensions of the buffer, not the number of bytes. |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 119 | */ |
Eino-Ville Talvala | 727d172 | 2015-06-09 13:44:19 -0700 | [diff] [blame] | 120 | virtual status_t createStream(sp<Surface> consumer, |
Eino-Ville Talvala | 3d82c0d | 2015-02-23 15:19:19 -0800 | [diff] [blame] | 121 | uint32_t width, uint32_t height, int format, |
Zhijun He | 125684a | 2015-12-26 15:07:30 -0800 | [diff] [blame] | 122 | android_dataspace dataSpace, camera3_stream_rotation_t rotation, int *id, |
Zhijun He | 5d677d1 | 2016-05-29 16:52:39 -0700 | [diff] [blame] | 123 | int streamSetId = camera3::CAMERA3_STREAM_SET_ID_INVALID, |
Shuzhen Wang | 758c215 | 2017-01-10 18:26:18 -0800 | [diff] [blame] | 124 | bool isShared = false, uint32_t consumerUsage = 0) = 0; |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 125 | |
| 126 | /** |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 127 | * Create an output stream of the requested size, format, rotation and |
| 128 | * dataspace with a number of consumers. |
| 129 | * |
| 130 | * For HAL_PIXEL_FORMAT_BLOB formats, the width and height should be the |
| 131 | * logical dimensions of the buffer, not the number of bytes. |
| 132 | */ |
| 133 | virtual status_t createStream(const std::vector<sp<Surface>>& consumers, |
| 134 | bool hasDeferredConsumer, uint32_t width, uint32_t height, int format, |
| 135 | android_dataspace dataSpace, camera3_stream_rotation_t rotation, int *id, |
| 136 | int streamSetId = camera3::CAMERA3_STREAM_SET_ID_INVALID, |
Shuzhen Wang | 758c215 | 2017-01-10 18:26:18 -0800 | [diff] [blame] | 137 | bool isShared = false, uint32_t consumerUsage = 0) = 0; |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 138 | |
| 139 | /** |
Chien-Yu Chen | 618ff8a | 2015-03-13 11:27:17 -0700 | [diff] [blame] | 140 | * Create an input stream of width, height, and format. |
| 141 | * |
| 142 | * Return value is the stream ID if non-negative and an error if negative. |
| 143 | */ |
| 144 | virtual status_t createInputStream(uint32_t width, uint32_t height, |
| 145 | int32_t format, /*out*/ int32_t *id) = 0; |
| 146 | |
| 147 | /** |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 148 | * Get information about a given stream. |
| 149 | */ |
| 150 | virtual status_t getStreamInfo(int id, |
Eino-Ville Talvala | d46a6b9 | 2015-05-14 17:26:24 -0700 | [diff] [blame] | 151 | uint32_t *width, uint32_t *height, |
| 152 | uint32_t *format, android_dataspace *dataSpace) = 0; |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 153 | |
| 154 | /** |
| 155 | * Set stream gralloc buffer transform |
| 156 | */ |
| 157 | virtual status_t setStreamTransform(int id, int transform) = 0; |
| 158 | |
| 159 | /** |
| 160 | * Delete stream. Must not be called if there are requests in flight which |
| 161 | * reference that stream. |
| 162 | */ |
| 163 | virtual status_t deleteStream(int id) = 0; |
| 164 | |
| 165 | /** |
Igor Murashkin | e2d167e | 2014-08-19 16:19:59 -0700 | [diff] [blame] | 166 | * Take the currently-defined set of streams and configure the HAL to use |
| 167 | * them. This is a long-running operation (may be several hundered ms). |
| 168 | * |
| 169 | * The device must be idle (see waitUntilDrained) before calling this. |
| 170 | * |
| 171 | * Returns OK on success; otherwise on error: |
| 172 | * - BAD_VALUE if the set of streams was invalid (e.g. fmts or sizes) |
| 173 | * - INVALID_OPERATION if the device was in the wrong state |
| 174 | */ |
Eino-Ville Talvala | bbbbe84 | 2017-02-28 17:50:56 -0800 | [diff] [blame] | 175 | virtual status_t configureStreams(int operatingMode = 0) = 0; |
Igor Murashkin | e2d167e | 2014-08-19 16:19:59 -0700 | [diff] [blame] | 176 | |
Chien-Yu Chen | 618ff8a | 2015-03-13 11:27:17 -0700 | [diff] [blame] | 177 | // get the buffer producer of the input stream |
| 178 | virtual status_t getInputBufferProducer( |
| 179 | sp<IGraphicBufferProducer> *producer) = 0; |
| 180 | |
Igor Murashkin | e2d167e | 2014-08-19 16:19:59 -0700 | [diff] [blame] | 181 | /** |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 182 | * Create a metadata buffer with fields that the HAL device believes are |
| 183 | * best for the given use case |
| 184 | */ |
| 185 | virtual status_t createDefaultRequest(int templateId, |
| 186 | CameraMetadata *request) = 0; |
| 187 | |
| 188 | /** |
| 189 | * Wait until all requests have been processed. Returns INVALID_OPERATION if |
| 190 | * the streaming slot is not empty, or TIMED_OUT if the requests haven't |
| 191 | * finished processing in 10 seconds. |
| 192 | */ |
| 193 | virtual status_t waitUntilDrained() = 0; |
| 194 | |
| 195 | /** |
Zhijun He | 28c9b6f | 2014-08-08 12:00:47 -0700 | [diff] [blame] | 196 | * Get Jpeg buffer size for a given jpeg resolution. |
| 197 | * Negative values are error codes. |
| 198 | */ |
| 199 | virtual ssize_t getJpegBufferSize(uint32_t width, uint32_t height) const = 0; |
| 200 | |
| 201 | /** |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 202 | * Abstract class for HAL notification listeners |
| 203 | */ |
Yin-Chia Yeh | e1c8063 | 2016-08-08 14:48:05 -0700 | [diff] [blame] | 204 | class NotificationListener : public virtual RefBase { |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 205 | public: |
Eino-Ville Talvala | f1e98d8 | 2013-09-06 09:32:43 -0700 | [diff] [blame] | 206 | // The set of notifications is a merge of the notifications required for |
| 207 | // API1 and API2. |
| 208 | |
| 209 | // Required for API 1 and 2 |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 210 | virtual void notifyError(int32_t errorCode, |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 211 | const CaptureResultExtras &resultExtras) = 0; |
Eino-Ville Talvala | f1e98d8 | 2013-09-06 09:32:43 -0700 | [diff] [blame] | 212 | |
| 213 | // Required only for API2 |
| 214 | virtual void notifyIdle() = 0; |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 215 | virtual void notifyShutter(const CaptureResultExtras &resultExtras, |
Eino-Ville Talvala | f1e98d8 | 2013-09-06 09:32:43 -0700 | [diff] [blame] | 216 | nsecs_t timestamp) = 0; |
Eino-Ville Talvala | 4d44cad | 2015-04-11 13:15:45 -0700 | [diff] [blame] | 217 | virtual void notifyPrepared(int streamId) = 0; |
Shuzhen Wang | 9d06601 | 2016-09-30 11:30:20 -0700 | [diff] [blame] | 218 | virtual void notifyRequestQueueEmpty() = 0; |
Eino-Ville Talvala | f1e98d8 | 2013-09-06 09:32:43 -0700 | [diff] [blame] | 219 | |
| 220 | // Required only for API1 |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 221 | virtual void notifyAutoFocus(uint8_t newState, int triggerId) = 0; |
| 222 | virtual void notifyAutoExposure(uint8_t newState, int triggerId) = 0; |
| 223 | virtual void notifyAutoWhitebalance(uint8_t newState, |
| 224 | int triggerId) = 0; |
Chien-Yu Chen | e8c535e | 2016-04-14 12:18:26 -0700 | [diff] [blame] | 225 | virtual void notifyRepeatingRequestError(long lastFrameNumber) = 0; |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 226 | protected: |
| 227 | virtual ~NotificationListener(); |
| 228 | }; |
| 229 | |
| 230 | /** |
| 231 | * Connect HAL notifications to a listener. Overwrites previous |
| 232 | * listener. Set to NULL to stop receiving notifications. |
| 233 | */ |
Yin-Chia Yeh | e1c8063 | 2016-08-08 14:48:05 -0700 | [diff] [blame] | 234 | virtual status_t setNotifyCallback(wp<NotificationListener> listener) = 0; |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 235 | |
| 236 | /** |
Eino-Ville Talvala | 46910bd | 2013-07-18 19:15:17 -0700 | [diff] [blame] | 237 | * Whether the device supports calling notifyAutofocus, notifyAutoExposure, |
| 238 | * and notifyAutoWhitebalance; if this returns false, the client must |
| 239 | * synthesize these notifications from received frame metadata. |
| 240 | */ |
| 241 | virtual bool willNotify3A() = 0; |
| 242 | |
| 243 | /** |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 244 | * Wait for a new frame to be produced, with timeout in nanoseconds. |
| 245 | * Returns TIMED_OUT when no frame produced within the specified duration |
Eino-Ville Talvala | f1e98d8 | 2013-09-06 09:32:43 -0700 | [diff] [blame] | 246 | * May be called concurrently to most methods, except for getNextFrame |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 247 | */ |
| 248 | virtual status_t waitForNextFrame(nsecs_t timeout) = 0; |
| 249 | |
| 250 | /** |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 251 | * Get next capture result frame from the result queue. Returns NOT_ENOUGH_DATA |
| 252 | * if the queue is empty; caller takes ownership of the metadata buffer inside |
| 253 | * the capture result object's metadata field. |
| 254 | * May be called concurrently to most methods, except for waitForNextFrame. |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 255 | */ |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 256 | virtual status_t getNextResult(CaptureResult *frame) = 0; |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 257 | |
| 258 | /** |
| 259 | * Trigger auto-focus. The latest ID used in a trigger autofocus or cancel |
| 260 | * autofocus call will be returned by the HAL in all subsequent AF |
| 261 | * notifications. |
| 262 | */ |
| 263 | virtual status_t triggerAutofocus(uint32_t id) = 0; |
| 264 | |
| 265 | /** |
| 266 | * Cancel auto-focus. The latest ID used in a trigger autofocus/cancel |
| 267 | * autofocus call will be returned by the HAL in all subsequent AF |
| 268 | * notifications. |
| 269 | */ |
| 270 | virtual status_t triggerCancelAutofocus(uint32_t id) = 0; |
| 271 | |
| 272 | /** |
| 273 | * Trigger pre-capture metering. The latest ID used in a trigger pre-capture |
| 274 | * call will be returned by the HAL in all subsequent AE and AWB |
| 275 | * notifications. |
| 276 | */ |
| 277 | virtual status_t triggerPrecaptureMetering(uint32_t id) = 0; |
| 278 | |
| 279 | /** |
Eino-Ville Talvala | abaa51d | 2013-08-14 11:37:00 -0700 | [diff] [blame] | 280 | * Flush all pending and in-flight requests. Blocks until flush is |
| 281 | * complete. |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 282 | * 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] | 283 | */ |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 284 | virtual status_t flush(int64_t *lastFrameNumber = NULL) = 0; |
Eino-Ville Talvala | abaa51d | 2013-08-14 11:37:00 -0700 | [diff] [blame] | 285 | |
Zhijun He | 204e329 | 2014-07-14 17:09:23 -0700 | [diff] [blame] | 286 | /** |
Eino-Ville Talvala | 4d44cad | 2015-04-11 13:15:45 -0700 | [diff] [blame] | 287 | * Prepare stream by preallocating buffers for it asynchronously. |
| 288 | * Calls notifyPrepared() once allocation is complete. |
| 289 | */ |
| 290 | virtual status_t prepare(int streamId) = 0; |
| 291 | |
| 292 | /** |
Eino-Ville Talvala | b25e3c8 | 2015-07-15 16:04:27 -0700 | [diff] [blame] | 293 | * Free stream resources by dumping its unused gralloc buffers. |
| 294 | */ |
| 295 | virtual status_t tearDown(int streamId) = 0; |
| 296 | |
| 297 | /** |
Shuzhen Wang | b0fdc1e | 2016-03-20 23:21:39 -0700 | [diff] [blame] | 298 | * Add buffer listener for a particular stream in the device. |
| 299 | */ |
| 300 | virtual status_t addBufferListenerForStream(int streamId, |
| 301 | wp<camera3::Camera3StreamBufferListener> listener) = 0; |
| 302 | |
| 303 | /** |
Ruben Brunk | c78ac26 | 2015-08-13 17:58:46 -0700 | [diff] [blame] | 304 | * Prepare stream by preallocating up to maxCount buffers for it asynchronously. |
| 305 | * Calls notifyPrepared() once allocation is complete. |
| 306 | */ |
| 307 | virtual status_t prepare(int maxCount, int streamId) = 0; |
| 308 | |
| 309 | /** |
Zhijun He | 204e329 | 2014-07-14 17:09:23 -0700 | [diff] [blame] | 310 | * Get the HAL device version. |
| 311 | */ |
| 312 | virtual uint32_t getDeviceVersion() = 0; |
Zhijun He | 5d677d1 | 2016-05-29 16:52:39 -0700 | [diff] [blame] | 313 | |
| 314 | /** |
| 315 | * Set the deferred consumer surface and finish the rest of the stream configuration. |
| 316 | */ |
Shuzhen Wang | 758c215 | 2017-01-10 18:26:18 -0800 | [diff] [blame] | 317 | virtual status_t setConsumerSurfaces(int streamId, |
| 318 | const std::vector<sp<Surface>>& consumers) = 0; |
Zhijun He | 5d677d1 | 2016-05-29 16:52:39 -0700 | [diff] [blame] | 319 | |
Eino-Ville Talvala | 7fa43f3 | 2013-02-06 17:20:07 -0800 | [diff] [blame] | 320 | }; |
| 321 | |
| 322 | }; // namespace android |
| 323 | |
| 324 | #endif |