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