Fix a bug in RtcEventLogSource
A recent change (https://codereview.webrtc.org/2855143002/) introduced a bug in RtcEventLogSource::NextPacket(). The rtp_packet_index_ must be incremented when a valid packet is found and delivered. Otherwise, the same packet will be delivered over and over again. The recent change also altered the way that audio packets are sifted out. Now, the RTP header is always parsed before discarding any non-audio packets. This means that RtpHeaderParser::Parse is always called, also with video packets, which sometimes contain padding. When header-only dumps (such as RtcEventLogs) are created, the payload is stripped, and the payload length is equal to the RTP header length. However, if the original packet was padded, the RTP header will carry information about this padding length, and the parser will check that the pyaload length is at least the header + padding. This is not the case for header-only dumps, and the parser will return an error. In this CL, we ignore that error when a header-only packet has padding length larger than 0. BUG=webrtc:7538 Review-Url: https://codereview.webrtc.org/2912323003 Cr-Commit-Position: refs/heads/master@{#18385}
This commit is contained in:
committed by
Commit Bot
parent
e80f4c91d0
commit
7a2862a933
@ -129,8 +129,13 @@ void Packet::DeleteRedHeaders(std::list<RTPHeader*>* headers) {
|
||||
bool Packet::ParseHeader(const RtpHeaderParser& parser) {
|
||||
bool valid_header = parser.Parse(
|
||||
payload_memory_.get(), static_cast<int>(packet_length_bytes_), &header_);
|
||||
assert(valid_header);
|
||||
if (!valid_header) {
|
||||
// Special case for dummy packets that have padding marked in the RTP header.
|
||||
// This causes the RTP header parser to report failure, but is fine in this
|
||||
// context.
|
||||
const bool header_only_with_padding =
|
||||
(header_.headerLength == packet_length_bytes_ &&
|
||||
header_.paddingLength > 0);
|
||||
if (!valid_header && !header_only_with_padding) {
|
||||
return false;
|
||||
}
|
||||
assert(header_.headerLength <= packet_length_bytes_);
|
||||
|
||||
@ -75,6 +75,7 @@ std::unique_ptr<Packet> RtcEventLogSource::NextPacket() {
|
||||
// Check if the packet should not be filtered out.
|
||||
if (!filter_.test(packet->header().payloadType) &&
|
||||
!(use_ssrc_filter_ && packet->header().ssrc != ssrc_)) {
|
||||
++rtp_packet_index_;
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,8 +72,7 @@ std::unique_ptr<Packet> RtpFileSource::NextPacket() {
|
||||
packet_memory.release(), temp_packet.length,
|
||||
temp_packet.original_length, temp_packet.time_ms, *parser_.get()));
|
||||
if (!packet->valid_header()) {
|
||||
assert(false);
|
||||
return NULL;
|
||||
continue;
|
||||
}
|
||||
if (filter_.test(packet->header().payloadType) ||
|
||||
(use_ssrc_filter_ && packet->header().ssrc != ssrc_)) {
|
||||
|
||||
Reference in New Issue
Block a user