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

Side by Side Diff: webrtc/video/send_statistics_proxy.cc

Issue 1410533004: Round Rate computations from RateTracker. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Correct first-bucket rounding. Created 5 years, 1 month 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
« no previous file with comments | « webrtc/video/receive_statistics_proxy.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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
11 #include "webrtc/video/send_statistics_proxy.h" 11 #include "webrtc/video/send_statistics_proxy.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <cmath>
14 #include <map> 15 #include <map>
15 16
16 #include "webrtc/base/checks.h" 17 #include "webrtc/base/checks.h"
17 18
18 #include "webrtc/base/logging.h" 19 #include "webrtc/base/logging.h"
19 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" 20 #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
20 #include "webrtc/system_wrappers/include/metrics.h" 21 #include "webrtc/system_wrappers/include/metrics.h"
21 22
22 namespace webrtc { 23 namespace webrtc {
23 namespace { 24 namespace {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 max_sent_height_per_timestamp_(0) { 64 max_sent_height_per_timestamp_(0) {
64 UpdateCodecTypeHistogram(config_.encoder_settings.payload_name); 65 UpdateCodecTypeHistogram(config_.encoder_settings.payload_name);
65 } 66 }
66 67
67 SendStatisticsProxy::~SendStatisticsProxy() { 68 SendStatisticsProxy::~SendStatisticsProxy() {
68 UpdateHistograms(); 69 UpdateHistograms();
69 } 70 }
70 71
71 void SendStatisticsProxy::UpdateHistograms() { 72 void SendStatisticsProxy::UpdateHistograms() {
72 int input_fps = 73 int input_fps =
73 static_cast<int>(input_frame_rate_tracker_.ComputeTotalRate()); 74 round(input_frame_rate_tracker_.ComputeTotalRate());
74 if (input_fps > 0) 75 if (input_fps > 0)
75 RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.InputFramesPerSecond", input_fps); 76 RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.InputFramesPerSecond", input_fps);
76 int sent_fps = 77 int sent_fps =
77 static_cast<int>(sent_frame_rate_tracker_.ComputeTotalRate()); 78 round(sent_frame_rate_tracker_.ComputeTotalRate());
78 if (sent_fps > 0) 79 if (sent_fps > 0)
79 RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.SentFramesPerSecond", sent_fps); 80 RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.SentFramesPerSecond", sent_fps);
80 81
81 const int kMinRequiredSamples = 200; 82 const int kMinRequiredSamples = 200;
82 int in_width = input_width_counter_.Avg(kMinRequiredSamples); 83 int in_width = input_width_counter_.Avg(kMinRequiredSamples);
83 int in_height = input_height_counter_.Avg(kMinRequiredSamples); 84 int in_height = input_height_counter_.Avg(kMinRequiredSamples);
84 if (in_width != -1) { 85 if (in_width != -1) {
85 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.InputWidthInPixels", in_width); 86 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.InputWidthInPixels", in_width);
86 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.InputHeightInPixels", in_height); 87 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.InputHeightInPixels", in_height);
87 } 88 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 149
149 void SendStatisticsProxy::OnSuspendChange(bool is_suspended) { 150 void SendStatisticsProxy::OnSuspendChange(bool is_suspended) {
150 rtc::CritScope lock(&crit_); 151 rtc::CritScope lock(&crit_);
151 stats_.suspended = is_suspended; 152 stats_.suspended = is_suspended;
152 } 153 }
153 154
154 VideoSendStream::Stats SendStatisticsProxy::GetStats() { 155 VideoSendStream::Stats SendStatisticsProxy::GetStats() {
155 rtc::CritScope lock(&crit_); 156 rtc::CritScope lock(&crit_);
156 PurgeOldStats(); 157 PurgeOldStats();
157 stats_.input_frame_rate = 158 stats_.input_frame_rate =
158 static_cast<int>(input_frame_rate_tracker_.ComputeRate()); 159 round(input_frame_rate_tracker_.ComputeRate());
159 return stats_; 160 return stats_;
160 } 161 }
161 162
162 void SendStatisticsProxy::PurgeOldStats() { 163 void SendStatisticsProxy::PurgeOldStats() {
163 int64_t old_stats_ms = clock_->TimeInMilliseconds() - kStatsTimeoutMs; 164 int64_t old_stats_ms = clock_->TimeInMilliseconds() - kStatsTimeoutMs;
164 for (std::map<uint32_t, VideoSendStream::StreamStats>::iterator it = 165 for (std::map<uint32_t, VideoSendStream::StreamStats>::iterator it =
165 stats_.substreams.begin(); 166 stats_.substreams.begin();
166 it != stats_.substreams.end(); ++it) { 167 it != stats_.substreams.end(); ++it) {
167 uint32_t ssrc = it->first; 168 uint32_t ssrc = it->first;
168 if (update_times_[ssrc].resolution_update_ms <= old_stats_ms) { 169 if (update_times_[ssrc].resolution_update_ms <= old_stats_ms) {
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 } 380 }
380 381
381 int SendStatisticsProxy::BoolSampleCounter::Fraction( 382 int SendStatisticsProxy::BoolSampleCounter::Fraction(
382 int min_required_samples, float multiplier) const { 383 int min_required_samples, float multiplier) const {
383 if (num_samples < min_required_samples || num_samples == 0) 384 if (num_samples < min_required_samples || num_samples == 0)
384 return -1; 385 return -1;
385 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); 386 return static_cast<int>((sum * multiplier / num_samples) + 0.5f);
386 } 387 }
387 388
388 } // namespace webrtc 389 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/receive_statistics_proxy.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698