Index: webrtc/video/send_statistics_proxy.cc |
diff --git a/webrtc/video/send_statistics_proxy.cc b/webrtc/video/send_statistics_proxy.cc |
index 57189f3175b338e8168ad9006982026fab3726d7..3dea7b9aa84da768a5cc0b30474d79d8874debc6 100644 |
--- a/webrtc/video/send_statistics_proxy.cc |
+++ b/webrtc/video/send_statistics_proxy.cc |
@@ -55,81 +55,74 @@ const int SendStatisticsProxy::kStatsTimeoutMs = 5000; |
SendStatisticsProxy::SendStatisticsProxy(Clock* clock, |
const VideoSendStream::Config& config) |
- : clock_(clock), |
- config_(config), |
- input_frame_rate_tracker_(100u, 10u), |
- sent_frame_rate_tracker_(100u, 10u), |
- last_sent_frame_timestamp_(0), |
- max_sent_width_per_timestamp_(0), |
- max_sent_height_per_timestamp_(0) { |
+ : clock_(clock), config_(config), codec_mode_(kRealtimeVideo) { |
UpdateCodecTypeHistogram(config_.encoder_settings.payload_name); |
} |
SendStatisticsProxy::~SendStatisticsProxy() { |
- UpdateHistograms(); |
+ stats_set_->UpdateHistograms(); |
} |
-void SendStatisticsProxy::UpdateHistograms() { |
+void SendStatisticsProxy::StatsSet::UpdateHistograms() { |
int input_fps = |
pbos-webrtc
2015/11/12 10:38:19
This one should probably also have kMinRequiredSam
sprang_webrtc
2015/11/12 11:01:25
Done.
|
round(input_frame_rate_tracker_.ComputeTotalRate()); |
if (input_fps > 0) |
- RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.InputFramesPerSecond", input_fps); |
+ RTC_HISTOGRAM_COUNTS_100(kPrefix + "InputFramesPerSecond", input_fps); |
int sent_fps = |
round(sent_frame_rate_tracker_.ComputeTotalRate()); |
if (sent_fps > 0) |
- RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.SentFramesPerSecond", sent_fps); |
+ RTC_HISTOGRAM_COUNTS_100(kPrefix + "SentFramesPerSecond", sent_fps); |
const int kMinRequiredSamples = 200; |
int in_width = input_width_counter_.Avg(kMinRequiredSamples); |
int in_height = input_height_counter_.Avg(kMinRequiredSamples); |
if (in_width != -1) { |
- RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.InputWidthInPixels", in_width); |
- RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.InputHeightInPixels", in_height); |
+ RTC_HISTOGRAM_COUNTS_10000(kPrefix + "InputWidthInPixels", in_width); |
+ RTC_HISTOGRAM_COUNTS_10000(kPrefix + "InputHeightInPixels", in_height); |
} |
int sent_width = sent_width_counter_.Avg(kMinRequiredSamples); |
int sent_height = sent_height_counter_.Avg(kMinRequiredSamples); |
if (sent_width != -1) { |
- RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.SentWidthInPixels", sent_width); |
- RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.SentHeightInPixels", sent_height); |
+ RTC_HISTOGRAM_COUNTS_10000(kPrefix + "SentWidthInPixels", sent_width); |
+ RTC_HISTOGRAM_COUNTS_10000(kPrefix + "SentHeightInPixels", sent_height); |
} |
int encode_ms = encode_time_counter_.Avg(kMinRequiredSamples); |
if (encode_ms != -1) |
- RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.EncodeTimeInMs", encode_ms); |
+ RTC_HISTOGRAM_COUNTS_1000(kPrefix + "EncodeTimeInMs", encode_ms); |
int key_frames_permille = key_frame_counter_.Permille(kMinRequiredSamples); |
if (key_frames_permille != -1) { |
- RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.KeyFramesSentInPermille", |
- key_frames_permille); |
+ RTC_HISTOGRAM_COUNTS_1000(kPrefix + "KeyFramesSentInPermille", |
+ key_frames_permille); |
} |
int quality_limited = |
quality_limited_frame_counter_.Percent(kMinRequiredSamples); |
if (quality_limited != -1) { |
- RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.QualityLimitedResolutionInPercent", |
+ RTC_HISTOGRAM_PERCENTAGE(kPrefix + "QualityLimitedResolutionInPercent", |
quality_limited); |
} |
int downscales = quality_downscales_counter_.Avg(kMinRequiredSamples); |
if (downscales != -1) { |
- RTC_HISTOGRAM_ENUMERATION("WebRTC.Video.QualityLimitedResolutionDownscales", |
+ RTC_HISTOGRAM_ENUMERATION(kPrefix + "QualityLimitedResolutionDownscales", |
downscales, 20); |
} |
int bw_limited = bw_limited_frame_counter_.Percent(kMinRequiredSamples); |
if (bw_limited != -1) { |
- RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.BandwidthLimitedResolutionInPercent", |
- bw_limited); |
+ RTC_HISTOGRAM_PERCENTAGE(kPrefix + "BandwidthLimitedResolutionInPercent", |
+ bw_limited); |
} |
int num_disabled = bw_resolutions_disabled_counter_.Avg(kMinRequiredSamples); |
if (num_disabled != -1) { |
- RTC_HISTOGRAM_ENUMERATION( |
- "WebRTC.Video.BandwidthLimitedResolutionsDisabled", num_disabled, 10); |
+ RTC_HISTOGRAM_ENUMERATION(kPrefix + "BandwidthLimitedResolutionsDisabled", |
+ num_disabled, 10); |
} |
int delay_ms = delay_counter_.Avg(kMinRequiredSamples); |
if (delay_ms != -1) |
- RTC_HISTOGRAM_COUNTS_100000("WebRTC.Video.SendSideDelayInMs", delay_ms); |
+ RTC_HISTOGRAM_COUNTS_100000(kPrefix + "SendSideDelayInMs", delay_ms); |
int max_delay_ms = max_delay_counter_.Avg(kMinRequiredSamples); |
if (max_delay_ms != -1) { |
- RTC_HISTOGRAM_COUNTS_100000( |
- "WebRTC.Video.SendSideDelayMaxInMs", max_delay_ms); |
+ RTC_HISTOGRAM_COUNTS_100000(kPrefix + "SendSideDelayMaxInMs", max_delay_ms); |
} |
} |
@@ -156,7 +149,7 @@ VideoSendStream::Stats SendStatisticsProxy::GetStats() { |
rtc::CritScope lock(&crit_); |
PurgeOldStats(); |
stats_.input_frame_rate = |
- round(input_frame_rate_tracker_.ComputeRate()); |
+ round(stats_set_->input_frame_rate_tracker_.ComputeRate()); |
return stats_; |
} |
@@ -166,7 +159,7 @@ void SendStatisticsProxy::PurgeOldStats() { |
stats_.substreams.begin(); |
it != stats_.substreams.end(); ++it) { |
uint32_t ssrc = it->first; |
- if (update_times_[ssrc].resolution_update_ms <= old_stats_ms) { |
+ if (stats_set_->update_times_[ssrc].resolution_update_ms <= old_stats_ms) { |
it->second.width = 0; |
it->second.height = 0; |
} |
@@ -227,58 +220,62 @@ void SendStatisticsProxy::OnSendEncodedImage( |
stats->width = encoded_image._encodedWidth; |
stats->height = encoded_image._encodedHeight; |
- update_times_[ssrc].resolution_update_ms = clock_->TimeInMilliseconds(); |
+ stats_set_->update_times_[ssrc].resolution_update_ms = |
+ clock_->TimeInMilliseconds(); |
- key_frame_counter_.Add(encoded_image._frameType == kVideoFrameKey); |
+ stats_set_->key_frame_counter_.Add(encoded_image._frameType == |
+ kVideoFrameKey); |
if (encoded_image.adapt_reason_.quality_resolution_downscales != -1) { |
bool downscaled = |
encoded_image.adapt_reason_.quality_resolution_downscales > 0; |
- quality_limited_frame_counter_.Add(downscaled); |
+ stats_set_->quality_limited_frame_counter_.Add(downscaled); |
if (downscaled) { |
- quality_downscales_counter_.Add( |
+ stats_set_->quality_downscales_counter_.Add( |
encoded_image.adapt_reason_.quality_resolution_downscales); |
} |
} |
if (encoded_image.adapt_reason_.bw_resolutions_disabled != -1) { |
bool bw_limited = encoded_image.adapt_reason_.bw_resolutions_disabled > 0; |
- bw_limited_frame_counter_.Add(bw_limited); |
+ stats_set_->bw_limited_frame_counter_.Add(bw_limited); |
if (bw_limited) { |
- bw_resolutions_disabled_counter_.Add( |
- encoded_image.adapt_reason_.bw_resolutions_disabled); |
+ stats_set_->bw_resolutions_disabled_counter_.Add( |
+ encoded_image.adapt_reason_.bw_resolutions_disabled); |
} |
} |
// TODO(asapersson): This is incorrect if simulcast layers are encoded on |
// different threads and there is no guarantee that one frame of all layers |
// are encoded before the next start. |
- if (last_sent_frame_timestamp_ > 0 && |
- encoded_image._timeStamp != last_sent_frame_timestamp_) { |
- sent_frame_rate_tracker_.AddSamples(1); |
- sent_width_counter_.Add(max_sent_width_per_timestamp_); |
- sent_height_counter_.Add(max_sent_height_per_timestamp_); |
- max_sent_width_per_timestamp_ = 0; |
- max_sent_height_per_timestamp_ = 0; |
+ if (stats_set_->last_sent_frame_timestamp_ > 0 && |
+ encoded_image._timeStamp != stats_set_->last_sent_frame_timestamp_) { |
+ stats_set_->sent_frame_rate_tracker_.AddSamples(1); |
+ stats_set_->sent_width_counter_.Add( |
+ stats_set_->max_sent_width_per_timestamp_); |
+ stats_set_->sent_height_counter_.Add( |
+ stats_set_->max_sent_height_per_timestamp_); |
+ stats_set_->max_sent_width_per_timestamp_ = 0; |
+ stats_set_->max_sent_height_per_timestamp_ = 0; |
} |
- last_sent_frame_timestamp_ = encoded_image._timeStamp; |
- max_sent_width_per_timestamp_ = |
- std::max(max_sent_width_per_timestamp_, |
+ stats_set_->last_sent_frame_timestamp_ = encoded_image._timeStamp; |
+ stats_set_->max_sent_width_per_timestamp_ = |
+ std::max(stats_set_->max_sent_width_per_timestamp_, |
static_cast<int>(encoded_image._encodedWidth)); |
- max_sent_height_per_timestamp_ = |
- std::max(max_sent_height_per_timestamp_, |
+ stats_set_->max_sent_height_per_timestamp_ = |
+ std::max(stats_set_->max_sent_height_per_timestamp_, |
static_cast<int>(encoded_image._encodedHeight)); |
} |
void SendStatisticsProxy::OnIncomingFrame(int width, int height) { |
rtc::CritScope lock(&crit_); |
- input_frame_rate_tracker_.AddSamples(1); |
- input_width_counter_.Add(width); |
- input_height_counter_.Add(height); |
+ stats_set_->input_frame_rate_tracker_.AddSamples(1); |
+ stats_set_->input_width_counter_.Add(width); |
+ stats_set_->input_height_counter_.Add(height); |
} |
void SendStatisticsProxy::OnEncodedFrame(int encode_time_ms) { |
rtc::CritScope lock(&crit_); |
- encode_time_counter_.Add(encode_time_ms); |
+ stats_set_->encode_time_counter_.Add(encode_time_ms); |
} |
void SendStatisticsProxy::RtcpPacketTypesCounterUpdated( |
@@ -348,8 +345,8 @@ void SendStatisticsProxy::SendSideDelayUpdated(int avg_delay_ms, |
stats->avg_delay_ms = avg_delay_ms; |
stats->max_delay_ms = max_delay_ms; |
- delay_counter_.Add(avg_delay_ms); |
- max_delay_counter_.Add(max_delay_ms); |
+ stats_set_->delay_counter_.Add(avg_delay_ms); |
+ stats_set_->max_delay_counter_.Add(max_delay_ms); |
} |
void SendStatisticsProxy::SampleCounter::Add(int sample) { |
@@ -386,4 +383,15 @@ int SendStatisticsProxy::BoolSampleCounter::Fraction( |
return static_cast<int>((sum * multiplier / num_samples) + 0.5f); |
} |
+void SendStatisticsProxy::SetCodecMode(VideoCodecMode mode) { |
+ rtc::CritScope lock(&crit_); |
+ if (codec_mode_ != mode) { |
+ stats_set_->UpdateHistograms(); |
+ stats_set_.reset(new StatsSet(mode == kRealtimeVideo |
+ ? "WebRTC.Video." |
+ : "WebRTC.Video.Screenshare.")); |
+ codec_mode_ = mode; |
+ } |
+} |
+ |
} // namespace webrtc |