Index: webrtc/video/send_statistics_proxy.cc |
diff --git a/webrtc/video/send_statistics_proxy.cc b/webrtc/video/send_statistics_proxy.cc |
index 57d38a523b664a0ffcd4d074f80a0f8dd09df422..c0d4902f55cf74c3f4be27389a59fb889fe31b34 100644 |
--- a/webrtc/video/send_statistics_proxy.cc |
+++ b/webrtc/video/send_statistics_proxy.cc |
@@ -23,6 +23,11 @@ namespace webrtc { |
namespace { |
const float kEncodeTimeWeigthFactor = 0.5f; |
+// Packet with a larger delay are removed and excluded from the delay stats. |
+// Set to larger than max histogram delay which is 10000. |
+const int64_t kMaxSentPacketDelayMs = 11000; |
+const size_t kMaxSendPacketMapSize = 2000; |
+ |
// Used by histograms. Values of entries should not be changed. |
enum HistogramCodecType { |
kVideoUnknown = 0, |
@@ -149,6 +154,11 @@ void SendStatisticsProxy::UmaSamplesContainer::UpdateHistograms() { |
RTC_HISTOGRAM_COUNTS_100000(uma_prefix_ + "SendSideDelayMaxInMs", |
max_delay_ms); |
} |
+ for (const auto& it : send_delay_counters_) { |
+ int send_delay_ms = it.second.Avg(kMinRequiredSamples); |
+ if (send_delay_ms != -1) |
+ RTC_HISTOGRAM_COUNTS_10000(uma_prefix_ + "SendDelayInMs", send_delay_ms); |
+ } |
} |
void SendStatisticsProxy::SetContentType( |
@@ -383,6 +393,50 @@ void SendStatisticsProxy::SendSideDelayUpdated(int avg_delay_ms, |
uma_container_->max_delay_counter_.Add(max_delay_ms); |
} |
+void SendStatisticsProxy::OnSendPacket(uint16_t packet_id, |
+ int64_t capture_time_ms, |
+ uint32_t ssrc) { |
+ rtc::CritScope lock(&crit_); |
+ VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); |
+ if (stats == nullptr) |
+ return; |
+ |
+ int64_t now = clock_->TimeInMilliseconds(); |
+ RemoveOld(now, &packets_); |
+ |
+ if (packets_.size() > kMaxSendPacketMapSize) |
+ return; |
+ |
+ packets_.insert( |
+ std::make_pair(packet_id, Packet(ssrc, capture_time_ms, now))); |
+} |
+ |
+bool SendStatisticsProxy::OnSentPacket(int packet_id) { |
+ if (packet_id == -1) |
+ return false; |
+ |
+ rtc::CritScope lock(&crit_); |
+ auto it = packets_.find(packet_id); |
+ if (it == packets_.end()) |
+ return false; |
+ |
+ // TODO(asapersson): Update delay_counter_ here (capture -> sent). |
+ int diff_send = clock_->TimeInMilliseconds() - it->second.send_time_ms_; |
+ uma_container_->send_delay_counters_[it->second.ssrc_].Add(diff_send); |
+ packets_.erase(it); |
+ return true; |
+} |
+ |
+void SendStatisticsProxy::RemoveOld(int64_t now, PacketMap* packets) { |
+ while (!packets->empty()) { |
+ auto it = packets->begin(); |
+ if (now - it->second.capture_time_ms_ < kMaxSentPacketDelayMs) { |
stefan-webrtc
2016/01/18 19:48:25
Feel free to remove {}
åsapersson
2016/04/06 14:52:37
Done.
|
+ break; |
+ } |
+ packets->erase(it); |
+ } |
+} |
+ |
void SendStatisticsProxy::SampleCounter::Add(int sample) { |
sum += sample; |
++num_samples; |