| Index: webrtc/modules/rtp_rtcp/source/rtcp_sender.cc
|
| diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc b/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc
|
| index 93d7aa3c1f1e76f45fe21a34e74006bbc2e38e14..dd7ba3350ed292588ec7269de5638a1e905c3be6 100644
|
| --- a/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc
|
| +++ b/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc
|
| @@ -139,7 +139,7 @@ class RTCPSender::RtcpContext {
|
| RTCPSender::RTCPSender(
|
| bool audio,
|
| Clock* clock,
|
| - ReceiveStatistics* receive_statistics,
|
| + ReceiveStatisticsReporter* receive_statistics,
|
| RtcpPacketTypeCounterObserver* packet_type_counter_observer,
|
| RtcEventLog* event_log,
|
| Transport* outgoing_transport)
|
| @@ -455,10 +455,7 @@ std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildSR(const RtcpContext& ctx) {
|
| report->SetRtpTimestamp(rtp_timestamp);
|
| report->SetPacketCount(ctx.feedback_state_.packets_sent);
|
| report->SetOctetCount(ctx.feedback_state_.media_bytes_sent);
|
| -
|
| - for (auto it : report_blocks_)
|
| - report->AddReportBlock(it.second);
|
| -
|
| + report->SetReportBlocks(std::move(report_blocks_));
|
| report_blocks_.clear();
|
|
|
| return std::unique_ptr<rtcp::RtcpPacket>(report);
|
| @@ -481,9 +478,7 @@ std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildSDES(
|
| std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildRR(const RtcpContext& ctx) {
|
| rtcp::ReceiverReport* report = new rtcp::ReceiverReport();
|
| report->SetSenderSsrc(ssrc_);
|
| - for (auto it : report_blocks_)
|
| - report->AddReportBlock(it.second);
|
| -
|
| + report->SetReportBlocks(std::move(report_blocks_));
|
| report_blocks_.clear();
|
| return std::unique_ptr<rtcp::RtcpPacket>(report);
|
| }
|
| @@ -830,59 +825,32 @@ void RTCPSender::PrepareReport(const FeedbackState& feedback_state) {
|
| random_.Rand(minIntervalMs * 1 / 2, minIntervalMs * 3 / 2);
|
| next_time_to_send_rtcp_ = clock_->TimeInMilliseconds() + timeToNext;
|
|
|
| - if (receive_statistics_) {
|
| - StatisticianMap statisticians =
|
| - receive_statistics_->GetActiveStatisticians();
|
| - RTC_DCHECK(report_blocks_.empty());
|
| - for (auto& it : statisticians) {
|
| - AddReportBlock(feedback_state, it.first, it.second);
|
| - }
|
| - }
|
| - }
|
| -}
|
| -
|
| -bool RTCPSender::AddReportBlock(const FeedbackState& feedback_state,
|
| - uint32_t ssrc,
|
| - StreamStatistician* statistician) {
|
| - // Do we have receive statistics to send?
|
| - RtcpStatistics stats;
|
| - if (!statistician->GetStatistics(&stats, true))
|
| - return false;
|
| -
|
| - if (report_blocks_.size() >= RTCP_MAX_REPORT_BLOCKS) {
|
| - LOG(LS_WARNING) << "Too many report blocks.";
|
| - return false;
|
| - }
|
| - RTC_DCHECK(report_blocks_.find(ssrc) == report_blocks_.end());
|
| - rtcp::ReportBlock* block = &report_blocks_[ssrc];
|
| - block->SetMediaSsrc(ssrc);
|
| - block->SetFractionLost(stats.fraction_lost);
|
| - if (!block->SetCumulativeLost(stats.cumulative_lost)) {
|
| - report_blocks_.erase(ssrc);
|
| - LOG(LS_WARNING) << "Cumulative lost is oversized.";
|
| - return false;
|
| - }
|
| - block->SetExtHighestSeqNum(stats.extended_max_sequence_number);
|
| - block->SetJitter(stats.jitter);
|
| - block->SetLastSr(feedback_state.remote_sr);
|
| -
|
| - // TODO(sprang): Do we really need separate time stamps for each report?
|
| - // Get our NTP as late as possible to avoid a race.
|
| - NtpTime ntp = clock_->CurrentNtpTime();
|
| -
|
| - // Delay since last received report.
|
| - if ((feedback_state.last_rr_ntp_secs != 0) ||
|
| - (feedback_state.last_rr_ntp_frac != 0)) {
|
| - // Get the 16 lowest bits of seconds and the 16 highest bits of fractions.
|
| + if (!receive_statistics_)
|
| + return;
|
| + RTC_DCHECK(report_blocks_.empty());
|
| + report_blocks_ = receive_statistics_->GetActiveStatistics();
|
| + if (report_blocks_.size() > RTCP_MAX_REPORT_BLOCKS)
|
| + report_blocks_.resize(RTCP_MAX_REPORT_BLOCKS);
|
| +
|
| + if (report_blocks_.empty())
|
| + return;
|
| + if (feedback_state.last_rr_ntp_secs == 0 &&
|
| + feedback_state.last_rr_ntp_frac == 0)
|
| + return;
|
| + NtpTime ntp = clock_->CurrentNtpTime();
|
| + // Delay since last received report.
|
| uint32_t now = CompactNtp(ntp);
|
|
|
| - uint32_t receiveTime = feedback_state.last_rr_ntp_secs & 0x0000FFFF;
|
| - receiveTime <<= 16;
|
| - receiveTime += (feedback_state.last_rr_ntp_frac & 0xffff0000) >> 16;
|
| + uint32_t receive_time = feedback_state.last_rr_ntp_secs & 0x0000FFFF;
|
| + receive_time <<= 16;
|
| + receive_time += (feedback_state.last_rr_ntp_frac & 0xffff0000) >> 16;
|
|
|
| - block->SetDelayLastSr(now - receiveTime);
|
| + uint32_t delay_last_sr = now - receive_time;
|
| + for (auto& rb : report_blocks_) {
|
| + rb.SetLastSr(feedback_state.remote_sr);
|
| + rb.SetDelayLastSr(delay_last_sr);
|
| + }
|
| }
|
| - return true;
|
| }
|
|
|
| void RTCPSender::SetCsrcs(const std::vector<uint32_t>& csrcs) {
|
|
|