blob: 2d1af321e14d7727eae9e194d4dec97b704112c1 [file] [log] [blame]
Yin-Chia Yehb97babb2015-03-12 13:42:44 -07001/*
2**
Shuzhen Wangc28189a2017-11-27 23:05:10 -08003** Copyright 2015-2018, The Android Open Source Project
Yin-Chia Yehb97babb2015-03-12 13:42:44 -07004**
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 Talvalad56db1d2015-12-17 16:50:35 -080019//#define LOG_NDEBUG 0
20
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070021#include <utils/Log.h>
22
23#include <camera/camera2/OutputConfiguration.h>
Austin Borger71d8f672023-06-01 16:51:35 -070024#include <camera/StringUtils.h>
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070025#include <binder/Parcel.h>
Mathias Agopian032845c2017-02-08 17:05:02 -080026#include <gui/view/Surface.h>
Emilian Peev2295df72021-11-12 18:14:10 -080027#include <system/camera_metadata.h>
Shuzhen Wang0709c282024-02-12 09:09:32 -080028#include <system/graphics.h>
Brian Andersonf6753562016-10-11 14:51:05 -070029#include <utils/String8.h>
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070030
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070031
Austin Borger9e2b27c2022-07-15 11:27:24 -070032namespace android {
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070033
34const int OutputConfiguration::INVALID_ROTATION = -1;
Zhijun He018107a2016-01-18 15:32:50 -080035const int OutputConfiguration::INVALID_SET_ID = -1;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070036
Shuzhen Wang0129d522016-10-30 22:43:41 -070037const std::vector<sp<IGraphicBufferProducer>>&
38 OutputConfiguration::getGraphicBufferProducers() const {
39 return mGbps;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070040}
41
42int OutputConfiguration::getRotation() const {
43 return mRotation;
44}
45
Zhijun He018107a2016-01-18 15:32:50 -080046int OutputConfiguration::getSurfaceSetID() const {
47 return mSurfaceSetID;
48}
49
Zhijun He5d677d12016-05-29 16:52:39 -070050int OutputConfiguration::getSurfaceType() const {
51 return mSurfaceType;
52}
53
54int OutputConfiguration::getWidth() const {
55 return mWidth;
56}
57
58int OutputConfiguration::getHeight() const {
59 return mHeight;
60}
61
Shuzhen Wang758c2152017-01-10 18:26:18 -080062bool OutputConfiguration::isDeferred() const {
63 return mIsDeferred;
64}
65
66bool OutputConfiguration::isShared() const {
67 return mIsShared;
68}
69
Austin Borger71d8f672023-06-01 16:51:35 -070070std::string OutputConfiguration::getPhysicalCameraId() const {
Shuzhen Wangc28189a2017-11-27 23:05:10 -080071 return mPhysicalCameraId;
72}
73
Shuzhen Wang83bff122020-11-20 15:51:39 -080074bool OutputConfiguration::isMultiResolution() const {
75 return mIsMultiResolution;
76}
77
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -080078const std::vector<int32_t> &OutputConfiguration::getSensorPixelModesUsed() const {
79 return mSensorPixelModesUsed;
80}
81
Emilian Peevc81a7592022-02-14 17:38:18 -080082int64_t OutputConfiguration::getDynamicRangeProfile() const {
Emilian Peev2295df72021-11-12 18:14:10 -080083 return mDynamicRangeProfile;
84}
85
Austin Borger9e2b27c2022-07-15 11:27:24 -070086int32_t OutputConfiguration::getColorSpace() const {
87 return mColorSpace;
88}
89
Shuzhen Wang8ed1e872022-03-08 16:34:33 -080090int64_t OutputConfiguration::getStreamUseCase() const {
Shuzhen Wangc8ab4522021-12-14 20:12:42 -080091 return mStreamUseCase;
92}
93
Shuzhen Wange4208922022-02-01 16:52:48 -080094int OutputConfiguration::getTimestampBase() const {
95 return mTimestampBase;
96}
97
Shuzhen Wang610d7b82022-02-08 14:37:22 -080098int OutputConfiguration::getMirrorMode() const {
99 return mMirrorMode;
100}
101
Shuzhen Wangbce53db2022-12-03 00:38:20 +0000102bool OutputConfiguration::useReadoutTimestamp() const {
103 return mUseReadoutTimestamp;
104}
105
Shuzhen Wang0709c282024-02-12 09:09:32 -0800106int OutputConfiguration::getFormat() const {
107 return mFormat;
108}
109
110int OutputConfiguration::getDataspace() const {
111 return mDataspace;
112}
113
114int64_t OutputConfiguration::getUsage() const {
115 return mUsage;
116}
117
118bool OutputConfiguration::isComplete() const {
119 return !((mSurfaceType == SURFACE_TYPE_MEDIA_RECORDER ||
120 mSurfaceType == SURFACE_TYPE_MEDIA_CODEC ||
121 mSurfaceType == SURFACE_TYPE_IMAGE_READER) &&
122 mGbps.empty());
123}
124
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800125OutputConfiguration::OutputConfiguration() :
126 mRotation(INVALID_ROTATION),
Zhijun He5d677d12016-05-29 16:52:39 -0700127 mSurfaceSetID(INVALID_SET_ID),
128 mSurfaceType(SURFACE_TYPE_UNKNOWN),
129 mWidth(0),
Shuzhen Wang758c2152017-01-10 18:26:18 -0800130 mHeight(0),
131 mIsDeferred(false),
Shuzhen Wang83bff122020-11-20 15:51:39 -0800132 mIsShared(false),
Emilian Peev2295df72021-11-12 18:14:10 -0800133 mIsMultiResolution(false),
Shuzhen Wangc8ab4522021-12-14 20:12:42 -0800134 mDynamicRangeProfile(ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_STANDARD),
Austin Borger9e2b27c2022-07-15 11:27:24 -0700135 mColorSpace(ANDROID_REQUEST_AVAILABLE_COLOR_SPACE_PROFILES_MAP_UNSPECIFIED),
Shuzhen Wange4208922022-02-01 16:52:48 -0800136 mStreamUseCase(ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT),
Shuzhen Wang610d7b82022-02-08 14:37:22 -0800137 mTimestampBase(TIMESTAMP_BASE_DEFAULT),
Shuzhen Wangbce53db2022-12-03 00:38:20 +0000138 mMirrorMode(MIRROR_MODE_AUTO),
Shuzhen Wang0709c282024-02-12 09:09:32 -0800139 mUseReadoutTimestamp(false),
140 mFormat(HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED),
141 mDataspace(0),
142 mUsage(0) {
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800143}
144
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800145OutputConfiguration::OutputConfiguration(const android::Parcel& parcel) :
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800146 mRotation(INVALID_ROTATION),
147 mSurfaceSetID(INVALID_SET_ID) {
148 readFromParcel(&parcel);
149}
150
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800151status_t OutputConfiguration::readFromParcel(const android::Parcel* parcel) {
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800152 status_t err = OK;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700153 int rotation = 0;
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800154
155 if (parcel == nullptr) return BAD_VALUE;
156
157 if ((err = parcel->readInt32(&rotation)) != OK) {
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700158 ALOGE("%s: Failed to read rotation from parcel", __FUNCTION__);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800159 return err;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700160 }
161
Zhijun He018107a2016-01-18 15:32:50 -0800162 int setID = INVALID_SET_ID;
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800163 if ((err = parcel->readInt32(&setID)) != OK) {
Zhijun He018107a2016-01-18 15:32:50 -0800164 ALOGE("%s: Failed to read surface set ID from parcel", __FUNCTION__);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800165 return err;
Zhijun He018107a2016-01-18 15:32:50 -0800166 }
167
Zhijun He5d677d12016-05-29 16:52:39 -0700168 int surfaceType = SURFACE_TYPE_UNKNOWN;
169 if ((err = parcel->readInt32(&surfaceType)) != OK) {
170 ALOGE("%s: Failed to read surface type from parcel", __FUNCTION__);
171 return err;
172 }
173
174 int width = 0;
175 if ((err = parcel->readInt32(&width)) != OK) {
176 ALOGE("%s: Failed to read surface width from parcel", __FUNCTION__);
177 return err;
178 }
179
180 int height = 0;
181 if ((err = parcel->readInt32(&height)) != OK) {
182 ALOGE("%s: Failed to read surface height from parcel", __FUNCTION__);
183 return err;
184 }
185
Shuzhen Wang758c2152017-01-10 18:26:18 -0800186 int isDeferred = 0;
187 if ((err = parcel->readInt32(&isDeferred)) != OK) {
188 ALOGE("%s: Failed to read surface isDeferred flag from parcel", __FUNCTION__);
Shuzhen Wang0129d522016-10-30 22:43:41 -0700189 return err;
190 }
Shuzhen Wang758c2152017-01-10 18:26:18 -0800191
192 int isShared = 0;
193 if ((err = parcel->readInt32(&isShared)) != OK) {
194 ALOGE("%s: Failed to read surface isShared flag from parcel", __FUNCTION__);
195 return err;
196 }
197
198 if (isDeferred && surfaceType != SURFACE_TYPE_SURFACE_VIEW &&
199 surfaceType != SURFACE_TYPE_SURFACE_TEXTURE) {
200 ALOGE("%s: Invalid surface type for deferred configuration", __FUNCTION__);
Shuzhen Wang0129d522016-10-30 22:43:41 -0700201 return BAD_VALUE;
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800202 }
203
Shuzhen Wang758c2152017-01-10 18:26:18 -0800204 std::vector<view::Surface> surfaceShims;
205 if ((err = parcel->readParcelableVector(&surfaceShims)) != OK) {
206 ALOGE("%s: Failed to read surface(s) from parcel", __FUNCTION__);
207 return err;
Shuzhen Wang0129d522016-10-30 22:43:41 -0700208 }
209
Austin Borger71d8f672023-06-01 16:51:35 -0700210 String16 physicalCameraId;
211 parcel->readString16(&physicalCameraId);
212 mPhysicalCameraId = toStdString(physicalCameraId);
Shuzhen Wangc28189a2017-11-27 23:05:10 -0800213
Shuzhen Wang83bff122020-11-20 15:51:39 -0800214 int isMultiResolution = 0;
215 if ((err = parcel->readInt32(&isMultiResolution)) != OK) {
216 ALOGE("%s: Failed to read surface isMultiResolution flag from parcel", __FUNCTION__);
217 return err;
218 }
219
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800220 std::vector<int32_t> sensorPixelModesUsed;
Jayant Chowdhary84df28c2021-05-26 22:32:21 -0700221 if ((err = parcel->readInt32Vector(&sensorPixelModesUsed)) != OK) {
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800222 ALOGE("%s: Failed to read sensor pixel mode(s) from parcel", __FUNCTION__);
223 return err;
224 }
Emilian Peevc81a7592022-02-14 17:38:18 -0800225 int64_t dynamicProfile;
226 if ((err = parcel->readInt64(&dynamicProfile)) != OK) {
Emilian Peev2295df72021-11-12 18:14:10 -0800227 ALOGE("%s: Failed to read surface dynamic range profile flag from parcel", __FUNCTION__);
228 return err;
229 }
Austin Borger9e2b27c2022-07-15 11:27:24 -0700230 int32_t colorSpace;
231 if ((err = parcel->readInt32(&colorSpace)) != OK) {
232 ALOGE("%s: Failed to read surface color space flag from parcel", __FUNCTION__);
233 return err;
234 }
Emilian Peev2295df72021-11-12 18:14:10 -0800235
Shuzhen Wang8ed1e872022-03-08 16:34:33 -0800236 int64_t streamUseCase = ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT;
237 if ((err = parcel->readInt64(&streamUseCase)) != OK) {
Shuzhen Wangc8ab4522021-12-14 20:12:42 -0800238 ALOGE("%s: Failed to read stream use case from parcel", __FUNCTION__);
239 return err;
240 }
241
Shuzhen Wange4208922022-02-01 16:52:48 -0800242 int timestampBase = TIMESTAMP_BASE_DEFAULT;
243 if ((err = parcel->readInt32(&timestampBase)) != OK) {
244 ALOGE("%s: Failed to read timestamp base from parcel", __FUNCTION__);
245 return err;
246 }
247
Shuzhen Wang610d7b82022-02-08 14:37:22 -0800248 int mirrorMode = MIRROR_MODE_AUTO;
249 if ((err = parcel->readInt32(&mirrorMode)) != OK) {
250 ALOGE("%s: Failed to read mirroring mode from parcel", __FUNCTION__);
251 return err;
252 }
253
Shuzhen Wangbce53db2022-12-03 00:38:20 +0000254 int useReadoutTimestamp = 0;
255 if ((err = parcel->readInt32(&useReadoutTimestamp)) != OK) {
256 ALOGE("%s: Failed to read useReadoutTimestamp flag from parcel", __FUNCTION__);
257 return err;
258 }
259
Shuzhen Wang0709c282024-02-12 09:09:32 -0800260 int format = HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED;
261 if ((err = parcel->readInt32(&format)) != OK) {
262 ALOGE("%s: Failed to read format from parcel", __FUNCTION__);
263 return err;
264 }
265
266 int dataspace = 0;
267 if ((err = parcel->readInt32(&dataspace)) != OK) {
268 ALOGE("%s: Failed to read dataspace from parcel", __FUNCTION__);
269 return err;
270 }
271
272 int64_t usage = 0;
273 if ((err = parcel->readInt64(&usage)) != OK) {
274 ALOGE("%s: Failed to read usage flag from parcel", __FUNCTION__);
275 return err;
276 }
277
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700278 mRotation = rotation;
Zhijun He018107a2016-01-18 15:32:50 -0800279 mSurfaceSetID = setID;
Zhijun He5d677d12016-05-29 16:52:39 -0700280 mSurfaceType = surfaceType;
281 mWidth = width;
282 mHeight = height;
Shuzhen Wang758c2152017-01-10 18:26:18 -0800283 mIsDeferred = isDeferred != 0;
284 mIsShared = isShared != 0;
Shuzhen Wang83bff122020-11-20 15:51:39 -0800285 mIsMultiResolution = isMultiResolution != 0;
Shuzhen Wangc8ab4522021-12-14 20:12:42 -0800286 mStreamUseCase = streamUseCase;
Shuzhen Wange4208922022-02-01 16:52:48 -0800287 mTimestampBase = timestampBase;
Shuzhen Wang610d7b82022-02-08 14:37:22 -0800288 mMirrorMode = mirrorMode;
Shuzhen Wangbce53db2022-12-03 00:38:20 +0000289 mUseReadoutTimestamp = useReadoutTimestamp != 0;
Shuzhen Wang758c2152017-01-10 18:26:18 -0800290 for (auto& surface : surfaceShims) {
291 ALOGV("%s: OutputConfiguration: %p, name %s", __FUNCTION__,
292 surface.graphicBufferProducer.get(),
Tomasz Wasilczyk12b04a52023-08-11 15:52:22 +0000293 toString8(surface.name).c_str());
Shuzhen Wang758c2152017-01-10 18:26:18 -0800294 mGbps.push_back(surface.graphicBufferProducer);
295 }
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700296
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800297 mSensorPixelModesUsed = std::move(sensorPixelModesUsed);
Emilian Peev2295df72021-11-12 18:14:10 -0800298 mDynamicRangeProfile = dynamicProfile;
Austin Borger9e2b27c2022-07-15 11:27:24 -0700299 mColorSpace = colorSpace;
Shuzhen Wang0709c282024-02-12 09:09:32 -0800300 mFormat = format;
301 mDataspace = dataspace;
302 mUsage = usage;
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800303
Shuzhen Wangc28189a2017-11-27 23:05:10 -0800304 ALOGV("%s: OutputConfiguration: rotation = %d, setId = %d, surfaceType = %d,"
Shuzhen Wang8ed1e872022-03-08 16:34:33 -0800305 " physicalCameraId = %s, isMultiResolution = %d, streamUseCase = %" PRId64
Shuzhen Wang0709c282024-02-12 09:09:32 -0800306 ", timestampBase = %d, mirrorMode = %d, useReadoutTimestamp = %d, format = %d, "
307 "dataspace = %d, usage = %" PRId64,
Shuzhen Wange4208922022-02-01 16:52:48 -0800308 __FUNCTION__, mRotation, mSurfaceSetID, mSurfaceType,
Austin Borger71d8f672023-06-01 16:51:35 -0700309 mPhysicalCameraId.c_str(), mIsMultiResolution, mStreamUseCase, timestampBase,
Shuzhen Wang0709c282024-02-12 09:09:32 -0800310 mMirrorMode, mUseReadoutTimestamp, mFormat, mDataspace, mUsage);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800311
312 return err;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700313}
314
Zhijun He018107a2016-01-18 15:32:50 -0800315OutputConfiguration::OutputConfiguration(sp<IGraphicBufferProducer>& gbp, int rotation,
Austin Borger71d8f672023-06-01 16:51:35 -0700316 const std::string& physicalId,
Emilian Peev40ead602017-09-26 15:46:36 +0100317 int surfaceSetID, bool isShared) {
Shuzhen Wang0129d522016-10-30 22:43:41 -0700318 mGbps.push_back(gbp);
Ruben Brunk3450ba72015-06-16 11:00:37 -0700319 mRotation = rotation;
Zhijun He018107a2016-01-18 15:32:50 -0800320 mSurfaceSetID = surfaceSetID;
Shuzhen Wang758c2152017-01-10 18:26:18 -0800321 mIsDeferred = false;
Emilian Peev40ead602017-09-26 15:46:36 +0100322 mIsShared = isShared;
Shuzhen Wang0ff9ae32018-12-05 18:06:12 -0800323 mPhysicalCameraId = physicalId;
Shuzhen Wang83bff122020-11-20 15:51:39 -0800324 mIsMultiResolution = false;
Emilian Peev2295df72021-11-12 18:14:10 -0800325 mDynamicRangeProfile = ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_STANDARD;
Austin Borger9e2b27c2022-07-15 11:27:24 -0700326 mColorSpace = ANDROID_REQUEST_AVAILABLE_COLOR_SPACE_PROFILES_MAP_UNSPECIFIED;
Shuzhen Wangc8ab4522021-12-14 20:12:42 -0800327 mStreamUseCase = ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT;
Shuzhen Wange4208922022-02-01 16:52:48 -0800328 mTimestampBase = TIMESTAMP_BASE_DEFAULT;
Shuzhen Wang610d7b82022-02-08 14:37:22 -0800329 mMirrorMode = MIRROR_MODE_AUTO;
Shuzhen Wangbce53db2022-12-03 00:38:20 +0000330 mUseReadoutTimestamp = false;
Shuzhen Wang0709c282024-02-12 09:09:32 -0800331 mFormat = HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED;
332 mDataspace = 0;
333 mUsage = 0;
Ruben Brunk3450ba72015-06-16 11:00:37 -0700334}
335
Jayant Chowdharybe543d42018-08-15 13:16:14 -0700336OutputConfiguration::OutputConfiguration(
337 const std::vector<sp<IGraphicBufferProducer>>& gbps,
Austin Borger71d8f672023-06-01 16:51:35 -0700338 int rotation, const std::string& physicalCameraId, int surfaceSetID, int surfaceType,
Shuzhen Wang0ff9ae32018-12-05 18:06:12 -0800339 int width, int height, bool isShared)
Jayant Chowdharybe543d42018-08-15 13:16:14 -0700340 : mGbps(gbps), mRotation(rotation), mSurfaceSetID(surfaceSetID), mSurfaceType(surfaceType),
Shuzhen Wang0ff9ae32018-12-05 18:06:12 -0800341 mWidth(width), mHeight(height), mIsDeferred(false), mIsShared(isShared),
Emilian Peev2295df72021-11-12 18:14:10 -0800342 mPhysicalCameraId(physicalCameraId), mIsMultiResolution(false),
Shuzhen Wangc8ab4522021-12-14 20:12:42 -0800343 mDynamicRangeProfile(ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_STANDARD),
Austin Borger9e2b27c2022-07-15 11:27:24 -0700344 mColorSpace(ANDROID_REQUEST_AVAILABLE_COLOR_SPACE_PROFILES_MAP_UNSPECIFIED),
Shuzhen Wange4208922022-02-01 16:52:48 -0800345 mStreamUseCase(ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT),
Shuzhen Wang610d7b82022-02-08 14:37:22 -0800346 mTimestampBase(TIMESTAMP_BASE_DEFAULT),
Shuzhen Wang0709c282024-02-12 09:09:32 -0800347 mMirrorMode(MIRROR_MODE_AUTO), mUseReadoutTimestamp(false),
348 mFormat(HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED), mDataspace(0),
349 mUsage(0) { }
Jayant Chowdharybe543d42018-08-15 13:16:14 -0700350
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800351status_t OutputConfiguration::writeToParcel(android::Parcel* parcel) const {
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700352
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800353 if (parcel == nullptr) return BAD_VALUE;
354 status_t err = OK;
355
356 err = parcel->writeInt32(mRotation);
357 if (err != OK) return err;
358
359 err = parcel->writeInt32(mSurfaceSetID);
360 if (err != OK) return err;
361
Zhijun He5d677d12016-05-29 16:52:39 -0700362 err = parcel->writeInt32(mSurfaceType);
363 if (err != OK) return err;
364
365 err = parcel->writeInt32(mWidth);
366 if (err != OK) return err;
367
368 err = parcel->writeInt32(mHeight);
369 if (err != OK) return err;
370
Shuzhen Wang758c2152017-01-10 18:26:18 -0800371 err = parcel->writeInt32(mIsDeferred ? 1 : 0);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800372 if (err != OK) return err;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700373
Shuzhen Wang758c2152017-01-10 18:26:18 -0800374 err = parcel->writeInt32(mIsShared ? 1 : 0);
375 if (err != OK) return err;
376
377 std::vector<view::Surface> surfaceShims;
378 for (auto& gbp : mGbps) {
Shuzhen Wang0129d522016-10-30 22:43:41 -0700379 view::Surface surfaceShim;
380 surfaceShim.name = String16("unknown_name"); // name of surface
Shuzhen Wang758c2152017-01-10 18:26:18 -0800381 surfaceShim.graphicBufferProducer = gbp;
382 surfaceShims.push_back(surfaceShim);
Shuzhen Wang0129d522016-10-30 22:43:41 -0700383 }
Shuzhen Wang758c2152017-01-10 18:26:18 -0800384 err = parcel->writeParcelableVector(surfaceShims);
385 if (err != OK) return err;
Shuzhen Wang0129d522016-10-30 22:43:41 -0700386
Austin Borger71d8f672023-06-01 16:51:35 -0700387 String16 physicalCameraId = toString16(mPhysicalCameraId);
388 err = parcel->writeString16(physicalCameraId);
Shuzhen Wangc28189a2017-11-27 23:05:10 -0800389 if (err != OK) return err;
390
Shuzhen Wang83bff122020-11-20 15:51:39 -0800391 err = parcel->writeInt32(mIsMultiResolution ? 1 : 0);
392 if (err != OK) return err;
393
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800394 err = parcel->writeParcelableVector(mSensorPixelModesUsed);
395 if (err != OK) return err;
396
Emilian Peevc81a7592022-02-14 17:38:18 -0800397 err = parcel->writeInt64(mDynamicRangeProfile);
Emilian Peev2295df72021-11-12 18:14:10 -0800398 if (err != OK) return err;
399
Austin Borger9e2b27c2022-07-15 11:27:24 -0700400 err = parcel->writeInt32(mColorSpace);
401 if (err != OK) return err;
402
Shuzhen Wang8ed1e872022-03-08 16:34:33 -0800403 err = parcel->writeInt64(mStreamUseCase);
Shuzhen Wangc8ab4522021-12-14 20:12:42 -0800404 if (err != OK) return err;
405
Shuzhen Wange4208922022-02-01 16:52:48 -0800406 err = parcel->writeInt32(mTimestampBase);
407 if (err != OK) return err;
408
Shuzhen Wang610d7b82022-02-08 14:37:22 -0800409 err = parcel->writeInt32(mMirrorMode);
410 if (err != OK) return err;
411
Shuzhen Wangbce53db2022-12-03 00:38:20 +0000412 err = parcel->writeInt32(mUseReadoutTimestamp ? 1 : 0);
413 if (err != OK) return err;
414
Shuzhen Wang0709c282024-02-12 09:09:32 -0800415 err = parcel->writeInt32(mFormat);
416 if (err != OK) return err;
417
418 err = parcel->writeInt32(mDataspace);
419 if (err != OK) return err;
420
421 err = parcel->writeInt64(mUsage);
422 if (err != OK) return err;
423
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700424 return OK;
425}
426
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800427template <typename T>
428static bool simpleVectorsEqual(T first, T second) {
429 if (first.size() != second.size()) {
430 return false;
431 }
432
433 for (size_t i = 0; i < first.size(); i++) {
434 if (first[i] != second[i]) {
435 return false;
436 }
437 }
438 return true;
439}
440
Shuzhen Wang0129d522016-10-30 22:43:41 -0700441bool OutputConfiguration::gbpsEqual(const OutputConfiguration& other) const {
442 const std::vector<sp<IGraphicBufferProducer> >& otherGbps =
443 other.getGraphicBufferProducers();
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800444 return simpleVectorsEqual(otherGbps, mGbps);
445}
Shuzhen Wang0129d522016-10-30 22:43:41 -0700446
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800447bool OutputConfiguration::sensorPixelModesUsedEqual(const OutputConfiguration& other) const {
448 const std::vector<int32_t>& othersensorPixelModesUsed = other.getSensorPixelModesUsed();
449 return simpleVectorsEqual(othersensorPixelModesUsed, mSensorPixelModesUsed);
450}
451
452bool OutputConfiguration::sensorPixelModesUsedLessThan(const OutputConfiguration& other) const {
453 const std::vector<int32_t>& spms = other.getSensorPixelModesUsed();
454
455 if (mSensorPixelModesUsed.size() != spms.size()) {
456 return mSensorPixelModesUsed.size() < spms.size();
Shuzhen Wang0129d522016-10-30 22:43:41 -0700457 }
458
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800459 for (size_t i = 0; i < spms.size(); i++) {
460 if (mSensorPixelModesUsed[i] != spms[i]) {
461 return mSensorPixelModesUsed[i] < spms[i];
Shuzhen Wang0129d522016-10-30 22:43:41 -0700462 }
463 }
464
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800465 return false;
Shuzhen Wang0129d522016-10-30 22:43:41 -0700466}
467
468bool OutputConfiguration::gbpsLessThan(const OutputConfiguration& other) const {
469 const std::vector<sp<IGraphicBufferProducer> >& otherGbps =
470 other.getGraphicBufferProducers();
471
472 if (mGbps.size() != otherGbps.size()) {
473 return mGbps.size() < otherGbps.size();
474 }
475
476 for (size_t i = 0; i < mGbps.size(); i++) {
477 if (mGbps[i] != otherGbps[i]) {
478 return mGbps[i] < otherGbps[i];
479 }
480 }
481
482 return false;
483}
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700484}; // namespace android