Make FakeDecodeFromFile handle codec-internal CNG
This implementation interprets payloads of size 1 as codec-internal SID
frames, marking the start of a CNG period. Changes were made to other
parts of the test payload chain, since it had to make use of the virtual
payload size in the case of header-only RTP files.
BUG=webrtc:2692
Review-Url: https://codereview.webrtc.org/2275903002
Cr-Commit-Position: refs/heads/master@{#13901}
diff --git a/webrtc/modules/audio_coding/neteq/tools/neteq_packet_source_input.cc b/webrtc/modules/audio_coding/neteq/tools/neteq_packet_source_input.cc
index 5c7c1ed..9af2089 100644
--- a/webrtc/modules/audio_coding/neteq/tools/neteq_packet_source_input.cc
+++ b/webrtc/modules/audio_coding/neteq/tools/neteq_packet_source_input.cc
@@ -43,8 +43,16 @@
}
std::unique_ptr<PacketData> packet_data(new PacketData);
packet_->ConvertHeader(&packet_data->header);
- packet_data->payload.SetData(packet_->payload(),
- packet_->payload_length_bytes());
+ if (packet_->payload_length_bytes() == 0 &&
+ packet_->virtual_payload_length_bytes() > 0) {
+ // This is a header-only "dummy" packet. Set the payload to all zeros, with
+ // length according to the virtual length.
+ packet_data->payload.SetSize(packet_->virtual_payload_length_bytes());
+ std::fill_n(packet_data->payload.data(), packet_data->payload.size(), 0);
+ } else {
+ packet_data->payload.SetData(packet_->payload(),
+ packet_->payload_length_bytes());
+ }
packet_data->time_ms = packet_->time_ms();
LoadNextPacket();