Camera: Collect capture latency histogram
For each camera session, collect capture latency histogram for all streams. Test: Camera CTS, and observe statsd output Bug: 154159000 Change-Id: I7741371ca8540cdf9c9a47246c0ef0f0f82df32a
This commit is contained in:
@@ -19,7 +19,6 @@ import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
/**
|
||||
* The camera stream statistics used for passing camera stream information from
|
||||
* camera service to camera service proxy.
|
||||
@@ -30,6 +29,8 @@ import java.util.ArrayList;
|
||||
* @hide
|
||||
*/
|
||||
public class CameraStreamStats implements Parcelable {
|
||||
public static final int HISTOGRAM_TYPE_UNKNOWN = 0;
|
||||
public static final int HISTOGRAM_TYPE_CAPTURE_LATENCY = 1;
|
||||
|
||||
private int mWidth;
|
||||
private int mHeight;
|
||||
@@ -41,6 +42,9 @@ public class CameraStreamStats implements Parcelable {
|
||||
private int mStartLatencyMs;
|
||||
private int mMaxHalBuffers;
|
||||
private int mMaxAppBuffers;
|
||||
private int mHistogramType;
|
||||
private float[] mHistogramBins;
|
||||
private long[] mHistogramCounts;
|
||||
|
||||
private static final String TAG = "CameraStreamStats";
|
||||
|
||||
@@ -55,6 +59,7 @@ public class CameraStreamStats implements Parcelable {
|
||||
mStartLatencyMs = 0;
|
||||
mMaxHalBuffers = 0;
|
||||
mMaxAppBuffers = 0;
|
||||
mHistogramType = HISTOGRAM_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
public CameraStreamStats(int width, int height, int format,
|
||||
@@ -70,6 +75,7 @@ public class CameraStreamStats implements Parcelable {
|
||||
mStartLatencyMs = startLatencyMs;
|
||||
mMaxHalBuffers = maxHalBuffers;
|
||||
mMaxAppBuffers = maxAppBuffers;
|
||||
mHistogramType = HISTOGRAM_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
public static final @android.annotation.NonNull Parcelable.Creator<CameraStreamStats> CREATOR =
|
||||
@@ -112,6 +118,9 @@ public class CameraStreamStats implements Parcelable {
|
||||
dest.writeInt(mStartLatencyMs);
|
||||
dest.writeInt(mMaxHalBuffers);
|
||||
dest.writeInt(mMaxAppBuffers);
|
||||
dest.writeInt(mHistogramType);
|
||||
dest.writeFloatArray(mHistogramBins);
|
||||
dest.writeLongArray(mHistogramCounts);
|
||||
}
|
||||
|
||||
public void readFromParcel(Parcel in) {
|
||||
@@ -125,6 +134,9 @@ public class CameraStreamStats implements Parcelable {
|
||||
mStartLatencyMs = in.readInt();
|
||||
mMaxHalBuffers = in.readInt();
|
||||
mMaxAppBuffers = in.readInt();
|
||||
mHistogramType = in.readInt();
|
||||
mHistogramBins = in.createFloatArray();
|
||||
mHistogramCounts = in.createLongArray();
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
@@ -166,4 +178,16 @@ public class CameraStreamStats implements Parcelable {
|
||||
public int getMaxAppBuffers() {
|
||||
return mMaxAppBuffers;
|
||||
}
|
||||
|
||||
public int getHistogramType() {
|
||||
return mHistogramType;
|
||||
}
|
||||
|
||||
public float[] getHistogramBins() {
|
||||
return mHistogramBins;
|
||||
}
|
||||
|
||||
public long[] getHistogramCounts() {
|
||||
return mHistogramCounts;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ import com.android.server.wm.WindowManagerInternal;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -466,8 +467,13 @@ public class CameraServiceProxy extends SystemService
|
||||
streamProtos[i].firstCaptureLatencyMillis = streamStats.getStartLatencyMs();
|
||||
streamProtos[i].maxHalBuffers = streamStats.getMaxHalBuffers();
|
||||
streamProtos[i].maxAppBuffers = streamStats.getMaxAppBuffers();
|
||||
streamProtos[i].histogramType = streamStats.getHistogramType();
|
||||
streamProtos[i].histogramBins = streamStats.getHistogramBins();
|
||||
streamProtos[i].histogramCounts = streamStats.getHistogramCounts();
|
||||
|
||||
if (CameraServiceProxy.DEBUG) {
|
||||
String histogramTypeName =
|
||||
cameraHistogramTypeToString(streamProtos[i].histogramType);
|
||||
Slog.v(TAG, "Stream " + i + ": width " + streamProtos[i].width
|
||||
+ ", height " + streamProtos[i].height
|
||||
+ ", format " + streamProtos[i].format
|
||||
@@ -478,7 +484,12 @@ public class CameraServiceProxy extends SystemService
|
||||
+ ", firstCaptureLatencyMillis "
|
||||
+ streamProtos[i].firstCaptureLatencyMillis
|
||||
+ ", maxHalBuffers " + streamProtos[i].maxHalBuffers
|
||||
+ ", maxAppBuffers " + streamProtos[i].maxAppBuffers);
|
||||
+ ", maxAppBuffers " + streamProtos[i].maxAppBuffers
|
||||
+ ", histogramType " + histogramTypeName
|
||||
+ ", histogramBins "
|
||||
+ Arrays.toString(streamProtos[i].histogramBins)
|
||||
+ ", histogramCounts "
|
||||
+ Arrays.toString(streamProtos[i].histogramCounts));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -797,4 +808,14 @@ public class CameraServiceProxy extends SystemService
|
||||
return "CAMERA_FACING_UNKNOWN";
|
||||
}
|
||||
|
||||
private static String cameraHistogramTypeToString(int cameraHistogramType) {
|
||||
switch (cameraHistogramType) {
|
||||
case CameraStreamStats.HISTOGRAM_TYPE_CAPTURE_LATENCY:
|
||||
return "HISTOGRAM_TYPE_CAPTURE_LATENCY";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return "HISTOGRAM_TYPE_UNKNOWN";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user