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