Revert of Setting up an RTP input fuzzer for NetEq (patchset #2 id:20001 of https://codereview.webrtc.org/2315633002/ )
Reason for revert: Broke all Chromium libFuzzer builds https://bugs.chromium.org/p/chromium/issues/detail?id=645069 Original issue's description: > Setting up an RTP input fuzzer for NetEq > > This CL introduces a new fuzzer target neteq_rtp_fuzzer that > manipulates the RTP header fields before inserting the packets into > NetEq. A few helper classes are also introduced. > > BUG=webrtc:5447 > NOTRY=True > > Committed: https://crrev.com/2d273f1e97cd5030ed1686f27ce1118291b66395 > Cr-Commit-Position: refs/heads/master@{#14103} TBR=ivoc@webrtc.org,kjellander@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=webrtc:5447 Review-Url: https://codereview.webrtc.org/2328483002 Cr-Commit-Position: refs/heads/master@{#14131}
This commit is contained in:
parent
17e3fa1fb4
commit
22c8d5a3e0
@ -1110,8 +1110,6 @@ if (rtc_include_tests) {
|
||||
"neteq/tools/audio_sink.h",
|
||||
"neteq/tools/constant_pcm_packet_source.cc",
|
||||
"neteq/tools/constant_pcm_packet_source.h",
|
||||
"neteq/tools/encode_neteq_input.cc",
|
||||
"neteq/tools/encode_neteq_input.h",
|
||||
"neteq/tools/fake_decode_from_file.cc",
|
||||
"neteq/tools/fake_decode_from_file.h",
|
||||
"neteq/tools/input_audio_file.cc",
|
||||
|
||||
@ -231,8 +231,6 @@
|
||||
'tools/audio_sink.cc',
|
||||
'tools/constant_pcm_packet_source.cc',
|
||||
'tools/constant_pcm_packet_source.h',
|
||||
'tools/encode_neteq_input.cc',
|
||||
'tools/encode_neteq_input.h',
|
||||
'tools/fake_decode_from_file.cc',
|
||||
'tools/fake_decode_from_file.h',
|
||||
'tools/input_audio_file.cc',
|
||||
|
||||
@ -1,89 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/audio_coding/neteq/tools/encode_neteq_input.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
EncodeNetEqInput::EncodeNetEqInput(std::unique_ptr<InputAudioFile> input,
|
||||
std::unique_ptr<AudioEncoder> encoder,
|
||||
int64_t input_duration_ms)
|
||||
: input_(std::move(input)),
|
||||
encoder_(std::move(encoder)),
|
||||
input_duration_ms_(input_duration_ms) {
|
||||
CreatePacket();
|
||||
}
|
||||
|
||||
rtc::Optional<int64_t> EncodeNetEqInput::NextPacketTime() const {
|
||||
RTC_DCHECK(packet_data_);
|
||||
return rtc::Optional<int64_t>(static_cast<int64_t>(packet_data_->time_ms));
|
||||
}
|
||||
|
||||
rtc::Optional<int64_t> EncodeNetEqInput::NextOutputEventTime() const {
|
||||
return rtc::Optional<int64_t>(next_output_event_ms_);
|
||||
}
|
||||
|
||||
std::unique_ptr<NetEqInput::PacketData> EncodeNetEqInput::PopPacket() {
|
||||
RTC_DCHECK(packet_data_);
|
||||
// Grab the packet to return...
|
||||
std::unique_ptr<PacketData> packet_to_return = std::move(packet_data_);
|
||||
// ... and line up the next packet for future use.
|
||||
CreatePacket();
|
||||
|
||||
return packet_to_return;
|
||||
}
|
||||
|
||||
void EncodeNetEqInput::AdvanceOutputEvent() {
|
||||
next_output_event_ms_ += kOutputPeriodMs;
|
||||
}
|
||||
|
||||
rtc::Optional<RTPHeader> EncodeNetEqInput::NextHeader() const {
|
||||
RTC_DCHECK(packet_data_);
|
||||
return rtc::Optional<RTPHeader>(packet_data_->header.header);
|
||||
}
|
||||
|
||||
void EncodeNetEqInput::CreatePacket() {
|
||||
// Create a new PacketData object.
|
||||
RTC_DCHECK(!packet_data_);
|
||||
packet_data_.reset(new NetEqInput::PacketData);
|
||||
RTC_DCHECK_EQ(packet_data_->payload.size(), 0u);
|
||||
|
||||
// Loop until we get a packet.
|
||||
AudioEncoder::EncodedInfo info;
|
||||
RTC_DCHECK(!info.send_even_if_empty);
|
||||
int num_blocks = 0;
|
||||
while (packet_data_->payload.size() == 0 && !info.send_even_if_empty) {
|
||||
const size_t num_samples = rtc::CheckedDivExact(
|
||||
static_cast<int>(encoder_->SampleRateHz() * kOutputPeriodMs), 1000);
|
||||
std::unique_ptr<int16_t[]> audio(new int16_t[num_samples]);
|
||||
RTC_CHECK(input_->Read(num_samples, audio.get()));
|
||||
|
||||
info = encoder_->Encode(
|
||||
rtp_timestamp_, rtc::ArrayView<const int16_t>(audio.get(), num_samples),
|
||||
&packet_data_->payload);
|
||||
|
||||
rtp_timestamp_ +=
|
||||
num_samples * encoder_->RtpTimestampRateHz() / encoder_->SampleRateHz();
|
||||
++num_blocks;
|
||||
}
|
||||
packet_data_->header.header.timestamp = info.encoded_timestamp;
|
||||
packet_data_->header.header.payloadType = info.payload_type;
|
||||
packet_data_->header.header.sequenceNumber = sequence_number_++;
|
||||
packet_data_->time_ms = next_packet_time_ms_;
|
||||
next_packet_time_ms_ += num_blocks * kOutputPeriodMs;
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
} // namespace webrtc
|
||||
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_ENCODE_NETEQ_INPUT_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_ENCODE_NETEQ_INPUT_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/modules/audio_coding/codecs/audio_encoder.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/tools/input_audio_file.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/tools/neteq_input.h"
|
||||
#include "webrtc/modules/include/module_common_types.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
// This class provides a NetEqInput that takes audio from an input file and
|
||||
// encodes it using a given audio encoder.
|
||||
class EncodeNetEqInput : public NetEqInput {
|
||||
public:
|
||||
// The source will end after the given input duration.
|
||||
EncodeNetEqInput(std::unique_ptr<InputAudioFile> input,
|
||||
std::unique_ptr<AudioEncoder> encoder,
|
||||
int64_t input_duration_ms);
|
||||
|
||||
rtc::Optional<int64_t> NextPacketTime() const override;
|
||||
|
||||
rtc::Optional<int64_t> NextOutputEventTime() const override;
|
||||
|
||||
std::unique_ptr<PacketData> PopPacket() override;
|
||||
|
||||
void AdvanceOutputEvent() override;
|
||||
|
||||
bool ended() const override {
|
||||
return next_output_event_ms_ <= input_duration_ms_;
|
||||
}
|
||||
|
||||
rtc::Optional<RTPHeader> NextHeader() const override;
|
||||
|
||||
private:
|
||||
static constexpr int64_t kOutputPeriodMs = 10;
|
||||
|
||||
void CreatePacket();
|
||||
|
||||
std::unique_ptr<InputAudioFile> input_;
|
||||
std::unique_ptr<AudioEncoder> encoder_;
|
||||
std::unique_ptr<PacketData> packet_data_;
|
||||
int32_t rtp_timestamp_ = 0;
|
||||
int16_t sequence_number_ = 0;
|
||||
int64_t next_packet_time_ms_ = 0;
|
||||
int64_t next_output_event_ms_ = 0;
|
||||
const int64_t input_duration_ms_;
|
||||
};
|
||||
|
||||
} // namespace test
|
||||
} // namespace webrtc
|
||||
#endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_ENCODE_NETEQ_INPUT_H_
|
||||
@ -65,9 +65,7 @@ class NetEqInput {
|
||||
// time).
|
||||
virtual void AdvanceOutputEvent() = 0;
|
||||
|
||||
// Returns true if the source has come to an end. An implementation must
|
||||
// eventually return true from this method, or the test will end up in an
|
||||
// infinite loop.
|
||||
// Returns true if the source has come to an end.
|
||||
virtual bool ended() const = 0;
|
||||
|
||||
// Returns the RTP header for the next packet, i.e., the packet that will be
|
||||
|
||||
@ -184,19 +184,6 @@ webrtc_fuzzer_test("audio_decoder_opus_redundant_fuzzer") {
|
||||
]
|
||||
}
|
||||
|
||||
webrtc_fuzzer_test("neteq_rtp_fuzzer") {
|
||||
sources = [
|
||||
"neteq_rtp_fuzzer.cc",
|
||||
]
|
||||
deps = [
|
||||
"../../modules/audio_coding:neteq",
|
||||
"../../modules/audio_coding:neteq_unittest_tools",
|
||||
"../../modules/audio_coding:pcm16b",
|
||||
"../../modules/rtp_rtcp",
|
||||
"../../test:test_support",
|
||||
]
|
||||
}
|
||||
|
||||
# TODO(katrielc) Enable in Chromium when CL 2022833002 lands.
|
||||
# Although the dependency on media compiles in standalone, it is
|
||||
# flagged by gn check, so breaks when rolled into Chromium.
|
||||
|
||||
@ -1,140 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/base/array_view.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/tools/audio_checksum.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/tools/encode_neteq_input.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/tools/neteq_test.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/byte_io.h"
|
||||
#include "webrtc/test/testsupport/fileutils.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
namespace {
|
||||
constexpr int kPayloadType = 95;
|
||||
|
||||
class FuzzRtpInput : public NetEqInput {
|
||||
public:
|
||||
explicit FuzzRtpInput(rtc::ArrayView<const uint8_t> data) : data_(data) {
|
||||
std::unique_ptr<InputAudioFile> audio_input(
|
||||
new InputAudioFile(ResourcePath("audio_coding/testfile32kHz", "pcm")));
|
||||
AudioEncoderPcm16B::Config config;
|
||||
config.payload_type = kPayloadType;
|
||||
config.sample_rate_hz = 32000;
|
||||
std::unique_ptr<AudioEncoder> encoder(new AudioEncoderPcm16B(config));
|
||||
input_.reset(new EncodeNetEqInput(std::move(audio_input),
|
||||
std::move(encoder),
|
||||
std::numeric_limits<int64_t>::max()));
|
||||
packet_ = input_->PopPacket();
|
||||
FuzzHeader();
|
||||
}
|
||||
|
||||
rtc::Optional<int64_t> NextPacketTime() const override {
|
||||
return rtc::Optional<int64_t>(packet_->time_ms);
|
||||
}
|
||||
|
||||
rtc::Optional<int64_t> NextOutputEventTime() const override {
|
||||
return input_->NextOutputEventTime();
|
||||
}
|
||||
|
||||
std::unique_ptr<PacketData> PopPacket() override {
|
||||
RTC_DCHECK(packet_);
|
||||
std::unique_ptr<PacketData> packet_to_return = std::move(packet_);
|
||||
packet_ = input_->PopPacket();
|
||||
FuzzHeader();
|
||||
return packet_to_return;
|
||||
}
|
||||
|
||||
void AdvanceOutputEvent() override { return input_->AdvanceOutputEvent(); }
|
||||
|
||||
bool ended() const override { return ended_; }
|
||||
|
||||
rtc::Optional<RTPHeader> NextHeader() const override {
|
||||
RTC_DCHECK(packet_);
|
||||
return rtc::Optional<RTPHeader>(packet_->header.header);
|
||||
}
|
||||
|
||||
private:
|
||||
void FuzzHeader() {
|
||||
constexpr size_t kNumBytesToFuzz = 11;
|
||||
if (data_ix_ + kNumBytesToFuzz > data_.size()) {
|
||||
ended_ = true;
|
||||
return;
|
||||
}
|
||||
RTC_DCHECK(packet_);
|
||||
const size_t start_ix = data_ix_;
|
||||
packet_->header.header.payloadType =
|
||||
ByteReader<uint8_t>::ReadLittleEndian(&data_[data_ix_]);
|
||||
packet_->header.header.payloadType &= 0x7F;
|
||||
data_ix_ += sizeof(uint8_t);
|
||||
packet_->header.header.sequenceNumber =
|
||||
ByteReader<uint16_t>::ReadLittleEndian(&data_[data_ix_]);
|
||||
data_ix_ += sizeof(uint16_t);
|
||||
packet_->header.header.timestamp =
|
||||
ByteReader<uint32_t>::ReadLittleEndian(&data_[data_ix_]);
|
||||
data_ix_ += sizeof(uint32_t);
|
||||
packet_->header.header.ssrc =
|
||||
ByteReader<uint32_t>::ReadLittleEndian(&data_[data_ix_]);
|
||||
data_ix_ += sizeof(uint32_t);
|
||||
RTC_CHECK_EQ(data_ix_ - start_ix, kNumBytesToFuzz);
|
||||
}
|
||||
|
||||
bool ended_ = false;
|
||||
rtc::ArrayView<const uint8_t> data_;
|
||||
size_t data_ix_ = 0;
|
||||
std::unique_ptr<EncodeNetEqInput> input_;
|
||||
std::unique_ptr<PacketData> packet_;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
void FuzzOneInputTest(const uint8_t* data, size_t size) {
|
||||
std::unique_ptr<FuzzRtpInput> input(
|
||||
new FuzzRtpInput(rtc::ArrayView<const uint8_t>(data, size)));
|
||||
std::unique_ptr<AudioChecksum> output(new AudioChecksum);
|
||||
NetEqTestErrorCallback dummy_callback; // Does nothing with error callbacks.
|
||||
NetEq::Config config;
|
||||
NetEqTest::DecoderMap codecs;
|
||||
codecs[0] = std::make_pair(NetEqDecoder::kDecoderPCMu, "pcmu");
|
||||
codecs[8] = std::make_pair(NetEqDecoder::kDecoderPCMa, "pcma");
|
||||
codecs[102] = std::make_pair(NetEqDecoder::kDecoderILBC, "ilbc");
|
||||
codecs[103] = std::make_pair(NetEqDecoder::kDecoderISAC, "isac");
|
||||
codecs[104] = std::make_pair(NetEqDecoder::kDecoderISACswb, "isac-swb");
|
||||
codecs[111] = std::make_pair(NetEqDecoder::kDecoderOpus, "opus");
|
||||
codecs[93] = std::make_pair(NetEqDecoder::kDecoderPCM16B, "pcm16-nb");
|
||||
codecs[94] = std::make_pair(NetEqDecoder::kDecoderPCM16Bwb, "pcm16-wb");
|
||||
codecs[96] =
|
||||
std::make_pair(NetEqDecoder::kDecoderPCM16Bswb48kHz, "pcm16-swb48");
|
||||
codecs[9] = std::make_pair(NetEqDecoder::kDecoderG722, "g722");
|
||||
codecs[106] = std::make_pair(NetEqDecoder::kDecoderAVT, "avt");
|
||||
codecs[117] = std::make_pair(NetEqDecoder::kDecoderRED, "red");
|
||||
codecs[13] = std::make_pair(NetEqDecoder::kDecoderCNGnb, "cng-nb");
|
||||
codecs[98] = std::make_pair(NetEqDecoder::kDecoderCNGwb, "cng-wb");
|
||||
codecs[99] = std::make_pair(NetEqDecoder::kDecoderCNGswb32kHz, "cng-swb32");
|
||||
codecs[100] = std::make_pair(NetEqDecoder::kDecoderCNGswb48kHz, "cng-swb48");
|
||||
// This is the payload type that will be used for encoding.
|
||||
codecs[kPayloadType] =
|
||||
std::make_pair(NetEqDecoder::kDecoderPCM16Bswb32kHz, "pcm16-swb32");
|
||||
NetEqTest::ExtDecoderMap ext_codecs;
|
||||
|
||||
NetEqTest test(config, codecs, ext_codecs, std::move(input),
|
||||
std::move(output), &dummy_callback);
|
||||
test.Run();
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
|
||||
void FuzzOneInput(const uint8_t* data, size_t size) {
|
||||
test::FuzzOneInputTest(data, size);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
Loading…
x
Reference in New Issue
Block a user