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

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

Issue 2340763002: Split RtcpReceiver::HandleSenderReceiverReport into two functions (Closed)
Patch Set: Comments fixes Created 4 years, 3 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') | no next file » | 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 71cf86f3ec872cbfc9380cfcf6b1fb128a583d9e..0192d624dd69da21f875c96b52391867413d131b 100644
--- a/webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc
@@ -299,8 +299,10 @@ int32_t RTCPReceiver::IncomingRTCPPacket(
// next top level packet.
switch (pktType) {
case RTCPPacketTypes::kSr:
+ HandleSenderReport(*rtcpParser, rtcpPacketInformation);
+ break;
case RTCPPacketTypes::kRr:
- HandleSenderReceiverReport(*rtcpParser, rtcpPacketInformation);
+ HandleReceiverReport(*rtcpParser, rtcpPacketInformation);
break;
case RTCPPacketTypes::kSdes:
HandleSDES(*rtcpParser, rtcpPacketInformation);
@@ -374,24 +376,18 @@ int32_t RTCPReceiver::IncomingRTCPPacket(
return 0;
}
-void RTCPReceiver::HandleSenderReceiverReport(
+void RTCPReceiver::HandleSenderReport(
RTCPUtility::RTCPParserV2& rtcpParser,
RTCPPacketInformation& rtcpPacketInformation) {
RTCPUtility::RTCPPacketTypes rtcpPacketType = rtcpParser.PacketType();
const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
- assert((rtcpPacketType == RTCPPacketTypes::kRr) ||
- (rtcpPacketType == RTCPPacketTypes::kSr));
+ RTC_DCHECK(rtcpPacketType == RTCPPacketTypes::kSr);
// SR.SenderSSRC
// The synchronization source identifier for the originator of this SR packet
- // rtcpPacket.RR.SenderSSRC
- // The source of the packet sender, same as of SR? or is this a CE?
-
- const uint32_t remoteSSRC = (rtcpPacketType == RTCPPacketTypes::kRr)
- ? rtcpPacket.RR.SenderSSRC
- : rtcpPacket.SR.SenderSSRC;
+ const uint32_t remoteSSRC = rtcpPacket.SR.SenderSSRC;
rtcpPacketInformation.remoteSSRC = remoteSSRC;
@@ -401,38 +397,29 @@ void RTCPReceiver::HandleSenderReceiverReport(
return;
}
- if (rtcpPacketType == RTCPPacketTypes::kSr) {
- TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "SR",
- "remote_ssrc", remoteSSRC, "ssrc", main_ssrc_);
-
- if (_remoteSSRC ==
- remoteSSRC) // have I received RTP packets from this party
- {
- // only signal that we have received a SR when we accept one
- rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpSr;
+ TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "SR",
+ "remote_ssrc", remoteSSRC, "ssrc", main_ssrc_);
- rtcpPacketInformation.ntp_secs = rtcpPacket.SR.NTPMostSignificant;
- rtcpPacketInformation.ntp_frac = rtcpPacket.SR.NTPLeastSignificant;
- rtcpPacketInformation.rtp_timestamp = rtcpPacket.SR.RTPTimestamp;
+ // Have I received RTP packets from this party?
+ if (_remoteSSRC == remoteSSRC) {
+ // Only signal that we have received a SR when we accept one.
+ rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpSr;
- // We will only store the send report from one source, but
- // we will store all the receive block
+ rtcpPacketInformation.ntp_secs = rtcpPacket.SR.NTPMostSignificant;
+ rtcpPacketInformation.ntp_frac = rtcpPacket.SR.NTPLeastSignificant;
+ rtcpPacketInformation.rtp_timestamp = rtcpPacket.SR.RTPTimestamp;
- // Save the NTP time of this report
- _remoteSenderInfo.NTPseconds = rtcpPacket.SR.NTPMostSignificant;
- _remoteSenderInfo.NTPfraction = rtcpPacket.SR.NTPLeastSignificant;
- _remoteSenderInfo.RTPtimeStamp = rtcpPacket.SR.RTPTimestamp;
- _remoteSenderInfo.sendPacketCount = rtcpPacket.SR.SenderPacketCount;
- _remoteSenderInfo.sendOctetCount = rtcpPacket.SR.SenderOctetCount;
+ // Save the NTP time of this report.
+ _remoteSenderInfo.NTPseconds = rtcpPacket.SR.NTPMostSignificant;
+ _remoteSenderInfo.NTPfraction = rtcpPacket.SR.NTPLeastSignificant;
+ _remoteSenderInfo.RTPtimeStamp = rtcpPacket.SR.RTPTimestamp;
+ _remoteSenderInfo.sendPacketCount = rtcpPacket.SR.SenderPacketCount;
+ _remoteSenderInfo.sendOctetCount = rtcpPacket.SR.SenderOctetCount;
- _clock->CurrentNtp(_lastReceivedSRNTPsecs, _lastReceivedSRNTPfrac);
- } else {
- rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpRr;
- }
+ _clock->CurrentNtp(_lastReceivedSRNTPsecs, _lastReceivedSRNTPfrac);
} else {
- TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RR",
- "remote_ssrc", remoteSSRC, "ssrc", main_ssrc_);
-
+ // We will only store the send report from one source, but
+ // we will store all the receive blocks.
rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpRr;
}
// Update that this remote is alive.
@@ -446,6 +433,42 @@ void RTCPReceiver::HandleSenderReceiverReport(
}
}
+void RTCPReceiver::HandleReceiverReport(
+ RTCPUtility::RTCPParserV2& rtcpParser,
+ RTCPPacketInformation& rtcpPacketInformation) {
+ RTCPUtility::RTCPPacketTypes rtcpPacketType = rtcpParser.PacketType();
+ const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
+
+ RTC_DCHECK(rtcpPacketType == RTCPPacketTypes::kRr);
+
+ // rtcpPacket.RR.SenderSSRC
+ // The source of the packet sender, same as of SR? or is this a CE?
+ const uint32_t remoteSSRC = rtcpPacket.RR.SenderSSRC;
+
+ rtcpPacketInformation.remoteSSRC = remoteSSRC;
+
+ RTCPReceiveInformation* ptrReceiveInfo = CreateReceiveInformation(remoteSSRC);
+ if (!ptrReceiveInfo) {
+ rtcpParser.Iterate();
+ return;
+ }
+
+ TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RR",
+ "remote_ssrc", remoteSSRC, "ssrc", main_ssrc_);
+
+ rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpRr;
+
+ // Update that this remote is alive.
+ ptrReceiveInfo->last_time_received_ms = _clock->TimeInMilliseconds();
+
+ rtcpPacketType = rtcpParser.Iterate();
+
+ while (rtcpPacketType == RTCPPacketTypes::kReportBlockItem) {
+ HandleReportBlock(rtcpPacket, rtcpPacketInformation, remoteSSRC);
+ rtcpPacketType = rtcpParser.Iterate();
+ }
+}
+
void RTCPReceiver::HandleReportBlock(
const RTCPUtility::RTCPPacket& rtcpPacket,
RTCPPacketInformation& rtcpPacketInformation,
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_receiver.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698