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 #ifndef ANDROID_HARDWARE_CAMERA_SERVICE_SESSION_STATS_H 18 #define ANDROID_HARDWARE_CAMERA_SERVICE_SESSION_STATS_H 19 20 #include <binder/Parcelable.h> 21 22 #include <camera/CameraMetadata.h> 23 24 namespace android { 25 namespace hardware { 26 27 /** 28 * Camera stream info and statistics 29 */ 30 class CameraStreamStats : public android::Parcelable { 31 public: 32 enum HistogramType { 33 HISTOGRAM_TYPE_UNKNOWN = 0, 34 HISTOGRAM_TYPE_CAPTURE_LATENCY = 1, 35 }; 36 37 int mWidth; 38 int mHeight; 39 int mFormat; 40 float mMaxPreviewFps; 41 int mDataSpace; 42 int64_t mUsage; 43 44 // The number of requested buffers 45 int64_t mRequestCount; 46 // The number of buffer errors 47 int64_t mErrorCount; 48 49 // The capture latency of 1st request for this stream 50 int32_t mStartLatencyMs; 51 52 // Buffer count info 53 int mMaxHalBuffers; 54 int mMaxAppBuffers; 55 56 // Histogram type. So far only capture latency histogram is supported. 57 int mHistogramType; 58 // The bounary values separating adjacent histogram bins. 59 // A vector of {h1, h2, h3} represents bins of [0, h1), [h1, h2), [h2, h3), 60 // and [h3, infinity) 61 std::vector<float> mHistogramBins; 62 // The counts for all histogram bins. 63 // size(mHistogramBins) + 1 = size(mHistogramCounts) 64 std::vector<int64_t> mHistogramCounts; 65 66 // Dynamic range profile 67 int64_t mDynamicRangeProfile; 68 // Stream use case 69 int64_t mStreamUseCase; 70 CameraStreamStats()71 CameraStreamStats() : 72 mWidth(0), mHeight(0), mFormat(0), mMaxPreviewFps(0), mDataSpace(0), mUsage(0), 73 mRequestCount(0), mErrorCount(0), mStartLatencyMs(0), 74 mMaxHalBuffers(0), mMaxAppBuffers(0), mHistogramType(HISTOGRAM_TYPE_UNKNOWN), 75 mDynamicRangeProfile(ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_STANDARD), 76 mStreamUseCase(ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT) {} CameraStreamStats(int width,int height,int format,float maxPreviewFps,int dataSpace,int64_t usage,int maxHalBuffers,int maxAppBuffers,int dynamicRangeProfile,int streamUseCase)77 CameraStreamStats(int width, int height, int format, float maxPreviewFps, int dataSpace, 78 int64_t usage, int maxHalBuffers, int maxAppBuffers, int dynamicRangeProfile, 79 int streamUseCase) 80 : mWidth(width), mHeight(height), mFormat(format), mMaxPreviewFps(maxPreviewFps), 81 mDataSpace(dataSpace), mUsage(usage), mRequestCount(0), mErrorCount(0), 82 mStartLatencyMs(0), mMaxHalBuffers(maxHalBuffers), mMaxAppBuffers(maxAppBuffers), 83 mHistogramType(HISTOGRAM_TYPE_UNKNOWN), 84 mDynamicRangeProfile(dynamicRangeProfile), 85 mStreamUseCase(streamUseCase) {} 86 87 virtual status_t readFromParcel(const android::Parcel* parcel) override; 88 virtual status_t writeToParcel(android::Parcel* parcel) const override; 89 }; 90 91 /** 92 * Camera session statistics 93 * 94 * This includes session wide info and stream statistics. 95 */ 96 class CameraSessionStats : public android::Parcelable { 97 public: 98 /** 99 * Values for notifyCameraState newCameraState 100 */ 101 static const int CAMERA_STATE_OPEN; 102 static const int CAMERA_STATE_ACTIVE; 103 static const int CAMERA_STATE_IDLE; 104 static const int CAMERA_STATE_CLOSED; 105 106 /** 107 * Values for notifyCameraState facing 108 */ 109 static const int CAMERA_FACING_BACK; 110 static const int CAMERA_FACING_FRONT; 111 static const int CAMERA_FACING_EXTERNAL; 112 113 /** 114 * Values for notifyCameraState api level 115 */ 116 static const int CAMERA_API_LEVEL_1; 117 static const int CAMERA_API_LEVEL_2; 118 119 String16 mCameraId; 120 int mFacing; 121 int mNewCameraState; 122 String16 mClientName; 123 int mApiLevel; 124 bool mIsNdk; 125 // latency in ms for camera open, close, or session creation. 126 int mLatencyMs; 127 float mMaxPreviewFps; 128 129 // Session info and statistics 130 int mSessionType; 131 int mInternalReconfigure; 132 // The number of capture requests 133 int64_t mRequestCount; 134 // The number of result error 135 int64_t mResultErrorCount; 136 // Whether the device runs into an error state 137 bool mDeviceError; 138 std::vector<CameraStreamStats> mStreamStats; 139 String16 mUserTag; 140 int mVideoStabilizationMode; 141 142 // Constructors 143 CameraSessionStats(); 144 CameraSessionStats(const String16& cameraId, int facing, int newCameraState, 145 const String16& clientName, int apiLevel, bool isNdk, int32_t latencyMs); 146 147 virtual status_t readFromParcel(const android::Parcel* parcel) override; 148 virtual status_t writeToParcel(android::Parcel* parcel) const override; 149 }; 150 151 }; // namespace hardware 152 }; // namespace android 153 154 #endif // ANDROID_HARDWARE_CAMERA_SERVICE_SESSION_STATS_H 155