Index: webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc |
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc b/webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc |
index 3affb318aa70428e2a20489abf14d1cffdd3f397..378ef130d1a27811137462ace01ece5ca2fe4e19 100644 |
--- a/webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc |
+++ b/webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc |
@@ -31,6 +31,7 @@ |
RTPSenderVideo::RTPSenderVideo(Clock* clock, RTPSenderInterface* rtpSender) |
: _rtpSender(*rtpSender), |
+ clock_(clock), |
_videoType(kRtpVideoGeneric), |
_retransmissionSettings(kRetransmitBaseLayer), |
// Generic FEC |
@@ -41,8 +42,8 @@ |
delta_fec_params_(), |
key_fec_params_(), |
producer_fec_(&fec_), |
- _fecOverheadRate(clock, NULL), |
- _videoBitrate(clock, NULL) { |
+ fec_bitrate_(1000, RateStatistics::kBpsScale), |
+ video_bitrate_(1000, RateStatistics::kBpsScale) { |
memset(&delta_fec_params_, 0, sizeof(delta_fec_params_)); |
memset(&key_fec_params_, 0, sizeof(key_fec_params_)); |
delta_fec_params_.max_fec_frames = key_fec_params_.max_fec_frames = 1; |
@@ -95,7 +96,9 @@ |
if (_rtpSender.SendToNetwork(data_buffer, payload_length, rtp_header_length, |
capture_time_ms, storage, |
RtpPacketSender::kLowPriority) == 0) { |
- _videoBitrate.Update(payload_length + rtp_header_length); |
+ rtc::CritScope cs(&stats_crit_); |
+ video_bitrate_.Update(payload_length + rtp_header_length, |
+ clock_->TimeInMilliseconds()); |
TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), |
"Video::PacketNormal", "timestamp", capture_timestamp, |
"seqnum", seq_num); |
@@ -141,7 +144,8 @@ |
red_packet->data(), red_packet->length() - rtp_header_length, |
rtp_header_length, capture_time_ms, media_packet_storage, |
RtpPacketSender::kLowPriority) == 0) { |
- _videoBitrate.Update(red_packet->length()); |
+ rtc::CritScope cs(&stats_crit_); |
+ video_bitrate_.Update(red_packet->length(), clock_->TimeInMilliseconds()); |
TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), |
"Video::PacketRed", "timestamp", capture_timestamp, |
"seqnum", media_seq_num); |
@@ -153,7 +157,8 @@ |
fec_packet->data(), fec_packet->length() - rtp_header_length, |
rtp_header_length, capture_time_ms, fec_storage, |
RtpPacketSender::kLowPriority) == 0) { |
- _fecOverheadRate.Update(fec_packet->length()); |
+ rtc::CritScope cs(&stats_crit_); |
+ fec_bitrate_.Update(fec_packet->length(), clock_->TimeInMilliseconds()); |
TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), |
"Video::PacketFec", "timestamp", capture_timestamp, |
"seqnum", next_fec_sequence_number); |
@@ -337,17 +342,14 @@ |
return 0; |
} |
-void RTPSenderVideo::ProcessBitrate() { |
- _videoBitrate.Process(); |
- _fecOverheadRate.Process(); |
-} |
- |
uint32_t RTPSenderVideo::VideoBitrateSent() const { |
- return _videoBitrate.BitrateLast(); |
+ rtc::CritScope cs(&stats_crit_); |
+ return video_bitrate_.Rate(clock_->TimeInMilliseconds()).value_or(0); |
} |
uint32_t RTPSenderVideo::FecOverheadRate() const { |
- return _fecOverheadRate.BitrateLast(); |
+ rtc::CritScope cs(&stats_crit_); |
+ return fec_bitrate_.Rate(clock_->TimeInMilliseconds()).value_or(0); |
} |
int RTPSenderVideo::SelectiveRetransmissions() const { |