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