OLD | NEW |
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 <map> | 13 #include <map> |
14 | 14 |
15 #include "webrtc/base/checks.h" | 15 #include "webrtc/base/checks.h" |
16 | 16 |
17 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" | 17 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" |
18 #include "webrtc/system_wrappers/interface/logging.h" | 18 #include "webrtc/system_wrappers/interface/logging.h" |
| 19 #include "webrtc/system_wrappers/interface/metrics.h" |
19 | 20 |
20 namespace webrtc { | 21 namespace webrtc { |
21 | 22 |
22 const int SendStatisticsProxy::kStatsTimeoutMs = 5000; | 23 const int SendStatisticsProxy::kStatsTimeoutMs = 5000; |
23 | 24 |
24 SendStatisticsProxy::SendStatisticsProxy(Clock* clock, | 25 SendStatisticsProxy::SendStatisticsProxy(Clock* clock, |
25 const VideoSendStream::Config& config) | 26 const VideoSendStream::Config& config) |
26 : clock_(clock), | 27 : clock_(clock), |
27 config_(config) { | 28 config_(config) { |
28 } | 29 } |
29 | 30 |
30 SendStatisticsProxy::~SendStatisticsProxy() {} | 31 SendStatisticsProxy::~SendStatisticsProxy() { |
| 32 UpdateHistograms(); |
| 33 } |
| 34 |
| 35 void SendStatisticsProxy::UpdateHistograms() { |
| 36 int fps; |
| 37 { |
| 38 rtc::CritScope lock(&crit_); |
| 39 fps = static_cast<int>(input_frame_rate_tracker_total_.units_second()); |
| 40 } |
| 41 if (fps > 0) { |
| 42 RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.InputFramesPerSecond", fps); |
| 43 } |
| 44 } |
31 | 45 |
32 void SendStatisticsProxy::OutgoingRate(const int video_channel, | 46 void SendStatisticsProxy::OutgoingRate(const int video_channel, |
33 const unsigned int framerate, | 47 const unsigned int framerate, |
34 const unsigned int bitrate) { | 48 const unsigned int bitrate) { |
35 rtc::CritScope lock(&crit_); | 49 rtc::CritScope lock(&crit_); |
36 stats_.encode_frame_rate = framerate; | 50 stats_.encode_frame_rate = framerate; |
37 stats_.media_bitrate_bps = bitrate; | 51 stats_.media_bitrate_bps = bitrate; |
38 } | 52 } |
39 | 53 |
40 void SendStatisticsProxy::CpuOveruseMetricsUpdated( | 54 void SendStatisticsProxy::CpuOveruseMetricsUpdated( |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 return; | 137 return; |
124 | 138 |
125 stats->width = encoded_image._encodedWidth; | 139 stats->width = encoded_image._encodedWidth; |
126 stats->height = encoded_image._encodedHeight; | 140 stats->height = encoded_image._encodedHeight; |
127 update_times_[ssrc].resolution_update_ms = clock_->TimeInMilliseconds(); | 141 update_times_[ssrc].resolution_update_ms = clock_->TimeInMilliseconds(); |
128 } | 142 } |
129 | 143 |
130 void SendStatisticsProxy::OnIncomingFrame() { | 144 void SendStatisticsProxy::OnIncomingFrame() { |
131 rtc::CritScope lock(&crit_); | 145 rtc::CritScope lock(&crit_); |
132 input_frame_rate_tracker_.Update(1); | 146 input_frame_rate_tracker_.Update(1); |
| 147 input_frame_rate_tracker_total_.Update(1); |
133 } | 148 } |
134 | 149 |
135 void SendStatisticsProxy::RtcpPacketTypesCounterUpdated( | 150 void SendStatisticsProxy::RtcpPacketTypesCounterUpdated( |
136 uint32_t ssrc, | 151 uint32_t ssrc, |
137 const RtcpPacketTypeCounter& packet_counter) { | 152 const RtcpPacketTypeCounter& packet_counter) { |
138 rtc::CritScope lock(&crit_); | 153 rtc::CritScope lock(&crit_); |
139 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); | 154 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); |
140 if (stats == nullptr) | 155 if (stats == nullptr) |
141 return; | 156 return; |
142 | 157 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 uint32_t ssrc) { | 209 uint32_t ssrc) { |
195 rtc::CritScope lock(&crit_); | 210 rtc::CritScope lock(&crit_); |
196 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); | 211 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); |
197 if (stats == nullptr) | 212 if (stats == nullptr) |
198 return; | 213 return; |
199 stats->avg_delay_ms = avg_delay_ms; | 214 stats->avg_delay_ms = avg_delay_ms; |
200 stats->max_delay_ms = max_delay_ms; | 215 stats->max_delay_ms = max_delay_ms; |
201 } | 216 } |
202 | 217 |
203 } // namespace webrtc | 218 } // namespace webrtc |
OLD | NEW |