diff --git a/talk/examples/android/src/org/appspot/apprtc/AppRTCDemoActivity.java b/talk/examples/android/src/org/appspot/apprtc/AppRTCDemoActivity.java index ef97cda61..213da7bb8 100644 --- a/talk/examples/android/src/org/appspot/apprtc/AppRTCDemoActivity.java +++ b/talk/examples/android/src/org/appspot/apprtc/AppRTCDemoActivity.java @@ -200,19 +200,49 @@ public class AppRTCDemoActivity extends Activity private void updateHUD(StatsReport[] reports) { StringBuilder builder = new StringBuilder(); for (StatsReport report : reports) { - if (!report.id.equals("bweforvideo")) { + // bweforvideo to show statistics for video Bandwidth Estimation, + // which is global per-session. + if (report.id.equals("bweforvideo")) { + for (StatsReport.Value value : report.values) { + String name = value.name.replace("goog", "") + .replace("Available", "").replace("Bandwidth", "") + .replace("Bitrate", "").replace("Enc", ""); + + builder.append(name).append("=").append(value.value) + .append(" "); + } + builder.append("\n"); + } else if (report.type.equals("googCandidatePair")) { + String activeConnectionStats = getActiveConnectionStats(report); + if (activeConnectionStats == null) { + continue; + } + builder.append(activeConnectionStats); + } else { continue; } - for (StatsReport.Value value : report.values) { - String name = value.name.replace("goog", "").replace("Available", "") - .replace("Bandwidth", "").replace("Bitrate", "").replace("Enc", ""); - builder.append(name).append("=").append(value.value).append(" "); - } builder.append("\n"); } hudView.setText(builder.toString() + hudView.getText()); } + // Return the active connection stats else return null + private String getActiveConnectionStats(StatsReport report) { + StringBuilder activeConnectionbuilder = new StringBuilder(); + // googCandidatePair to show information about the active + // connection. + for (StatsReport.Value value : report.values) { + if (value.name.equals("googActiveConnection") + && value.value.equals("false")) { + return null; + } + String name = value.name.replace("goog", ""); + activeConnectionbuilder.append(name).append("=") + .append(value.value).append("\n"); + } + return activeConnectionbuilder.toString(); + } + @Override public void onPause() { super.onPause();