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

Unified Diff: media/cast/net/rtcp/rtcp_utility.cc

Issue 1520613004: cast: Split Rtcp into two for sender and receiver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@timestamp
Patch Set: Rebased Created 5 years 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 | « media/cast/net/rtcp/rtcp_utility.h ('k') | media/cast/net/rtcp/sender_rtcp_session.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cast/net/rtcp/rtcp_utility.cc
diff --git a/media/cast/net/rtcp/rtcp_utility.cc b/media/cast/net/rtcp/rtcp_utility.cc
index 4febe8c61fb88881e214cb09b15033a138f3d55b..74af3a04fb45ab8b3998c185d80cafdcda4e49a4 100644
--- a/media/cast/net/rtcp/rtcp_utility.cc
+++ b/media/cast/net/rtcp/rtcp_utility.cc
@@ -24,7 +24,8 @@ const int64_t kUnixEpochInNtpSeconds = INT64_C(2208988800);
// Magic fractional unit. Used to convert time (in microseconds) to/from
// fractional NTP seconds.
const double kMagicFractionalUnit = 4.294967296E3;
-}
+
+} // namespace
RtcpParser::RtcpParser(uint32_t local_ssrc, uint32_t remote_ssrc)
: local_ssrc_(local_ssrc),
@@ -197,7 +198,7 @@ bool RtcpParser::ParseApplicationDefined(base::BigEndianReader* reader,
if (name != kCast)
return false;
- switch (header.IC /* subtype */ ) {
+ switch (header.IC) { // subtype
case kReceiverLogSubtype:
if (!ParseCastReceiverLogFrameItem(reader))
return false;
@@ -354,8 +355,8 @@ bool RtcpParser::ParseExtendedReportReceiverReferenceTimeReport(
base::BigEndianReader* reader,
uint32_t remote_ssrc) {
receiver_reference_time_report_.remote_ssrc = remote_ssrc;
- if(!reader->ReadU32(&receiver_reference_time_report_.ntp_seconds) ||
- !reader->ReadU32(&receiver_reference_time_report_.ntp_fraction))
+ if (!reader->ReadU32(&receiver_reference_time_report_.ntp_seconds) ||
+ !reader->ReadU32(&receiver_reference_time_report_.ntp_fraction))
return false;
has_receiver_reference_time_report_ = true;
@@ -454,5 +455,33 @@ base::TimeTicks ConvertNtpToTimeTicks(uint32_t ntp_seconds,
return base::TimeTicks::UnixEpoch() + elapsed_since_unix_epoch;
}
+namespace {
+enum {
+ // Minimum number of bytes required to make a valid RTCP packet.
+ kMinLengthOfRtcp = 8,
+};
+} // namespace
+
+bool IsRtcpPacket(const uint8_t* packet, size_t length) {
+ if (length < kMinLengthOfRtcp) {
+ LOG(ERROR) << "Invalid RTCP packet received.";
+ return false;
+ }
+
+ uint8_t packet_type = packet[1];
+ return packet_type >= kPacketTypeLow && packet_type <= kPacketTypeHigh;
+}
+
+uint32_t GetSsrcOfSender(const uint8_t* rtcp_buffer, size_t length) {
+ if (length < kMinLengthOfRtcp)
+ return 0;
+ uint32_t ssrc_of_sender;
+ base::BigEndianReader big_endian_reader(
+ reinterpret_cast<const char*>(rtcp_buffer), length);
+ big_endian_reader.Skip(4); // Skip header.
+ big_endian_reader.ReadU32(&ssrc_of_sender);
+ return ssrc_of_sender;
+}
+
} // namespace cast
} // namespace media
« no previous file with comments | « media/cast/net/rtcp/rtcp_utility.h ('k') | media/cast/net/rtcp/sender_rtcp_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698