blob: 33220ce441a27bbdc574555dcdb1037987b51e01 [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>
Brian Andersonf6753562016-10-11 14:51:05 -070028#include <utils/String8.h>
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070029
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070030
Austin Borger9e2b27c2022-07-15 11:27:24 -070031namespace android {
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070032
33const int OutputConfiguration::INVALID_ROTATION = -1;
Zhijun He018107a2016-01-18 15:32:50 -080034const int OutputConfiguration::INVALID_SET_ID = -1;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070035
Shuzhen Wang0129d522016-10-30 22:43:41 -070036const std::vector<sp<IGraphicBufferProducer>>&
37 OutputConfiguration::getGraphicBufferProducers() const {
38 return mGbps;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070039}
40
41int OutputConfiguration::getRotation() const {
42 return mRotation;
43}
44
Zhijun He018107a2016-01-18 15:32:50 -080045int OutputConfiguration::getSurfaceSetID() const {
46 return mSurfaceSetID;
47}
48
Zhijun He5d677d12016-05-29 16:52:39 -070049int OutputConfiguration::getSurfaceType() const {
50 return mSurfaceType;
51}
52
53int OutputConfiguration::getWidth() const {
54 return mWidth;
55}
56
57int OutputConfiguration::getHeight() const {
58 return mHeight;
59}
60
Shuzhen Wang758c2152017-01-10 18:26:18 -080061bool OutputConfiguration::isDeferred() const {
62 return mIsDeferred;
63}
64
65bool OutputConfiguration::isShared() const {
66 return mIsShared;
67}
68
Austin Borger71d8f672023-06-01 16:51:35 -070069std::string OutputConfiguration::getPhysicalCameraId() const {
Shuzhen Wangc28189a2017-11-27 23:05:10 -080070 return mPhysicalCameraId;
71}
72
Shuzhen Wang83bff122020-11-20 15:51:39 -080073bool OutputConfiguration::isMultiResolution() const {
74 return mIsMultiResolution;
75}
76
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -080077const std::vector<int32_t> &OutputConfiguration::getSensorPixelModesUsed() const {
78 return mSensorPixelModesUsed;
79}
80
Emilian Peevc81a7592022-02-14 17:38:18 -080081int64_t OutputConfiguration::getDynamicRangeProfile() const {
Emilian Peev2295df72021-11-12 18:14:10 -080082 return mDynamicRangeProfile;
83}
84
Austin Borger9e2b27c2022-07-15 11:27:24 -070085int32_t OutputConfiguration::getColorSpace() const {
86 return mColorSpace;
87}
88
Shuzhen Wang8ed1e872022-03-08 16:34:33 -080089int64_t OutputConfiguration::getStreamUseCase() const {
Shuzhen Wangc8ab4522021-12-14 20:12:42 -080090 return mStreamUseCase;
91}
92
Shuzhen Wange4208922022-02-01 16:52:48 -080093int OutputConfiguration::getTimestampBase() const {
94 return mTimestampBase;
95}
96
Shuzhen Wang610d7b82022-02-08 14:37:22 -080097int OutputConfiguration::getMirrorMode() const {
98 return mMirrorMode;
99}
100
Shuzhen Wangbce53db2022-12-03 00:38:20 +0000101bool OutputConfiguration::useReadoutTimestamp() const {
102 return mUseReadoutTimestamp;
103}
104
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800105OutputConfiguration::OutputConfiguration() :
106 mRotation(INVALID_ROTATION),
Zhijun He5d677d12016-05-29 16:52:39 -0700107 mSurfaceSetID(INVALID_SET_ID),
108 mSurfaceType(SURFACE_TYPE_UNKNOWN),
109 mWidth(0),
Shuzhen Wang758c2152017-01-10 18:26:18 -0800110 mHeight(0),
111 mIsDeferred(false),
Shuzhen Wang83bff122020-11-20 15:51:39 -0800112 mIsShared(false),
Emilian Peev2295df72021-11-12 18:14:10 -0800113 mIsMultiResolution(false),
Shuzhen Wangc8ab4522021-12-14 20:12:42 -0800114 mDynamicRangeProfile(ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_STANDARD),
Austin Borger9e2b27c2022-07-15 11:27:24 -0700115 mColorSpace(ANDROID_REQUEST_AVAILABLE_COLOR_SPACE_PROFILES_MAP_UNSPECIFIED),
Shuzhen Wange4208922022-02-01 16:52:48 -0800116 mStreamUseCase(ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT),
Shuzhen Wang610d7b82022-02-08 14:37:22 -0800117 mTimestampBase(TIMESTAMP_BASE_DEFAULT),
Shuzhen Wangbce53db2022-12-03 00:38:20 +0000118 mMirrorMode(MIRROR_MODE_AUTO),
119 mUseReadoutTimestamp(false) {
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800120}
121
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800122OutputConfiguration::OutputConfiguration(const android::Parcel& parcel) :
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800123 mRotation(INVALID_ROTATION),
124 mSurfaceSetID(INVALID_SET_ID) {
125 readFromParcel(&parcel);
126}
127
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800128status_t OutputConfiguration::readFromParcel(const android::Parcel* parcel) {
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800129 status_t err = OK;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700130 int rotation = 0;
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800131
132 if (parcel == nullptr) return BAD_VALUE;
133
134 if ((err = parcel->readInt32(&rotation)) != OK) {
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700135 ALOGE("%s: Failed to read rotation from parcel", __FUNCTION__);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800136 return err;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700137 }
138
Zhijun He018107a2016-01-18 15:32:50 -0800139 int setID = INVALID_SET_ID;
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800140 if ((err = parcel->readInt32(&setID)) != OK) {
Zhijun He018107a2016-01-18 15:32:50 -0800141 ALOGE("%s: Failed to read surface set ID from parcel", __FUNCTION__);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800142 return err;
Zhijun He018107a2016-01-18 15:32:50 -0800143 }
144
Zhijun He5d677d12016-05-29 16:52:39 -0700145 int surfaceType = SURFACE_TYPE_UNKNOWN;
146 if ((err = parcel->readInt32(&surfaceType)) != OK) {
147 ALOGE("%s: Failed to read surface type from parcel", __FUNCTION__);
148 return err;
149 }
150
151 int width = 0;
152 if ((err = parcel->readInt32(&width)) != OK) {
153 ALOGE("%s: Failed to read surface width from parcel", __FUNCTION__);
154 return err;
155 }
156
157 int height = 0;
158 if ((err = parcel->readInt32(&height)) != OK) {
159 ALOGE("%s: Failed to read surface height from parcel", __FUNCTION__);
160 return err;
161 }
162
Shuzhen Wang758c2152017-01-10 18:26:18 -0800163 int isDeferred = 0;
164 if ((err = parcel->readInt32(&isDeferred)) != OK) {
165 ALOGE("%s: Failed to read surface isDeferred flag from parcel", __FUNCTION__);
Shuzhen Wang0129d522016-10-30 22:43:41 -0700166 return err;
167 }
Shuzhen Wang758c2152017-01-10 18:26:18 -0800168
169 int isShared = 0;
170 if ((err = parcel->readInt32(&isShared)) != OK) {
171 ALOGE("%s: Failed to read surface isShared flag from parcel", __FUNCTION__);
172 return err;
173 }
174
175 if (isDeferred && surfaceType != SURFACE_TYPE_SURFACE_VIEW &&
176 surfaceType != SURFACE_TYPE_SURFACE_TEXTURE) {
177 ALOGE("%s: Invalid surface type for deferred configuration", __FUNCTION__);
Shuzhen Wang0129d522016-10-30 22:43:41 -0700178 return BAD_VALUE;
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800179 }
180
Shuzhen Wang758c2152017-01-10 18:26:18 -0800181 std::vector<view::Surface> surfaceShims;
182 if ((err = parcel->readParcelableVector(&surfaceShims)) != OK) {
183 ALOGE("%s: Failed to read surface(s) from parcel", __FUNCTION__);
184 return err;
Shuzhen Wang0129d522016-10-30 22:43:41 -0700185 }
186
Austin Borger71d8f672023-06-01 16:51:35 -0700187 String16 physicalCameraId;
188 parcel->readString16(&physicalCameraId);
189 mPhysicalCameraId = toStdString(physicalCameraId);
Shuzhen Wangc28189a2017-11-27 23:05:10 -0800190
Shuzhen Wang83bff122020-11-20 15:51:39 -0800191 int isMultiResolution = 0;
192 if ((err = parcel->readInt32(&isMultiResolution)) != OK) {
193 ALOGE("%s: Failed to read surface isMultiResolution flag from parcel", __FUNCTION__);
194 return err;
195 }
196
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800197 std::vector<int32_t> sensorPixelModesUsed;
Jayant Chowdhary84df28c2021-05-26 22:32:21 -0700198 if ((err = parcel->readInt32Vector(&sensorPixelModesUsed)) != OK) {
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800199 ALOGE("%s: Failed to read sensor pixel mode(s) from parcel", __FUNCTION__);
200 return err;
201 }
Emilian Peevc81a7592022-02-14 17:38:18 -0800202 int64_t dynamicProfile;
203 if ((err = parcel->readInt64(&dynamicProfile)) != OK) {
Emilian Peev2295df72021-11-12 18:14:10 -0800204 ALOGE("%s: Failed to read surface dynamic range profile flag from parcel", __FUNCTION__);
205 return err;
206 }
Austin Borger9e2b27c2022-07-15 11:27:24 -0700207 int32_t colorSpace;
208 if ((err = parcel->readInt32(&colorSpace)) != OK) {
209 ALOGE("%s: Failed to read surface color space flag from parcel", __FUNCTION__);
210 return err;
211 }
Emilian Peev2295df72021-11-12 18:14:10 -0800212
Shuzhen Wang8ed1e872022-03-08 16:34:33 -0800213 int64_t streamUseCase = ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT;
214 if ((err = parcel->readInt64(&streamUseCase)) != OK) {
Shuzhen Wangc8ab4522021-12-14 20:12:42 -0800215 ALOGE("%s: Failed to read stream use case from parcel", __FUNCTION__);
216 return err;
217 }
218
Shuzhen Wange4208922022-02-01 16:52:48 -0800219 int timestampBase = TIMESTAMP_BASE_DEFAULT;
220 if ((err = parcel->readInt32(&timestampBase)) != OK) {
221 ALOGE("%s: Failed to read timestamp base from parcel", __FUNCTION__);
222 return err;
223 }
224
Shuzhen Wang610d7b82022-02-08 14:37:22 -0800225 int mirrorMode = MIRROR_MODE_AUTO;
226 if ((err = parcel->readInt32(&mirrorMode)) != OK) {
227 ALOGE("%s: Failed to read mirroring mode from parcel", __FUNCTION__);
228 return err;
229 }
230
Shuzhen Wangbce53db2022-12-03 00:38:20 +0000231 int useReadoutTimestamp = 0;
232 if ((err = parcel->readInt32(&useReadoutTimestamp)) != OK) {
233 ALOGE("%s: Failed to read useReadoutTimestamp flag from parcel", __FUNCTION__);
234 return err;
235 }
236
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700237 mRotation = rotation;
Zhijun He018107a2016-01-18 15:32:50 -0800238 mSurfaceSetID = setID;
Zhijun He5d677d12016-05-29 16:52:39 -0700239 mSurfaceType = surfaceType;
240 mWidth = width;
241 mHeight = height;
Shuzhen Wang758c2152017-01-10 18:26:18 -0800242 mIsDeferred = isDeferred != 0;
243 mIsShared = isShared != 0;
Shuzhen Wang83bff122020-11-20 15:51:39 -0800244 mIsMultiResolution = isMultiResolution != 0;
Shuzhen Wangc8ab4522021-12-14 20:12:42 -0800245 mStreamUseCase = streamUseCase;
Shuzhen Wange4208922022-02-01 16:52:48 -0800246 mTimestampBase = timestampBase;
Shuzhen Wang610d7b82022-02-08 14:37:22 -0800247 mMirrorMode = mirrorMode;
Shuzhen Wangbce53db2022-12-03 00:38:20 +0000248 mUseReadoutTimestamp = useReadoutTimestamp != 0;
Shuzhen Wang758c2152017-01-10 18:26:18 -0800249 for (auto& surface : surfaceShims) {
250 ALOGV("%s: OutputConfiguration: %p, name %s", __FUNCTION__,
251 surface.graphicBufferProducer.get(),
Austin Borger71d8f672023-06-01 16:51:35 -0700252 toString8(surface.name).string());
Shuzhen Wang758c2152017-01-10 18:26:18 -0800253 mGbps.push_back(surface.graphicBufferProducer);
254 }
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700255
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800256 mSensorPixelModesUsed = std::move(sensorPixelModesUsed);
Emilian Peev2295df72021-11-12 18:14:10 -0800257 mDynamicRangeProfile = dynamicProfile;
Austin Borger9e2b27c2022-07-15 11:27:24 -0700258 mColorSpace = colorSpace;
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800259
Shuzhen Wangc28189a2017-11-27 23:05:10 -0800260 ALOGV("%s: OutputConfiguration: rotation = %d, setId = %d, surfaceType = %d,"
Shuzhen Wang8ed1e872022-03-08 16:34:33 -0800261 " physicalCameraId = %s, isMultiResolution = %d, streamUseCase = %" PRId64
Shuzhen Wangbce53db2022-12-03 00:38:20 +0000262 ", timestampBase = %d, mirrorMode = %d, useReadoutTimestamp = %d",
Shuzhen Wange4208922022-02-01 16:52:48 -0800263 __FUNCTION__, mRotation, mSurfaceSetID, mSurfaceType,
Austin Borger71d8f672023-06-01 16:51:35 -0700264 mPhysicalCameraId.c_str(), mIsMultiResolution, mStreamUseCase, timestampBase,
Shuzhen Wangbce53db2022-12-03 00:38:20 +0000265 mMirrorMode, mUseReadoutTimestamp);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800266
267 return err;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700268}
269
Zhijun He018107a2016-01-18 15:32:50 -0800270OutputConfiguration::OutputConfiguration(sp<IGraphicBufferProducer>& gbp, int rotation,
Austin Borger71d8f672023-06-01 16:51:35 -0700271 const std::string& physicalId,
Emilian Peev40ead602017-09-26 15:46:36 +0100272 int surfaceSetID, bool isShared) {
Shuzhen Wang0129d522016-10-30 22:43:41 -0700273 mGbps.push_back(gbp);
Ruben Brunk3450ba72015-06-16 11:00:37 -0700274 mRotation = rotation;
Zhijun He018107a2016-01-18 15:32:50 -0800275 mSurfaceSetID = surfaceSetID;
Shuzhen Wang758c2152017-01-10 18:26:18 -0800276 mIsDeferred = false;
Emilian Peev40ead602017-09-26 15:46:36 +0100277 mIsShared = isShared;
Shuzhen Wang0ff9ae32018-12-05 18:06:12 -0800278 mPhysicalCameraId = physicalId;
Shuzhen Wang83bff122020-11-20 15:51:39 -0800279 mIsMultiResolution = false;
Emilian Peev2295df72021-11-12 18:14:10 -0800280 mDynamicRangeProfile = ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_STANDARD;
Austin Borger9e2b27c2022-07-15 11:27:24 -0700281 mColorSpace = ANDROID_REQUEST_AVAILABLE_COLOR_SPACE_PROFILES_MAP_UNSPECIFIED;
Shuzhen Wangc8ab4522021-12-14 20:12:42 -0800282 mStreamUseCase = ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT;
Shuzhen Wange4208922022-02-01 16:52:48 -0800283 mTimestampBase = TIMESTAMP_BASE_DEFAULT;
Shuzhen Wang610d7b82022-02-08 14:37:22 -0800284 mMirrorMode = MIRROR_MODE_AUTO;
Shuzhen Wangbce53db2022-12-03 00:38:20 +0000285 mUseReadoutTimestamp = false;
Ruben Brunk3450ba72015-06-16 11:00:37 -0700286}
287
Jayant Chowdharybe543d42018-08-15 13:16:14 -0700288OutputConfiguration::OutputConfiguration(
289 const std::vector<sp<IGraphicBufferProducer>>& gbps,
Austin Borger71d8f672023-06-01 16:51:35 -0700290 int rotation, const std::string& physicalCameraId, int surfaceSetID, int surfaceType,
Shuzhen Wang0ff9ae32018-12-05 18:06:12 -0800291 int width, int height, bool isShared)
Jayant Chowdharybe543d42018-08-15 13:16:14 -0700292 : mGbps(gbps), mRotation(rotation), mSurfaceSetID(surfaceSetID), mSurfaceType(surfaceType),
Shuzhen Wang0ff9ae32018-12-05 18:06:12 -0800293 mWidth(width), mHeight(height), mIsDeferred(false), mIsShared(isShared),
Emilian Peev2295df72021-11-12 18:14:10 -0800294 mPhysicalCameraId(physicalCameraId), mIsMultiResolution(false),
Shuzhen Wangc8ab4522021-12-14 20:12:42 -0800295 mDynamicRangeProfile(ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_STANDARD),
Austin Borger9e2b27c2022-07-15 11:27:24 -0700296 mColorSpace(ANDROID_REQUEST_AVAILABLE_COLOR_SPACE_PROFILES_MAP_UNSPECIFIED),
Shuzhen Wange4208922022-02-01 16:52:48 -0800297 mStreamUseCase(ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT),
Shuzhen Wang610d7b82022-02-08 14:37:22 -0800298 mTimestampBase(TIMESTAMP_BASE_DEFAULT),
Shuzhen Wangbce53db2022-12-03 00:38:20 +0000299 mMirrorMode(MIRROR_MODE_AUTO), mUseReadoutTimestamp(false) { }
Jayant Chowdharybe543d42018-08-15 13:16:14 -0700300
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800301status_t OutputConfiguration::writeToParcel(android::Parcel* parcel) const {
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700302
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800303 if (parcel == nullptr) return BAD_VALUE;
304 status_t err = OK;
305
306 err = parcel->writeInt32(mRotation);
307 if (err != OK) return err;
308
309 err = parcel->writeInt32(mSurfaceSetID);
310 if (err != OK) return err;
311
Zhijun He5d677d12016-05-29 16:52:39 -0700312 err = parcel->writeInt32(mSurfaceType);
313 if (err != OK) return err;
314
315 err = parcel->writeInt32(mWidth);
316 if (err != OK) return err;
317
318 err = parcel->writeInt32(mHeight);
319 if (err != OK) return err;
320
Shuzhen Wang758c2152017-01-10 18:26:18 -0800321 err = parcel->writeInt32(mIsDeferred ? 1 : 0);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800322 if (err != OK) return err;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700323
Shuzhen Wang758c2152017-01-10 18:26:18 -0800324 err = parcel->writeInt32(mIsShared ? 1 : 0);
325 if (err != OK) return err;
326
327 std::vector<view::Surface> surfaceShims;
328 for (auto& gbp : mGbps) {
Shuzhen Wang0129d522016-10-30 22:43:41 -0700329 view::Surface surfaceShim;
330 surfaceShim.name = String16("unknown_name"); // name of surface
Shuzhen Wang758c2152017-01-10 18:26:18 -0800331 surfaceShim.graphicBufferProducer = gbp;
332 surfaceShims.push_back(surfaceShim);
Shuzhen Wang0129d522016-10-30 22:43:41 -0700333 }
Shuzhen Wang758c2152017-01-10 18:26:18 -0800334 err = parcel->writeParcelableVector(surfaceShims);
335 if (err != OK) return err;
Shuzhen Wang0129d522016-10-30 22:43:41 -0700336
Austin Borger71d8f672023-06-01 16:51:35 -0700337 String16 physicalCameraId = toString16(mPhysicalCameraId);
338 err = parcel->writeString16(physicalCameraId);
Shuzhen Wangc28189a2017-11-27 23:05:10 -0800339 if (err != OK) return err;
340
Shuzhen Wang83bff122020-11-20 15:51:39 -0800341 err = parcel->writeInt32(mIsMultiResolution ? 1 : 0);
342 if (err != OK) return err;
343
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800344 err = parcel->writeParcelableVector(mSensorPixelModesUsed);
345 if (err != OK) return err;
346
Emilian Peevc81a7592022-02-14 17:38:18 -0800347 err = parcel->writeInt64(mDynamicRangeProfile);
Emilian Peev2295df72021-11-12 18:14:10 -0800348 if (err != OK) return err;
349
Austin Borger9e2b27c2022-07-15 11:27:24 -0700350 err = parcel->writeInt32(mColorSpace);
351 if (err != OK) return err;
352
Shuzhen Wang8ed1e872022-03-08 16:34:33 -0800353 err = parcel->writeInt64(mStreamUseCase);
Shuzhen Wangc8ab4522021-12-14 20:12:42 -0800354 if (err != OK) return err;
355
Shuzhen Wange4208922022-02-01 16:52:48 -0800356 err = parcel->writeInt32(mTimestampBase);
357 if (err != OK) return err;
358
Shuzhen Wang610d7b82022-02-08 14:37:22 -0800359 err = parcel->writeInt32(mMirrorMode);
360 if (err != OK) return err;
361
Shuzhen Wangbce53db2022-12-03 00:38:20 +0000362 err = parcel->writeInt32(mUseReadoutTimestamp ? 1 : 0);
363 if (err != OK) return err;
364
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700365 return OK;
366}
367
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800368template <typename T>
369static bool simpleVectorsEqual(T first, T second) {
370 if (first.size() != second.size()) {
371 return false;
372 }
373
374 for (size_t i = 0; i < first.size(); i++) {
375 if (first[i] != second[i]) {
376 return false;
377 }
378 }
379 return true;
380}
381
Shuzhen Wang0129d522016-10-30 22:43:41 -0700382bool OutputConfiguration::gbpsEqual(const OutputConfiguration& other) const {
383 const std::vector<sp<IGraphicBufferProducer> >& otherGbps =
384 other.getGraphicBufferProducers();
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800385 return simpleVectorsEqual(otherGbps, mGbps);
386}
Shuzhen Wang0129d522016-10-30 22:43:41 -0700387
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800388bool OutputConfiguration::sensorPixelModesUsedEqual(const OutputConfiguration& other) const {
389 const std::vector<int32_t>& othersensorPixelModesUsed = other.getSensorPixelModesUsed();
390 return simpleVectorsEqual(othersensorPixelModesUsed, mSensorPixelModesUsed);
391}
392
393bool OutputConfiguration::sensorPixelModesUsedLessThan(const OutputConfiguration& other) const {
394 const std::vector<int32_t>& spms = other.getSensorPixelModesUsed();
395
396 if (mSensorPixelModesUsed.size() != spms.size()) {
397 return mSensorPixelModesUsed.size() < spms.size();
Shuzhen Wang0129d522016-10-30 22:43:41 -0700398 }
399
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800400 for (size_t i = 0; i < spms.size(); i++) {
401 if (mSensorPixelModesUsed[i] != spms[i]) {
402 return mSensorPixelModesUsed[i] < spms[i];
Shuzhen Wang0129d522016-10-30 22:43:41 -0700403 }
404 }
405
Jayant Chowdhary13f9b2f2020-12-02 22:46:15 -0800406 return false;
Shuzhen Wang0129d522016-10-30 22:43:41 -0700407}
408
409bool OutputConfiguration::gbpsLessThan(const OutputConfiguration& other) const {
410 const std::vector<sp<IGraphicBufferProducer> >& otherGbps =
411 other.getGraphicBufferProducers();
412
413 if (mGbps.size() != otherGbps.size()) {
414 return mGbps.size() < otherGbps.size();
415 }
416
417 for (size_t i = 0; i < mGbps.size(); i++) {
418 if (mGbps[i] != otherGbps[i]) {
419 return mGbps[i] < otherGbps[i];
420 }
421 }
422
423 return false;
424}
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700425}; // namespace android