blob: da4484a9cfb1d0beee07c0e62f96a19981e1cad5 [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>
24#include <binder/Parcel.h>
Mathias Agopian032845c2017-02-08 17:05:02 -080025#include <gui/view/Surface.h>
Emilian Peev2295df72021-11-12 18:14:10 -080026#include <system/camera_metadata.h>
Brian Andersonf6753562016-10-11 14:51:05 -070027#include <utils/String8.h>
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070028
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070029
Austin Borger9e2b27c2022-07-15 11:27:24 -070030namespace android {
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070031
32const int OutputConfiguration::INVALID_ROTATION = -1;
Zhijun He018107a2016-01-18 15:32:50 -080033const int OutputConfiguration::INVALID_SET_ID = -1;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070034
Shuzhen Wang0129d522016-10-30 22:43:41 -070035const std::vector<sp<IGraphicBufferProducer>>&
36 OutputConfiguration::getGraphicBufferProducers() const {
37 return mGbps;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070038}
39
40int OutputConfiguration::getRotation() const {
41 return mRotation;
42}
43
Zhijun He018107a2016-01-18 15:32:50 -080044int OutputConfiguration::getSurfaceSetID() const {
45 return mSurfaceSetID;
46}
47
Zhijun He5d677d12016-05-29 16:52:39 -070048int OutputConfiguration::getSurfaceType() const {
49 return mSurfaceType;
50}
51
52int OutputConfiguration::getWidth() const {
53 return mWidth;
54}
55
56int OutputConfiguration::getHeight() const {
57 return mHeight;
58}
59
Shuzhen Wang758c2152017-01-10 18:26:18 -080060bool OutputConfiguration::isDeferred() const {
61 return mIsDeferred;
62}
63
64bool OutputConfiguration::isShared() const {
65 return mIsShared;
66}
67
Shuzhen Wangc28189a2017-11-27 23:05:10 -080068String16 OutputConfiguration::getPhysicalCameraId() const {
69 return mPhysicalCameraId;
70}
71
Shuzhen Wang83bff122020-11-20 15:51:39 -080072bool OutputConfiguration::isMultiResolution() const {
73 return mIsMultiResolution;
74}
75
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -080076const std::vector<int32_t> &OutputConfiguration::getSensorPixelModesUsed() const {
77 return mSensorPixelModesUsed;
78}
79
Emilian Peevc81a7592022-02-14 17:38:18 -080080int64_t OutputConfiguration::getDynamicRangeProfile() const {
Emilian Peev2295df72021-11-12 18:14:10 -080081 return mDynamicRangeProfile;
82}
83
Austin Borger9e2b27c2022-07-15 11:27:24 -070084int32_t OutputConfiguration::getColorSpace() const {
85 return mColorSpace;
86}
87
Shuzhen Wang8ed1e872022-03-08 16:34:33 -080088int64_t OutputConfiguration::getStreamUseCase() const {
Shuzhen Wangc8ab4522021-12-14 20:12:42 -080089 return mStreamUseCase;
90}
91
Shuzhen Wange4208922022-02-01 16:52:48 -080092int OutputConfiguration::getTimestampBase() const {
93 return mTimestampBase;
94}
95
Shuzhen Wang610d7b82022-02-08 14:37:22 -080096int OutputConfiguration::getMirrorMode() const {
97 return mMirrorMode;
98}
99
Shuzhen Wangbce53db2022-12-03 00:38:20 +0000100bool OutputConfiguration::useReadoutTimestamp() const {
101 return mUseReadoutTimestamp;
102}
103
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800104OutputConfiguration::OutputConfiguration() :
105 mRotation(INVALID_ROTATION),
Zhijun He5d677d12016-05-29 16:52:39 -0700106 mSurfaceSetID(INVALID_SET_ID),
107 mSurfaceType(SURFACE_TYPE_UNKNOWN),
108 mWidth(0),
Shuzhen Wang758c2152017-01-10 18:26:18 -0800109 mHeight(0),
110 mIsDeferred(false),
Shuzhen Wang83bff122020-11-20 15:51:39 -0800111 mIsShared(false),
Emilian Peev2295df72021-11-12 18:14:10 -0800112 mIsMultiResolution(false),
Shuzhen Wangc8ab4522021-12-14 20:12:42 -0800113 mDynamicRangeProfile(ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_STANDARD),
Austin Borger9e2b27c2022-07-15 11:27:24 -0700114 mColorSpace(ANDROID_REQUEST_AVAILABLE_COLOR_SPACE_PROFILES_MAP_UNSPECIFIED),
Shuzhen Wange4208922022-02-01 16:52:48 -0800115 mStreamUseCase(ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT),
Shuzhen Wang610d7b82022-02-08 14:37:22 -0800116 mTimestampBase(TIMESTAMP_BASE_DEFAULT),
Shuzhen Wangbce53db2022-12-03 00:38:20 +0000117 mMirrorMode(MIRROR_MODE_AUTO),
118 mUseReadoutTimestamp(false) {
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800119}
120
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800121OutputConfiguration::OutputConfiguration(const android::Parcel& parcel) :
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800122 mRotation(INVALID_ROTATION),
123 mSurfaceSetID(INVALID_SET_ID) {
124 readFromParcel(&parcel);
125}
126
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800127status_t OutputConfiguration::readFromParcel(const android::Parcel* parcel) {
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800128 status_t err = OK;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700129 int rotation = 0;
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800130
131 if (parcel == nullptr) return BAD_VALUE;
132
133 if ((err = parcel->readInt32(&rotation)) != OK) {
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700134 ALOGE("%s: Failed to read rotation from parcel", __FUNCTION__);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800135 return err;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700136 }
137
Zhijun He018107a2016-01-18 15:32:50 -0800138 int setID = INVALID_SET_ID;
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800139 if ((err = parcel->readInt32(&setID)) != OK) {
Zhijun He018107a2016-01-18 15:32:50 -0800140 ALOGE("%s: Failed to read surface set ID from parcel", __FUNCTION__);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800141 return err;
Zhijun He018107a2016-01-18 15:32:50 -0800142 }
143
Zhijun He5d677d12016-05-29 16:52:39 -0700144 int surfaceType = SURFACE_TYPE_UNKNOWN;
145 if ((err = parcel->readInt32(&surfaceType)) != OK) {
146 ALOGE("%s: Failed to read surface type from parcel", __FUNCTION__);
147 return err;
148 }
149
150 int width = 0;
151 if ((err = parcel->readInt32(&width)) != OK) {
152 ALOGE("%s: Failed to read surface width from parcel", __FUNCTION__);
153 return err;
154 }
155
156 int height = 0;
157 if ((err = parcel->readInt32(&height)) != OK) {
158 ALOGE("%s: Failed to read surface height from parcel", __FUNCTION__);
159 return err;
160 }
161
Shuzhen Wang758c2152017-01-10 18:26:18 -0800162 int isDeferred = 0;
163 if ((err = parcel->readInt32(&isDeferred)) != OK) {
164 ALOGE("%s: Failed to read surface isDeferred flag from parcel", __FUNCTION__);
Shuzhen Wang0129d522016-10-30 22:43:41 -0700165 return err;
166 }
Shuzhen Wang758c2152017-01-10 18:26:18 -0800167
168 int isShared = 0;
169 if ((err = parcel->readInt32(&isShared)) != OK) {
170 ALOGE("%s: Failed to read surface isShared flag from parcel", __FUNCTION__);
171 return err;
172 }
173
174 if (isDeferred && surfaceType != SURFACE_TYPE_SURFACE_VIEW &&
175 surfaceType != SURFACE_TYPE_SURFACE_TEXTURE) {
176 ALOGE("%s: Invalid surface type for deferred configuration", __FUNCTION__);
Shuzhen Wang0129d522016-10-30 22:43:41 -0700177 return BAD_VALUE;
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800178 }
179
Shuzhen Wang758c2152017-01-10 18:26:18 -0800180 std::vector<view::Surface> surfaceShims;
181 if ((err = parcel->readParcelableVector(&surfaceShims)) != OK) {
182 ALOGE("%s: Failed to read surface(s) from parcel", __FUNCTION__);
183 return err;
Shuzhen Wang0129d522016-10-30 22:43:41 -0700184 }
185
Shuzhen Wangc28189a2017-11-27 23:05:10 -0800186 parcel->readString16(&mPhysicalCameraId);
187
Shuzhen Wang83bff122020-11-20 15:51:39 -0800188 int isMultiResolution = 0;
189 if ((err = parcel->readInt32(&isMultiResolution)) != OK) {
190 ALOGE("%s: Failed to read surface isMultiResolution flag from parcel", __FUNCTION__);
191 return err;
192 }
193
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800194 std::vector<int32_t> sensorPixelModesUsed;
Jayant Chowdhary84df28c2021-05-26 22:32:21 -0700195 if ((err = parcel->readInt32Vector(&sensorPixelModesUsed)) != OK) {
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800196 ALOGE("%s: Failed to read sensor pixel mode(s) from parcel", __FUNCTION__);
197 return err;
198 }
Emilian Peevc81a7592022-02-14 17:38:18 -0800199 int64_t dynamicProfile;
200 if ((err = parcel->readInt64(&dynamicProfile)) != OK) {
Emilian Peev2295df72021-11-12 18:14:10 -0800201 ALOGE("%s: Failed to read surface dynamic range profile flag from parcel", __FUNCTION__);
202 return err;
203 }
Austin Borger9e2b27c2022-07-15 11:27:24 -0700204 int32_t colorSpace;
205 if ((err = parcel->readInt32(&colorSpace)) != OK) {
206 ALOGE("%s: Failed to read surface color space flag from parcel", __FUNCTION__);
207 return err;
208 }
Emilian Peev2295df72021-11-12 18:14:10 -0800209
Shuzhen Wang8ed1e872022-03-08 16:34:33 -0800210 int64_t streamUseCase = ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT;
211 if ((err = parcel->readInt64(&streamUseCase)) != OK) {
Shuzhen Wangc8ab4522021-12-14 20:12:42 -0800212 ALOGE("%s: Failed to read stream use case from parcel", __FUNCTION__);
213 return err;
214 }
215
Shuzhen Wange4208922022-02-01 16:52:48 -0800216 int timestampBase = TIMESTAMP_BASE_DEFAULT;
217 if ((err = parcel->readInt32(&timestampBase)) != OK) {
218 ALOGE("%s: Failed to read timestamp base from parcel", __FUNCTION__);
219 return err;
220 }
221
Shuzhen Wang610d7b82022-02-08 14:37:22 -0800222 int mirrorMode = MIRROR_MODE_AUTO;
223 if ((err = parcel->readInt32(&mirrorMode)) != OK) {
224 ALOGE("%s: Failed to read mirroring mode from parcel", __FUNCTION__);
225 return err;
226 }
227
Shuzhen Wangbce53db2022-12-03 00:38:20 +0000228 int useReadoutTimestamp = 0;
229 if ((err = parcel->readInt32(&useReadoutTimestamp)) != OK) {
230 ALOGE("%s: Failed to read useReadoutTimestamp flag from parcel", __FUNCTION__);
231 return err;
232 }
233
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700234 mRotation = rotation;
Zhijun He018107a2016-01-18 15:32:50 -0800235 mSurfaceSetID = setID;
Zhijun He5d677d12016-05-29 16:52:39 -0700236 mSurfaceType = surfaceType;
237 mWidth = width;
238 mHeight = height;
Shuzhen Wang758c2152017-01-10 18:26:18 -0800239 mIsDeferred = isDeferred != 0;
240 mIsShared = isShared != 0;
Shuzhen Wang83bff122020-11-20 15:51:39 -0800241 mIsMultiResolution = isMultiResolution != 0;
Shuzhen Wangc8ab4522021-12-14 20:12:42 -0800242 mStreamUseCase = streamUseCase;
Shuzhen Wange4208922022-02-01 16:52:48 -0800243 mTimestampBase = timestampBase;
Shuzhen Wang610d7b82022-02-08 14:37:22 -0800244 mMirrorMode = mirrorMode;
Shuzhen Wangbce53db2022-12-03 00:38:20 +0000245 mUseReadoutTimestamp = useReadoutTimestamp != 0;
Shuzhen Wang758c2152017-01-10 18:26:18 -0800246 for (auto& surface : surfaceShims) {
247 ALOGV("%s: OutputConfiguration: %p, name %s", __FUNCTION__,
248 surface.graphicBufferProducer.get(),
249 String8(surface.name).string());
250 mGbps.push_back(surface.graphicBufferProducer);
251 }
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700252
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800253 mSensorPixelModesUsed = std::move(sensorPixelModesUsed);
Emilian Peev2295df72021-11-12 18:14:10 -0800254 mDynamicRangeProfile = dynamicProfile;
Austin Borger9e2b27c2022-07-15 11:27:24 -0700255 mColorSpace = colorSpace;
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800256
Shuzhen Wangc28189a2017-11-27 23:05:10 -0800257 ALOGV("%s: OutputConfiguration: rotation = %d, setId = %d, surfaceType = %d,"
Shuzhen Wang8ed1e872022-03-08 16:34:33 -0800258 " physicalCameraId = %s, isMultiResolution = %d, streamUseCase = %" PRId64
Shuzhen Wangbce53db2022-12-03 00:38:20 +0000259 ", timestampBase = %d, mirrorMode = %d, useReadoutTimestamp = %d",
Shuzhen Wange4208922022-02-01 16:52:48 -0800260 __FUNCTION__, mRotation, mSurfaceSetID, mSurfaceType,
Shuzhen Wang610d7b82022-02-08 14:37:22 -0800261 String8(mPhysicalCameraId).string(), mIsMultiResolution, mStreamUseCase, timestampBase,
Shuzhen Wangbce53db2022-12-03 00:38:20 +0000262 mMirrorMode, mUseReadoutTimestamp);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800263
264 return err;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700265}
266
Zhijun He018107a2016-01-18 15:32:50 -0800267OutputConfiguration::OutputConfiguration(sp<IGraphicBufferProducer>& gbp, int rotation,
Shuzhen Wang0ff9ae32018-12-05 18:06:12 -0800268 const String16& physicalId,
Emilian Peev40ead602017-09-26 15:46:36 +0100269 int surfaceSetID, bool isShared) {
Shuzhen Wang0129d522016-10-30 22:43:41 -0700270 mGbps.push_back(gbp);
Ruben Brunk3450ba72015-06-16 11:00:37 -0700271 mRotation = rotation;
Zhijun He018107a2016-01-18 15:32:50 -0800272 mSurfaceSetID = surfaceSetID;
Shuzhen Wang758c2152017-01-10 18:26:18 -0800273 mIsDeferred = false;
Emilian Peev40ead602017-09-26 15:46:36 +0100274 mIsShared = isShared;
Shuzhen Wang0ff9ae32018-12-05 18:06:12 -0800275 mPhysicalCameraId = physicalId;
Shuzhen Wang83bff122020-11-20 15:51:39 -0800276 mIsMultiResolution = false;
Emilian Peev2295df72021-11-12 18:14:10 -0800277 mDynamicRangeProfile = ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_STANDARD;
Austin Borger9e2b27c2022-07-15 11:27:24 -0700278 mColorSpace = ANDROID_REQUEST_AVAILABLE_COLOR_SPACE_PROFILES_MAP_UNSPECIFIED;
Shuzhen Wangc8ab4522021-12-14 20:12:42 -0800279 mStreamUseCase = ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT;
Shuzhen Wange4208922022-02-01 16:52:48 -0800280 mTimestampBase = TIMESTAMP_BASE_DEFAULT;
Shuzhen Wang610d7b82022-02-08 14:37:22 -0800281 mMirrorMode = MIRROR_MODE_AUTO;
Shuzhen Wangbce53db2022-12-03 00:38:20 +0000282 mUseReadoutTimestamp = false;
Ruben Brunk3450ba72015-06-16 11:00:37 -0700283}
284
Jayant Chowdharybe543d42018-08-15 13:16:14 -0700285OutputConfiguration::OutputConfiguration(
286 const std::vector<sp<IGraphicBufferProducer>>& gbps,
Shuzhen Wang0ff9ae32018-12-05 18:06:12 -0800287 int rotation, const String16& physicalCameraId, int surfaceSetID, int surfaceType,
288 int width, int height, bool isShared)
Jayant Chowdharybe543d42018-08-15 13:16:14 -0700289 : mGbps(gbps), mRotation(rotation), mSurfaceSetID(surfaceSetID), mSurfaceType(surfaceType),
Shuzhen Wang0ff9ae32018-12-05 18:06:12 -0800290 mWidth(width), mHeight(height), mIsDeferred(false), mIsShared(isShared),
Emilian Peev2295df72021-11-12 18:14:10 -0800291 mPhysicalCameraId(physicalCameraId), mIsMultiResolution(false),
Shuzhen Wangc8ab4522021-12-14 20:12:42 -0800292 mDynamicRangeProfile(ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_STANDARD),
Austin Borger9e2b27c2022-07-15 11:27:24 -0700293 mColorSpace(ANDROID_REQUEST_AVAILABLE_COLOR_SPACE_PROFILES_MAP_UNSPECIFIED),
Shuzhen Wange4208922022-02-01 16:52:48 -0800294 mStreamUseCase(ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT),
Shuzhen Wang610d7b82022-02-08 14:37:22 -0800295 mTimestampBase(TIMESTAMP_BASE_DEFAULT),
Shuzhen Wangbce53db2022-12-03 00:38:20 +0000296 mMirrorMode(MIRROR_MODE_AUTO), mUseReadoutTimestamp(false) { }
Jayant Chowdharybe543d42018-08-15 13:16:14 -0700297
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800298status_t OutputConfiguration::writeToParcel(android::Parcel* parcel) const {
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700299
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800300 if (parcel == nullptr) return BAD_VALUE;
301 status_t err = OK;
302
303 err = parcel->writeInt32(mRotation);
304 if (err != OK) return err;
305
306 err = parcel->writeInt32(mSurfaceSetID);
307 if (err != OK) return err;
308
Zhijun He5d677d12016-05-29 16:52:39 -0700309 err = parcel->writeInt32(mSurfaceType);
310 if (err != OK) return err;
311
312 err = parcel->writeInt32(mWidth);
313 if (err != OK) return err;
314
315 err = parcel->writeInt32(mHeight);
316 if (err != OK) return err;
317
Shuzhen Wang758c2152017-01-10 18:26:18 -0800318 err = parcel->writeInt32(mIsDeferred ? 1 : 0);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800319 if (err != OK) return err;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700320
Shuzhen Wang758c2152017-01-10 18:26:18 -0800321 err = parcel->writeInt32(mIsShared ? 1 : 0);
322 if (err != OK) return err;
323
324 std::vector<view::Surface> surfaceShims;
325 for (auto& gbp : mGbps) {
Shuzhen Wang0129d522016-10-30 22:43:41 -0700326 view::Surface surfaceShim;
327 surfaceShim.name = String16("unknown_name"); // name of surface
Shuzhen Wang758c2152017-01-10 18:26:18 -0800328 surfaceShim.graphicBufferProducer = gbp;
329 surfaceShims.push_back(surfaceShim);
Shuzhen Wang0129d522016-10-30 22:43:41 -0700330 }
Shuzhen Wang758c2152017-01-10 18:26:18 -0800331 err = parcel->writeParcelableVector(surfaceShims);
332 if (err != OK) return err;
Shuzhen Wang0129d522016-10-30 22:43:41 -0700333
Shuzhen Wangc28189a2017-11-27 23:05:10 -0800334 err = parcel->writeString16(mPhysicalCameraId);
335 if (err != OK) return err;
336
Shuzhen Wang83bff122020-11-20 15:51:39 -0800337 err = parcel->writeInt32(mIsMultiResolution ? 1 : 0);
338 if (err != OK) return err;
339
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800340 err = parcel->writeParcelableVector(mSensorPixelModesUsed);
341 if (err != OK) return err;
342
Emilian Peevc81a7592022-02-14 17:38:18 -0800343 err = parcel->writeInt64(mDynamicRangeProfile);
Emilian Peev2295df72021-11-12 18:14:10 -0800344 if (err != OK) return err;
345
Austin Borger9e2b27c2022-07-15 11:27:24 -0700346 err = parcel->writeInt32(mColorSpace);
347 if (err != OK) return err;
348
Shuzhen Wang8ed1e872022-03-08 16:34:33 -0800349 err = parcel->writeInt64(mStreamUseCase);
Shuzhen Wangc8ab4522021-12-14 20:12:42 -0800350 if (err != OK) return err;
351
Shuzhen Wange4208922022-02-01 16:52:48 -0800352 err = parcel->writeInt32(mTimestampBase);
353 if (err != OK) return err;
354
Shuzhen Wang610d7b82022-02-08 14:37:22 -0800355 err = parcel->writeInt32(mMirrorMode);
356 if (err != OK) return err;
357
Shuzhen Wangbce53db2022-12-03 00:38:20 +0000358 err = parcel->writeInt32(mUseReadoutTimestamp ? 1 : 0);
359 if (err != OK) return err;
360
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700361 return OK;
362}
363
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800364template <typename T>
365static bool simpleVectorsEqual(T first, T second) {
366 if (first.size() != second.size()) {
367 return false;
368 }
369
370 for (size_t i = 0; i < first.size(); i++) {
371 if (first[i] != second[i]) {
372 return false;
373 }
374 }
375 return true;
376}
377
Shuzhen Wang0129d522016-10-30 22:43:41 -0700378bool OutputConfiguration::gbpsEqual(const OutputConfiguration& other) const {
379 const std::vector<sp<IGraphicBufferProducer> >& otherGbps =
380 other.getGraphicBufferProducers();
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800381 return simpleVectorsEqual(otherGbps, mGbps);
382}
Shuzhen Wang0129d522016-10-30 22:43:41 -0700383
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800384bool OutputConfiguration::sensorPixelModesUsedEqual(const OutputConfiguration& other) const {
385 const std::vector<int32_t>& othersensorPixelModesUsed = other.getSensorPixelModesUsed();
386 return simpleVectorsEqual(othersensorPixelModesUsed, mSensorPixelModesUsed);
387}
388
389bool OutputConfiguration::sensorPixelModesUsedLessThan(const OutputConfiguration& other) const {
390 const std::vector<int32_t>& spms = other.getSensorPixelModesUsed();
391
392 if (mSensorPixelModesUsed.size() != spms.size()) {
393 return mSensorPixelModesUsed.size() < spms.size();
Shuzhen Wang0129d522016-10-30 22:43:41 -0700394 }
395
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800396 for (size_t i = 0; i < spms.size(); i++) {
397 if (mSensorPixelModesUsed[i] != spms[i]) {
398 return mSensorPixelModesUsed[i] < spms[i];
Shuzhen Wang0129d522016-10-30 22:43:41 -0700399 }
400 }
401
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800402 return false;
Shuzhen Wang0129d522016-10-30 22:43:41 -0700403}
404
405bool OutputConfiguration::gbpsLessThan(const OutputConfiguration& other) const {
406 const std::vector<sp<IGraphicBufferProducer> >& otherGbps =
407 other.getGraphicBufferProducers();
408
409 if (mGbps.size() != otherGbps.size()) {
410 return mGbps.size() < otherGbps.size();
411 }
412
413 for (size_t i = 0; i < mGbps.size(); i++) {
414 if (mGbps[i] != otherGbps[i]) {
415 return mGbps[i] < otherGbps[i];
416 }
417 }
418
419 return false;
420}
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700421}; // namespace android