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