Minor fixes and refactoring for RtpTransport until the Demux.
This change fixes some inefficiencies and quirks in the code that
originates in RtpTransport leading up to the demux.
This work is in preparation for more refactoring of the Demux stage
onwards.
Bug: webrtc:10297
Change-Id: I7b8f00134657d62c722939618a55a91a2b6040bd
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/128220
Commit-Queue: Amit Hilbuch <amithi@webrtc.org>
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Reviewed-by: Seth Hampson <shampson@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27185}
diff --git a/pc/channel.cc b/pc/channel.cc
index 991e9e3..647663e 100644
--- a/pc/channel.cc
+++ b/pc/channel.cc
@@ -93,11 +93,6 @@
}
}
-static bool ValidPacket(bool rtcp, const rtc::CopyOnWriteBuffer* packet) {
- // Check the packet size. We could check the header too if needed.
- return packet && IsValidRtpRtcpPacketSize(rtcp, packet->size());
-}
-
template <class Codec>
void RtpParametersFromMediaDescription(
const MediaContentDescriptionImpl<Codec>* desc,
@@ -402,6 +397,8 @@
bool BaseChannel::SendPacket(bool rtcp,
rtc::CopyOnWriteBuffer* packet,
const rtc::PacketOptions& options) {
+ // Until all the code is migrated to use RtpPacketType instead of bool.
+ RtpPacketType packet_type = rtcp ? RtpPacketType::kRtcp : RtpPacketType::kRtp;
// SendPacket gets called from MediaEngine, on a pacer or an encoder thread.
// If the thread is not our network thread, we will post to our network
// so that the real work happens on our network. This avoids us having to
@@ -430,9 +427,9 @@
}
// Protect ourselves against crazy data.
- if (!ValidPacket(rtcp, packet)) {
+ if (!IsValidRtpPacketSize(packet_type, packet->size())) {
RTC_LOG(LS_ERROR) << "Dropping outgoing " << content_name_ << " "
- << RtpRtcpStringLiteral(rtcp)
+ << RtpPacketTypeToString(packet_type)
<< " packet: wrong size=" << packet->size();
return false;
}
@@ -524,7 +521,9 @@
// for us to just eat packets here. This is all sidestepped if RTCP mux
// is used anyway.
RTC_LOG(LS_WARNING)
- << "Can't process incoming " << RtpRtcpStringLiteral(rtcp)
+ << "Can't process incoming "
+ << RtpPacketTypeToString(rtcp ? RtpPacketType::kRtcp
+ : RtpPacketType::kRtp)
<< " packet when SRTP is inactive and crypto is required";
return;
}