From 0c2981364f4ba1ee189afd69de02893bd3d3bdc1 Mon Sep 17 00:00:00 2001 From: philipel Date: Fri, 30 Dec 2022 11:45:22 +0100 Subject: [PATCH] Generate packets of original packet length in video_replay. An RTP dump may or may not include the payload of the recorded RTP packets. When the payload is not present packets should still be created with their original packet length. Bug: webrtc:14801 Change-Id: Ice74cb5f7d370aaefac5f370445ffd3f2fc5924c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/289920 Commit-Queue: Philip Eliasson Reviewed-by: Mirko Bonadei Cr-Commit-Position: refs/heads/main@{#38979} --- rtc_tools/video_replay.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/rtc_tools/video_replay.cc b/rtc_tools/video_replay.cc index b829ab519b..6fc9a98245 100644 --- a/rtc_tools/video_replay.cc +++ b/rtc_tools/video_replay.cc @@ -570,7 +570,17 @@ class RtpReplayer final { if (!rtp_reader_->NextPacket(&packet)) { break; } - rtc::CopyOnWriteBuffer packet_buffer(packet.data, packet.length); + rtc::CopyOnWriteBuffer packet_buffer( + packet.original_length > 0 ? packet.original_length : packet.length); + memcpy(packet_buffer.MutableData(), packet.data, packet.length); + if (packet.length < packet.original_length) { + // Only the RTP header was recorded in the RTP dump, payload is not + // known and and padding length is not known, zero the payload and + // clear the padding bit. + memset(packet_buffer.MutableData() + packet.length, 0, + packet.original_length - packet.length); + packet_buffer.MutableData()[0] &= ~0x20; + } RtpPacket header; header.Parse(packet_buffer); if (header.Timestamp() < start_timestamp ||