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

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

Issue 1228393008: Add resolution and fps stats to histograms. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 5 years, 5 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
« no previous file with comments | « webrtc/video/send_statistics_proxy.h ('k') | webrtc/video/video_capture_input.cc » ('j') | 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 <map> 14 #include <map>
14 15
15 #include "webrtc/base/checks.h" 16 #include "webrtc/base/checks.h"
16 17
17 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" 18 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
18 #include "webrtc/system_wrappers/interface/logging.h" 19 #include "webrtc/system_wrappers/interface/logging.h"
19 #include "webrtc/system_wrappers/interface/metrics.h" 20 #include "webrtc/system_wrappers/interface/metrics.h"
20 21
21 namespace webrtc { 22 namespace webrtc {
22 23
23 const int SendStatisticsProxy::kStatsTimeoutMs = 5000; 24 const int SendStatisticsProxy::kStatsTimeoutMs = 5000;
24 25
25 SendStatisticsProxy::SendStatisticsProxy(Clock* clock, 26 SendStatisticsProxy::SendStatisticsProxy(Clock* clock,
26 const VideoSendStream::Config& config) 27 const VideoSendStream::Config& config)
27 : clock_(clock), config_(config), last_sent_frame_timestamp_(0) { 28 : clock_(clock),
29 config_(config),
30 last_sent_frame_timestamp_(0),
31 max_sent_width_per_timestamp_(0),
32 max_sent_height_per_timestamp_(0) {
28 } 33 }
29 34
30 SendStatisticsProxy::~SendStatisticsProxy() { 35 SendStatisticsProxy::~SendStatisticsProxy() {
31 UpdateHistograms(); 36 UpdateHistograms();
32 } 37 }
33 38
34 void SendStatisticsProxy::UpdateHistograms() { 39 void SendStatisticsProxy::UpdateHistograms() {
35 int input_fps = 40 int input_fps =
36 static_cast<int>(input_frame_rate_tracker_total_.units_second()); 41 static_cast<int>(input_frame_rate_tracker_total_.units_second());
42 if (input_fps > 0)
43 RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.InputFramesPerSecond", input_fps);
37 int sent_fps = 44 int sent_fps =
38 static_cast<int>(sent_frame_rate_tracker_total_.units_second()); 45 static_cast<int>(sent_frame_rate_tracker_total_.units_second());
39
40 if (input_fps > 0)
41 RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.InputFramesPerSecond", input_fps);
42 if (sent_fps > 0) 46 if (sent_fps > 0)
43 RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.SentFramesPerSecond", sent_fps); 47 RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.SentFramesPerSecond", sent_fps);
48
49 const int kMinRequiredSamples = 100;
50 int in_width = input_width_counter_.Avg(kMinRequiredSamples);
51 int in_height = input_height_counter_.Avg(kMinRequiredSamples);
52 if (in_width != -1) {
53 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.InputWidthInPixels", in_width);
54 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.InputHeightInPixels", in_height);
55 }
56 int sent_width = sent_width_counter_.Avg(kMinRequiredSamples);
57 int sent_height = sent_height_counter_.Avg(kMinRequiredSamples);
58 if (sent_width != -1) {
59 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.SentWidthInPixels", sent_width);
60 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.SentHeightInPixels", sent_height);
61 }
44 } 62 }
45 63
46 void SendStatisticsProxy::OutgoingRate(const int video_channel, 64 void SendStatisticsProxy::OutgoingRate(const int video_channel,
47 const unsigned int framerate, 65 const unsigned int framerate,
48 const unsigned int bitrate) { 66 const unsigned int bitrate) {
49 rtc::CritScope lock(&crit_); 67 rtc::CritScope lock(&crit_);
50 stats_.encode_frame_rate = framerate; 68 stats_.encode_frame_rate = framerate;
51 stats_.media_bitrate_bps = bitrate; 69 stats_.media_bitrate_bps = bitrate;
52 } 70 }
53 71
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 uint32_t ssrc = config_.rtp.ssrcs[simulcast_idx]; 150 uint32_t ssrc = config_.rtp.ssrcs[simulcast_idx];
133 151
134 rtc::CritScope lock(&crit_); 152 rtc::CritScope lock(&crit_);
135 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); 153 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc);
136 if (stats == nullptr) 154 if (stats == nullptr)
137 return; 155 return;
138 156
139 stats->width = encoded_image._encodedWidth; 157 stats->width = encoded_image._encodedWidth;
140 stats->height = encoded_image._encodedHeight; 158 stats->height = encoded_image._encodedHeight;
141 update_times_[ssrc].resolution_update_ms = clock_->TimeInMilliseconds(); 159 update_times_[ssrc].resolution_update_ms = clock_->TimeInMilliseconds();
142 if (encoded_image._timeStamp != last_sent_frame_timestamp_) { 160
143 last_sent_frame_timestamp_ = encoded_image._timeStamp; 161 // TODO(asapersson): This is incorrect if simulcast layers are encoded on
162 // different threads and there is no guarantee that one frame of all layers
163 // are encoded before the next start.
164 if (last_sent_frame_timestamp_ > 0 &&
165 encoded_image._timeStamp != last_sent_frame_timestamp_) {
144 sent_frame_rate_tracker_total_.Update(1); 166 sent_frame_rate_tracker_total_.Update(1);
167 sent_width_counter_.Add(max_sent_width_per_timestamp_);
168 sent_height_counter_.Add(max_sent_height_per_timestamp_);
169 max_sent_width_per_timestamp_ = 0;
170 max_sent_height_per_timestamp_ = 0;
145 } 171 }
172 last_sent_frame_timestamp_ = encoded_image._timeStamp;
173 max_sent_width_per_timestamp_ =
174 std::max(max_sent_width_per_timestamp_,
175 static_cast<int>(encoded_image._encodedWidth));
176 max_sent_height_per_timestamp_ =
177 std::max(max_sent_height_per_timestamp_,
178 static_cast<int>(encoded_image._encodedHeight));
146 } 179 }
147 180
148 void SendStatisticsProxy::OnIncomingFrame() { 181 void SendStatisticsProxy::OnIncomingFrame(int width, int height) {
149 rtc::CritScope lock(&crit_); 182 rtc::CritScope lock(&crit_);
150 input_frame_rate_tracker_.Update(1); 183 input_frame_rate_tracker_.Update(1);
151 input_frame_rate_tracker_total_.Update(1); 184 input_frame_rate_tracker_total_.Update(1);
185 input_width_counter_.Add(width);
186 input_height_counter_.Add(height);
152 } 187 }
153 188
154 void SendStatisticsProxy::RtcpPacketTypesCounterUpdated( 189 void SendStatisticsProxy::RtcpPacketTypesCounterUpdated(
155 uint32_t ssrc, 190 uint32_t ssrc,
156 const RtcpPacketTypeCounter& packet_counter) { 191 const RtcpPacketTypeCounter& packet_counter) {
157 rtc::CritScope lock(&crit_); 192 rtc::CritScope lock(&crit_);
158 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); 193 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc);
159 if (stats == nullptr) 194 if (stats == nullptr)
160 return; 195 return;
161 196
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 int max_delay_ms, 247 int max_delay_ms,
213 uint32_t ssrc) { 248 uint32_t ssrc) {
214 rtc::CritScope lock(&crit_); 249 rtc::CritScope lock(&crit_);
215 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); 250 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc);
216 if (stats == nullptr) 251 if (stats == nullptr)
217 return; 252 return;
218 stats->avg_delay_ms = avg_delay_ms; 253 stats->avg_delay_ms = avg_delay_ms;
219 stats->max_delay_ms = max_delay_ms; 254 stats->max_delay_ms = max_delay_ms;
220 } 255 }
221 256
257 void SendStatisticsProxy::SampleCounter::Add(int sample) {
258 sum += sample;
259 ++num_samples;
260 }
261
262 int SendStatisticsProxy::SampleCounter::Avg(int min_required_samples) const {
263 if (num_samples < min_required_samples || num_samples == 0)
264 return -1;
265 return sum / num_samples;
266 }
267
222 } // namespace webrtc 268 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/send_statistics_proxy.h ('k') | webrtc/video/video_capture_input.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698