2011-07-07 08:21:25 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2011 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_AUDIO_CODING_TEST_TESTVADDTX_H_
|
|
|
|
|
#define MODULES_AUDIO_CODING_TEST_TESTVADDTX_H_
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2016-02-14 20:40:57 -08:00
|
|
|
#include <memory>
|
2015-03-03 12:02:30 +00:00
|
|
|
|
2022-07-20 12:53:07 +02:00
|
|
|
#include "absl/strings/string_view.h"
|
2018-10-01 17:26:11 +02:00
|
|
|
#include "api/audio_codecs/audio_decoder_factory.h"
|
|
|
|
|
#include "api/audio_codecs/audio_encoder_factory.h"
|
2024-06-18 11:20:40 +02:00
|
|
|
#include "api/environment/environment.h"
|
2024-09-13 13:46:56 +00:00
|
|
|
#include "api/neteq/neteq.h"
|
2018-10-01 17:26:11 +02:00
|
|
|
#include "common_audio/vad/include/vad.h"
|
2024-09-13 13:46:56 +00:00
|
|
|
#include "modules/audio_coding/acm2/acm_resampler.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/audio_coding/include/audio_coding_module.h"
|
|
|
|
|
#include "modules/audio_coding/include/audio_coding_module_typedefs.h"
|
|
|
|
|
#include "modules/audio_coding/test/Channel.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2011-12-16 10:09:04 +00:00
|
|
|
namespace webrtc {
|
|
|
|
|
|
2020-03-10 09:28:33 +01:00
|
|
|
// This class records the frame type, and delegates actual sending to the
|
2021-07-28 20:00:17 +02:00
|
|
|
// `next_` AudioPacketizationCallback.
|
2020-03-10 09:28:33 +01:00
|
|
|
class MonitoringAudioPacketizationCallback : public AudioPacketizationCallback {
|
2013-05-03 07:34:12 +00:00
|
|
|
public:
|
2020-03-10 09:28:33 +01:00
|
|
|
explicit MonitoringAudioPacketizationCallback(
|
|
|
|
|
AudioPacketizationCallback* next);
|
|
|
|
|
|
|
|
|
|
int32_t SendData(AudioFrameType frame_type,
|
|
|
|
|
uint8_t payload_type,
|
|
|
|
|
uint32_t timestamp,
|
|
|
|
|
const uint8_t* payload_data,
|
|
|
|
|
size_t payload_len_bytes,
|
|
|
|
|
int64_t absolute_capture_timestamp_ms) override;
|
|
|
|
|
|
2013-08-27 07:33:51 +00:00
|
|
|
void PrintStatistics();
|
2013-05-03 07:34:12 +00:00
|
|
|
void ResetStatistics();
|
2015-03-03 12:02:30 +00:00
|
|
|
void GetStatistics(uint32_t* stats);
|
2018-06-19 15:03:05 +02:00
|
|
|
|
2013-05-03 07:34:12 +00:00
|
|
|
private:
|
2015-10-19 02:39:06 -07:00
|
|
|
// 0 - kEmptyFrame
|
2015-03-06 07:50:34 +00:00
|
|
|
// 1 - kAudioFrameSpeech
|
|
|
|
|
// 2 - kAudioFrameCN
|
2019-03-19 14:10:16 +01:00
|
|
|
uint32_t counter_[3];
|
2020-03-10 09:28:33 +01:00
|
|
|
AudioPacketizationCallback* const next_;
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
|
|
|
|
|
2015-03-03 12:02:30 +00:00
|
|
|
// TestVadDtx is to verify that VAD/DTX perform as they should. It runs through
|
|
|
|
|
// an audio file and check if the occurrence of various packet types follows
|
|
|
|
|
// expectation. TestVadDtx needs its derived class to implement the Perform()
|
|
|
|
|
// to put the test together.
|
2018-10-01 12:31:22 +02:00
|
|
|
class TestVadDtx {
|
2013-05-03 07:34:12 +00:00
|
|
|
public:
|
2015-03-03 12:02:30 +00:00
|
|
|
static const int kOutputFreqHz = 16000;
|
|
|
|
|
|
|
|
|
|
TestVadDtx();
|
|
|
|
|
|
|
|
|
|
protected:
|
2018-10-01 17:26:11 +02:00
|
|
|
// Returns true iff CN was added.
|
|
|
|
|
bool RegisterCodec(const SdpAudioFormat& codec_format,
|
2024-08-29 13:00:40 +00:00
|
|
|
std::optional<Vad::Aggressiveness> vad_mode);
|
2015-03-03 12:02:30 +00:00
|
|
|
|
|
|
|
|
// Encoding a file and see if the numbers that various packets occur follow
|
|
|
|
|
// the expectation. Saves result to a file.
|
|
|
|
|
// expects[x] means
|
|
|
|
|
// -1 : do not care,
|
2021-07-28 20:00:17 +02:00
|
|
|
// 0 : there have been no packets of type `x`,
|
|
|
|
|
// 1 : there have been packets of type `x`,
|
|
|
|
|
// with `x` indicates the following packet types
|
2015-10-19 02:39:06 -07:00
|
|
|
// 0 - kEmptyFrame
|
2015-03-06 07:50:34 +00:00
|
|
|
// 1 - kAudioFrameSpeech
|
|
|
|
|
// 2 - kAudioFrameCN
|
2022-07-20 12:53:07 +02:00
|
|
|
void Run(absl::string_view in_filename,
|
2015-03-03 12:02:30 +00:00
|
|
|
int frequency,
|
|
|
|
|
int channels,
|
2022-07-20 12:53:07 +02:00
|
|
|
absl::string_view out_filename,
|
2015-03-03 12:02:30 +00:00
|
|
|
bool append,
|
|
|
|
|
const int* expects);
|
|
|
|
|
|
2024-06-18 11:20:40 +02:00
|
|
|
const Environment env_;
|
2018-10-01 17:26:11 +02:00
|
|
|
const rtc::scoped_refptr<AudioEncoderFactory> encoder_factory_;
|
|
|
|
|
const rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_;
|
2016-02-14 20:40:57 -08:00
|
|
|
std::unique_ptr<AudioCodingModule> acm_send_;
|
2024-09-13 13:46:56 +00:00
|
|
|
std::unique_ptr<NetEq> neteq_;
|
|
|
|
|
acm2::ResamplerHelper resampler_helper_;
|
2016-02-14 20:40:57 -08:00
|
|
|
std::unique_ptr<Channel> channel_;
|
2020-03-10 09:28:33 +01:00
|
|
|
std::unique_ptr<MonitoringAudioPacketizationCallback> packetization_callback_;
|
2016-07-06 09:34:22 -07:00
|
|
|
uint32_t time_stamp_ = 0x12345678;
|
2015-03-03 12:02:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// TestWebRtcVadDtx is to verify that the WebRTC VAD/DTX perform as they should.
|
|
|
|
|
class TestWebRtcVadDtx final : public TestVadDtx {
|
|
|
|
|
public:
|
|
|
|
|
TestWebRtcVadDtx();
|
|
|
|
|
|
2018-10-01 12:31:22 +02:00
|
|
|
void Perform();
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-05-03 07:34:12 +00:00
|
|
|
private:
|
2018-10-01 17:26:11 +02:00
|
|
|
void RunTestCases(const SdpAudioFormat& codec_format);
|
|
|
|
|
void Test(bool new_outfile, bool expect_dtx_enabled);
|
2015-03-03 12:02:30 +00:00
|
|
|
|
|
|
|
|
int output_file_num_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// TestOpusDtx is to verify that the Opus DTX performs as it should.
|
|
|
|
|
class TestOpusDtx final : public TestVadDtx {
|
|
|
|
|
public:
|
2018-10-01 12:31:22 +02:00
|
|
|
void Perform();
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
|
|
|
|
|
2013-05-03 07:34:12 +00:00
|
|
|
} // namespace webrtc
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_AUDIO_CODING_TEST_TESTVADDTX_H_
|