Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 1 | /* |
| 2 | ** |
Shuzhen Wang | c28189a | 2017-11-27 23:05:10 -0800 | [diff] [blame] | 3 | ** Copyright 2015-2018, The Android Open Source Project |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 4 | ** |
| 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | ** you may not use this file except in compliance with the License. |
| 7 | ** You may obtain a copy of the License at |
| 8 | ** |
| 9 | ** http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | ** |
| 11 | ** Unless required by applicable law or agreed to in writing, software |
| 12 | ** distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | ** See the License for the specific language governing permissions and |
| 15 | ** limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | #define LOG_TAG "OutputConfiguration" |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 19 | //#define LOG_NDEBUG 0 |
| 20 | |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 21 | #include <utils/Log.h> |
| 22 | |
| 23 | #include <camera/camera2/OutputConfiguration.h> |
Austin Borger | 71d8f67 | 2023-06-01 16:51:35 -0700 | [diff] [blame] | 24 | #include <camera/StringUtils.h> |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 25 | #include <binder/Parcel.h> |
Mathias Agopian | 032845c | 2017-02-08 17:05:02 -0800 | [diff] [blame] | 26 | #include <gui/view/Surface.h> |
Emilian Peev | 2295df7 | 2021-11-12 18:14:10 -0800 | [diff] [blame] | 27 | #include <system/camera_metadata.h> |
Shuzhen Wang | 0709c28 | 2024-02-12 09:09:32 -0800 | [diff] [blame^] | 28 | #include <system/graphics.h> |
Brian Anderson | f675356 | 2016-10-11 14:51:05 -0700 | [diff] [blame] | 29 | #include <utils/String8.h> |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 30 | |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 31 | |
Austin Borger | 9e2b27c | 2022-07-15 11:27:24 -0700 | [diff] [blame] | 32 | namespace android { |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 33 | |
| 34 | const int OutputConfiguration::INVALID_ROTATION = -1; |
Zhijun He | 018107a | 2016-01-18 15:32:50 -0800 | [diff] [blame] | 35 | const int OutputConfiguration::INVALID_SET_ID = -1; |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 36 | |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 37 | const std::vector<sp<IGraphicBufferProducer>>& |
| 38 | OutputConfiguration::getGraphicBufferProducers() const { |
| 39 | return mGbps; |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | int OutputConfiguration::getRotation() const { |
| 43 | return mRotation; |
| 44 | } |
| 45 | |
Zhijun He | 018107a | 2016-01-18 15:32:50 -0800 | [diff] [blame] | 46 | int OutputConfiguration::getSurfaceSetID() const { |
| 47 | return mSurfaceSetID; |
| 48 | } |
| 49 | |
Zhijun He | 5d677d1 | 2016-05-29 16:52:39 -0700 | [diff] [blame] | 50 | int OutputConfiguration::getSurfaceType() const { |
| 51 | return mSurfaceType; |
| 52 | } |
| 53 | |
| 54 | int OutputConfiguration::getWidth() const { |
| 55 | return mWidth; |
| 56 | } |
| 57 | |
| 58 | int OutputConfiguration::getHeight() const { |
| 59 | return mHeight; |
| 60 | } |
| 61 | |
Shuzhen Wang | 758c215 | 2017-01-10 18:26:18 -0800 | [diff] [blame] | 62 | bool OutputConfiguration::isDeferred() const { |
| 63 | return mIsDeferred; |
| 64 | } |
| 65 | |
| 66 | bool OutputConfiguration::isShared() const { |
| 67 | return mIsShared; |
| 68 | } |
| 69 | |
Austin Borger | 71d8f67 | 2023-06-01 16:51:35 -0700 | [diff] [blame] | 70 | std::string OutputConfiguration::getPhysicalCameraId() const { |
Shuzhen Wang | c28189a | 2017-11-27 23:05:10 -0800 | [diff] [blame] | 71 | return mPhysicalCameraId; |
| 72 | } |
| 73 | |
Shuzhen Wang | 83bff12 | 2020-11-20 15:51:39 -0800 | [diff] [blame] | 74 | bool OutputConfiguration::isMultiResolution() const { |
| 75 | return mIsMultiResolution; |
| 76 | } |
| 77 | |
Jayant Chowdhary | 13f9b2f | 2020-12-02 22:46:15 -0800 | [diff] [blame] | 78 | const std::vector<int32_t> &OutputConfiguration::getSensorPixelModesUsed() const { |
| 79 | return mSensorPixelModesUsed; |
| 80 | } |
| 81 | |
Emilian Peev | c81a759 | 2022-02-14 17:38:18 -0800 | [diff] [blame] | 82 | int64_t OutputConfiguration::getDynamicRangeProfile() const { |
Emilian Peev | 2295df7 | 2021-11-12 18:14:10 -0800 | [diff] [blame] | 83 | return mDynamicRangeProfile; |
| 84 | } |
| 85 | |
Austin Borger | 9e2b27c | 2022-07-15 11:27:24 -0700 | [diff] [blame] | 86 | int32_t OutputConfiguration::getColorSpace() const { |
| 87 | return mColorSpace; |
| 88 | } |
| 89 | |
Shuzhen Wang | 8ed1e87 | 2022-03-08 16:34:33 -0800 | [diff] [blame] | 90 | int64_t OutputConfiguration::getStreamUseCase() const { |
Shuzhen Wang | c8ab452 | 2021-12-14 20:12:42 -0800 | [diff] [blame] | 91 | return mStreamUseCase; |
| 92 | } |
| 93 | |
Shuzhen Wang | e420892 | 2022-02-01 16:52:48 -0800 | [diff] [blame] | 94 | int OutputConfiguration::getTimestampBase() const { |
| 95 | return mTimestampBase; |
| 96 | } |
| 97 | |
Shuzhen Wang | 610d7b8 | 2022-02-08 14:37:22 -0800 | [diff] [blame] | 98 | int OutputConfiguration::getMirrorMode() const { |
| 99 | return mMirrorMode; |
| 100 | } |
| 101 | |
Shuzhen Wang | bce53db | 2022-12-03 00:38:20 +0000 | [diff] [blame] | 102 | bool OutputConfiguration::useReadoutTimestamp() const { |
| 103 | return mUseReadoutTimestamp; |
| 104 | } |
| 105 | |
Shuzhen Wang | 0709c28 | 2024-02-12 09:09:32 -0800 | [diff] [blame^] | 106 | int OutputConfiguration::getFormat() const { |
| 107 | return mFormat; |
| 108 | } |
| 109 | |
| 110 | int OutputConfiguration::getDataspace() const { |
| 111 | return mDataspace; |
| 112 | } |
| 113 | |
| 114 | int64_t OutputConfiguration::getUsage() const { |
| 115 | return mUsage; |
| 116 | } |
| 117 | |
| 118 | bool OutputConfiguration::isComplete() const { |
| 119 | return !((mSurfaceType == SURFACE_TYPE_MEDIA_RECORDER || |
| 120 | mSurfaceType == SURFACE_TYPE_MEDIA_CODEC || |
| 121 | mSurfaceType == SURFACE_TYPE_IMAGE_READER) && |
| 122 | mGbps.empty()); |
| 123 | } |
| 124 | |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 125 | OutputConfiguration::OutputConfiguration() : |
| 126 | mRotation(INVALID_ROTATION), |
Zhijun He | 5d677d1 | 2016-05-29 16:52:39 -0700 | [diff] [blame] | 127 | mSurfaceSetID(INVALID_SET_ID), |
| 128 | mSurfaceType(SURFACE_TYPE_UNKNOWN), |
| 129 | mWidth(0), |
Shuzhen Wang | 758c215 | 2017-01-10 18:26:18 -0800 | [diff] [blame] | 130 | mHeight(0), |
| 131 | mIsDeferred(false), |
Shuzhen Wang | 83bff12 | 2020-11-20 15:51:39 -0800 | [diff] [blame] | 132 | mIsShared(false), |
Emilian Peev | 2295df7 | 2021-11-12 18:14:10 -0800 | [diff] [blame] | 133 | mIsMultiResolution(false), |
Shuzhen Wang | c8ab452 | 2021-12-14 20:12:42 -0800 | [diff] [blame] | 134 | mDynamicRangeProfile(ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_STANDARD), |
Austin Borger | 9e2b27c | 2022-07-15 11:27:24 -0700 | [diff] [blame] | 135 | mColorSpace(ANDROID_REQUEST_AVAILABLE_COLOR_SPACE_PROFILES_MAP_UNSPECIFIED), |
Shuzhen Wang | e420892 | 2022-02-01 16:52:48 -0800 | [diff] [blame] | 136 | mStreamUseCase(ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT), |
Shuzhen Wang | 610d7b8 | 2022-02-08 14:37:22 -0800 | [diff] [blame] | 137 | mTimestampBase(TIMESTAMP_BASE_DEFAULT), |
Shuzhen Wang | bce53db | 2022-12-03 00:38:20 +0000 | [diff] [blame] | 138 | mMirrorMode(MIRROR_MODE_AUTO), |
Shuzhen Wang | 0709c28 | 2024-02-12 09:09:32 -0800 | [diff] [blame^] | 139 | mUseReadoutTimestamp(false), |
| 140 | mFormat(HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED), |
| 141 | mDataspace(0), |
| 142 | mUsage(0) { |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 143 | } |
| 144 | |
Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 145 | OutputConfiguration::OutputConfiguration(const android::Parcel& parcel) : |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 146 | mRotation(INVALID_ROTATION), |
| 147 | mSurfaceSetID(INVALID_SET_ID) { |
| 148 | readFromParcel(&parcel); |
| 149 | } |
| 150 | |
Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 151 | status_t OutputConfiguration::readFromParcel(const android::Parcel* parcel) { |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 152 | status_t err = OK; |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 153 | int rotation = 0; |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 154 | |
| 155 | if (parcel == nullptr) return BAD_VALUE; |
| 156 | |
| 157 | if ((err = parcel->readInt32(&rotation)) != OK) { |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 158 | ALOGE("%s: Failed to read rotation from parcel", __FUNCTION__); |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 159 | return err; |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 160 | } |
| 161 | |
Zhijun He | 018107a | 2016-01-18 15:32:50 -0800 | [diff] [blame] | 162 | int setID = INVALID_SET_ID; |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 163 | if ((err = parcel->readInt32(&setID)) != OK) { |
Zhijun He | 018107a | 2016-01-18 15:32:50 -0800 | [diff] [blame] | 164 | ALOGE("%s: Failed to read surface set ID from parcel", __FUNCTION__); |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 165 | return err; |
Zhijun He | 018107a | 2016-01-18 15:32:50 -0800 | [diff] [blame] | 166 | } |
| 167 | |
Zhijun He | 5d677d1 | 2016-05-29 16:52:39 -0700 | [diff] [blame] | 168 | int surfaceType = SURFACE_TYPE_UNKNOWN; |
| 169 | if ((err = parcel->readInt32(&surfaceType)) != OK) { |
| 170 | ALOGE("%s: Failed to read surface type from parcel", __FUNCTION__); |
| 171 | return err; |
| 172 | } |
| 173 | |
| 174 | int width = 0; |
| 175 | if ((err = parcel->readInt32(&width)) != OK) { |
| 176 | ALOGE("%s: Failed to read surface width from parcel", __FUNCTION__); |
| 177 | return err; |
| 178 | } |
| 179 | |
| 180 | int height = 0; |
| 181 | if ((err = parcel->readInt32(&height)) != OK) { |
| 182 | ALOGE("%s: Failed to read surface height from parcel", __FUNCTION__); |
| 183 | return err; |
| 184 | } |
| 185 | |
Shuzhen Wang | 758c215 | 2017-01-10 18:26:18 -0800 | [diff] [blame] | 186 | int isDeferred = 0; |
| 187 | if ((err = parcel->readInt32(&isDeferred)) != OK) { |
| 188 | ALOGE("%s: Failed to read surface isDeferred flag from parcel", __FUNCTION__); |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 189 | return err; |
| 190 | } |
Shuzhen Wang | 758c215 | 2017-01-10 18:26:18 -0800 | [diff] [blame] | 191 | |
| 192 | int isShared = 0; |
| 193 | if ((err = parcel->readInt32(&isShared)) != OK) { |
| 194 | ALOGE("%s: Failed to read surface isShared flag from parcel", __FUNCTION__); |
| 195 | return err; |
| 196 | } |
| 197 | |
| 198 | if (isDeferred && surfaceType != SURFACE_TYPE_SURFACE_VIEW && |
| 199 | surfaceType != SURFACE_TYPE_SURFACE_TEXTURE) { |
| 200 | ALOGE("%s: Invalid surface type for deferred configuration", __FUNCTION__); |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 201 | return BAD_VALUE; |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 202 | } |
| 203 | |
Shuzhen Wang | 758c215 | 2017-01-10 18:26:18 -0800 | [diff] [blame] | 204 | std::vector<view::Surface> surfaceShims; |
| 205 | if ((err = parcel->readParcelableVector(&surfaceShims)) != OK) { |
| 206 | ALOGE("%s: Failed to read surface(s) from parcel", __FUNCTION__); |
| 207 | return err; |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 208 | } |
| 209 | |
Austin Borger | 71d8f67 | 2023-06-01 16:51:35 -0700 | [diff] [blame] | 210 | String16 physicalCameraId; |
| 211 | parcel->readString16(&physicalCameraId); |
| 212 | mPhysicalCameraId = toStdString(physicalCameraId); |
Shuzhen Wang | c28189a | 2017-11-27 23:05:10 -0800 | [diff] [blame] | 213 | |
Shuzhen Wang | 83bff12 | 2020-11-20 15:51:39 -0800 | [diff] [blame] | 214 | int isMultiResolution = 0; |
| 215 | if ((err = parcel->readInt32(&isMultiResolution)) != OK) { |
| 216 | ALOGE("%s: Failed to read surface isMultiResolution flag from parcel", __FUNCTION__); |
| 217 | return err; |
| 218 | } |
| 219 | |
Jayant Chowdhary | 13f9b2f | 2020-12-02 22:46:15 -0800 | [diff] [blame] | 220 | std::vector<int32_t> sensorPixelModesUsed; |
Jayant Chowdhary | 84df28c | 2021-05-26 22:32:21 -0700 | [diff] [blame] | 221 | if ((err = parcel->readInt32Vector(&sensorPixelModesUsed)) != OK) { |
Jayant Chowdhary | 13f9b2f | 2020-12-02 22:46:15 -0800 | [diff] [blame] | 222 | ALOGE("%s: Failed to read sensor pixel mode(s) from parcel", __FUNCTION__); |
| 223 | return err; |
| 224 | } |
Emilian Peev | c81a759 | 2022-02-14 17:38:18 -0800 | [diff] [blame] | 225 | int64_t dynamicProfile; |
| 226 | if ((err = parcel->readInt64(&dynamicProfile)) != OK) { |
Emilian Peev | 2295df7 | 2021-11-12 18:14:10 -0800 | [diff] [blame] | 227 | ALOGE("%s: Failed to read surface dynamic range profile flag from parcel", __FUNCTION__); |
| 228 | return err; |
| 229 | } |
Austin Borger | 9e2b27c | 2022-07-15 11:27:24 -0700 | [diff] [blame] | 230 | int32_t colorSpace; |
| 231 | if ((err = parcel->readInt32(&colorSpace)) != OK) { |
| 232 | ALOGE("%s: Failed to read surface color space flag from parcel", __FUNCTION__); |
| 233 | return err; |
| 234 | } |
Emilian Peev | 2295df7 | 2021-11-12 18:14:10 -0800 | [diff] [blame] | 235 | |
Shuzhen Wang | 8ed1e87 | 2022-03-08 16:34:33 -0800 | [diff] [blame] | 236 | int64_t streamUseCase = ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT; |
| 237 | if ((err = parcel->readInt64(&streamUseCase)) != OK) { |
Shuzhen Wang | c8ab452 | 2021-12-14 20:12:42 -0800 | [diff] [blame] | 238 | ALOGE("%s: Failed to read stream use case from parcel", __FUNCTION__); |
| 239 | return err; |
| 240 | } |
| 241 | |
Shuzhen Wang | e420892 | 2022-02-01 16:52:48 -0800 | [diff] [blame] | 242 | int timestampBase = TIMESTAMP_BASE_DEFAULT; |
| 243 | if ((err = parcel->readInt32(×tampBase)) != OK) { |
| 244 | ALOGE("%s: Failed to read timestamp base from parcel", __FUNCTION__); |
| 245 | return err; |
| 246 | } |
| 247 | |
Shuzhen Wang | 610d7b8 | 2022-02-08 14:37:22 -0800 | [diff] [blame] | 248 | int mirrorMode = MIRROR_MODE_AUTO; |
| 249 | if ((err = parcel->readInt32(&mirrorMode)) != OK) { |
| 250 | ALOGE("%s: Failed to read mirroring mode from parcel", __FUNCTION__); |
| 251 | return err; |
| 252 | } |
| 253 | |
Shuzhen Wang | bce53db | 2022-12-03 00:38:20 +0000 | [diff] [blame] | 254 | int useReadoutTimestamp = 0; |
| 255 | if ((err = parcel->readInt32(&useReadoutTimestamp)) != OK) { |
| 256 | ALOGE("%s: Failed to read useReadoutTimestamp flag from parcel", __FUNCTION__); |
| 257 | return err; |
| 258 | } |
| 259 | |
Shuzhen Wang | 0709c28 | 2024-02-12 09:09:32 -0800 | [diff] [blame^] | 260 | int format = HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED; |
| 261 | if ((err = parcel->readInt32(&format)) != OK) { |
| 262 | ALOGE("%s: Failed to read format from parcel", __FUNCTION__); |
| 263 | return err; |
| 264 | } |
| 265 | |
| 266 | int dataspace = 0; |
| 267 | if ((err = parcel->readInt32(&dataspace)) != OK) { |
| 268 | ALOGE("%s: Failed to read dataspace from parcel", __FUNCTION__); |
| 269 | return err; |
| 270 | } |
| 271 | |
| 272 | int64_t usage = 0; |
| 273 | if ((err = parcel->readInt64(&usage)) != OK) { |
| 274 | ALOGE("%s: Failed to read usage flag from parcel", __FUNCTION__); |
| 275 | return err; |
| 276 | } |
| 277 | |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 278 | mRotation = rotation; |
Zhijun He | 018107a | 2016-01-18 15:32:50 -0800 | [diff] [blame] | 279 | mSurfaceSetID = setID; |
Zhijun He | 5d677d1 | 2016-05-29 16:52:39 -0700 | [diff] [blame] | 280 | mSurfaceType = surfaceType; |
| 281 | mWidth = width; |
| 282 | mHeight = height; |
Shuzhen Wang | 758c215 | 2017-01-10 18:26:18 -0800 | [diff] [blame] | 283 | mIsDeferred = isDeferred != 0; |
| 284 | mIsShared = isShared != 0; |
Shuzhen Wang | 83bff12 | 2020-11-20 15:51:39 -0800 | [diff] [blame] | 285 | mIsMultiResolution = isMultiResolution != 0; |
Shuzhen Wang | c8ab452 | 2021-12-14 20:12:42 -0800 | [diff] [blame] | 286 | mStreamUseCase = streamUseCase; |
Shuzhen Wang | e420892 | 2022-02-01 16:52:48 -0800 | [diff] [blame] | 287 | mTimestampBase = timestampBase; |
Shuzhen Wang | 610d7b8 | 2022-02-08 14:37:22 -0800 | [diff] [blame] | 288 | mMirrorMode = mirrorMode; |
Shuzhen Wang | bce53db | 2022-12-03 00:38:20 +0000 | [diff] [blame] | 289 | mUseReadoutTimestamp = useReadoutTimestamp != 0; |
Shuzhen Wang | 758c215 | 2017-01-10 18:26:18 -0800 | [diff] [blame] | 290 | for (auto& surface : surfaceShims) { |
| 291 | ALOGV("%s: OutputConfiguration: %p, name %s", __FUNCTION__, |
| 292 | surface.graphicBufferProducer.get(), |
Tomasz Wasilczyk | 12b04a5 | 2023-08-11 15:52:22 +0000 | [diff] [blame] | 293 | toString8(surface.name).c_str()); |
Shuzhen Wang | 758c215 | 2017-01-10 18:26:18 -0800 | [diff] [blame] | 294 | mGbps.push_back(surface.graphicBufferProducer); |
| 295 | } |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 296 | |
Jayant Chowdhary | 13f9b2f | 2020-12-02 22:46:15 -0800 | [diff] [blame] | 297 | mSensorPixelModesUsed = std::move(sensorPixelModesUsed); |
Emilian Peev | 2295df7 | 2021-11-12 18:14:10 -0800 | [diff] [blame] | 298 | mDynamicRangeProfile = dynamicProfile; |
Austin Borger | 9e2b27c | 2022-07-15 11:27:24 -0700 | [diff] [blame] | 299 | mColorSpace = colorSpace; |
Shuzhen Wang | 0709c28 | 2024-02-12 09:09:32 -0800 | [diff] [blame^] | 300 | mFormat = format; |
| 301 | mDataspace = dataspace; |
| 302 | mUsage = usage; |
Jayant Chowdhary | 13f9b2f | 2020-12-02 22:46:15 -0800 | [diff] [blame] | 303 | |
Shuzhen Wang | c28189a | 2017-11-27 23:05:10 -0800 | [diff] [blame] | 304 | ALOGV("%s: OutputConfiguration: rotation = %d, setId = %d, surfaceType = %d," |
Shuzhen Wang | 8ed1e87 | 2022-03-08 16:34:33 -0800 | [diff] [blame] | 305 | " physicalCameraId = %s, isMultiResolution = %d, streamUseCase = %" PRId64 |
Shuzhen Wang | 0709c28 | 2024-02-12 09:09:32 -0800 | [diff] [blame^] | 306 | ", timestampBase = %d, mirrorMode = %d, useReadoutTimestamp = %d, format = %d, " |
| 307 | "dataspace = %d, usage = %" PRId64, |
Shuzhen Wang | e420892 | 2022-02-01 16:52:48 -0800 | [diff] [blame] | 308 | __FUNCTION__, mRotation, mSurfaceSetID, mSurfaceType, |
Austin Borger | 71d8f67 | 2023-06-01 16:51:35 -0700 | [diff] [blame] | 309 | mPhysicalCameraId.c_str(), mIsMultiResolution, mStreamUseCase, timestampBase, |
Shuzhen Wang | 0709c28 | 2024-02-12 09:09:32 -0800 | [diff] [blame^] | 310 | mMirrorMode, mUseReadoutTimestamp, mFormat, mDataspace, mUsage); |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 311 | |
| 312 | return err; |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 313 | } |
| 314 | |
Zhijun He | 018107a | 2016-01-18 15:32:50 -0800 | [diff] [blame] | 315 | OutputConfiguration::OutputConfiguration(sp<IGraphicBufferProducer>& gbp, int rotation, |
Austin Borger | 71d8f67 | 2023-06-01 16:51:35 -0700 | [diff] [blame] | 316 | const std::string& physicalId, |
Emilian Peev | 40ead60 | 2017-09-26 15:46:36 +0100 | [diff] [blame] | 317 | int surfaceSetID, bool isShared) { |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 318 | mGbps.push_back(gbp); |
Ruben Brunk | 3450ba7 | 2015-06-16 11:00:37 -0700 | [diff] [blame] | 319 | mRotation = rotation; |
Zhijun He | 018107a | 2016-01-18 15:32:50 -0800 | [diff] [blame] | 320 | mSurfaceSetID = surfaceSetID; |
Shuzhen Wang | 758c215 | 2017-01-10 18:26:18 -0800 | [diff] [blame] | 321 | mIsDeferred = false; |
Emilian Peev | 40ead60 | 2017-09-26 15:46:36 +0100 | [diff] [blame] | 322 | mIsShared = isShared; |
Shuzhen Wang | 0ff9ae3 | 2018-12-05 18:06:12 -0800 | [diff] [blame] | 323 | mPhysicalCameraId = physicalId; |
Shuzhen Wang | 83bff12 | 2020-11-20 15:51:39 -0800 | [diff] [blame] | 324 | mIsMultiResolution = false; |
Emilian Peev | 2295df7 | 2021-11-12 18:14:10 -0800 | [diff] [blame] | 325 | mDynamicRangeProfile = ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_STANDARD; |
Austin Borger | 9e2b27c | 2022-07-15 11:27:24 -0700 | [diff] [blame] | 326 | mColorSpace = ANDROID_REQUEST_AVAILABLE_COLOR_SPACE_PROFILES_MAP_UNSPECIFIED; |
Shuzhen Wang | c8ab452 | 2021-12-14 20:12:42 -0800 | [diff] [blame] | 327 | mStreamUseCase = ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT; |
Shuzhen Wang | e420892 | 2022-02-01 16:52:48 -0800 | [diff] [blame] | 328 | mTimestampBase = TIMESTAMP_BASE_DEFAULT; |
Shuzhen Wang | 610d7b8 | 2022-02-08 14:37:22 -0800 | [diff] [blame] | 329 | mMirrorMode = MIRROR_MODE_AUTO; |
Shuzhen Wang | bce53db | 2022-12-03 00:38:20 +0000 | [diff] [blame] | 330 | mUseReadoutTimestamp = false; |
Shuzhen Wang | 0709c28 | 2024-02-12 09:09:32 -0800 | [diff] [blame^] | 331 | mFormat = HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED; |
| 332 | mDataspace = 0; |
| 333 | mUsage = 0; |
Ruben Brunk | 3450ba7 | 2015-06-16 11:00:37 -0700 | [diff] [blame] | 334 | } |
| 335 | |
Jayant Chowdhary | be543d4 | 2018-08-15 13:16:14 -0700 | [diff] [blame] | 336 | OutputConfiguration::OutputConfiguration( |
| 337 | const std::vector<sp<IGraphicBufferProducer>>& gbps, |
Austin Borger | 71d8f67 | 2023-06-01 16:51:35 -0700 | [diff] [blame] | 338 | int rotation, const std::string& physicalCameraId, int surfaceSetID, int surfaceType, |
Shuzhen Wang | 0ff9ae3 | 2018-12-05 18:06:12 -0800 | [diff] [blame] | 339 | int width, int height, bool isShared) |
Jayant Chowdhary | be543d4 | 2018-08-15 13:16:14 -0700 | [diff] [blame] | 340 | : mGbps(gbps), mRotation(rotation), mSurfaceSetID(surfaceSetID), mSurfaceType(surfaceType), |
Shuzhen Wang | 0ff9ae3 | 2018-12-05 18:06:12 -0800 | [diff] [blame] | 341 | mWidth(width), mHeight(height), mIsDeferred(false), mIsShared(isShared), |
Emilian Peev | 2295df7 | 2021-11-12 18:14:10 -0800 | [diff] [blame] | 342 | mPhysicalCameraId(physicalCameraId), mIsMultiResolution(false), |
Shuzhen Wang | c8ab452 | 2021-12-14 20:12:42 -0800 | [diff] [blame] | 343 | mDynamicRangeProfile(ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_STANDARD), |
Austin Borger | 9e2b27c | 2022-07-15 11:27:24 -0700 | [diff] [blame] | 344 | mColorSpace(ANDROID_REQUEST_AVAILABLE_COLOR_SPACE_PROFILES_MAP_UNSPECIFIED), |
Shuzhen Wang | e420892 | 2022-02-01 16:52:48 -0800 | [diff] [blame] | 345 | mStreamUseCase(ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT), |
Shuzhen Wang | 610d7b8 | 2022-02-08 14:37:22 -0800 | [diff] [blame] | 346 | mTimestampBase(TIMESTAMP_BASE_DEFAULT), |
Shuzhen Wang | 0709c28 | 2024-02-12 09:09:32 -0800 | [diff] [blame^] | 347 | mMirrorMode(MIRROR_MODE_AUTO), mUseReadoutTimestamp(false), |
| 348 | mFormat(HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED), mDataspace(0), |
| 349 | mUsage(0) { } |
Jayant Chowdhary | be543d4 | 2018-08-15 13:16:14 -0700 | [diff] [blame] | 350 | |
Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 351 | status_t OutputConfiguration::writeToParcel(android::Parcel* parcel) const { |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 352 | |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 353 | if (parcel == nullptr) return BAD_VALUE; |
| 354 | status_t err = OK; |
| 355 | |
| 356 | err = parcel->writeInt32(mRotation); |
| 357 | if (err != OK) return err; |
| 358 | |
| 359 | err = parcel->writeInt32(mSurfaceSetID); |
| 360 | if (err != OK) return err; |
| 361 | |
Zhijun He | 5d677d1 | 2016-05-29 16:52:39 -0700 | [diff] [blame] | 362 | err = parcel->writeInt32(mSurfaceType); |
| 363 | if (err != OK) return err; |
| 364 | |
| 365 | err = parcel->writeInt32(mWidth); |
| 366 | if (err != OK) return err; |
| 367 | |
| 368 | err = parcel->writeInt32(mHeight); |
| 369 | if (err != OK) return err; |
| 370 | |
Shuzhen Wang | 758c215 | 2017-01-10 18:26:18 -0800 | [diff] [blame] | 371 | err = parcel->writeInt32(mIsDeferred ? 1 : 0); |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 372 | if (err != OK) return err; |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 373 | |
Shuzhen Wang | 758c215 | 2017-01-10 18:26:18 -0800 | [diff] [blame] | 374 | err = parcel->writeInt32(mIsShared ? 1 : 0); |
| 375 | if (err != OK) return err; |
| 376 | |
| 377 | std::vector<view::Surface> surfaceShims; |
| 378 | for (auto& gbp : mGbps) { |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 379 | view::Surface surfaceShim; |
| 380 | surfaceShim.name = String16("unknown_name"); // name of surface |
Shuzhen Wang | 758c215 | 2017-01-10 18:26:18 -0800 | [diff] [blame] | 381 | surfaceShim.graphicBufferProducer = gbp; |
| 382 | surfaceShims.push_back(surfaceShim); |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 383 | } |
Shuzhen Wang | 758c215 | 2017-01-10 18:26:18 -0800 | [diff] [blame] | 384 | err = parcel->writeParcelableVector(surfaceShims); |
| 385 | if (err != OK) return err; |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 386 | |
Austin Borger | 71d8f67 | 2023-06-01 16:51:35 -0700 | [diff] [blame] | 387 | String16 physicalCameraId = toString16(mPhysicalCameraId); |
| 388 | err = parcel->writeString16(physicalCameraId); |
Shuzhen Wang | c28189a | 2017-11-27 23:05:10 -0800 | [diff] [blame] | 389 | if (err != OK) return err; |
| 390 | |
Shuzhen Wang | 83bff12 | 2020-11-20 15:51:39 -0800 | [diff] [blame] | 391 | err = parcel->writeInt32(mIsMultiResolution ? 1 : 0); |
| 392 | if (err != OK) return err; |
| 393 | |
Jayant Chowdhary | 13f9b2f | 2020-12-02 22:46:15 -0800 | [diff] [blame] | 394 | err = parcel->writeParcelableVector(mSensorPixelModesUsed); |
| 395 | if (err != OK) return err; |
| 396 | |
Emilian Peev | c81a759 | 2022-02-14 17:38:18 -0800 | [diff] [blame] | 397 | err = parcel->writeInt64(mDynamicRangeProfile); |
Emilian Peev | 2295df7 | 2021-11-12 18:14:10 -0800 | [diff] [blame] | 398 | if (err != OK) return err; |
| 399 | |
Austin Borger | 9e2b27c | 2022-07-15 11:27:24 -0700 | [diff] [blame] | 400 | err = parcel->writeInt32(mColorSpace); |
| 401 | if (err != OK) return err; |
| 402 | |
Shuzhen Wang | 8ed1e87 | 2022-03-08 16:34:33 -0800 | [diff] [blame] | 403 | err = parcel->writeInt64(mStreamUseCase); |
Shuzhen Wang | c8ab452 | 2021-12-14 20:12:42 -0800 | [diff] [blame] | 404 | if (err != OK) return err; |
| 405 | |
Shuzhen Wang | e420892 | 2022-02-01 16:52:48 -0800 | [diff] [blame] | 406 | err = parcel->writeInt32(mTimestampBase); |
| 407 | if (err != OK) return err; |
| 408 | |
Shuzhen Wang | 610d7b8 | 2022-02-08 14:37:22 -0800 | [diff] [blame] | 409 | err = parcel->writeInt32(mMirrorMode); |
| 410 | if (err != OK) return err; |
| 411 | |
Shuzhen Wang | bce53db | 2022-12-03 00:38:20 +0000 | [diff] [blame] | 412 | err = parcel->writeInt32(mUseReadoutTimestamp ? 1 : 0); |
| 413 | if (err != OK) return err; |
| 414 | |
Shuzhen Wang | 0709c28 | 2024-02-12 09:09:32 -0800 | [diff] [blame^] | 415 | err = parcel->writeInt32(mFormat); |
| 416 | if (err != OK) return err; |
| 417 | |
| 418 | err = parcel->writeInt32(mDataspace); |
| 419 | if (err != OK) return err; |
| 420 | |
| 421 | err = parcel->writeInt64(mUsage); |
| 422 | if (err != OK) return err; |
| 423 | |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 424 | return OK; |
| 425 | } |
| 426 | |
Jayant Chowdhary | 13f9b2f | 2020-12-02 22:46:15 -0800 | [diff] [blame] | 427 | template <typename T> |
| 428 | static bool simpleVectorsEqual(T first, T second) { |
| 429 | if (first.size() != second.size()) { |
| 430 | return false; |
| 431 | } |
| 432 | |
| 433 | for (size_t i = 0; i < first.size(); i++) { |
| 434 | if (first[i] != second[i]) { |
| 435 | return false; |
| 436 | } |
| 437 | } |
| 438 | return true; |
| 439 | } |
| 440 | |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 441 | bool OutputConfiguration::gbpsEqual(const OutputConfiguration& other) const { |
| 442 | const std::vector<sp<IGraphicBufferProducer> >& otherGbps = |
| 443 | other.getGraphicBufferProducers(); |
Jayant Chowdhary | 13f9b2f | 2020-12-02 22:46:15 -0800 | [diff] [blame] | 444 | return simpleVectorsEqual(otherGbps, mGbps); |
| 445 | } |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 446 | |
Jayant Chowdhary | 13f9b2f | 2020-12-02 22:46:15 -0800 | [diff] [blame] | 447 | bool OutputConfiguration::sensorPixelModesUsedEqual(const OutputConfiguration& other) const { |
| 448 | const std::vector<int32_t>& othersensorPixelModesUsed = other.getSensorPixelModesUsed(); |
| 449 | return simpleVectorsEqual(othersensorPixelModesUsed, mSensorPixelModesUsed); |
| 450 | } |
| 451 | |
| 452 | bool OutputConfiguration::sensorPixelModesUsedLessThan(const OutputConfiguration& other) const { |
| 453 | const std::vector<int32_t>& spms = other.getSensorPixelModesUsed(); |
| 454 | |
| 455 | if (mSensorPixelModesUsed.size() != spms.size()) { |
| 456 | return mSensorPixelModesUsed.size() < spms.size(); |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 457 | } |
| 458 | |
Jayant Chowdhary | 13f9b2f | 2020-12-02 22:46:15 -0800 | [diff] [blame] | 459 | for (size_t i = 0; i < spms.size(); i++) { |
| 460 | if (mSensorPixelModesUsed[i] != spms[i]) { |
| 461 | return mSensorPixelModesUsed[i] < spms[i]; |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 462 | } |
| 463 | } |
| 464 | |
Jayant Chowdhary | 13f9b2f | 2020-12-02 22:46:15 -0800 | [diff] [blame] | 465 | return false; |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 466 | } |
| 467 | |
| 468 | bool OutputConfiguration::gbpsLessThan(const OutputConfiguration& other) const { |
| 469 | const std::vector<sp<IGraphicBufferProducer> >& otherGbps = |
| 470 | other.getGraphicBufferProducers(); |
| 471 | |
| 472 | if (mGbps.size() != otherGbps.size()) { |
| 473 | return mGbps.size() < otherGbps.size(); |
| 474 | } |
| 475 | |
| 476 | for (size_t i = 0; i < mGbps.size(); i++) { |
| 477 | if (mGbps[i] != otherGbps[i]) { |
| 478 | return mGbps[i] < otherGbps[i]; |
| 479 | } |
| 480 | } |
| 481 | |
| 482 | return false; |
| 483 | } |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 484 | }; // namespace android |