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 | 0fb3ad9 | 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 | |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 134 | mWidth = width; |
| 135 | mHeight = height; |
| 136 | mFormat = format; |
Austin Borger | 4a870a3 | 2022-02-25 01:48:41 +0000 | [diff] [blame] | 137 | mMaxPreviewFps = maxPreviewFps; |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 138 | mDataSpace = dataSpace; |
| 139 | mUsage = usage; |
| 140 | mRequestCount = requestCount; |
| 141 | mErrorCount = errorCount; |
| 142 | mStartLatencyMs = startLatencyMs; |
| 143 | mMaxHalBuffers = maxHalBuffers; |
| 144 | mMaxAppBuffers = maxAppBuffers; |
Shuzhen Wang | db8f278 | 2020-10-30 08:43:37 -0700 | [diff] [blame] | 145 | mHistogramType = histogramType; |
| 146 | mHistogramBins = std::move(histogramBins); |
| 147 | mHistogramCounts = std::move(histogramCounts); |
Emilian Peev | 2295df7 | 2021-11-12 18:14:10 -0800 | [diff] [blame] | 148 | mDynamicRangeProfile = dynamicRangeProfile; |
Shuzhen Wang | c8ab452 | 2021-12-14 20:12:42 -0800 | [diff] [blame] | 149 | mStreamUseCase = streamUseCase; |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 150 | |
| 151 | return OK; |
| 152 | } |
| 153 | |
| 154 | status_t CameraStreamStats::writeToParcel(android::Parcel* parcel) const { |
| 155 | if (parcel == NULL) { |
| 156 | ALOGE("%s: Null parcel", __FUNCTION__); |
| 157 | return BAD_VALUE; |
| 158 | } |
| 159 | |
| 160 | status_t err = OK; |
| 161 | |
| 162 | if ((err = parcel->writeInt32(mWidth)) != OK) { |
| 163 | ALOGE("%s: Failed to write stream width!", __FUNCTION__); |
| 164 | return err; |
| 165 | } |
| 166 | |
| 167 | if ((err = parcel->writeInt32(mHeight)) != OK) { |
| 168 | ALOGE("%s: Failed to write stream height!", __FUNCTION__); |
| 169 | return err; |
| 170 | } |
| 171 | |
| 172 | if ((err = parcel->writeInt32(mFormat)) != OK) { |
| 173 | ALOGE("%s: Failed to write stream format!", __FUNCTION__); |
| 174 | return err; |
| 175 | } |
| 176 | |
Austin Borger | 4a870a3 | 2022-02-25 01:48:41 +0000 | [diff] [blame] | 177 | if ((err = parcel->writeFloat(mMaxPreviewFps)) != OK) { |
| 178 | ALOGE("%s: Failed to write stream maxPreviewFps!", __FUNCTION__); |
| 179 | return err; |
| 180 | } |
| 181 | |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 182 | if ((err = parcel->writeInt32(mDataSpace)) != OK) { |
| 183 | ALOGE("%s: Failed to write stream dataSpace!", __FUNCTION__); |
| 184 | return err; |
| 185 | } |
| 186 | |
| 187 | if ((err = parcel->writeInt64(mUsage)) != OK) { |
| 188 | ALOGE("%s: Failed to write stream usage!", __FUNCTION__); |
| 189 | return err; |
| 190 | } |
| 191 | |
| 192 | if ((err = parcel->writeInt64(mRequestCount)) != OK) { |
| 193 | ALOGE("%s: Failed to write stream request count!", __FUNCTION__); |
| 194 | return err; |
| 195 | } |
| 196 | |
| 197 | if ((err = parcel->writeInt64(mErrorCount)) != OK) { |
| 198 | ALOGE("%s: Failed to write stream error count!", __FUNCTION__); |
| 199 | return err; |
| 200 | } |
| 201 | |
| 202 | if ((err = parcel->writeInt32(mStartLatencyMs)) != OK) { |
| 203 | ALOGE("%s: Failed to write stream start latency!", __FUNCTION__); |
| 204 | return err; |
| 205 | } |
| 206 | |
| 207 | if ((err = parcel->writeInt32(mMaxHalBuffers)) != OK) { |
| 208 | ALOGE("%s: Failed to write max hal buffers", __FUNCTION__); |
| 209 | return err; |
| 210 | } |
| 211 | |
| 212 | if ((err = parcel->writeInt32(mMaxAppBuffers)) != OK) { |
| 213 | ALOGE("%s: Failed to write max app buffers", __FUNCTION__); |
| 214 | return err; |
| 215 | } |
| 216 | |
Shuzhen Wang | db8f278 | 2020-10-30 08:43:37 -0700 | [diff] [blame] | 217 | if ((err = parcel->writeInt32(mHistogramType)) != OK) { |
| 218 | ALOGE("%s: Failed to write histogram type", __FUNCTION__); |
| 219 | return err; |
| 220 | } |
| 221 | |
| 222 | if ((err = parcel->writeFloatVector(mHistogramBins)) != OK) { |
| 223 | ALOGE("%s: Failed to write histogram bins!", __FUNCTION__); |
| 224 | return err; |
| 225 | } |
| 226 | |
| 227 | if ((err = parcel->writeInt64Vector(mHistogramCounts)) != OK) { |
| 228 | ALOGE("%s: Failed to write histogram counts!", __FUNCTION__); |
| 229 | return err; |
| 230 | } |
| 231 | |
Shuzhen Wang | 8ed1e87 | 2022-03-08 16:34:33 -0800 | [diff] [blame] | 232 | if ((err = parcel->writeInt64(mDynamicRangeProfile)) != OK) { |
Emilian Peev | 2295df7 | 2021-11-12 18:14:10 -0800 | [diff] [blame] | 233 | ALOGE("%s: Failed to write dynamic range profile type", __FUNCTION__); |
| 234 | return err; |
| 235 | } |
| 236 | |
Shuzhen Wang | 8ed1e87 | 2022-03-08 16:34:33 -0800 | [diff] [blame] | 237 | if ((err = parcel->writeInt64(mStreamUseCase)) != OK) { |
Shuzhen Wang | c8ab452 | 2021-12-14 20:12:42 -0800 | [diff] [blame] | 238 | ALOGE("%s: Failed to write stream use case!", __FUNCTION__); |
| 239 | return err; |
| 240 | } |
| 241 | |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 242 | return OK; |
| 243 | } |
| 244 | |
Shuzhen Wang | bac18d9 | 2020-11-19 14:50:30 -0800 | [diff] [blame] | 245 | const int CameraSessionStats::CAMERA_STATE_OPEN = 0; |
| 246 | const int CameraSessionStats::CAMERA_STATE_ACTIVE = 1; |
| 247 | const int CameraSessionStats::CAMERA_STATE_IDLE = 2; |
| 248 | const int CameraSessionStats::CAMERA_STATE_CLOSED = 3; |
| 249 | |
| 250 | const int CameraSessionStats::CAMERA_FACING_BACK = 0; |
| 251 | const int CameraSessionStats::CAMERA_FACING_FRONT = 1; |
| 252 | const int CameraSessionStats::CAMERA_FACING_EXTERNAL = 2; |
| 253 | |
| 254 | const int CameraSessionStats::CAMERA_API_LEVEL_1 = 1; |
| 255 | const int CameraSessionStats::CAMERA_API_LEVEL_2 = 2; |
| 256 | |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 257 | CameraSessionStats::CameraSessionStats() : |
| 258 | mFacing(CAMERA_FACING_BACK), |
| 259 | mNewCameraState(CAMERA_STATE_CLOSED), |
| 260 | mApiLevel(0), |
| 261 | mIsNdk(false), |
| 262 | mLatencyMs(-1), |
Austin Borger | 4a870a3 | 2022-02-25 01:48:41 +0000 | [diff] [blame] | 263 | mMaxPreviewFps(0), |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 264 | mSessionType(0), |
| 265 | mInternalReconfigure(0), |
| 266 | mRequestCount(0), |
| 267 | mResultErrorCount(0), |
Shuzhen Wang | 9372b0b | 2022-05-11 18:55:19 -0700 | [diff] [blame] | 268 | mDeviceError(false), |
| 269 | mVideoStabilizationMode(-1) {} |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 270 | |
Austin Borger | 0fb3ad9 | 2023-06-01 16:51:35 -0700 | [diff] [blame^] | 271 | CameraSessionStats::CameraSessionStats(const std::string& cameraId, |
| 272 | int facing, int newCameraState, const std::string& clientName, |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 273 | int apiLevel, bool isNdk, int32_t latencyMs) : |
| 274 | mCameraId(cameraId), |
| 275 | mFacing(facing), |
| 276 | mNewCameraState(newCameraState), |
| 277 | mClientName(clientName), |
| 278 | mApiLevel(apiLevel), |
| 279 | mIsNdk(isNdk), |
| 280 | mLatencyMs(latencyMs), |
Austin Borger | 4a870a3 | 2022-02-25 01:48:41 +0000 | [diff] [blame] | 281 | mMaxPreviewFps(0), |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 282 | mSessionType(0), |
| 283 | mInternalReconfigure(0), |
| 284 | mRequestCount(0), |
| 285 | mResultErrorCount(0), |
Shuzhen Wang | 9372b0b | 2022-05-11 18:55:19 -0700 | [diff] [blame] | 286 | mDeviceError(0), |
| 287 | mVideoStabilizationMode(-1) {} |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 288 | |
| 289 | status_t CameraSessionStats::readFromParcel(const android::Parcel* parcel) { |
| 290 | if (parcel == NULL) { |
| 291 | ALOGE("%s: Null parcel", __FUNCTION__); |
| 292 | return BAD_VALUE; |
| 293 | } |
| 294 | |
| 295 | status_t err = OK; |
| 296 | |
| 297 | String16 id; |
| 298 | if ((err = parcel->readString16(&id)) != OK) { |
| 299 | ALOGE("%s: Failed to read camera id!", __FUNCTION__); |
| 300 | return BAD_VALUE; |
| 301 | } |
| 302 | |
| 303 | int facing = 0; |
| 304 | if ((err = parcel->readInt32(&facing)) != OK) { |
| 305 | ALOGE("%s: Failed to read camera facing from parcel", __FUNCTION__); |
| 306 | return err; |
| 307 | } |
| 308 | |
| 309 | int32_t newCameraState; |
| 310 | if ((err = parcel->readInt32(&newCameraState)) != OK) { |
| 311 | ALOGE("%s: Failed to read new camera state from parcel", __FUNCTION__); |
| 312 | return err; |
| 313 | } |
| 314 | |
| 315 | String16 clientName; |
| 316 | if ((err = parcel->readString16(&clientName)) != OK) { |
| 317 | ALOGE("%s: Failed to read client name!", __FUNCTION__); |
| 318 | return BAD_VALUE; |
| 319 | } |
| 320 | |
| 321 | int32_t apiLevel; |
| 322 | if ((err = parcel->readInt32(&apiLevel)) != OK) { |
| 323 | ALOGE("%s: Failed to read api level from parcel", __FUNCTION__); |
| 324 | return err; |
| 325 | } |
| 326 | |
| 327 | bool isNdk; |
| 328 | if ((err = parcel->readBool(&isNdk)) != OK) { |
| 329 | ALOGE("%s: Failed to read isNdk flag from parcel", __FUNCTION__); |
| 330 | return err; |
| 331 | } |
| 332 | |
| 333 | int32_t latencyMs; |
| 334 | if ((err = parcel->readInt32(&latencyMs)) != OK) { |
| 335 | ALOGE("%s: Failed to read latencyMs from parcel", __FUNCTION__); |
| 336 | return err; |
| 337 | } |
| 338 | |
Austin Borger | 4a870a3 | 2022-02-25 01:48:41 +0000 | [diff] [blame] | 339 | float maxPreviewFps; |
| 340 | if ((err = parcel->readFloat(&maxPreviewFps)) != OK) { |
| 341 | ALOGE("%s: Failed to read maxPreviewFps from parcel", __FUNCTION__); |
| 342 | return err; |
| 343 | } |
| 344 | |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 345 | int32_t sessionType; |
| 346 | if ((err = parcel->readInt32(&sessionType)) != OK) { |
| 347 | ALOGE("%s: Failed to read session type from parcel", __FUNCTION__); |
| 348 | return err; |
| 349 | } |
| 350 | |
| 351 | int32_t internalReconfigure; |
| 352 | if ((err = parcel->readInt32(&internalReconfigure)) != OK) { |
| 353 | ALOGE("%s: Failed to read internal reconfigure count from parcel", __FUNCTION__); |
| 354 | return err; |
| 355 | } |
| 356 | |
| 357 | int64_t requestCount; |
| 358 | if ((err = parcel->readInt64(&requestCount)) != OK) { |
| 359 | ALOGE("%s: Failed to read request count from parcel", __FUNCTION__); |
| 360 | return err; |
| 361 | } |
| 362 | |
| 363 | int64_t resultErrorCount; |
| 364 | if ((err = parcel->readInt64(&resultErrorCount)) != OK) { |
| 365 | ALOGE("%s: Failed to read result error count from parcel", __FUNCTION__); |
| 366 | return err; |
| 367 | } |
| 368 | |
| 369 | bool deviceError; |
| 370 | if ((err = parcel->readBool(&deviceError)) != OK) { |
| 371 | ALOGE("%s: Failed to read device error flag from parcel", __FUNCTION__); |
| 372 | return err; |
| 373 | } |
| 374 | |
| 375 | std::vector<CameraStreamStats> streamStats; |
| 376 | if ((err = parcel->readParcelableVector(&streamStats)) != OK) { |
| 377 | ALOGE("%s: Failed to read stream state from parcel", __FUNCTION__); |
| 378 | return err; |
| 379 | } |
| 380 | |
Shuzhen Wang | d26b186 | 2022-03-07 12:05:05 -0800 | [diff] [blame] | 381 | String16 userTag; |
| 382 | if ((err = parcel->readString16(&userTag)) != OK) { |
| 383 | ALOGE("%s: Failed to read user tag!", __FUNCTION__); |
| 384 | return BAD_VALUE; |
| 385 | } |
| 386 | |
Shuzhen Wang | 9372b0b | 2022-05-11 18:55:19 -0700 | [diff] [blame] | 387 | int32_t videoStabilizationMode; |
| 388 | if ((err = parcel->readInt32(&videoStabilizationMode)) != OK) { |
| 389 | ALOGE("%s: Failed to read video stabilization mode from parcel", __FUNCTION__); |
| 390 | return err; |
| 391 | } |
| 392 | |
Austin Borger | 0fb3ad9 | 2023-06-01 16:51:35 -0700 | [diff] [blame^] | 393 | mCameraId = toStdString(id); |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 394 | mFacing = facing; |
| 395 | mNewCameraState = newCameraState; |
Austin Borger | 0fb3ad9 | 2023-06-01 16:51:35 -0700 | [diff] [blame^] | 396 | mClientName = toStdString(clientName); |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 397 | mApiLevel = apiLevel; |
| 398 | mIsNdk = isNdk; |
| 399 | mLatencyMs = latencyMs; |
Austin Borger | 4a870a3 | 2022-02-25 01:48:41 +0000 | [diff] [blame] | 400 | mMaxPreviewFps = maxPreviewFps; |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 401 | mSessionType = sessionType; |
| 402 | mInternalReconfigure = internalReconfigure; |
| 403 | mRequestCount = requestCount; |
| 404 | mResultErrorCount = resultErrorCount; |
| 405 | mDeviceError = deviceError; |
| 406 | mStreamStats = std::move(streamStats); |
Austin Borger | 0fb3ad9 | 2023-06-01 16:51:35 -0700 | [diff] [blame^] | 407 | mUserTag = toStdString(userTag); |
Shuzhen Wang | 9372b0b | 2022-05-11 18:55:19 -0700 | [diff] [blame] | 408 | mVideoStabilizationMode = videoStabilizationMode; |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 409 | |
| 410 | return OK; |
| 411 | } |
| 412 | |
| 413 | status_t CameraSessionStats::writeToParcel(android::Parcel* parcel) const { |
| 414 | if (parcel == NULL) { |
| 415 | ALOGE("%s: Null parcel", __FUNCTION__); |
| 416 | return BAD_VALUE; |
| 417 | } |
| 418 | |
| 419 | status_t err = OK; |
| 420 | |
Austin Borger | 0fb3ad9 | 2023-06-01 16:51:35 -0700 | [diff] [blame^] | 421 | if ((err = parcel->writeString16(toString16(mCameraId))) != OK) { |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 422 | ALOGE("%s: Failed to write camera id!", __FUNCTION__); |
| 423 | return err; |
| 424 | } |
| 425 | |
| 426 | if ((err = parcel->writeInt32(mFacing)) != OK) { |
| 427 | ALOGE("%s: Failed to write camera facing!", __FUNCTION__); |
| 428 | return err; |
| 429 | } |
| 430 | |
| 431 | if ((err = parcel->writeInt32(mNewCameraState)) != OK) { |
| 432 | ALOGE("%s: Failed to write new camera state!", __FUNCTION__); |
| 433 | return err; |
| 434 | } |
| 435 | |
Austin Borger | 0fb3ad9 | 2023-06-01 16:51:35 -0700 | [diff] [blame^] | 436 | if ((err = parcel->writeString16(toString16(mClientName))) != OK) { |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 437 | ALOGE("%s: Failed to write client name!", __FUNCTION__); |
| 438 | return err; |
| 439 | } |
| 440 | |
| 441 | if ((err = parcel->writeInt32(mApiLevel)) != OK) { |
| 442 | ALOGE("%s: Failed to write api level!", __FUNCTION__); |
| 443 | return err; |
| 444 | } |
| 445 | |
| 446 | if ((err = parcel->writeBool(mIsNdk)) != OK) { |
| 447 | ALOGE("%s: Failed to write isNdk flag!", __FUNCTION__); |
| 448 | return err; |
| 449 | } |
| 450 | |
| 451 | if ((err = parcel->writeInt32(mLatencyMs)) != OK) { |
| 452 | ALOGE("%s: Failed to write latency in Ms!", __FUNCTION__); |
| 453 | return err; |
| 454 | } |
| 455 | |
Austin Borger | 4a870a3 | 2022-02-25 01:48:41 +0000 | [diff] [blame] | 456 | if ((err = parcel->writeFloat(mMaxPreviewFps)) != OK) { |
| 457 | ALOGE("%s: Failed to write maxPreviewFps!", __FUNCTION__); |
| 458 | return err; |
| 459 | } |
| 460 | |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 461 | if ((err = parcel->writeInt32(mSessionType)) != OK) { |
| 462 | ALOGE("%s: Failed to write session type!", __FUNCTION__); |
| 463 | return err; |
| 464 | } |
| 465 | |
| 466 | if ((err = parcel->writeInt32(mInternalReconfigure)) != OK) { |
| 467 | ALOGE("%s: Failed to write internal reconfigure count!", __FUNCTION__); |
| 468 | return err; |
| 469 | } |
| 470 | |
| 471 | if ((err = parcel->writeInt64(mRequestCount)) != OK) { |
| 472 | ALOGE("%s: Failed to write request count!", __FUNCTION__); |
| 473 | return err; |
| 474 | } |
| 475 | |
| 476 | if ((err = parcel->writeInt64(mResultErrorCount)) != OK) { |
| 477 | ALOGE("%s: Failed to write result error count!", __FUNCTION__); |
| 478 | return err; |
| 479 | } |
| 480 | |
| 481 | if ((err = parcel->writeBool(mDeviceError)) != OK) { |
| 482 | ALOGE("%s: Failed to write device error flag!", __FUNCTION__); |
| 483 | return err; |
| 484 | } |
| 485 | |
| 486 | if ((err = parcel->writeParcelableVector(mStreamStats)) != OK) { |
| 487 | ALOGE("%s: Failed to write stream states!", __FUNCTION__); |
| 488 | return err; |
| 489 | } |
| 490 | |
Austin Borger | 0fb3ad9 | 2023-06-01 16:51:35 -0700 | [diff] [blame^] | 491 | if ((err = parcel->writeString16(toString16(mUserTag))) != OK) { |
Shuzhen Wang | d26b186 | 2022-03-07 12:05:05 -0800 | [diff] [blame] | 492 | ALOGE("%s: Failed to write user tag!", __FUNCTION__); |
| 493 | return err; |
| 494 | } |
Shuzhen Wang | 9372b0b | 2022-05-11 18:55:19 -0700 | [diff] [blame] | 495 | |
| 496 | if ((err = parcel->writeInt32(mVideoStabilizationMode)) != OK) { |
| 497 | ALOGE("%s: Failed to write video stabilization mode!", __FUNCTION__); |
| 498 | return err; |
| 499 | } |
Shuzhen Wang | 316781a | 2020-08-18 18:11:01 -0700 | [diff] [blame] | 500 | return OK; |
| 501 | } |
| 502 | |
| 503 | } // namespace hardware |
| 504 | } // namesmpace android |