Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(563)

Side by Side Diff: webrtc/api/android/java/src/org/webrtc/Metrics.java

Issue 2547483003: Move /webrtc/api/android files to /webrtc/sdk/android (Closed)
Patch Set: Move to api folder under Android instead of src Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 package org.webrtc;
12
13 import java.util.HashMap;
14 import java.util.Map;
15
16 // Java-side of androidmetrics_jni.cc.
17 //
18 // Rtc histograms can be queried through the API, getAndReset().
19 // The returned map holds the name of a histogram and its samples.
20 //
21 // Example of |map| with one histogram:
22 // |name|: "WebRTC.Video.InputFramesPerSecond"
23 // |min|: 1
24 // |max|: 100
25 // |bucketCount|: 50
26 // |samples|: [30]:1
27 //
28 // Most histograms are not updated frequently (e.g. most video metrics are an
29 // average over the call and recorded when a stream is removed).
30 // The metrics can for example be retrieved when a peer connection is closed.
31
32 public class Metrics {
33 private static final String TAG = "Metrics";
34
35 static {
36 System.loadLibrary("jingle_peerconnection_so");
37 }
38 public final Map<String, HistogramInfo> map =
39 new HashMap<String, HistogramInfo>(); // <name, HistogramInfo>
40
41 /**
42 * Class holding histogram information.
43 */
44 public static class HistogramInfo {
45 public final int min;
46 public final int max;
47 public final int bucketCount;
48 public final Map<Integer, Integer> samples =
49 new HashMap<Integer, Integer>(); // <value, # of events>
50
51 public HistogramInfo(int min, int max, int bucketCount) {
52 this.min = min;
53 this.max = max;
54 this.bucketCount = bucketCount;
55 }
56
57 public void addSample(int value, int numEvents) {
58 samples.put(value, numEvents);
59 }
60 }
61
62 private void add(String name, HistogramInfo info) {
63 map.put(name, info);
64 }
65
66 // Enables gathering of metrics (which can be fetched with getAndReset()).
67 // Must be called before PeerConnectionFactory is created.
68 public static void enable() {
69 nativeEnable();
70 }
71
72 // Gets and clears native histograms.
73 public static Metrics getAndReset() {
74 return nativeGetAndReset();
75 }
76
77 private static native void nativeEnable();
78 private static native Metrics nativeGetAndReset();
79 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698