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