Add UMA stats for the resolution camera is started in.
BUG=webrtc:6302 Review-Url: https://codereview.webrtc.org/2476313002 Cr-Commit-Position: refs/heads/master@{#15022}
This commit is contained in:
parent
d64bf6f312
commit
9d1315a961
@ -10,19 +10,17 @@
|
||||
|
||||
package org.webrtc;
|
||||
|
||||
import org.webrtc.CameraEnumerationAndroid.CaptureFormat;
|
||||
import org.webrtc.Metrics.Histogram;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.SystemClock;
|
||||
import android.view.Surface;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.webrtc.CameraEnumerationAndroid.CaptureFormat;
|
||||
import org.webrtc.Metrics.Histogram;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class Camera1Session implements CameraSession {
|
||||
@ -33,6 +31,8 @@ public class Camera1Session implements CameraSession {
|
||||
Histogram.createCounts("WebRTC.Android.Camera1.StartTimeMs", 1, 10000, 50);
|
||||
private static final Histogram camera1StopTimeMsHistogram =
|
||||
Histogram.createCounts("WebRTC.Android.Camera1.StopTimeMs", 1, 10000, 50);
|
||||
private static final Histogram camera1ResolutionHistogram = Histogram.createEnumeration(
|
||||
"WebRTC.Android.Camera1.Resolution", CameraEnumerationAndroid.COMMON_RESOLUTIONS.size());
|
||||
|
||||
private static enum SessionState { RUNNING, STOPPED }
|
||||
|
||||
@ -138,6 +138,7 @@ public class Camera1Session implements CameraSession {
|
||||
|
||||
final Size previewSize = CameraEnumerationAndroid.getClosestSupportedSize(
|
||||
Camera1Enumerator.convertSizes(parameters.getSupportedPreviewSizes()), width, height);
|
||||
CameraEnumerationAndroid.reportCameraResolution(camera1ResolutionHistogram, previewSize);
|
||||
|
||||
return new CaptureFormat(previewSize.width, previewSize.height, fpsRange);
|
||||
}
|
||||
|
||||
@ -10,9 +10,6 @@
|
||||
|
||||
package org.webrtc;
|
||||
|
||||
import org.webrtc.CameraEnumerationAndroid.CaptureFormat;
|
||||
import org.webrtc.Metrics.Histogram;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.graphics.SurfaceTexture;
|
||||
@ -28,10 +25,11 @@ import android.os.Handler;
|
||||
import android.util.Range;
|
||||
import android.view.Surface;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.webrtc.CameraEnumerationAndroid.CaptureFormat;
|
||||
import org.webrtc.Metrics.Histogram;
|
||||
|
||||
@TargetApi(21)
|
||||
public class Camera2Session implements CameraSession {
|
||||
@ -41,6 +39,8 @@ public class Camera2Session implements CameraSession {
|
||||
Histogram.createCounts("WebRTC.Android.Camera2.StartTimeMs", 1, 10000, 50);
|
||||
private static final Histogram camera2StopTimeMsHistogram =
|
||||
Histogram.createCounts("WebRTC.Android.Camera2.StopTimeMs", 1, 10000, 50);
|
||||
private static final Histogram camera2ResolutionHistogram = Histogram.createEnumeration(
|
||||
"WebRTC.Android.Camera2.Resolution", CameraEnumerationAndroid.COMMON_RESOLUTIONS.size());
|
||||
|
||||
private static enum SessionState { RUNNING, STOPPED }
|
||||
|
||||
@ -345,6 +345,7 @@ public class Camera2Session implements CameraSession {
|
||||
CameraEnumerationAndroid.getClosestSupportedFramerateRange(framerateRanges, framerate);
|
||||
|
||||
final Size bestSize = CameraEnumerationAndroid.getClosestSupportedSize(sizes, width, height);
|
||||
CameraEnumerationAndroid.reportCameraResolution(camera2ResolutionHistogram, bestSize);
|
||||
|
||||
captureFormat = new CaptureFormat(bestSize.width, bestSize.height, bestFpsRange);
|
||||
Logging.d(TAG, "Using capture format: " + captureFormat);
|
||||
|
||||
@ -13,14 +13,41 @@ package org.webrtc;
|
||||
import static java.lang.Math.abs;
|
||||
|
||||
import android.graphics.ImageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import org.webrtc.Metrics.Histogram;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class CameraEnumerationAndroid {
|
||||
private final static String TAG = "CameraEnumerationAndroid";
|
||||
|
||||
static final ArrayList<Size> COMMON_RESOLUTIONS = new ArrayList<Size>(Arrays.asList(
|
||||
// 0, Unknown resolution
|
||||
new Size(160, 120), // 1, QQVGA
|
||||
new Size(240, 160), // 2, HQVGA
|
||||
new Size(320, 240), // 3, QVGA
|
||||
new Size(400, 240), // 4, WQVGA
|
||||
new Size(480, 320), // 5, HVGA
|
||||
new Size(640, 360), // 6, nHD
|
||||
new Size(640, 480), // 7, VGA
|
||||
new Size(768, 480), // 8, WVGA
|
||||
new Size(854, 480), // 9, FWVGA
|
||||
new Size(800, 600), // 10, SVGA
|
||||
new Size(960, 540), // 11, qHD
|
||||
new Size(960, 640), // 12, DVGA
|
||||
new Size(1024, 576), // 13, WSVGA
|
||||
new Size(1024, 600), // 14, WVSGA
|
||||
new Size(1280, 720), // 15, HD
|
||||
new Size(1280, 1024), // 16, SXGA
|
||||
new Size(1920, 1080), // 17, Full HD
|
||||
new Size(1920, 1440), // 18, Full HD 4:3
|
||||
new Size(2560, 1440), // 19, QHD
|
||||
new Size(3840, 2160) // 20, UHD
|
||||
));
|
||||
|
||||
public static class CaptureFormat {
|
||||
// Class to represent a framerate range. The framerate varies because of lightning conditions.
|
||||
// The values are multiplied by 1000, so 1000 represents one frame per second.
|
||||
@ -169,4 +196,12 @@ public class CameraEnumerationAndroid {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Helper method for camera classes.
|
||||
static void reportCameraResolution(Histogram histogram, Size resolution) {
|
||||
int index = COMMON_RESOLUTIONS.indexOf(resolution);
|
||||
// 0 is reserved for unknown resolution, so add 1.
|
||||
// indexOf returns -1 for unknown resolutions so it becomes 0 automatically.
|
||||
histogram.addSample(index + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,11 +81,16 @@ public class Metrics {
|
||||
return new Histogram(nativeCreateCounts(name, min, max, bucketCount), name);
|
||||
}
|
||||
|
||||
static public Histogram createEnumeration(String name, int max) {
|
||||
return new Histogram(nativeCreateEnumeration(name, max), name);
|
||||
}
|
||||
|
||||
public void addSample(int sample) {
|
||||
nativeAddSample(handle, sample);
|
||||
}
|
||||
|
||||
private static native long nativeCreateCounts(String name, int min, int max, int bucketCount);
|
||||
private static native long nativeCreateEnumeration(String name, int max);
|
||||
private static native void nativeAddSample(long handle, int sample);
|
||||
}
|
||||
|
||||
|
||||
@ -10,15 +10,11 @@
|
||||
|
||||
package org.webrtc;
|
||||
|
||||
import org.webrtc.CameraEnumerationAndroid.CaptureFormat;
|
||||
import org.webrtc.Metrics.Histogram;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.SystemClock;
|
||||
import android.view.Surface;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.HashSet;
|
||||
@ -27,6 +23,8 @@ import java.util.Set;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import org.webrtc.CameraEnumerationAndroid.CaptureFormat;
|
||||
import org.webrtc.Metrics.Histogram;
|
||||
|
||||
// Android specific implementation of VideoCapturer.
|
||||
// An instance of this class can be created by an application using
|
||||
@ -53,6 +51,9 @@ public class VideoCapturerAndroid
|
||||
Histogram.createCounts("WebRTC.Android.VideoCapturerAndroid.StartTimeMs", 1, 10000, 50);
|
||||
private static final Histogram videoCapturerAndroidStopTimeMsHistogram =
|
||||
Histogram.createCounts("WebRTC.Android.VideoCapturerAndroid.StopTimeMs", 1, 10000, 50);
|
||||
private static final Histogram videoCapturerAndroidResolutionHistogram =
|
||||
Histogram.createEnumeration("WebRTC.Android.VideoCapturerAndroid.Resolution",
|
||||
CameraEnumerationAndroid.COMMON_RESOLUTIONS.size());
|
||||
|
||||
private android.hardware.Camera camera; // Only non-null while capturing.
|
||||
private final AtomicBoolean isCameraRunning = new AtomicBoolean();
|
||||
@ -396,6 +397,8 @@ public class VideoCapturerAndroid
|
||||
Camera1Enumerator.convertSizes(parameters.getSupportedPreviewSizes());
|
||||
final Size previewSize =
|
||||
CameraEnumerationAndroid.getClosestSupportedSize(supportedPreviewSizes, width, height);
|
||||
CameraEnumerationAndroid.reportCameraResolution(
|
||||
videoCapturerAndroidResolutionHistogram, previewSize);
|
||||
Logging.d(TAG, "Available preview sizes: " + supportedPreviewSizes);
|
||||
|
||||
final CaptureFormat captureFormat =
|
||||
|
||||
@ -66,6 +66,13 @@ JOW(jlong, Metrics_00024Histogram_nativeCreateCounts)
|
||||
webrtc::metrics::HistogramFactoryGetCounts(name, min, max, buckets));
|
||||
}
|
||||
|
||||
JOW(jlong, Metrics_00024Histogram_nativeCreateEnumeration)
|
||||
(JNIEnv* jni, jclass, jstring j_name, jint max) {
|
||||
std::string name = JavaToStdString(jni, j_name);
|
||||
return jlongFromPointer(
|
||||
webrtc::metrics::HistogramFactoryGetEnumeration(name, max));
|
||||
}
|
||||
|
||||
JOW(void, Metrics_00024Histogram_nativeAddSample)
|
||||
(JNIEnv* jni, jclass, jlong histogram, jint sample) {
|
||||
if (histogram) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user