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

Side by Side 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 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
(...skipping 19 matching lines...) Expand all
30 30
31 namespace webrtc { 31 namespace webrtc {
32 32
33 class SendStatisticsProxy : public CpuOveruseMetricsObserver, 33 class SendStatisticsProxy : public CpuOveruseMetricsObserver,
34 public RtcpStatisticsCallback, 34 public RtcpStatisticsCallback,
35 public RtcpPacketTypeCounterObserver, 35 public RtcpPacketTypeCounterObserver,
36 public StreamDataCountersCallback, 36 public StreamDataCountersCallback,
37 public BitrateStatisticsObserver, 37 public BitrateStatisticsObserver,
38 public FrameCountObserver, 38 public FrameCountObserver,
39 public VideoEncoderRateObserver, 39 public VideoEncoderRateObserver,
40 public SendSideDelayObserver { 40 public SendSideDelayObserver,
41 public SendPacketObserver {
41 public: 42 public:
42 static const int kStatsTimeoutMs; 43 static const int kStatsTimeoutMs;
43 44
44 SendStatisticsProxy(Clock* clock, 45 SendStatisticsProxy(Clock* clock,
45 const VideoSendStream::Config& config, 46 const VideoSendStream::Config& config,
46 VideoEncoderConfig::ContentType content_type); 47 VideoEncoderConfig::ContentType content_type);
47 virtual ~SendStatisticsProxy(); 48 virtual ~SendStatisticsProxy();
48 49
49 VideoSendStream::Stats GetStats(); 50 VideoSendStream::Stats GetStats();
50 51
(...skipping 11 matching lines...) Expand all
62 // how stats are collected. 63 // how stats are collected.
63 void SetContentType(VideoEncoderConfig::ContentType content_type); 64 void SetContentType(VideoEncoderConfig::ContentType content_type);
64 65
65 // Implements VideoEncoderRateObserver. 66 // Implements VideoEncoderRateObserver.
66 void OnSetRates(uint32_t bitrate_bps, int framerate) override; 67 void OnSetRates(uint32_t bitrate_bps, int framerate) override;
67 68
68 // Implements CpuOveruseMetricsObserver. 69 // Implements CpuOveruseMetricsObserver.
69 void OnEncodedFrameTimeMeasured(int encode_time_ms, 70 void OnEncodedFrameTimeMeasured(int encode_time_ms,
70 const CpuOveruseMetrics& metrics) override; 71 const CpuOveruseMetrics& metrics) override;
71 72
73 // Called when a packet is sent (leaving socket).
74 bool OnSentPacket(int packet_id);
75
72 protected: 76 protected:
73 // From RtcpStatisticsCallback. 77 // From RtcpStatisticsCallback.
74 void StatisticsUpdated(const RtcpStatistics& statistics, 78 void StatisticsUpdated(const RtcpStatistics& statistics,
75 uint32_t ssrc) override; 79 uint32_t ssrc) override;
76 void CNameChanged(const char* cname, uint32_t ssrc) override; 80 void CNameChanged(const char* cname, uint32_t ssrc) override;
77 // From RtcpPacketTypeCounterObserver. 81 // From RtcpPacketTypeCounterObserver.
78 void RtcpPacketTypesCounterUpdated( 82 void RtcpPacketTypesCounterUpdated(
79 uint32_t ssrc, 83 uint32_t ssrc,
80 const RtcpPacketTypeCounter& packet_counter) override; 84 const RtcpPacketTypeCounter& packet_counter) override;
81 // From StreamDataCountersCallback. 85 // From StreamDataCountersCallback.
82 void DataCountersUpdated(const StreamDataCounters& counters, 86 void DataCountersUpdated(const StreamDataCounters& counters,
83 uint32_t ssrc) override; 87 uint32_t ssrc) override;
84 88
85 // From BitrateStatisticsObserver. 89 // From BitrateStatisticsObserver.
86 void Notify(const BitrateStatistics& total_stats, 90 void Notify(const BitrateStatistics& total_stats,
87 const BitrateStatistics& retransmit_stats, 91 const BitrateStatistics& retransmit_stats,
88 uint32_t ssrc) override; 92 uint32_t ssrc) override;
89 93
90 // From FrameCountObserver. 94 // From FrameCountObserver.
91 void FrameCountUpdated(const FrameCounts& frame_counts, 95 void FrameCountUpdated(const FrameCounts& frame_counts,
92 uint32_t ssrc) override; 96 uint32_t ssrc) override;
93 97
94 void SendSideDelayUpdated(int avg_delay_ms, 98 void SendSideDelayUpdated(int avg_delay_ms,
95 int max_delay_ms, 99 int max_delay_ms,
96 uint32_t ssrc) override; 100 uint32_t ssrc) override;
97 101
102 // From SendPacketObserver.
103 // Called when a packet is sent to the transport.
104 void OnSendPacket(uint16_t packet_id,
105 int64_t capture_time_ms,
106 uint32_t ssrc) override;
107
98 private: 108 private:
109 // Map holding sent packets (mapped by sequence number).
110 struct SequenceNumberOlderThan {
111 bool operator()(uint16_t seq1, uint16_t seq2) const {
112 return IsNewerSequenceNumber(seq2, seq1);
113 }
114 };
115 struct Packet {
116 Packet(uint32_t ssrc, int64_t capture_time_ms, int64_t send_time_ms)
117 : ssrc(ssrc),
118 capture_time_ms(capture_time_ms),
119 send_time_ms(send_time_ms) {}
120 uint32_t ssrc;
121 int64_t capture_time_ms;
122 int64_t send_time_ms;
123 };
124 typedef std::map<uint16_t, Packet, SequenceNumberOlderThan> PacketMap;
125
99 class SampleCounter { 126 class SampleCounter {
100 public: 127 public:
101 SampleCounter() : sum(0), num_samples(0) {} 128 SampleCounter() : sum(0), num_samples(0) {}
102 ~SampleCounter() {} 129 ~SampleCounter() {}
103 void Add(int sample); 130 void Add(int sample);
104 int Avg(int min_required_samples) const; 131 int Avg(int min_required_samples) const;
105 132
106 private: 133 private:
107 int sum; 134 int sum;
108 int num_samples; 135 int num_samples;
(...skipping 16 matching lines...) Expand all
125 int64_t resolution_update_ms; 152 int64_t resolution_update_ms;
126 int64_t bitrate_update_ms; 153 int64_t bitrate_update_ms;
127 }; 154 };
128 struct QpCounters { 155 struct QpCounters {
129 SampleCounter vp8; // QP range: 0-127 156 SampleCounter vp8; // QP range: 0-127
130 SampleCounter vp9; // QP range: 0-255 157 SampleCounter vp9; // QP range: 0-255
131 }; 158 };
132 void PurgeOldStats() EXCLUSIVE_LOCKS_REQUIRED(crit_); 159 void PurgeOldStats() EXCLUSIVE_LOCKS_REQUIRED(crit_);
133 VideoSendStream::StreamStats* GetStatsEntry(uint32_t ssrc) 160 VideoSendStream::StreamStats* GetStatsEntry(uint32_t ssrc)
134 EXCLUSIVE_LOCKS_REQUIRED(crit_); 161 EXCLUSIVE_LOCKS_REQUIRED(crit_);
162 void RemoveOld(int64_t now, PacketMap* packets)
163 EXCLUSIVE_LOCKS_REQUIRED(crit_);
135 164
136 Clock* const clock_; 165 Clock* const clock_;
137 const VideoSendStream::Config config_; 166 const VideoSendStream::Config config_;
138 rtc::CriticalSection crit_; 167 rtc::CriticalSection crit_;
139 VideoEncoderConfig::ContentType content_type_ GUARDED_BY(crit_); 168 VideoEncoderConfig::ContentType content_type_ GUARDED_BY(crit_);
140 VideoSendStream::Stats stats_ GUARDED_BY(crit_); 169 VideoSendStream::Stats stats_ GUARDED_BY(crit_);
141 uint32_t last_sent_frame_timestamp_ GUARDED_BY(crit_); 170 uint32_t last_sent_frame_timestamp_ GUARDED_BY(crit_);
142 std::map<uint32_t, StatsUpdateTimes> update_times_ GUARDED_BY(crit_); 171 std::map<uint32_t, StatsUpdateTimes> update_times_ GUARDED_BY(crit_);
143 rtc::ExpFilter encode_time_ GUARDED_BY(crit_); 172 rtc::ExpFilter encode_time_ GUARDED_BY(crit_);
144 173
174 // Send delay stats.
175 PacketMap packets_ GUARDED_BY(crit_);
176 size_t num_old_packets_;
177 size_t num_skipped_packets_;
178
145 // Contains stats used for UMA histograms. These stats will be reset if 179 // Contains stats used for UMA histograms. These stats will be reset if
146 // content type changes between real-time video and screenshare, since these 180 // content type changes between real-time video and screenshare, since these
147 // will be reported separately. 181 // will be reported separately.
148 struct UmaSamplesContainer { 182 struct UmaSamplesContainer {
149 UmaSamplesContainer(const char* prefix, 183 UmaSamplesContainer(const char* prefix,
150 const VideoSendStream::Stats& start_stats, 184 const VideoSendStream::Stats& start_stats,
151 Clock* clock); 185 Clock* clock);
152 ~UmaSamplesContainer(); 186 ~UmaSamplesContainer();
153 187
154 void UpdateHistograms(const VideoSendStream::Config& config, 188 void UpdateHistograms(const VideoSendStream::Config& config,
(...skipping 16 matching lines...) Expand all
171 SampleCounter delay_counter_; 205 SampleCounter delay_counter_;
172 SampleCounter max_delay_counter_; 206 SampleCounter max_delay_counter_;
173 rtc::RateTracker input_frame_rate_tracker_; 207 rtc::RateTracker input_frame_rate_tracker_;
174 rtc::RateTracker sent_frame_rate_tracker_; 208 rtc::RateTracker sent_frame_rate_tracker_;
175 int64_t first_rtcp_stats_time_ms_; 209 int64_t first_rtcp_stats_time_ms_;
176 int64_t first_rtp_stats_time_ms_; 210 int64_t first_rtp_stats_time_ms_;
177 ReportBlockStats report_block_stats_; 211 ReportBlockStats report_block_stats_;
178 const VideoSendStream::Stats start_stats_; 212 const VideoSendStream::Stats start_stats_;
179 std::map<int, QpCounters> 213 std::map<int, QpCounters>
180 qp_counters_; // QP counters mapped by spatial idx. 214 qp_counters_; // QP counters mapped by spatial idx.
215 std::map<uint32_t, SampleCounter> send_delay_counters_; // Mapped by SSRC.
181 }; 216 };
182 217
183 std::unique_ptr<UmaSamplesContainer> uma_container_ GUARDED_BY(crit_); 218 std::unique_ptr<UmaSamplesContainer> uma_container_ GUARDED_BY(crit_);
184 }; 219 };
185 220
186 } // namespace webrtc 221 } // namespace webrtc
187 #endif // WEBRTC_VIDEO_SEND_STATISTICS_PROXY_H_ 222 #endif // WEBRTC_VIDEO_SEND_STATISTICS_PROXY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698