Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2020 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | // #define LOG_NDEBUG 0 |
| 18 | #define LOG_TAG "CameraSessionStats" |
| 19 | #include <utils/Log.h> |
| 20 | #include <utils/String16.h> |
| 21 | |
| 22 | #include <camera/CameraSessionStats.h> |
Austin Borger | 1c1bee0 | 2023-06-01 16:51:35 -0700 | [diff] [blame^] | 23 | #include <camera/StringUtils.h> |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 24 | |
| 25 | #include <binder/Parcel.h> |
| 26 | |
| 27 | namespace android { |
| 28 | namespace hardware { |
| 29 | |
| 30 | status_t CameraStreamStats::readFromParcel(const android::Parcel* parcel) { |
| 31 | if (parcel == NULL) { |
| 32 | ALOGE("%s: Null parcel", __FUNCTION__); |
| 33 | return BAD_VALUE; |
| 34 | } |
| 35 | |
| 36 | status_t err = OK; |
| 37 | |
| 38 | int width = 0; |
| 39 | if ((err = parcel->readInt32(&width)) != OK) { |
| 40 | ALOGE("%s: Failed to read width from parcel", __FUNCTION__); |
| 41 | return err; |
| 42 | } |
| 43 | |
| 44 | int height = 0; |
| 45 | if ((err = parcel->readInt32(&height)) != OK) { |
| 46 | ALOGE("%s: Failed to read height from parcel", __FUNCTION__); |
| 47 | return err; |
| 48 | } |
| 49 | |
| 50 | int format = 0; |
| 51 | if ((err = parcel->readInt32(&format)) != OK) { |
| 52 | ALOGE("%s: Failed to read format from parcel", __FUNCTION__); |
| 53 | return err; |
| 54 | } |
| 55 | |
Austin Borger | 4a870a3 | 2022-02-25 01:48:41 +0000 | [diff] [blame] | 56 | float maxPreviewFps = 0; |
| 57 | if ((err = parcel->readFloat(&maxPreviewFps)) != OK) { |
| 58 | ALOGE("%s: Failed to read maxPreviewFps from parcel", __FUNCTION__); |
| 59 | return err; |
| 60 | } |
| 61 | |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 62 | int dataSpace = 0; |
| 63 | if ((err = parcel->readInt32(&dataSpace)) != OK) { |
| 64 | ALOGE("%s: Failed to read dataSpace from parcel", __FUNCTION__); |
| 65 | return err; |
| 66 | } |
| 67 | |
| 68 | int64_t usage = 0; |
| 69 | if ((err = parcel->readInt64(&usage)) != OK) { |
| 70 | ALOGE("%s: Failed to read usage from parcel", __FUNCTION__); |
| 71 | return err; |
| 72 | } |
| 73 | |
| 74 | int64_t requestCount = 0; |
| 75 | if ((err = parcel->readInt64(&requestCount)) != OK) { |
| 76 | ALOGE("%s: Failed to read request count from parcel", __FUNCTION__); |
| 77 | return err; |
| 78 | } |
| 79 | |
| 80 | int64_t errorCount = 0; |
| 81 | if ((err = parcel->readInt64(&errorCount)) != OK) { |
| 82 | ALOGE("%s: Failed to read error count from parcel", __FUNCTION__); |
| 83 | return err; |
| 84 | } |
| 85 | |
| 86 | int startLatencyMs = 0; |
| 87 | if ((err = parcel->readInt32(&startLatencyMs)) != OK) { |
| 88 | ALOGE("%s: Failed to read start latency from parcel", __FUNCTION__); |
| 89 | return err; |
| 90 | } |
| 91 | |
| 92 | int maxHalBuffers = 0; |
| 93 | if ((err = parcel->readInt32(&maxHalBuffers)) != OK) { |
| 94 | ALOGE("%s: Failed to read max Hal buffers from parcel", __FUNCTION__); |
| 95 | return err; |
| 96 | } |
| 97 | |
| 98 | int maxAppBuffers = 0; |
| 99 | if ((err = parcel->readInt32(&maxAppBuffers)) != OK) { |
| 100 | ALOGE("%s: Failed to read max app buffers from parcel", __FUNCTION__); |
| 101 | return err; |
| 102 | } |
| 103 | |
Shuzhen Wang | db8f278 | 2020-10-30 08:43:37 -0700 | [diff] [blame] | 104 | int histogramType = HISTOGRAM_TYPE_UNKNOWN; |
| 105 | if ((err = parcel->readInt32(&histogramType)) != OK) { |
| 106 | ALOGE("%s: Failed to read histogram type from parcel", __FUNCTION__); |
| 107 | return err; |
| 108 | } |
| 109 | |
| 110 | std::vector<float> histogramBins; |
| 111 | if ((err = parcel->readFloatVector(&histogramBins)) != OK) { |
| 112 | ALOGE("%s: Failed to read histogram bins from parcel", __FUNCTION__); |
| 113 | return err; |
| 114 | } |
| 115 | |
| 116 | std::vector<int64_t> histogramCounts; |
| 117 | if ((err = parcel->readInt64Vector(&histogramCounts)) != OK) { |
| 118 | ALOGE("%s: Failed to read histogram counts from parcel", __FUNCTION__); |
| 119 | return err; |
| 120 | } |
| 121 | |
Shuzhen Wang | 8ed1e87 | 2022-03-08 16:34:33 -0800 | [diff] [blame] | 122 | int64_t dynamicRangeProfile = ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_STANDARD; |
| 123 | if ((err = parcel->readInt64(&dynamicRangeProfile)) != OK) { |
Emilian Peev | 2295df7 | 2021-11-12 18:14:10 -0800 | [diff] [blame] | 124 | ALOGE("%s: Failed to read dynamic range profile type from parcel", __FUNCTION__); |
| 125 | return err; |
| 126 | } |
| 127 | |
Shuzhen Wang | 8ed1e87 | 2022-03-08 16:34:33 -0800 | [diff] [blame] | 128 | int64_t streamUseCase = ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT; |
| 129 | if ((err = parcel->readInt64(&streamUseCase)) != OK) { |
Shuzhen Wang | c8ab452 | 2021-12-14 20:12:42 -0800 | [diff] [blame] | 130 | ALOGE("%s: Failed to read stream use case from parcel", __FUNCTION__); |
| 131 | return err; |
| 132 | } |
| 133 | |
Austin Borger | 9e2b27c | 2022-07-15 11:27:24 -0700 | [diff] [blame] | 134 | int32_t colorSpace = ANDROID_REQUEST_AVAILABLE_COLOR_SPACE_PROFILES_MAP_UNSPECIFIED; |
| 135 | if ((err = parcel->readInt32(&colorSpace)) != OK) { |
| 136 | ALOGE("%s: Failed to read color space from parcel", __FUNCTION__); |
| 137 | return err; |
| 138 | } |
| 139 | |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 140 | mWidth = width; |
| 141 | mHeight = height; |
| 142 | mFormat = format; |
Austin Borger | 4a870a3 | 2022-02-25 01:48:41 +0000 | [diff] [blame] | 143 | mMaxPreviewFps = maxPreviewFps; |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 144 | mDataSpace = dataSpace; |
| 145 | mUsage = usage; |
| 146 | mRequestCount = requestCount; |
| 147 | mErrorCount = errorCount; |
| 148 | mStartLatencyMs = startLatencyMs; |
| 149 | mMaxHalBuffers = maxHalBuffers; |
| 150 | mMaxAppBuffers = maxAppBuffers; |
Shuzhen Wang | db8f278 | 2020-10-30 08:43:37 -0700 | [diff] [blame] | 151 | mHistogramType = histogramType; |
| 152 | mHistogramBins = std::move(histogramBins); |
| 153 | mHistogramCounts = std::move(histogramCounts); |
Emilian Peev | 2295df7 | 2021-11-12 18:14:10 -0800 | [diff] [blame] | 154 | mDynamicRangeProfile = dynamicRangeProfile; |
Shuzhen Wang | c8ab452 | 2021-12-14 20:12:42 -0800 | [diff] [blame] | 155 | mStreamUseCase = streamUseCase; |
Austin Borger | 9e2b27c | 2022-07-15 11:27:24 -0700 | [diff] [blame] | 156 | mColorSpace = colorSpace; |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 157 | |
| 158 | return OK; |
| 159 | } |
| 160 | |
| 161 | status_t CameraStreamStats::writeToParcel(android::Parcel* parcel) const { |
| 162 | if (parcel == NULL) { |
| 163 | ALOGE("%s: Null parcel", __FUNCTION__); |
| 164 | return BAD_VALUE; |
| 165 | } |
| 166 | |
| 167 | status_t err = OK; |
| 168 | |
| 169 | if ((err = parcel->writeInt32(mWidth)) != OK) { |
| 170 | ALOGE("%s: Failed to write stream width!", __FUNCTION__); |
| 171 | return err; |
| 172 | } |
| 173 | |
| 174 | if ((err = parcel->writeInt32(mHeight)) != OK) { |
| 175 | ALOGE("%s: Failed to write stream height!", __FUNCTION__); |
| 176 | return err; |
| 177 | } |
| 178 | |
| 179 | if ((err = parcel->writeInt32(mFormat)) != OK) { |
| 180 | ALOGE("%s: Failed to write stream format!", __FUNCTION__); |
| 181 | return err; |
| 182 | } |
| 183 | |
Austin Borger | 4a870a3 | 2022-02-25 01:48:41 +0000 | [diff] [blame] | 184 | if ((err = parcel->writeFloat(mMaxPreviewFps)) != OK) { |
| 185 | ALOGE("%s: Failed to write stream maxPreviewFps!", __FUNCTION__); |
| 186 | return err; |
| 187 | } |
| 188 | |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 189 | if ((err = parcel->writeInt32(mDataSpace)) != OK) { |
| 190 | ALOGE("%s: Failed to write stream dataSpace!", __FUNCTION__); |
| 191 | return err; |
| 192 | } |
| 193 | |
| 194 | if ((err = parcel->writeInt64(mUsage)) != OK) { |
| 195 | ALOGE("%s: Failed to write stream usage!", __FUNCTION__); |
| 196 | return err; |
| 197 | } |
| 198 | |
| 199 | if ((err = parcel->writeInt64(mRequestCount)) != OK) { |
| 200 | ALOGE("%s: Failed to write stream request count!", __FUNCTION__); |
| 201 | return err; |
| 202 | } |
| 203 | |
| 204 | if ((err = parcel->writeInt64(mErrorCount)) != OK) { |
| 205 | ALOGE("%s: Failed to write stream error count!", __FUNCTION__); |
| 206 | return err; |
| 207 | } |
| 208 | |
| 209 | if ((err = parcel->writeInt32(mStartLatencyMs)) != OK) { |
| 210 | ALOGE("%s: Failed to write stream start latency!", __FUNCTION__); |
| 211 | return err; |
| 212 | } |
| 213 | |
| 214 | if ((err = parcel->writeInt32(mMaxHalBuffers)) != OK) { |
| 215 | ALOGE("%s: Failed to write max hal buffers", __FUNCTION__); |
| 216 | return err; |
| 217 | } |
| 218 | |
| 219 | if ((err = parcel->writeInt32(mMaxAppBuffers)) != OK) { |
| 220 | ALOGE("%s: Failed to write max app buffers", __FUNCTION__); |
| 221 | return err; |
| 222 | } |
| 223 | |
Shuzhen Wang | db8f278 | 2020-10-30 08:43:37 -0700 | [diff] [blame] | 224 | if ((err = parcel->writeInt32(mHistogramType)) != OK) { |
| 225 | ALOGE("%s: Failed to write histogram type", __FUNCTION__); |
| 226 | return err; |
| 227 | } |
| 228 | |
| 229 | if ((err = parcel->writeFloatVector(mHistogramBins)) != OK) { |
| 230 | ALOGE("%s: Failed to write histogram bins!", __FUNCTION__); |
| 231 | return err; |
| 232 | } |
| 233 | |
| 234 | if ((err = parcel->writeInt64Vector(mHistogramCounts)) != OK) { |
| 235 | ALOGE("%s: Failed to write histogram counts!", __FUNCTION__); |
| 236 | return err; |
| 237 | } |
| 238 | |
Shuzhen Wang | 8ed1e87 | 2022-03-08 16:34:33 -0800 | [diff] [blame] | 239 | if ((err = parcel->writeInt64(mDynamicRangeProfile)) != OK) { |
Emilian Peev | 2295df7 | 2021-11-12 18:14:10 -0800 | [diff] [blame] | 240 | ALOGE("%s: Failed to write dynamic range profile type", __FUNCTION__); |
| 241 | return err; |
| 242 | } |
| 243 | |
Shuzhen Wang | 8ed1e87 | 2022-03-08 16:34:33 -0800 | [diff] [blame] | 244 | if ((err = parcel->writeInt64(mStreamUseCase)) != OK) { |
Shuzhen Wang | c8ab452 | 2021-12-14 20:12:42 -0800 | [diff] [blame] | 245 | ALOGE("%s: Failed to write stream use case!", __FUNCTION__); |
| 246 | return err; |
| 247 | } |
| 248 | |
Austin Borger | 9e2b27c | 2022-07-15 11:27:24 -0700 | [diff] [blame] | 249 | if ((err = parcel->writeInt32(mColorSpace)) != OK) { |
| 250 | ALOGE("%s: Failed to write color space", __FUNCTION__); |
| 251 | return err; |
| 252 | } |
| 253 | |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 254 | return OK; |
| 255 | } |
| 256 | |
Shuzhen Wang | bac18d9 | 2020-11-19 14:50:30 -0800 | [diff] [blame] | 257 | const int CameraSessionStats::CAMERA_STATE_OPEN = 0; |
| 258 | const int CameraSessionStats::CAMERA_STATE_ACTIVE = 1; |
| 259 | const int CameraSessionStats::CAMERA_STATE_IDLE = 2; |
| 260 | const int CameraSessionStats::CAMERA_STATE_CLOSED = 3; |
| 261 | |
| 262 | const int CameraSessionStats::CAMERA_FACING_BACK = 0; |
| 263 | const int CameraSessionStats::CAMERA_FACING_FRONT = 1; |
| 264 | const int CameraSessionStats::CAMERA_FACING_EXTERNAL = 2; |
| 265 | |
| 266 | const int CameraSessionStats::CAMERA_API_LEVEL_1 = 1; |
| 267 | const int CameraSessionStats::CAMERA_API_LEVEL_2 = 2; |
| 268 | |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 269 | CameraSessionStats::CameraSessionStats() : |
| 270 | mFacing(CAMERA_FACING_BACK), |
| 271 | mNewCameraState(CAMERA_STATE_CLOSED), |
| 272 | mApiLevel(0), |
| 273 | mIsNdk(false), |
| 274 | mLatencyMs(-1), |
Avichal Rakesh | 88fc522 | 2023-03-03 15:00:59 -0800 | [diff] [blame] | 275 | mLogId(0), |
Austin Borger | 4a870a3 | 2022-02-25 01:48:41 +0000 | [diff] [blame] | 276 | mMaxPreviewFps(0), |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 277 | mSessionType(0), |
| 278 | mInternalReconfigure(0), |
| 279 | mRequestCount(0), |
| 280 | mResultErrorCount(0), |
Shuzhen Wang | 9372b0b | 2022-05-11 18:55:19 -0700 | [diff] [blame] | 281 | mDeviceError(false), |
Avichal Rakesh | 89691e1 | 2023-05-01 19:41:02 -0700 | [diff] [blame] | 282 | mVideoStabilizationMode(-1), |
Avichal Rakesh | 6e57a2b | 2023-05-01 17:53:37 -0700 | [diff] [blame] | 283 | mSessionIndex(0), |
| 284 | mCameraExtensionSessionStats() {} |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 285 | |
Austin Borger | 1c1bee0 | 2023-06-01 16:51:35 -0700 | [diff] [blame^] | 286 | CameraSessionStats::CameraSessionStats(const std::string& cameraId, |
| 287 | int facing, int newCameraState, const std::string& clientName, |
Avichal Rakesh | 88fc522 | 2023-03-03 15:00:59 -0800 | [diff] [blame] | 288 | int apiLevel, bool isNdk, int32_t latencyMs, int64_t logId) : |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 289 | mCameraId(cameraId), |
| 290 | mFacing(facing), |
| 291 | mNewCameraState(newCameraState), |
| 292 | mClientName(clientName), |
| 293 | mApiLevel(apiLevel), |
| 294 | mIsNdk(isNdk), |
| 295 | mLatencyMs(latencyMs), |
Avichal Rakesh | 88fc522 | 2023-03-03 15:00:59 -0800 | [diff] [blame] | 296 | mLogId(logId), |
Austin Borger | 4a870a3 | 2022-02-25 01:48:41 +0000 | [diff] [blame] | 297 | mMaxPreviewFps(0), |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 298 | mSessionType(0), |
| 299 | mInternalReconfigure(0), |
| 300 | mRequestCount(0), |
| 301 | mResultErrorCount(0), |
Shuzhen Wang | 9372b0b | 2022-05-11 18:55:19 -0700 | [diff] [blame] | 302 | mDeviceError(0), |
Avichal Rakesh | 89691e1 | 2023-05-01 19:41:02 -0700 | [diff] [blame] | 303 | mVideoStabilizationMode(-1), |
Avichal Rakesh | 6e57a2b | 2023-05-01 17:53:37 -0700 | [diff] [blame] | 304 | mSessionIndex(0), |
| 305 | mCameraExtensionSessionStats() {} |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 306 | |
| 307 | status_t CameraSessionStats::readFromParcel(const android::Parcel* parcel) { |
| 308 | if (parcel == NULL) { |
| 309 | ALOGE("%s: Null parcel", __FUNCTION__); |
| 310 | return BAD_VALUE; |
| 311 | } |
| 312 | |
| 313 | status_t err = OK; |
| 314 | |
| 315 | String16 id; |
| 316 | if ((err = parcel->readString16(&id)) != OK) { |
| 317 | ALOGE("%s: Failed to read camera id!", __FUNCTION__); |
| 318 | return BAD_VALUE; |
| 319 | } |
| 320 | |
| 321 | int facing = 0; |
| 322 | if ((err = parcel->readInt32(&facing)) != OK) { |
| 323 | ALOGE("%s: Failed to read camera facing from parcel", __FUNCTION__); |
| 324 | return err; |
| 325 | } |
| 326 | |
| 327 | int32_t newCameraState; |
| 328 | if ((err = parcel->readInt32(&newCameraState)) != OK) { |
| 329 | ALOGE("%s: Failed to read new camera state from parcel", __FUNCTION__); |
| 330 | return err; |
| 331 | } |
| 332 | |
| 333 | String16 clientName; |
| 334 | if ((err = parcel->readString16(&clientName)) != OK) { |
| 335 | ALOGE("%s: Failed to read client name!", __FUNCTION__); |
| 336 | return BAD_VALUE; |
| 337 | } |
| 338 | |
| 339 | int32_t apiLevel; |
| 340 | if ((err = parcel->readInt32(&apiLevel)) != OK) { |
| 341 | ALOGE("%s: Failed to read api level from parcel", __FUNCTION__); |
| 342 | return err; |
| 343 | } |
| 344 | |
| 345 | bool isNdk; |
| 346 | if ((err = parcel->readBool(&isNdk)) != OK) { |
| 347 | ALOGE("%s: Failed to read isNdk flag from parcel", __FUNCTION__); |
| 348 | return err; |
| 349 | } |
| 350 | |
| 351 | int32_t latencyMs; |
| 352 | if ((err = parcel->readInt32(&latencyMs)) != OK) { |
| 353 | ALOGE("%s: Failed to read latencyMs from parcel", __FUNCTION__); |
| 354 | return err; |
| 355 | } |
| 356 | |
Avichal Rakesh | 88fc522 | 2023-03-03 15:00:59 -0800 | [diff] [blame] | 357 | int64_t logId; |
| 358 | if ((err = parcel->readInt64(&logId)) != OK) { |
| 359 | ALOGE("%s: Failed to read log ID from parcel", __FUNCTION__); |
| 360 | return err; |
| 361 | } |
| 362 | |
Austin Borger | 4a870a3 | 2022-02-25 01:48:41 +0000 | [diff] [blame] | 363 | float maxPreviewFps; |
| 364 | if ((err = parcel->readFloat(&maxPreviewFps)) != OK) { |
| 365 | ALOGE("%s: Failed to read maxPreviewFps from parcel", __FUNCTION__); |
| 366 | return err; |
| 367 | } |
| 368 | |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 369 | int32_t sessionType; |
| 370 | if ((err = parcel->readInt32(&sessionType)) != OK) { |
| 371 | ALOGE("%s: Failed to read session type from parcel", __FUNCTION__); |
| 372 | return err; |
| 373 | } |
| 374 | |
| 375 | int32_t internalReconfigure; |
| 376 | if ((err = parcel->readInt32(&internalReconfigure)) != OK) { |
| 377 | ALOGE("%s: Failed to read internal reconfigure count from parcel", __FUNCTION__); |
| 378 | return err; |
| 379 | } |
| 380 | |
| 381 | int64_t requestCount; |
| 382 | if ((err = parcel->readInt64(&requestCount)) != OK) { |
| 383 | ALOGE("%s: Failed to read request count from parcel", __FUNCTION__); |
| 384 | return err; |
| 385 | } |
| 386 | |
| 387 | int64_t resultErrorCount; |
| 388 | if ((err = parcel->readInt64(&resultErrorCount)) != OK) { |
| 389 | ALOGE("%s: Failed to read result error count from parcel", __FUNCTION__); |
| 390 | return err; |
| 391 | } |
| 392 | |
| 393 | bool deviceError; |
| 394 | if ((err = parcel->readBool(&deviceError)) != OK) { |
| 395 | ALOGE("%s: Failed to read device error flag from parcel", __FUNCTION__); |
| 396 | return err; |
| 397 | } |
| 398 | |
| 399 | std::vector<CameraStreamStats> streamStats; |
| 400 | if ((err = parcel->readParcelableVector(&streamStats)) != OK) { |
| 401 | ALOGE("%s: Failed to read stream state from parcel", __FUNCTION__); |
| 402 | return err; |
| 403 | } |
| 404 | |
Shuzhen Wang | d26b186 | 2022-03-07 12:05:05 -0800 | [diff] [blame] | 405 | String16 userTag; |
| 406 | if ((err = parcel->readString16(&userTag)) != OK) { |
| 407 | ALOGE("%s: Failed to read user tag!", __FUNCTION__); |
| 408 | return BAD_VALUE; |
| 409 | } |
| 410 | |
Shuzhen Wang | 9372b0b | 2022-05-11 18:55:19 -0700 | [diff] [blame] | 411 | int32_t videoStabilizationMode; |
| 412 | if ((err = parcel->readInt32(&videoStabilizationMode)) != OK) { |
| 413 | ALOGE("%s: Failed to read video stabilization mode from parcel", __FUNCTION__); |
| 414 | return err; |
| 415 | } |
| 416 | |
Avichal Rakesh | 89691e1 | 2023-05-01 19:41:02 -0700 | [diff] [blame] | 417 | int32_t sessionIdx; |
| 418 | if ((err = parcel->readInt32(&sessionIdx)) != OK) { |
| 419 | ALOGE("%s: Failed to read session index from parcel", __FUNCTION__); |
| 420 | return err; |
| 421 | } |
| 422 | |
Avichal Rakesh | 6e57a2b | 2023-05-01 17:53:37 -0700 | [diff] [blame] | 423 | CameraExtensionSessionStats extStats{}; |
| 424 | if ((err = extStats.readFromParcel(parcel)) != OK) { |
| 425 | ALOGE("%s: Failed to read extension session stats from parcel", __FUNCTION__); |
| 426 | return err; |
| 427 | } |
| 428 | |
Austin Borger | 1c1bee0 | 2023-06-01 16:51:35 -0700 | [diff] [blame^] | 429 | mCameraId = toStdString(id); |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 430 | mFacing = facing; |
| 431 | mNewCameraState = newCameraState; |
Austin Borger | 1c1bee0 | 2023-06-01 16:51:35 -0700 | [diff] [blame^] | 432 | mClientName = toStdString(clientName); |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 433 | mApiLevel = apiLevel; |
| 434 | mIsNdk = isNdk; |
| 435 | mLatencyMs = latencyMs; |
Avichal Rakesh | 88fc522 | 2023-03-03 15:00:59 -0800 | [diff] [blame] | 436 | mLogId = logId; |
Austin Borger | 4a870a3 | 2022-02-25 01:48:41 +0000 | [diff] [blame] | 437 | mMaxPreviewFps = maxPreviewFps; |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 438 | mSessionType = sessionType; |
| 439 | mInternalReconfigure = internalReconfigure; |
| 440 | mRequestCount = requestCount; |
| 441 | mResultErrorCount = resultErrorCount; |
| 442 | mDeviceError = deviceError; |
| 443 | mStreamStats = std::move(streamStats); |
Austin Borger | 1c1bee0 | 2023-06-01 16:51:35 -0700 | [diff] [blame^] | 444 | mUserTag = toStdString(userTag); |
Shuzhen Wang | 9372b0b | 2022-05-11 18:55:19 -0700 | [diff] [blame] | 445 | mVideoStabilizationMode = videoStabilizationMode; |
Avichal Rakesh | 89691e1 | 2023-05-01 19:41:02 -0700 | [diff] [blame] | 446 | mSessionIndex = sessionIdx; |
Avichal Rakesh | 6e57a2b | 2023-05-01 17:53:37 -0700 | [diff] [blame] | 447 | mCameraExtensionSessionStats = extStats; |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 448 | |
| 449 | return OK; |
| 450 | } |
| 451 | |
| 452 | status_t CameraSessionStats::writeToParcel(android::Parcel* parcel) const { |
| 453 | if (parcel == NULL) { |
| 454 | ALOGE("%s: Null parcel", __FUNCTION__); |
| 455 | return BAD_VALUE; |
| 456 | } |
| 457 | |
| 458 | status_t err = OK; |
| 459 | |
Austin Borger | 1c1bee0 | 2023-06-01 16:51:35 -0700 | [diff] [blame^] | 460 | if ((err = parcel->writeString16(toString16(mCameraId))) != OK) { |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 461 | ALOGE("%s: Failed to write camera id!", __FUNCTION__); |
| 462 | return err; |
| 463 | } |
| 464 | |
| 465 | if ((err = parcel->writeInt32(mFacing)) != OK) { |
| 466 | ALOGE("%s: Failed to write camera facing!", __FUNCTION__); |
| 467 | return err; |
| 468 | } |
| 469 | |
| 470 | if ((err = parcel->writeInt32(mNewCameraState)) != OK) { |
| 471 | ALOGE("%s: Failed to write new camera state!", __FUNCTION__); |
| 472 | return err; |
| 473 | } |
| 474 | |
Austin Borger | 1c1bee0 | 2023-06-01 16:51:35 -0700 | [diff] [blame^] | 475 | if ((err = parcel->writeString16(toString16(mClientName))) != OK) { |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 476 | ALOGE("%s: Failed to write client name!", __FUNCTION__); |
| 477 | return err; |
| 478 | } |
| 479 | |
| 480 | if ((err = parcel->writeInt32(mApiLevel)) != OK) { |
| 481 | ALOGE("%s: Failed to write api level!", __FUNCTION__); |
| 482 | return err; |
| 483 | } |
| 484 | |
| 485 | if ((err = parcel->writeBool(mIsNdk)) != OK) { |
| 486 | ALOGE("%s: Failed to write isNdk flag!", __FUNCTION__); |
| 487 | return err; |
| 488 | } |
| 489 | |
| 490 | if ((err = parcel->writeInt32(mLatencyMs)) != OK) { |
| 491 | ALOGE("%s: Failed to write latency in Ms!", __FUNCTION__); |
| 492 | return err; |
| 493 | } |
| 494 | |
Avichal Rakesh | 88fc522 | 2023-03-03 15:00:59 -0800 | [diff] [blame] | 495 | if ((err = parcel->writeInt64(mLogId)) != OK) { |
| 496 | ALOGE("%s: Failed to write log ID!", __FUNCTION__); |
| 497 | return err; |
| 498 | } |
| 499 | |
Austin Borger | 4a870a3 | 2022-02-25 01:48:41 +0000 | [diff] [blame] | 500 | if ((err = parcel->writeFloat(mMaxPreviewFps)) != OK) { |
| 501 | ALOGE("%s: Failed to write maxPreviewFps!", __FUNCTION__); |
| 502 | return err; |
| 503 | } |
| 504 | |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 505 | if ((err = parcel->writeInt32(mSessionType)) != OK) { |
| 506 | ALOGE("%s: Failed to write session type!", __FUNCTION__); |
| 507 | return err; |
| 508 | } |
| 509 | |
| 510 | if ((err = parcel->writeInt32(mInternalReconfigure)) != OK) { |
| 511 | ALOGE("%s: Failed to write internal reconfigure count!", __FUNCTION__); |
| 512 | return err; |
| 513 | } |
| 514 | |
| 515 | if ((err = parcel->writeInt64(mRequestCount)) != OK) { |
| 516 | ALOGE("%s: Failed to write request count!", __FUNCTION__); |
| 517 | return err; |
| 518 | } |
| 519 | |
| 520 | if ((err = parcel->writeInt64(mResultErrorCount)) != OK) { |
| 521 | ALOGE("%s: Failed to write result error count!", __FUNCTION__); |
| 522 | return err; |
| 523 | } |
| 524 | |
| 525 | if ((err = parcel->writeBool(mDeviceError)) != OK) { |
| 526 | ALOGE("%s: Failed to write device error flag!", __FUNCTION__); |
| 527 | return err; |
| 528 | } |
| 529 | |
| 530 | if ((err = parcel->writeParcelableVector(mStreamStats)) != OK) { |
| 531 | ALOGE("%s: Failed to write stream states!", __FUNCTION__); |
| 532 | return err; |
| 533 | } |
| 534 | |
Austin Borger | 1c1bee0 | 2023-06-01 16:51:35 -0700 | [diff] [blame^] | 535 | if ((err = parcel->writeString16(toString16(mUserTag))) != OK) { |
Shuzhen Wang | d26b186 | 2022-03-07 12:05:05 -0800 | [diff] [blame] | 536 | ALOGE("%s: Failed to write user tag!", __FUNCTION__); |
| 537 | return err; |
| 538 | } |
Shuzhen Wang | 9372b0b | 2022-05-11 18:55:19 -0700 | [diff] [blame] | 539 | |
| 540 | if ((err = parcel->writeInt32(mVideoStabilizationMode)) != OK) { |
| 541 | ALOGE("%s: Failed to write video stabilization mode!", __FUNCTION__); |
| 542 | return err; |
| 543 | } |
Avichal Rakesh | 88fc522 | 2023-03-03 15:00:59 -0800 | [diff] [blame] | 544 | |
Avichal Rakesh | 89691e1 | 2023-05-01 19:41:02 -0700 | [diff] [blame] | 545 | if ((err = parcel->writeInt32(mSessionIndex)) != OK) { |
| 546 | ALOGE("%s: Failed to write session index!", __FUNCTION__); |
| 547 | return err; |
| 548 | } |
| 549 | |
Avichal Rakesh | 6e57a2b | 2023-05-01 17:53:37 -0700 | [diff] [blame] | 550 | if ((err = mCameraExtensionSessionStats.writeToParcel(parcel)) != OK) { |
| 551 | ALOGE("%s: Failed to write extension sessions stats!", __FUNCTION__); |
| 552 | return err; |
| 553 | } |
| 554 | |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 555 | return OK; |
| 556 | } |
| 557 | |
| 558 | } // namespace hardware |
| 559 | } // namesmpace android |