Reland of Allow custom metrics implementations on Android. (patchset #1 id:1 of https://codereview.webrtc.org/2516403002/ )
Reason for revert: Fix downstream. Original issue's description: > Revert of Allow custom metrics implementations on Android. (patchset #11 id:260001 of https://codereview.webrtc.org/2403463002/ ) > > Reason for revert: > Break downstream tests. > > Original issue's description: > > Allow custom metrics implementations on Android. > > > > BUG=webrtc:6499 > > > > Committed: https://crrev.com/de609b26c5fc77fd3388eae5594ee8a634edf8da > > Cr-Commit-Position: refs/heads/master@{#15169} > > TBR=kjellander@webrtc.org,magjed@webrtc.org,sakal@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=webrtc:6499 > > Committed: https://crrev.com/f570a2804ed8af6f6586f4aea51e089bd55d7e42 > Cr-Commit-Position: refs/heads/master@{#15171} TBR=kjellander@webrtc.org,magjed@webrtc.org,philipel@webrtc.org BUG=webrtc:6499 Review-Url: https://codereview.webrtc.org/2518293002 Cr-Commit-Position: refs/heads/master@{#15214}
This commit is contained in:
@ -709,7 +709,6 @@ if (rtc_include_tests) {
|
||||
deps = [
|
||||
"//base:base_java_test_support",
|
||||
"//webrtc/api:libjingle_peerconnection_java",
|
||||
"//webrtc/api:libjingle_peerconnection_jni",
|
||||
"//webrtc/examples:AppRTCMobile_javalib",
|
||||
]
|
||||
}
|
||||
|
||||
@ -171,12 +171,12 @@ if (is_android && !build_with_chromium) {
|
||||
|
||||
rtc_static_library("libjingle_peerconnection_jni") {
|
||||
sources = [
|
||||
"android/jni/androidhistogram_jni.cc",
|
||||
"android/jni/androidmediacodeccommon.h",
|
||||
"android/jni/androidmediadecoder_jni.cc",
|
||||
"android/jni/androidmediadecoder_jni.h",
|
||||
"android/jni/androidmediaencoder_jni.cc",
|
||||
"android/jni/androidmediaencoder_jni.h",
|
||||
"android/jni/androidmetrics_jni.cc",
|
||||
"android/jni/androidnetworkmonitor_jni.cc",
|
||||
"android/jni/androidnetworkmonitor_jni.h",
|
||||
"android/jni/androidvideotracksource.cc",
|
||||
@ -215,8 +215,6 @@ if (is_android && !build_with_chromium) {
|
||||
|
||||
deps = [
|
||||
":libjingle_peerconnection",
|
||||
"../system_wrappers:field_trial_default",
|
||||
"../system_wrappers:metrics_default",
|
||||
]
|
||||
|
||||
if (rtc_build_libyuv) {
|
||||
@ -231,6 +229,17 @@ if (is_android && !build_with_chromium) {
|
||||
}
|
||||
|
||||
rtc_static_library("libjingle_peerconnection_metrics_default_jni") {
|
||||
sources = [
|
||||
"android/jni/androidmetrics_jni.cc",
|
||||
]
|
||||
|
||||
configs += [ ":libjingle_peerconnection_jni_warnings_config" ]
|
||||
|
||||
deps = [
|
||||
":libjingle_peerconnection",
|
||||
"../system_wrappers:field_trial_default",
|
||||
"../system_wrappers:metrics_default",
|
||||
]
|
||||
}
|
||||
|
||||
rtc_shared_library("libjingle_peerconnection_so") {
|
||||
@ -243,6 +252,7 @@ if (is_android && !build_with_chromium) {
|
||||
deps = [
|
||||
":libjingle_peerconnection",
|
||||
":libjingle_peerconnection_jni",
|
||||
":libjingle_peerconnection_metrics_default_jni",
|
||||
]
|
||||
output_extension = "so"
|
||||
}
|
||||
@ -282,6 +292,7 @@ if (is_android) {
|
||||
"android/java/src/org/webrtc/GlShader.java",
|
||||
"android/java/src/org/webrtc/GlTextureFrameBuffer.java",
|
||||
"android/java/src/org/webrtc/GlUtil.java",
|
||||
"android/java/src/org/webrtc/Histogram.java",
|
||||
"android/java/src/org/webrtc/IceCandidate.java",
|
||||
"android/java/src/org/webrtc/MediaCodecVideoDecoder.java",
|
||||
"android/java/src/org/webrtc/MediaCodecVideoEncoder.java",
|
||||
@ -289,7 +300,6 @@ if (is_android) {
|
||||
"android/java/src/org/webrtc/MediaSource.java",
|
||||
"android/java/src/org/webrtc/MediaStream.java",
|
||||
"android/java/src/org/webrtc/MediaStreamTrack.java",
|
||||
"android/java/src/org/webrtc/Metrics.java",
|
||||
"android/java/src/org/webrtc/NetworkMonitor.java",
|
||||
"android/java/src/org/webrtc/NetworkMonitorAutoDetect.java",
|
||||
"android/java/src/org/webrtc/PeerConnection.java",
|
||||
@ -319,6 +329,14 @@ if (is_android) {
|
||||
"../base:base_java",
|
||||
]
|
||||
}
|
||||
|
||||
android_library("libjingle_peerconnection_metrics_default_java") {
|
||||
java_files = [ "android/java/src/org/webrtc/Metrics.java" ]
|
||||
|
||||
deps = [
|
||||
"../base:base_java",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
rtc_source_set("rtc_stats_api") {
|
||||
@ -503,6 +521,7 @@ if (rtc_include_tests) {
|
||||
|
||||
deps = [
|
||||
":libjingle_peerconnection_java",
|
||||
":libjingle_peerconnection_metrics_default_java",
|
||||
"../base:base_java",
|
||||
"//base:base_java",
|
||||
]
|
||||
|
||||
@ -20,7 +20,6 @@ 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 {
|
||||
|
||||
@ -29,7 +29,6 @@ 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 {
|
||||
|
||||
@ -18,7 +18,6 @@ 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 {
|
||||
|
||||
44
webrtc/api/android/java/src/org/webrtc/Histogram.java
Normal file
44
webrtc/api/android/java/src/org/webrtc/Histogram.java
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2016 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
package org.webrtc;
|
||||
|
||||
/**
|
||||
* Class for holding the native pointer of a histogram. Since there is no way to destroy a
|
||||
* histogram, please don't create unnecessary instances of this object. This class is thread safe.
|
||||
*
|
||||
* Usage example:
|
||||
* private static final Histogram someMetricHistogram =
|
||||
* Histogram.createCounts("WebRTC.Video.SomeMetric", 1, 10000, 50);
|
||||
* someMetricHistogram.addSample(someVariable);
|
||||
*/
|
||||
class Histogram {
|
||||
private final long handle;
|
||||
|
||||
private Histogram(long handle) {
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
static public Histogram createCounts(String name, int min, int max, int bucketCount) {
|
||||
return new Histogram(nativeCreateCounts(name, min, max, bucketCount));
|
||||
}
|
||||
|
||||
static public Histogram createEnumeration(String name, int max) {
|
||||
return new Histogram(nativeCreateEnumeration(name, max));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@ -59,41 +59,6 @@ public class Metrics {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for holding the native pointer of a histogram. Since there is no way to destroy a
|
||||
* histogram, please don't create unnecessary instances of this object. This class is thread safe.
|
||||
*
|
||||
* Usage example:
|
||||
* private static final Histogram someMetricHistogram =
|
||||
* Histogram.createCounts("WebRTC.Video.SomeMetric", 1, 10000, 50);
|
||||
* someMetricHistogram.addSample(someVariable);
|
||||
*/
|
||||
static class Histogram {
|
||||
private final long handle;
|
||||
private final String name; // Only used for logging.
|
||||
|
||||
private Histogram(long handle, String name) {
|
||||
this.handle = handle;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
static public Histogram createCounts(String name, int min, int max, int bucketCount) {
|
||||
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);
|
||||
}
|
||||
|
||||
private void add(String name, HistogramInfo info) {
|
||||
map.put(name, info);
|
||||
}
|
||||
|
||||
@ -1,2 +1,3 @@
|
||||
per-file Camera*=sakal@webrtc.org
|
||||
per-file Histogram.java=sakal@webrtc.org
|
||||
per-file Metrics.java=sakal@webrtc.org
|
||||
|
||||
@ -24,7 +24,6 @@ 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
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
per-file androidhistogram_jni.cc=sakal@webrtc.org
|
||||
per-file androidmetrics_jni.cc=sakal@webrtc.org
|
||||
per-file androidvideotracksource.*=sakal@webrtc.org
|
||||
per-file androidvideotracksource_jni.cc=sakal@webrtc.org
|
||||
|
||||
44
webrtc/api/android/jni/androidhistogram_jni.cc
Normal file
44
webrtc/api/android/jni/androidhistogram_jni.cc
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2016 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/api/android/jni/classreferenceholder.h"
|
||||
#include "webrtc/api/android/jni/jni_helpers.h"
|
||||
#include "webrtc/api/android/jni/native_handle_impl.h"
|
||||
#include "webrtc/system_wrappers/include/metrics.h"
|
||||
|
||||
// Enables collection of native histograms and creating them.
|
||||
namespace webrtc_jni {
|
||||
|
||||
JOW(jlong, Histogram_nativeCreateCounts)
|
||||
(JNIEnv* jni, jclass, jstring j_name, jint min, jint max, jint buckets) {
|
||||
std::string name = JavaToStdString(jni, j_name);
|
||||
return jlongFromPointer(
|
||||
webrtc::metrics::HistogramFactoryGetCounts(name, min, max, buckets));
|
||||
}
|
||||
|
||||
JOW(jlong, Histogram_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, Histogram_nativeAddSample)
|
||||
(JNIEnv* jni, jclass, jlong histogram, jint sample) {
|
||||
if (histogram) {
|
||||
HistogramAdd(reinterpret_cast<webrtc::metrics::Histogram*>(histogram),
|
||||
sample);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace webrtc_jni
|
||||
@ -13,7 +13,6 @@
|
||||
|
||||
#include "webrtc/api/android/jni/classreferenceholder.h"
|
||||
#include "webrtc/api/android/jni/jni_helpers.h"
|
||||
#include "webrtc/api/android/jni/native_handle_impl.h"
|
||||
#include "webrtc/system_wrappers/include/metrics.h"
|
||||
#include "webrtc/system_wrappers/include/metrics_default.h"
|
||||
|
||||
@ -26,11 +25,11 @@ JOW(void, Metrics_nativeEnable)(JNIEnv* jni, jclass) {
|
||||
|
||||
// Gets and clears native histograms.
|
||||
JOW(jobject, Metrics_nativeGetAndReset)(JNIEnv* jni, jclass) {
|
||||
jclass j_metrics_class = FindClass(jni, "org/webrtc/Metrics");
|
||||
jclass j_metrics_class = jni->FindClass("org/webrtc/Metrics");
|
||||
jmethodID j_add =
|
||||
GetMethodID(jni, j_metrics_class, "add",
|
||||
"(Ljava/lang/String;Lorg/webrtc/Metrics$HistogramInfo;)V");
|
||||
jclass j_info_class = FindClass(jni, "org/webrtc/Metrics$HistogramInfo");
|
||||
jclass j_info_class = jni->FindClass("org/webrtc/Metrics$HistogramInfo");
|
||||
jmethodID j_add_sample = GetMethodID(jni, j_info_class, "addSample", "(II)V");
|
||||
|
||||
// Create |Metrics|.
|
||||
@ -59,26 +58,4 @@ JOW(jobject, Metrics_nativeGetAndReset)(JNIEnv* jni, jclass) {
|
||||
return j_metrics;
|
||||
}
|
||||
|
||||
JOW(jlong, Metrics_00024Histogram_nativeCreateCounts)
|
||||
(JNIEnv* jni, jclass, jstring j_name, jint min, jint max, jint buckets) {
|
||||
std::string name = JavaToStdString(jni, j_name);
|
||||
return jlongFromPointer(
|
||||
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) {
|
||||
HistogramAdd(reinterpret_cast<webrtc::metrics::Histogram*>(histogram),
|
||||
sample);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace webrtc_jni
|
||||
|
||||
@ -69,8 +69,6 @@ ClassReferenceHolder::ClassReferenceHolder(JNIEnv* jni) {
|
||||
LoadClass(jni, "org/webrtc/MediaSource$State");
|
||||
LoadClass(jni, "org/webrtc/MediaStream");
|
||||
LoadClass(jni, "org/webrtc/MediaStreamTrack$State");
|
||||
LoadClass(jni, "org/webrtc/Metrics");
|
||||
LoadClass(jni, "org/webrtc/Metrics$HistogramInfo");
|
||||
LoadClass(jni, "org/webrtc/NetworkMonitor");
|
||||
LoadClass(jni, "org/webrtc/NetworkMonitorAutoDetect$ConnectionType");
|
||||
LoadClass(jni, "org/webrtc/NetworkMonitorAutoDetect$IPAddress");
|
||||
|
||||
@ -93,6 +93,7 @@ if (is_android) {
|
||||
deps = [
|
||||
":AppRTCMobile_resources",
|
||||
"//webrtc/api:libjingle_peerconnection_java",
|
||||
"//webrtc/api:libjingle_peerconnection_metrics_default_java",
|
||||
"//webrtc/base:base_java",
|
||||
"//webrtc/examples/androidapp/third_party/autobanh:autobanh_java",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user