From d69e526440eed24b8b2977130500f7c4e6592be7 Mon Sep 17 00:00:00 2001 From: Danil Chapovalov Date: Tue, 20 Sep 2016 15:48:09 +0200 Subject: [PATCH] Minor cleanups in RTPSender::UpdateRtpStats ssrc taken from packet instead of module removing extra lock removed unneccesary call to clock_ reduced number of lines. BUG=webrtc:5565 R=brandtr@webrtc.org Review URL: https://codereview.webrtc.org/2352023002 . Cr-Commit-Position: refs/heads/master@{#14307} --- webrtc/modules/rtp_rtcp/source/rtp_sender.cc | 24 +++++++------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender.cc b/webrtc/modules/rtp_rtcp/source/rtp_sender.cc index b9d2bb9fff..38069688f2 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_sender.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_sender.cc @@ -828,35 +828,27 @@ bool RTPSender::PrepareAndSendPacket(std::unique_ptr packet, void RTPSender::UpdateRtpStats(const RtpPacketToSend& packet, bool is_rtx, bool is_retransmit) { - StreamDataCounters* counters; - // Get ssrc before taking statistics_crit_ to avoid possible deadlock. - uint32_t ssrc = is_rtx ? RtxSsrc() : SSRC(); int64_t now_ms = clock_->TimeInMilliseconds(); rtc::CritScope lock(&statistics_crit_); - if (is_rtx) { - counters = &rtx_rtp_stats_; - } else { - counters = &rtp_stats_; - } + StreamDataCounters* counters = is_rtx ? &rtx_rtp_stats_ : &rtp_stats_; total_bitrate_sent_.Update(packet.size(), now_ms); - if (counters->first_packet_time_ms == -1) { - counters->first_packet_time_ms = clock_->TimeInMilliseconds(); - } - if (IsFecPacket(packet)) { + if (counters->first_packet_time_ms == -1) + counters->first_packet_time_ms = now_ms; + + if (IsFecPacket(packet)) CountPacket(&counters->fec, packet); - } + if (is_retransmit) { CountPacket(&counters->retransmitted, packet); nack_bitrate_sent_.Update(packet.size(), now_ms); } CountPacket(&counters->transmitted, packet); - if (rtp_stats_callback_) { - rtp_stats_callback_->DataCountersUpdated(*counters, ssrc); - } + if (rtp_stats_callback_) + rtp_stats_callback_->DataCountersUpdated(*counters, packet.Ssrc()); } bool RTPSender::IsFecPacket(const RtpPacketToSend& packet) const {