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