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

Unified Diff: webrtc/video/send_statistics_proxy.h

Issue 1478253002: Add histogram stats for send delay for a sent video stream. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/video/send_statistics_proxy.h
diff --git a/webrtc/video/send_statistics_proxy.h b/webrtc/video/send_statistics_proxy.h
index bb0372aec18542597c73bd49d87f78fb3277b1b2..c99b6b17949f436d141eb99facaf04b104c0033c 100644
--- a/webrtc/video/send_statistics_proxy.h
+++ b/webrtc/video/send_statistics_proxy.h
@@ -37,7 +37,8 @@ class SendStatisticsProxy : public CpuOveruseMetricsObserver,
public BitrateStatisticsObserver,
public FrameCountObserver,
public VideoEncoderRateObserver,
- public SendSideDelayObserver {
+ public SendSideDelayObserver,
+ public SendPacketObserver {
public:
static const int kStatsTimeoutMs;
@@ -69,6 +70,9 @@ class SendStatisticsProxy : public CpuOveruseMetricsObserver,
void OnEncodedFrameTimeMeasured(int encode_time_ms,
const CpuOveruseMetrics& metrics) override;
+ // Called when a packet is sent (leaving socket).
+ bool OnSentPacket(int packet_id);
+
protected:
// From RtcpStatisticsCallback.
void StatisticsUpdated(const RtcpStatistics& statistics,
@@ -95,7 +99,30 @@ class SendStatisticsProxy : public CpuOveruseMetricsObserver,
int max_delay_ms,
uint32_t ssrc) override;
+ // From SendPacketObserver.
+ // Called when a packet is sent to the transport.
+ void OnSendPacket(uint16_t packet_id,
+ int64_t capture_time_ms,
+ uint32_t ssrc) override;
+
private:
+ // Map holding sent packets (mapped by sequence number).
+ struct SequenceNumberOlderThan {
+ bool operator()(uint16_t seq1, uint16_t seq2) const {
+ return IsNewerSequenceNumber(seq2, seq1);
+ }
+ };
+ struct Packet {
+ Packet(uint32_t ssrc, int64_t capture_time_ms, int64_t send_time_ms)
+ : ssrc(ssrc),
+ capture_time_ms(capture_time_ms),
+ send_time_ms(send_time_ms) {}
+ uint32_t ssrc;
+ int64_t capture_time_ms;
+ int64_t send_time_ms;
+ };
+ typedef std::map<uint16_t, Packet, SequenceNumberOlderThan> PacketMap;
+
class SampleCounter {
public:
SampleCounter() : sum(0), num_samples(0) {}
@@ -132,6 +159,8 @@ class SendStatisticsProxy : public CpuOveruseMetricsObserver,
void PurgeOldStats() EXCLUSIVE_LOCKS_REQUIRED(crit_);
VideoSendStream::StreamStats* GetStatsEntry(uint32_t ssrc)
EXCLUSIVE_LOCKS_REQUIRED(crit_);
+ void RemoveOld(int64_t now, PacketMap* packets)
+ EXCLUSIVE_LOCKS_REQUIRED(crit_);
Clock* const clock_;
const VideoSendStream::Config config_;
@@ -142,6 +171,11 @@ class SendStatisticsProxy : public CpuOveruseMetricsObserver,
std::map<uint32_t, StatsUpdateTimes> update_times_ GUARDED_BY(crit_);
rtc::ExpFilter encode_time_ GUARDED_BY(crit_);
+ // Send delay stats.
+ PacketMap packets_ GUARDED_BY(crit_);
+ size_t num_old_packets_;
+ size_t num_skipped_packets_;
+
// Contains stats used for UMA histograms. These stats will be reset if
// content type changes between real-time video and screenshare, since these
// will be reported separately.
@@ -178,6 +212,7 @@ class SendStatisticsProxy : public CpuOveruseMetricsObserver,
const VideoSendStream::Stats start_stats_;
std::map<int, QpCounters>
qp_counters_; // QP counters mapped by spatial idx.
+ std::map<uint32_t, SampleCounter> send_delay_counters_; // Mapped by SSRC.
};
std::unique_ptr<UmaSamplesContainer> uma_container_ GUARDED_BY(crit_);

Powered by Google App Engine
This is Rietveld 408576698