Allow RTCP packets longer than 1500 bytes in RTC event log.

Bug: chromium:1134107
Change-Id: I05da32c57537c3c2fddae96918ff4e4685d62043
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/186720
Reviewed-by: Elad Alon <eladalon@webrtc.org>
Commit-Queue: Björn Terelius <terelius@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32315}
This commit is contained in:
Bjorn Terelius 2020-10-05 15:58:01 +02:00 committed by Commit Bot
parent 04482985b2
commit 9f0c89bd56
2 changed files with 8 additions and 10 deletions

View File

@ -696,8 +696,7 @@ std::string RtcEventLogEncoderLegacy::EncodeRtcpPacket(
rtcp::CommonHeader header;
const uint8_t* block_begin = packet.data();
const uint8_t* packet_end = packet.data() + packet.size();
RTC_DCHECK(packet.size() <= IP_PACKET_SIZE);
uint8_t buffer[IP_PACKET_SIZE];
std::vector<uint8_t> buffer(packet.size());
uint32_t buffer_length = 0;
while (block_begin < packet_end) {
if (!header.Parse(block_begin, packet_end - block_begin)) {
@ -716,7 +715,7 @@ std::string RtcEventLogEncoderLegacy::EncodeRtcpPacket(
// We log sender reports, receiver reports, bye messages
// inter-arrival jitter, third-party loss reports, payload-specific
// feedback and extended reports.
memcpy(buffer + buffer_length, block_begin, block_size);
memcpy(buffer.data() + buffer_length, block_begin, block_size);
buffer_length += block_size;
break;
case rtcp::App::kPacketType:
@ -729,7 +728,8 @@ std::string RtcEventLogEncoderLegacy::EncodeRtcpPacket(
block_begin += block_size;
}
rtclog_event.mutable_rtcp_packet()->set_packet_data(buffer, buffer_length);
rtclog_event.mutable_rtcp_packet()->set_packet_data(buffer.data(),
buffer_length);
return Serialize(&rtclog_event);
}

View File

@ -288,11 +288,9 @@ rtclog2::IceCandidatePairEvent::IceCandidatePairEventType ConvertToProtoFormat(
}
// Copies all RTCP blocks except APP, SDES and unknown from |packet| to
// |buffer|. |buffer| must have space for |IP_PACKET_SIZE| bytes. |packet| must
// be at most |IP_PACKET_SIZE| bytes long.
// |buffer|. |buffer| must have space for at least |packet.size()| bytes.
size_t RemoveNonWhitelistedRtcpBlocks(const rtc::Buffer& packet,
uint8_t* buffer) {
RTC_DCHECK(packet.size() <= IP_PACKET_SIZE);
RTC_DCHECK(buffer != nullptr);
rtcp::CommonHeader header;
const uint8_t* block_begin = packet.data();
@ -346,10 +344,10 @@ void EncodeRtcpPacket(rtc::ArrayView<const EventType*> batch,
const EventType* const base_event = batch[0];
proto_batch->set_timestamp_ms(base_event->timestamp_ms());
{
uint8_t buffer[IP_PACKET_SIZE];
std::vector<uint8_t> buffer(base_event->packet().size());
size_t buffer_length =
RemoveNonWhitelistedRtcpBlocks(base_event->packet(), buffer);
proto_batch->set_raw_packet(buffer, buffer_length);
RemoveNonWhitelistedRtcpBlocks(base_event->packet(), buffer.data());
proto_batch->set_raw_packet(buffer.data(), buffer_length);
}
if (batch.size() == 1) {