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

Side by Side Diff: webrtc/examples/androidapp/src/org/appspot/apprtc/HudFragment.java

Issue 1813053007: Update CPU Monitor to report CPU frequency and battery level. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Address comment Created 4 years, 9 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2015 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 20 matching lines...) Expand all
31 private View controlView; 31 private View controlView;
32 private TextView encoderStatView; 32 private TextView encoderStatView;
33 private TextView hudViewBwe; 33 private TextView hudViewBwe;
34 private TextView hudViewConnection; 34 private TextView hudViewConnection;
35 private TextView hudViewVideoSend; 35 private TextView hudViewVideoSend;
36 private TextView hudViewVideoRecv; 36 private TextView hudViewVideoRecv;
37 private ImageButton toggleDebugButton; 37 private ImageButton toggleDebugButton;
38 private boolean videoCallEnabled; 38 private boolean videoCallEnabled;
39 private boolean displayHud; 39 private boolean displayHud;
40 private volatile boolean isRunning; 40 private volatile boolean isRunning;
41 private final CpuMonitor cpuMonitor = new CpuMonitor(); 41 private CpuMonitor cpuMonitor;
42 42
43 @Override 43 @Override
44 public View onCreateView(LayoutInflater inflater, ViewGroup container, 44 public View onCreateView(LayoutInflater inflater, ViewGroup container,
45 Bundle savedInstanceState) { 45 Bundle savedInstanceState) {
46 controlView = inflater.inflate(R.layout.fragment_hud, container, false); 46 controlView = inflater.inflate(R.layout.fragment_hud, container, false);
47 47
48 // Create UI controls. 48 // Create UI controls.
49 encoderStatView = (TextView) controlView.findViewById(R.id.encoder_stat_call ); 49 encoderStatView = (TextView) controlView.findViewById(R.id.encoder_stat_call );
50 hudViewBwe = (TextView) controlView.findViewById(R.id.hud_stat_bwe); 50 hudViewBwe = (TextView) controlView.findViewById(R.id.hud_stat_bwe);
51 hudViewConnection = (TextView) controlView.findViewById(R.id.hud_stat_connec tion); 51 hudViewConnection = (TextView) controlView.findViewById(R.id.hud_stat_connec tion);
(...skipping 30 matching lines...) Expand all
82 hudViewsSetProperties(View.INVISIBLE); 82 hudViewsSetProperties(View.INVISIBLE);
83 isRunning = true; 83 isRunning = true;
84 } 84 }
85 85
86 @Override 86 @Override
87 public void onStop() { 87 public void onStop() {
88 isRunning = false; 88 isRunning = false;
89 super.onStop(); 89 super.onStop();
90 } 90 }
91 91
92 public void setCpuMonitor(CpuMonitor cpuMonitor) {
93 this.cpuMonitor = cpuMonitor;
94 }
95
92 private void hudViewsSetProperties(int visibility) { 96 private void hudViewsSetProperties(int visibility) {
93 hudViewBwe.setVisibility(visibility); 97 hudViewBwe.setVisibility(visibility);
94 hudViewConnection.setVisibility(visibility); 98 hudViewConnection.setVisibility(visibility);
95 hudViewVideoSend.setVisibility(visibility); 99 hudViewVideoSend.setVisibility(visibility);
96 hudViewVideoRecv.setVisibility(visibility); 100 hudViewVideoRecv.setVisibility(visibility);
97 hudViewBwe.setTextSize(TypedValue.COMPLEX_UNIT_PT, 5); 101 hudViewBwe.setTextSize(TypedValue.COMPLEX_UNIT_PT, 5);
98 hudViewConnection.setTextSize(TypedValue.COMPLEX_UNIT_PT, 5); 102 hudViewConnection.setTextSize(TypedValue.COMPLEX_UNIT_PT, 5);
99 hudViewVideoSend.setTextSize(TypedValue.COMPLEX_UNIT_PT, 5); 103 hudViewVideoSend.setTextSize(TypedValue.COMPLEX_UNIT_PT, 5);
100 hudViewVideoRecv.setTextSize(TypedValue.COMPLEX_UNIT_PT, 5); 104 hudViewVideoRecv.setTextSize(TypedValue.COMPLEX_UNIT_PT, 5);
101 } 105 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 encoderStat.append("Fps: ").append(fps).append("\n"); 186 encoderStat.append("Fps: ").append(fps).append("\n");
183 } 187 }
184 if (targetBitrate != null) { 188 if (targetBitrate != null) {
185 encoderStat.append("Target BR: ").append(targetBitrate).append("\n"); 189 encoderStat.append("Target BR: ").append(targetBitrate).append("\n");
186 } 190 }
187 if (actualBitrate != null) { 191 if (actualBitrate != null) {
188 encoderStat.append("Actual BR: ").append(actualBitrate).append("\n"); 192 encoderStat.append("Actual BR: ").append(actualBitrate).append("\n");
189 } 193 }
190 } 194 }
191 195
192 if (cpuMonitor.sampleCpuUtilization()) { 196 if (cpuMonitor != null) {
193 encoderStat.append("CPU%: ") 197 encoderStat.append("CPU%: ").append(cpuMonitor.getCpuUsageCurrent())
194 .append(cpuMonitor.getCpuCurrent()).append("/") 198 .append(". Freq: ").append(cpuMonitor.getCpuFrequencyScaleCurrent());
195 .append(cpuMonitor.getCpuAvg3()).append("/")
196 .append(cpuMonitor.getCpuAvgAll());
197 } 199 }
198 encoderStatView.setText(encoderStat.toString()); 200 encoderStatView.setText(encoderStat.toString());
199 } 201 }
200 } 202 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698