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

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: added render fps 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
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 if (in_width != -1)
pbos-webrtc 2015/07/20 13:52:22 Same here, treat in_{width,height} as one pair, an
åsapersson 2015/07/20 15:06:30 Done.
52 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.InputWidthInPixels", in_width);
53 int in_height = input_height_counter_.Avg(kMinRequiredSamples);
54 if (in_height != -1)
55 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.InputHeightInPixels", in_height);
56 int sent_width = sent_width_counter_.Avg(kMinRequiredSamples);
57 if (sent_width != -1)
58 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.SentWidthInPixels", sent_width);
59 int sent_height = sent_height_counter_.Avg(kMinRequiredSamples);
60 if (sent_height != -1)
61 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.SentHeightInPixels", sent_height);
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 if (last_sent_frame_timestamp_ > 0 &&
pbos-webrtc 2015/07/20 13:52:22 Write a TODO() saying that this is incorrect if si
åsapersson 2015/07/20 15:06:30 Done, added comment.
162 encoded_image._timeStamp != last_sent_frame_timestamp_) {
144 sent_frame_rate_tracker_total_.Update(1); 163 sent_frame_rate_tracker_total_.Update(1);
164 sent_width_counter_.Add(max_sent_width_per_timestamp_);
165 sent_height_counter_.Add(max_sent_height_per_timestamp_);
166 max_sent_width_per_timestamp_ = 0;
167 max_sent_height_per_timestamp_ = 0;
145 } 168 }
169 last_sent_frame_timestamp_ = encoded_image._timeStamp;
170 max_sent_width_per_timestamp_ = std::max(max_sent_width_per_timestamp_,
171 static_cast<int>(encoded_image._encodedWidth));
172 max_sent_height_per_timestamp_ = std::max(max_sent_height_per_timestamp_,
173 static_cast<int>(encoded_image._encodedHeight));
146 } 174 }
147 175
148 void SendStatisticsProxy::OnIncomingFrame() { 176 void SendStatisticsProxy::OnIncomingFrame(int width, int height) {
149 rtc::CritScope lock(&crit_); 177 rtc::CritScope lock(&crit_);
150 input_frame_rate_tracker_.Update(1); 178 input_frame_rate_tracker_.Update(1);
151 input_frame_rate_tracker_total_.Update(1); 179 input_frame_rate_tracker_total_.Update(1);
180 input_width_counter_.Add(width);
181 input_height_counter_.Add(height);
152 } 182 }
153 183
154 void SendStatisticsProxy::RtcpPacketTypesCounterUpdated( 184 void SendStatisticsProxy::RtcpPacketTypesCounterUpdated(
155 uint32_t ssrc, 185 uint32_t ssrc,
156 const RtcpPacketTypeCounter& packet_counter) { 186 const RtcpPacketTypeCounter& packet_counter) {
157 rtc::CritScope lock(&crit_); 187 rtc::CritScope lock(&crit_);
158 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); 188 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc);
159 if (stats == nullptr) 189 if (stats == nullptr)
160 return; 190 return;
161 191
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 uint32_t ssrc) { 243 uint32_t ssrc) {
214 rtc::CritScope lock(&crit_); 244 rtc::CritScope lock(&crit_);
215 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); 245 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc);
216 if (stats == nullptr) 246 if (stats == nullptr)
217 return; 247 return;
218 stats->avg_delay_ms = avg_delay_ms; 248 stats->avg_delay_ms = avg_delay_ms;
219 stats->max_delay_ms = max_delay_ms; 249 stats->max_delay_ms = max_delay_ms;
220 } 250 }
221 251
222 } // namespace webrtc 252 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698