Skip to content

Commit f64fcf6

Browse files
Add receive bitrates to histogram stats:
- total bitrate ("WebRTC.Video.BitrateReceivedInKbps") - media bitrate ("WebRTC.Video.MediaBitrateReceivedInKbps") - rtx bitrate ("WebRTC.Video.RtxBitrateReceivedInKbps") - padding bitrate ("WebRTC.Video.PaddingBitrateReceivedInKbps") BUG=crbug/419657 [email protected], [email protected] Review URL: https://webrtc-codereview.appspot.com/27189005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7756 4adac7df-926f-26a2-2b94-8c16560cd09d
1 parent f72bb66 commit f64fcf6

11 files changed

+85
-1
lines changed

webrtc/common_types.h

+9
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,15 @@ struct StreamDataCounters {
239239
retransmitted_packets(0),
240240
fec_packets(0) {}
241241

242+
void Add(const StreamDataCounters& other) {
243+
bytes += other.bytes;
244+
header_bytes += other.header_bytes;
245+
padding_bytes += other.padding_bytes;
246+
packets += other.packets;
247+
retransmitted_packets += other.retransmitted_packets;
248+
fec_packets += other.fec_packets;
249+
}
250+
242251
// TODO(pbos): Rename bytes -> media_bytes.
243252
size_t bytes; // Payload bytes, excluding RTP headers and padding.
244253
size_t header_bytes; // Number of bytes used by RTP headers.

webrtc/modules/rtp_rtcp/interface/receive_statistics.h

+5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ class StreamStatistician {
2828
virtual bool GetStatistics(RtcpStatistics* statistics, bool reset) = 0;
2929
virtual void GetDataCounters(size_t* bytes_received,
3030
uint32_t* packets_received) const = 0;
31+
32+
// Gets received stream data counters (includes reset counter values).
33+
virtual void GetReceiveStreamDataCounters(
34+
StreamDataCounters* data_counters) const = 0;
35+
3136
virtual uint32_t BitrateReceived() const = 0;
3237

3338
// Resets all statistics.

webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h

+2
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ class RTPPayloadRegistry {
7777

7878
void SetRtxSsrc(uint32_t ssrc);
7979

80+
bool GetRtxSsrc(uint32_t* ssrc) const;
81+
8082
void SetRtxPayloadType(int payload_type);
8183

8284
bool IsRtx(const RTPHeader& header) const;

webrtc/modules/rtp_rtcp/source/receive_statistics_impl.cc

+8
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ void StreamStatisticianImpl::ResetStatistics() {
6363
received_seq_wraps_ = 0;
6464
received_seq_max_ = 0;
6565
received_seq_first_ = 0;
66+
stored_sum_receive_counters_.Add(receive_counters_);
6667
receive_counters_ = StreamDataCounters();
6768
}
6869

@@ -314,6 +315,13 @@ void StreamStatisticianImpl::GetDataCounters(
314315
}
315316
}
316317

318+
void StreamStatisticianImpl::GetReceiveStreamDataCounters(
319+
StreamDataCounters* data_counters) const {
320+
CriticalSectionScoped cs(stream_lock_.get());
321+
*data_counters = receive_counters_;
322+
data_counters->Add(stored_sum_receive_counters_);
323+
}
324+
317325
uint32_t StreamStatisticianImpl::BitrateReceived() const {
318326
CriticalSectionScoped cs(stream_lock_.get());
319327
return incoming_bitrate_.BitrateNow();

webrtc/modules/rtp_rtcp/source/receive_statistics_impl.h

+5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class StreamStatisticianImpl : public StreamStatistician {
3333
virtual bool GetStatistics(RtcpStatistics* statistics, bool reset) OVERRIDE;
3434
virtual void GetDataCounters(size_t* bytes_received,
3535
uint32_t* packets_received) const OVERRIDE;
36+
virtual void GetReceiveStreamDataCounters(
37+
StreamDataCounters* data_counters) const OVERRIDE;
3638
virtual uint32_t BitrateReceived() const OVERRIDE;
3739
virtual void ResetStatistics() OVERRIDE;
3840
virtual bool IsRetransmitOfOldPacket(const RTPHeader& header,
@@ -83,6 +85,9 @@ class StreamStatisticianImpl : public StreamStatistician {
8385
size_t received_packet_overhead_;
8486
StreamDataCounters receive_counters_;
8587

88+
// Stored counter values. Includes sum of reset counter values for the stream.
89+
StreamDataCounters stored_sum_receive_counters_;
90+
8691
// Counter values when we sent the last report.
8792
uint32_t last_report_inorder_packets_;
8893
uint32_t last_report_old_packets_;

webrtc/modules/rtp_rtcp/source/rtp_payload_registry.cc

+6
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,12 @@ void RTPPayloadRegistry::SetRtxSsrc(uint32_t ssrc) {
286286
rtx_ = true;
287287
}
288288

289+
bool RTPPayloadRegistry::GetRtxSsrc(uint32_t* ssrc) const {
290+
CriticalSectionScoped cs(crit_sect_.get());
291+
*ssrc = ssrc_rtx_;
292+
return rtx_;
293+
}
294+
289295
void RTPPayloadRegistry::SetRtxPayloadType(int payload_type) {
290296
CriticalSectionScoped cs(crit_sect_.get());
291297
assert(payload_type >= 0);

webrtc/video/video_send_stream_tests.cc

+2
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ class FakeReceiveStatistics : public NullReceiveStatistics {
252252
*bytes_received = 0;
253253
*packets_received = 0;
254254
}
255+
virtual void GetReceiveStreamDataCounters(
256+
StreamDataCounters* data_counters) const OVERRIDE {}
255257
virtual uint32_t BitrateReceived() const OVERRIDE { return 0; }
256258
virtual void ResetStatistics() OVERRIDE {}
257259
virtual bool IsRetransmitOfOldPacket(const RTPHeader& header,

webrtc/video_engine/vie_channel.cc

+39-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ void ViEChannel::UpdateHistograms() {
258258
rtcp_received.fir_packets / elapsed_minutes);
259259
RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.PliPacketsReceivedPerMinute",
260260
rtcp_received.pli_packets / elapsed_minutes);
261-
} else if (vie_receiver_.GetRemoteSsrc() > 0) {
261+
} else if (vie_receiver_.GetRemoteSsrc() > 0) {
262262
// Get receive stats if we are receiving packets, i.e. there is a remote
263263
// ssrc.
264264
if (rtcp_sent.nack_requests > 0) {
@@ -281,6 +281,26 @@ void ViEChannel::UpdateHistograms() {
281281
0.5f));
282282
}
283283
}
284+
StreamDataCounters data;
285+
StreamDataCounters rtx_data;
286+
GetReceiveStreamDataCounters(&data, &rtx_data);
287+
uint32_t media_bytes = data.bytes;
288+
uint32_t rtx_bytes =
289+
rtx_data.bytes + rtx_data.header_bytes + rtx_data.padding_bytes;
290+
uint32_t total_bytes = data.bytes + data.header_bytes + data.padding_bytes;
291+
total_bytes += rtx_bytes;
292+
uint32_t padding_bytes = data.padding_bytes + rtx_data.padding_bytes;
293+
RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.BitrateReceivedInKbps",
294+
total_bytes * 8 / (elapsed_minutes * 60) / 1000);
295+
RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.MediaBitrateReceivedInKbps",
296+
media_bytes * 8 / (elapsed_minutes * 60) / 1000);
297+
RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.PaddingBitrateReceivedInKbps",
298+
padding_bytes * 8 / (elapsed_minutes * 60) / 1000);
299+
uint32_t ssrc = 0;
300+
if (vie_receiver_.GetRtxSsrc(&ssrc)) {
301+
RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.RtxBitrateReceivedInKbps",
302+
rtx_bytes * 8 / (elapsed_minutes * 60) / 1000);
303+
}
284304
}
285305
}
286306

@@ -1164,6 +1184,24 @@ int32_t ViEChannel::GetRtpStatistics(size_t* bytes_sent,
11641184
return 0;
11651185
}
11661186

1187+
void ViEChannel::GetReceiveStreamDataCounters(
1188+
StreamDataCounters* data,
1189+
StreamDataCounters* rtx_data) const {
1190+
StreamStatistician* statistician = vie_receiver_.GetReceiveStatistics()->
1191+
GetStatistician(vie_receiver_.GetRemoteSsrc());
1192+
if (statistician) {
1193+
statistician->GetReceiveStreamDataCounters(data);
1194+
}
1195+
uint32_t rtx_ssrc = 0;
1196+
if (vie_receiver_.GetRtxSsrc(&rtx_ssrc)) {
1197+
StreamStatistician* statistician =
1198+
vie_receiver_.GetReceiveStatistics()->GetStatistician(rtx_ssrc);
1199+
if (statistician) {
1200+
statistician->GetReceiveStreamDataCounters(rtx_data);
1201+
}
1202+
}
1203+
}
1204+
11671205
void ViEChannel::RegisterSendChannelRtpStatisticsCallback(
11681206
StreamDataCountersCallback* callback) {
11691207
rtp_rtcp_->RegisterSendChannelRtpStatisticsCallback(callback);

webrtc/video_engine/vie_channel.h

+4
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ class ViEChannel
194194
size_t* bytes_received,
195195
uint32_t* packets_received) const;
196196

197+
// Gets received stream data counters.
198+
void GetReceiveStreamDataCounters(StreamDataCounters* data,
199+
StreamDataCounters* rtx_data) const;
200+
197201
// Called on update of RTP statistics.
198202
void RegisterSendChannelRtpStatisticsCallback(
199203
StreamDataCountersCallback* callback);

webrtc/video_engine/vie_receiver.cc

+4
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ void ViEReceiver::SetRtxSsrc(uint32_t ssrc) {
110110
rtp_payload_registry_->SetRtxSsrc(ssrc);
111111
}
112112

113+
bool ViEReceiver::GetRtxSsrc(uint32_t* ssrc) const {
114+
return rtp_payload_registry_->GetRtxSsrc(ssrc);
115+
}
116+
113117
uint32_t ViEReceiver::GetRemoteSsrc() const {
114118
return rtp_receiver_->SSRC();
115119
}

webrtc/video_engine/vie_receiver.h

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class ViEReceiver : public RtpData {
4949
void SetNackStatus(bool enable, int max_nack_reordering_threshold);
5050
void SetRtxPayloadType(int payload_type);
5151
void SetRtxSsrc(uint32_t ssrc);
52+
bool GetRtxSsrc(uint32_t* ssrc) const;
5253

5354
uint32_t GetRemoteSsrc() const;
5455
int GetCsrcs(uint32_t* csrcs) const;

0 commit comments

Comments
 (0)