| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
package android.hardware; |
| 17 |
|
| 18 |
import android.hardware.camera2.CameraMetadata; |
| 19 |
import android.hardware.camera2.params.DynamicRangeProfiles; |
| 20 |
import android.os.Parcel; |
| 21 |
import android.os.Parcelable; |
| 22 |
import android.util.Log; |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
public class CameraStreamStats implements Parcelable { |
| 34 |
public static final int HISTOGRAM_TYPE_UNKNOWN = 0; |
| 35 |
public static final int HISTOGRAM_TYPE_CAPTURE_LATENCY = 1; |
| 36 |
|
| 37 |
private int mWidth; |
| 38 |
private int mHeight; |
| 39 |
private int mFormat; |
| 40 |
private float mMaxPreviewFps; |
| 41 |
private int mDataSpace; |
| 42 |
private long mUsage; |
| 43 |
private long mRequestCount; |
| 44 |
private long mErrorCount; |
| 45 |
private int mStartLatencyMs; |
| 46 |
private int mMaxHalBuffers; |
| 47 |
private int mMaxAppBuffers; |
| 48 |
private int mHistogramType; |
| 49 |
private float[] mHistogramBins; |
| 50 |
private long[] mHistogramCounts; |
| 51 |
private long mDynamicRangeProfile; |
| 52 |
private long mStreamUseCase; |
| 53 |
|
| 54 |
private static final String TAG = "CameraStreamStats"; |
| 55 |
|
| 56 |
public CameraStreamStats() { |
| 57 |
mWidth = 0; |
| 58 |
mHeight = 0; |
| 59 |
mFormat = 0; |
| 60 |
mMaxPreviewFps = 0; |
| 61 |
mDataSpace = 0; |
| 62 |
mUsage = 0; |
| 63 |
mRequestCount = 0; |
| 64 |
mErrorCount = 0; |
| 65 |
mStartLatencyMs = 0; |
| 66 |
mMaxHalBuffers = 0; |
| 67 |
mMaxAppBuffers = 0; |
| 68 |
mHistogramType = HISTOGRAM_TYPE_UNKNOWN; |
| 69 |
mDynamicRangeProfile = DynamicRangeProfiles.STANDARD; |
| 70 |
mStreamUseCase = CameraMetadata.SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT; |
| 71 |
} |
| 72 |
|
| 73 |
public CameraStreamStats(int width, int height, int format, float maxPreviewFps, |
| 74 |
int dataSpace, long usage, long requestCount, long errorCount, |
| 75 |
int startLatencyMs, int maxHalBuffers, int maxAppBuffers, long dynamicRangeProfile, |
| 76 |
long streamUseCase) { |
| 77 |
mWidth = width; |
| 78 |
mHeight = height; |
| 79 |
mFormat = format; |
| 80 |
mMaxPreviewFps = maxPreviewFps; |
| 81 |
mDataSpace = dataSpace; |
| 82 |
mUsage = usage; |
| 83 |
mRequestCount = requestCount; |
| 84 |
mErrorCount = errorCount; |
| 85 |
mStartLatencyMs = startLatencyMs; |
| 86 |
mMaxHalBuffers = maxHalBuffers; |
| 87 |
mMaxAppBuffers = maxAppBuffers; |
| 88 |
mHistogramType = HISTOGRAM_TYPE_UNKNOWN; |
| 89 |
mDynamicRangeProfile = dynamicRangeProfile; |
| 90 |
mStreamUseCase = streamUseCase; |
| 91 |
} |
| 92 |
|
| 93 |
public static final @android.annotation.NonNull Parcelable.Creator<CameraStreamStats> CREATOR = |
| 94 |
new Parcelable.Creator<CameraStreamStats>() { |
| 95 |
@Override |
| 96 |
public CameraStreamStats createFromParcel(Parcel in) { |
| 97 |
try { |
| 98 |
CameraStreamStats streamStats = new CameraStreamStats(in); |
| 99 |
return streamStats; |
| 100 |
} catch (Exception e) { |
| 101 |
Log.e(TAG, "Exception creating CameraStreamStats from parcel", e); |
| 102 |
return null; |
| 103 |
} |
| 104 |
} |
| 105 |
|
| 106 |
@Override |
| 107 |
public CameraStreamStats[] newArray(int size) { |
| 108 |
return new CameraStreamStats[size]; |
| 109 |
} |
| 110 |
}; |
| 111 |
|
| 112 |
private CameraStreamStats(Parcel in) { |
| 113 |
readFromParcel(in); |
| 114 |
} |
| 115 |
|
| 116 |
@Override |
| 117 |
public int describeContents() { |
| 118 |
return 0; |
| 119 |
} |
| 120 |
|
| 121 |
@Override |
| 122 |
public void writeToParcel(Parcel dest, int flags) { |
| 123 |
dest.writeInt(mWidth); |
| 124 |
dest.writeInt(mHeight); |
| 125 |
dest.writeInt(mFormat); |
| 126 |
dest.writeFloat(mMaxPreviewFps); |
| 127 |
dest.writeInt(mDataSpace); |
| 128 |
dest.writeLong(mUsage); |
| 129 |
dest.writeLong(mRequestCount); |
| 130 |
dest.writeLong(mErrorCount); |
| 131 |
dest.writeInt(mStartLatencyMs); |
| 132 |
dest.writeInt(mMaxHalBuffers); |
| 133 |
dest.writeInt(mMaxAppBuffers); |
| 134 |
dest.writeInt(mHistogramType); |
| 135 |
dest.writeFloatArray(mHistogramBins); |
| 136 |
dest.writeLongArray(mHistogramCounts); |
| 137 |
dest.writeLong(mDynamicRangeProfile); |
| 138 |
dest.writeLong(mStreamUseCase); |
| 139 |
} |
| 140 |
|
| 141 |
public void readFromParcel(Parcel in) { |
| 142 |
mWidth = in.readInt(); |
| 143 |
mHeight = in.readInt(); |
| 144 |
mFormat = in.readInt(); |
| 145 |
mMaxPreviewFps = in.readFloat(); |
| 146 |
mDataSpace = in.readInt(); |
| 147 |
mUsage = in.readLong(); |
| 148 |
mRequestCount = in.readLong(); |
| 149 |
mErrorCount = in.readLong(); |
| 150 |
mStartLatencyMs = in.readInt(); |
| 151 |
mMaxHalBuffers = in.readInt(); |
| 152 |
mMaxAppBuffers = in.readInt(); |
| 153 |
mHistogramType = in.readInt(); |
| 154 |
mHistogramBins = in.createFloatArray(); |
| 155 |
mHistogramCounts = in.createLongArray(); |
| 156 |
mDynamicRangeProfile = in.readLong(); |
| 157 |
mStreamUseCase = in.readLong(); |
| 158 |
} |
| 159 |
|
| 160 |
public int getWidth() { |
| 161 |
return mWidth; |
| 162 |
} |
| 163 |
|
| 164 |
public int getHeight() { |
| 165 |
return mHeight; |
| 166 |
} |
| 167 |
|
| 168 |
public int getFormat() { |
| 169 |
return mFormat; |
| 170 |
} |
| 171 |
|
| 172 |
public float getMaxPreviewFps() { |
| 173 |
return mMaxPreviewFps; |
| 174 |
} |
| 175 |
|
| 176 |
public int getDataSpace() { |
| 177 |
return mDataSpace; |
| 178 |
} |
| 179 |
|
| 180 |
public long getUsage() { |
| 181 |
return mUsage; |
| 182 |
} |
| 183 |
|
| 184 |
public long getRequestCount() { |
| 185 |
return mRequestCount; |
| 186 |
} |
| 187 |
|
| 188 |
public long getErrorCount() { |
| 189 |
return mErrorCount; |
| 190 |
} |
| 191 |
|
| 192 |
public int getStartLatencyMs() { |
| 193 |
return mStartLatencyMs; |
| 194 |
} |
| 195 |
|
| 196 |
public int getMaxHalBuffers() { |
| 197 |
return mMaxHalBuffers; |
| 198 |
} |
| 199 |
|
| 200 |
public int getMaxAppBuffers() { |
| 201 |
return mMaxAppBuffers; |
| 202 |
} |
| 203 |
|
| 204 |
public int getHistogramType() { |
| 205 |
return mHistogramType; |
| 206 |
} |
| 207 |
|
| 208 |
public float[] getHistogramBins() { |
| 209 |
return mHistogramBins; |
| 210 |
} |
| 211 |
|
| 212 |
public long[] getHistogramCounts() { |
| 213 |
return mHistogramCounts; |
| 214 |
} |
| 215 |
|
| 216 |
public long getDynamicRangeProfile() { |
| 217 |
return mDynamicRangeProfile; |
| 218 |
} |
| 219 |
|
| 220 |
public long getStreamUseCase() { |
| 221 |
return mStreamUseCase; |
| 222 |
} |
| 223 |
} |