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

Unified Diff: webrtc/sdk/android/api/org/webrtc/RTCStats.java

Issue 2807933003: Add Java binding for new getStats implementation. (Closed)
Patch Set: Fixing copyright year. Created 3 years, 8 months 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/sdk/android/api/org/webrtc/RTCStats.java
diff --git a/webrtc/sdk/android/api/org/webrtc/RTCStats.java b/webrtc/sdk/android/api/org/webrtc/RTCStats.java
new file mode 100644
index 0000000000000000000000000000000000000000..fa25e830d54d13b0fb37ad8ccad7575ba3e23104
--- /dev/null
+++ b/webrtc/sdk/android/api/org/webrtc/RTCStats.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2017 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;
+
+import java.util.Map;
+import java.util.SortedMap;
+
+/** Java version of webrtc::RTCStats. Represents an RTCStats object, as described in
+ * https://w3c.github.io/webrtc-stats/. The |id|, |timestamp_us| and |type|
+ * accessors have the same meaning for this class as for the RTCStats
+ * dictionary. */
hbos 2017/04/10 10:19:42 nit: Here and elsewhere, /** and */ on separate li
Taylor Brandstetter 2017/04/10 23:59:33 Done.
+public class RTCStats {
+ private final long timestamp_us;
hbos 2017/04/10 10:19:42 nit: Here, constructor, getter and toString: times
Taylor Brandstetter 2017/04/10 23:59:32 Done.
+ private final String type;
+ private final String id;
+ private final SortedMap<String, Object> members;
+
+ public RTCStats(long timestamp_us, String type, String id, SortedMap<String, Object> members) {
+ this.timestamp_us = timestamp_us;
+ this.type = type;
+ this.id = id;
+ this.members = members;
+ }
+
+ // Timestamp in nanoseconds.
+ public double timestamp_us() {
+ return timestamp_us;
+ }
+
+ // Equivalent to RTCStatsType in the stats spec.
+ public String type() {
+ return type;
+ }
+
+ // Unique ID representing this stats object. May be referred to by members of
+ // other stats objects.
+ public String id() {
+ return id;
+ }
+
+ /** Returns map of member names to values. Returns as an ordered map so that
+ * the stats object can be serialized with a consistent ordering.
+ *
+ * Values will be one of the following objects:
+ * - Boolean
+ * - Integer (for 32-bit signed integers)
+ * - Long (for 32-bit unsigned and 64-bit signed integers)
hbos 2017/04/10 10:19:42 Being able to distinguish between for example uint
Taylor Brandstetter 2017/04/10 23:59:32 If we don't have a clear use case, I'd suggest jus
+ * - BigInteger (for 64-bit unsigned integers)
+ * - Double
+ * - String
+ * - The array form of any of the above (e.g., Integer[]) */
+ public SortedMap<String, Object> members() {
+ return members;
hbos 2017/04/10 10:19:42 I thought about returning Collections.unmodifiable
Taylor Brandstetter 2017/04/10 23:59:32 I had the same line of thinking about arrays. And
+ }
+
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("{ timestamp_us: ")
+ .append(timestamp_us)
+ .append(", type: ")
+ .append(type)
+ .append(", id: ")
+ .append(id);
+ boolean first = true;
+ for (Map.Entry<String, Object> entry : members.entrySet()) {
+ builder.append(", ").append(entry.getKey()).append(": ").append(entry.getValue());
hbos 2017/04/10 10:19:42 An array toString() is not printed as e.g. "[1, 2,
Taylor Brandstetter 2017/04/10 23:59:33 Done, good catch.
+ }
+ builder.append(" }");
+ return builder.toString();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698