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