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

Unified Diff: webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc

Issue 1540383002: [rtp_rtcp] ReportBlockInformation cleaned and moved out of the rtcp_receiver_help. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_receiver.h ('k') | webrtc/modules/rtp_rtcp/source/rtcp_receiver_help.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc
diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc b/webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc
index 0259b73ff4e12fd666fda20d4b986df85d9d22bd..bd57c8fb5de39c7d3806f5fdeda100a5210c09c7 100644
--- a/webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc
@@ -25,9 +25,9 @@
#include "webrtc/system_wrappers/include/ntp_time.h"
namespace webrtc {
+using rtcp::ReportBlockInformation;
using RTCPHelp::RTCPPacketInformation;
using RTCPHelp::RTCPReceiveInformation;
-using RTCPHelp::RTCPReportBlockInformation;
using RTCPUtility::kBtVoipMetric;
using RTCPUtility::RTCPCnameInformation;
using RTCPUtility::RTCPPacketReportBlockItem;
@@ -170,23 +170,23 @@ int32_t RTCPReceiver::RTT(uint32_t remoteSSRC,
int64_t* maxRTT) const {
CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
- RTCPReportBlockInformation* reportBlock =
+ const ReportBlockInformation* report_block =
GetReportBlockInformation(remoteSSRC, main_ssrc_);
- if (reportBlock == NULL) {
+ if (!report_block || !report_block->HasRtt()) {
return -1;
}
if (RTT) {
- *RTT = reportBlock->RTT;
+ *RTT = report_block->LastRttMs();
}
if (avgRTT) {
- *avgRTT = reportBlock->avgRTT;
+ *avgRTT = report_block->AvgRttMs();
}
if (minRTT) {
- *minRTT = reportBlock->minRTT;
+ *minRTT = report_block->MinRttMs();
}
if (maxRTT) {
- *maxRTT = reportBlock->maxRTT;
+ *maxRTT = report_block->MaxRttMs();
}
return 0;
}
@@ -277,7 +277,7 @@ int32_t RTCPReceiver::StatisticsReceived(
const ReportBlockInfoMap* info_map = &(it->second);
ReportBlockInfoMap::const_iterator it_info = info_map->begin();
for (; it_info != info_map->end(); ++it_info) {
- receiveBlocks->push_back(it_info->second->remoteReceiveBlock);
+ receiveBlocks->push_back(it_info->second->LastBlock());
}
}
return 0;
@@ -488,9 +488,9 @@ void RTCPReceiver::HandleReportBlock(
return;
}
- RTCPReportBlockInformation* reportBlock =
- CreateOrGetReportBlockInformation(remoteSSRC,
- rtcpPacket.ReportBlockItem.SSRC);
+ ReportBlockInformation* reportBlock = CreateOrGetReportBlockInformation(
+ remoteSSRC, rtcpPacket.ReportBlockItem.SSRC);
+
if (reportBlock == NULL) {
LOG(LS_WARNING) << "Failed to CreateReportBlockInformation("
<< remoteSSRC << ")";
@@ -499,86 +499,30 @@ void RTCPReceiver::HandleReportBlock(
_lastReceivedRrMs = _clock->TimeInMilliseconds();
const RTCPPacketReportBlockItem& rb = rtcpPacket.ReportBlockItem;
- reportBlock->remoteReceiveBlock.remoteSSRC = remoteSSRC;
- reportBlock->remoteReceiveBlock.sourceSSRC = rb.SSRC;
- reportBlock->remoteReceiveBlock.fractionLost = rb.FractionLost;
- reportBlock->remoteReceiveBlock.cumulativeLost =
- rb.CumulativeNumOfPacketsLost;
if (rb.ExtendedHighestSequenceNumber >
- reportBlock->remoteReceiveBlock.extendedHighSeqNum) {
+ reportBlock->LastBlock().extendedHighSeqNum) {
// We have successfully delivered new RTP packets to the remote side after
// the last RR was sent from the remote side.
_lastIncreasedSequenceNumberMs = _lastReceivedRrMs;
}
- reportBlock->remoteReceiveBlock.extendedHighSeqNum =
- rb.ExtendedHighestSequenceNumber;
- reportBlock->remoteReceiveBlock.jitter = rb.Jitter;
- reportBlock->remoteReceiveBlock.delaySinceLastSR = rb.DelayLastSR;
- reportBlock->remoteReceiveBlock.lastSR = rb.LastSR;
-
- if (rtcpPacket.ReportBlockItem.Jitter > reportBlock->remoteMaxJitter) {
- reportBlock->remoteMaxJitter = rtcpPacket.ReportBlockItem.Jitter;
- }
-
- uint32_t send_time = rtcpPacket.ReportBlockItem.LastSR;
- uint32_t rtt = 0;
-
- if (send_time > 0) {
- uint32_t delay = rtcpPacket.ReportBlockItem.DelayLastSR;
- // Local NTP time.
- uint32_t receive_time = CompactNtp(NtpTime(*_clock));
-
- // RTT in 1/(2^16) seconds.
- uint32_t rtt_ntp = receive_time - delay - send_time;
- // Convert to 1/1000 seconds (milliseconds).
- uint32_t rtt_ms = CompactNtpIntervalToMs(rtt_ntp);
- rtt = std::max<uint32_t>(rtt_ms, 1);
- if (rtt > reportBlock->maxRTT) {
- // Store max RTT.
- reportBlock->maxRTT = rtt;
- }
- if (reportBlock->minRTT == 0) {
- // First RTT.
- reportBlock->minRTT = rtt;
- } else if (rtt < reportBlock->minRTT) {
- // Store min RTT.
- reportBlock->minRTT = rtt;
- }
- // Store last RTT.
- reportBlock->RTT = rtt;
-
- // store average RTT
- if (reportBlock->numAverageCalcs != 0) {
- float ac = static_cast<float>(reportBlock->numAverageCalcs);
- float newAverage =
- ((ac / (ac + 1)) * reportBlock->avgRTT) + ((1 / (ac + 1)) * rtt);
- reportBlock->avgRTT = static_cast<int64_t>(newAverage + 0.5f);
- } else {
- // First RTT.
- reportBlock->avgRTT = rtt;
- }
- reportBlock->numAverageCalcs++;
- }
- TRACE_COUNTER_ID1(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RR_RTT", rb.SSRC,
- rtt);
+ reportBlock->AddBlock(rb, remoteSSRC, NtpTime(*_clock));
rtcpPacketInformation.AddReportInfo(*reportBlock);
}
-RTCPReportBlockInformation* RTCPReceiver::CreateOrGetReportBlockInformation(
+ReportBlockInformation* RTCPReceiver::CreateOrGetReportBlockInformation(
uint32_t remote_ssrc,
uint32_t source_ssrc) {
- RTCPReportBlockInformation* info =
- GetReportBlockInformation(remote_ssrc, source_ssrc);
- if (info == NULL) {
- info = new RTCPReportBlockInformation;
- _receivedReportBlockMap[source_ssrc][remote_ssrc] = info;
+ ReportBlockInformation** info =
+ &_receivedReportBlockMap[source_ssrc][remote_ssrc];
+ if (!*info) {
+ *info = new ReportBlockInformation;
}
- return info;
+ return *info;
}
-RTCPReportBlockInformation* RTCPReceiver::GetReportBlockInformation(
+const ReportBlockInformation* RTCPReceiver::GetReportBlockInformation(
uint32_t remote_ssrc,
uint32_t source_ssrc) const {
ReportBlockMap::const_iterator it = _receivedReportBlockMap.find(source_ssrc);
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_receiver.h ('k') | webrtc/modules/rtp_rtcp/source/rtcp_receiver_help.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698