Revert "[ACM] iSAC audio codec removed"
This reverts commit b46c4bf27ba5c417fcba7f200d80fa4634e7e1a1. Reason for revert: breaks a downstream project Original change's description: > [ACM] iSAC audio codec removed > > Note: this CL has to leave behind one part of iSAC, which is its VAD > currently used by AGC1 in APM. The target visibility has been > restricted and the VAD will be removed together with AGC1 when the > time comes. > > Tested: see https://chromium-review.googlesource.com/c/chromium/src/+/4013319 > > Bug: webrtc:14450 > Change-Id: I69cc518b16280eae62a1f1977cdbfa24c08cf5f9 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/282421 > Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org> > Reviewed-by: Sam Zackrisson <saza@webrtc.org> > Reviewed-by: Henrik Boström <hbos@webrtc.org> > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> > Cr-Commit-Position: refs/heads/main@{#38652} Bug: webrtc:14450 Change-Id: Ice138004e84e8c5f896684e8d01133d4b2a77bb7 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/283800 Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Auto-Submit: Alessio Bazzica <alessiob@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Owners-Override: Mirko Bonadei <mbonadei@webrtc.org> Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com> Cr-Commit-Position: refs/heads/main@{#38655}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
cb2b133bf0
commit
fbeb76ab51
@ -110,7 +110,9 @@ void Receiver::Setup(AudioCodingModule* acm,
|
||||
EXPECT_EQ(0, acm->InitializeReceiver());
|
||||
|
||||
if (channels == 1) {
|
||||
acm->SetReceiveCodecs({{107, {"L16", 8000, 1}},
|
||||
acm->SetReceiveCodecs({{103, {"ISAC", 16000, 1}},
|
||||
{104, {"ISAC", 32000, 1}},
|
||||
{107, {"L16", 8000, 1}},
|
||||
{108, {"L16", 16000, 1}},
|
||||
{109, {"L16", 32000, 1}},
|
||||
{0, {"PCMU", 8000, 1}},
|
||||
@ -230,6 +232,7 @@ EncodeDecodeTest::EncodeDecodeTest() = default;
|
||||
|
||||
void EncodeDecodeTest::Perform() {
|
||||
const std::map<int, SdpAudioFormat> send_codecs = {
|
||||
{103, {"ISAC", 16000, 1}}, {104, {"ISAC", 32000, 1}},
|
||||
{107, {"L16", 8000, 1}}, {108, {"L16", 16000, 1}},
|
||||
{109, {"L16", 32000, 1}}, {0, {"PCMU", 8000, 1}},
|
||||
{8, {"PCMA", 8000, 1}},
|
||||
|
||||
@ -130,7 +130,9 @@ void TestAllCodecs::Perform() {
|
||||
acm_a_->InitializeReceiver();
|
||||
acm_b_->InitializeReceiver();
|
||||
|
||||
acm_b_->SetReceiveCodecs({{107, {"L16", 8000, 1}},
|
||||
acm_b_->SetReceiveCodecs({{103, {"ISAC", 16000, 1}},
|
||||
{104, {"ISAC", 32000, 1}},
|
||||
{107, {"L16", 8000, 1}},
|
||||
{108, {"L16", 16000, 1}},
|
||||
{109, {"L16", 32000, 1}},
|
||||
{111, {"L16", 8000, 2}},
|
||||
@ -184,6 +186,33 @@ void TestAllCodecs::Perform() {
|
||||
RegisterSendCodec('A', codec_ilbc, 8000, 15200, 320, 0);
|
||||
Run(channel_a_to_b_);
|
||||
outfile_b_.Close();
|
||||
#endif
|
||||
#if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX))
|
||||
test_count_++;
|
||||
OpenOutFile(test_count_);
|
||||
char codec_isac[] = "ISAC";
|
||||
RegisterSendCodec('A', codec_isac, 16000, -1, 480, kVariableSize);
|
||||
Run(channel_a_to_b_);
|
||||
RegisterSendCodec('A', codec_isac, 16000, -1, 960, kVariableSize);
|
||||
Run(channel_a_to_b_);
|
||||
RegisterSendCodec('A', codec_isac, 16000, 15000, 480, kVariableSize);
|
||||
Run(channel_a_to_b_);
|
||||
RegisterSendCodec('A', codec_isac, 16000, 32000, 960, kVariableSize);
|
||||
Run(channel_a_to_b_);
|
||||
outfile_b_.Close();
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_ISAC
|
||||
test_count_++;
|
||||
OpenOutFile(test_count_);
|
||||
RegisterSendCodec('A', codec_isac, 32000, -1, 960, kVariableSize);
|
||||
Run(channel_a_to_b_);
|
||||
RegisterSendCodec('A', codec_isac, 32000, 56000, 960, kVariableSize);
|
||||
Run(channel_a_to_b_);
|
||||
RegisterSendCodec('A', codec_isac, 32000, 37000, 960, kVariableSize);
|
||||
Run(channel_a_to_b_);
|
||||
RegisterSendCodec('A', codec_isac, 32000, 32000, 960, kVariableSize);
|
||||
Run(channel_a_to_b_);
|
||||
outfile_b_.Close();
|
||||
#endif
|
||||
test_count_++;
|
||||
OpenOutFile(test_count_);
|
||||
@ -290,11 +319,15 @@ void TestAllCodecs::RegisterSendCodec(char side,
|
||||
// Store packet-size in samples, used to validate the received packet.
|
||||
// If G.722, store half the size to compensate for the timestamp bug in the
|
||||
// RFC for G.722.
|
||||
// If iSAC runs in adaptive mode, packet size in samples can change on the
|
||||
// fly, so we exclude this test by setting `packet_size_samples_` to -1.
|
||||
int clockrate_hz = sampling_freq_hz;
|
||||
size_t num_channels = 1;
|
||||
if (absl::EqualsIgnoreCase(codec_name, "G722")) {
|
||||
packet_size_samples_ = packet_size / 2;
|
||||
clockrate_hz = sampling_freq_hz / 2;
|
||||
} else if (absl::EqualsIgnoreCase(codec_name, "ISAC") && (rate == -1)) {
|
||||
packet_size_samples_ = -1;
|
||||
} else if (absl::EqualsIgnoreCase(codec_name, "OPUS")) {
|
||||
packet_size_samples_ = packet_size;
|
||||
num_channels = 2;
|
||||
|
||||
@ -22,6 +22,8 @@
|
||||
#include "api/audio_codecs/g711/audio_encoder_g711.h"
|
||||
#include "api/audio_codecs/g722/audio_decoder_g722.h"
|
||||
#include "api/audio_codecs/g722/audio_encoder_g722.h"
|
||||
#include "api/audio_codecs/isac/audio_decoder_isac_float.h"
|
||||
#include "api/audio_codecs/isac/audio_encoder_isac_float.h"
|
||||
#include "api/audio_codecs/opus/audio_decoder_opus.h"
|
||||
#include "api/audio_codecs/opus/audio_encoder_opus.h"
|
||||
#include "modules/audio_coding/codecs/cng/audio_encoder_cng.h"
|
||||
@ -36,10 +38,12 @@ namespace webrtc {
|
||||
TestRedFec::TestRedFec()
|
||||
: encoder_factory_(CreateAudioEncoderFactory<AudioEncoderG711,
|
||||
AudioEncoderG722,
|
||||
AudioEncoderIsacFloat,
|
||||
AudioEncoderL16,
|
||||
AudioEncoderOpus>()),
|
||||
decoder_factory_(CreateAudioDecoderFactory<AudioDecoderG711,
|
||||
AudioDecoderG722,
|
||||
AudioDecoderIsacFloat,
|
||||
AudioDecoderL16,
|
||||
AudioDecoderOpus>()),
|
||||
_acmA(AudioCodingModule::Create(
|
||||
@ -91,6 +95,19 @@ void TestRedFec::Perform() {
|
||||
Run();
|
||||
_outFileB.Close();
|
||||
|
||||
RegisterSendCodec(_acmA, {"ISAC", 16000, 1}, Vad::kVadVeryAggressive, false);
|
||||
OpenOutFile(_testCntr);
|
||||
Run();
|
||||
_outFileB.Close();
|
||||
|
||||
// Switch to a 32 kHz codec; RED should be switched off.
|
||||
RegisterSendCodec(_acmA, {"ISAC", 32000, 1}, Vad::kVadVeryAggressive, false);
|
||||
OpenOutFile(_testCntr);
|
||||
Run();
|
||||
_outFileB.Close();
|
||||
|
||||
RegisterSendCodec(_acmA, {"ISAC", 32000, 1}, absl::nullopt, false);
|
||||
|
||||
_channelA2B->SetFECTestWithPacketLoss(true);
|
||||
// Following tests are under packet losses.
|
||||
|
||||
@ -101,6 +118,22 @@ void TestRedFec::Perform() {
|
||||
Run();
|
||||
_outFileB.Close();
|
||||
|
||||
// Switch to a 16 kHz codec, RED should have been switched off.
|
||||
RegisterSendCodec(_acmA, {"ISAC", 16000, 1}, Vad::kVadVeryAggressive, false);
|
||||
|
||||
OpenOutFile(_testCntr);
|
||||
Run();
|
||||
_outFileB.Close();
|
||||
|
||||
// Switch to a 32 kHz codec, RED should have been switched off.
|
||||
RegisterSendCodec(_acmA, {"ISAC", 32000, 1}, Vad::kVadVeryAggressive, false);
|
||||
|
||||
OpenOutFile(_testCntr);
|
||||
Run();
|
||||
_outFileB.Close();
|
||||
|
||||
RegisterSendCodec(_acmA, {"ISAC", 32000, 1}, absl::nullopt, false);
|
||||
|
||||
RegisterSendCodec(_acmA, {"opus", 48000, 2}, absl::nullopt, false);
|
||||
|
||||
// _channelA2B imposes 25% packet loss rate.
|
||||
|
||||
@ -18,6 +18,8 @@
|
||||
#include "api/audio_codecs/audio_encoder_factory_template.h"
|
||||
#include "api/audio_codecs/ilbc/audio_decoder_ilbc.h"
|
||||
#include "api/audio_codecs/ilbc/audio_encoder_ilbc.h"
|
||||
#include "api/audio_codecs/isac/audio_decoder_isac_float.h"
|
||||
#include "api/audio_codecs/isac/audio_encoder_isac_float.h"
|
||||
#include "api/audio_codecs/opus/audio_decoder_opus.h"
|
||||
#include "api/audio_codecs/opus/audio_encoder_opus.h"
|
||||
#include "modules/audio_coding/codecs/cng/audio_encoder_cng.h"
|
||||
@ -66,10 +68,12 @@ void MonitoringAudioPacketizationCallback::GetStatistics(uint32_t* counter) {
|
||||
}
|
||||
|
||||
TestVadDtx::TestVadDtx()
|
||||
: encoder_factory_(
|
||||
CreateAudioEncoderFactory<AudioEncoderIlbc, AudioEncoderOpus>()),
|
||||
decoder_factory_(
|
||||
CreateAudioDecoderFactory<AudioDecoderIlbc, AudioDecoderOpus>()),
|
||||
: encoder_factory_(CreateAudioEncoderFactory<AudioEncoderIlbc,
|
||||
AudioEncoderIsacFloat,
|
||||
AudioEncoderOpus>()),
|
||||
decoder_factory_(CreateAudioDecoderFactory<AudioDecoderIlbc,
|
||||
AudioDecoderIsacFloat,
|
||||
AudioDecoderOpus>()),
|
||||
acm_send_(AudioCodingModule::Create(
|
||||
AudioCodingModule::Config(decoder_factory_))),
|
||||
acm_receive_(AudioCodingModule::Create(
|
||||
@ -178,6 +182,8 @@ void TestVadDtx::Run(absl::string_view in_filename,
|
||||
TestWebRtcVadDtx::TestWebRtcVadDtx() : output_file_num_(0) {}
|
||||
|
||||
void TestWebRtcVadDtx::Perform() {
|
||||
RunTestCases({"ISAC", 16000, 1});
|
||||
RunTestCases({"ISAC", 32000, 1});
|
||||
RunTestCases({"ILBC", 8000, 1});
|
||||
RunTestCases({"opus", 48000, 2});
|
||||
}
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
#include "modules/audio_coding/test/TestStereo.h"
|
||||
#include "modules/audio_coding/test/TestVADDTX.h"
|
||||
#include "modules/audio_coding/test/TwoWayCommunication.h"
|
||||
#include "modules/audio_coding/test/iSACTest.h"
|
||||
#include "modules/audio_coding/test/opus_test.h"
|
||||
#include "test/gtest.h"
|
||||
#include "test/testsupport/file_utils.h"
|
||||
@ -41,6 +42,25 @@ TEST(AudioCodingModuleTest, TestRedFec) {
|
||||
webrtc::TestRedFec().Perform();
|
||||
}
|
||||
|
||||
#if defined(WEBRTC_ANDROID)
|
||||
TEST(AudioCodingModuleTest, DISABLED_TestIsac) {
|
||||
#else
|
||||
TEST(AudioCodingModuleTest, TestIsac) {
|
||||
#endif
|
||||
webrtc::ISACTest().Perform();
|
||||
}
|
||||
|
||||
#if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) && \
|
||||
defined(WEBRTC_CODEC_ILBC)
|
||||
#if defined(WEBRTC_ANDROID)
|
||||
TEST(AudioCodingModuleTest, DISABLED_TwoWayCommunication) {
|
||||
#else
|
||||
TEST(AudioCodingModuleTest, TwoWayCommunication) {
|
||||
#endif
|
||||
webrtc::TwoWayCommunication().Perform();
|
||||
}
|
||||
#endif
|
||||
|
||||
// Disabled on ios as flaky, see https://crbug.com/webrtc/7057
|
||||
#if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS)
|
||||
TEST(AudioCodingModuleTest, DISABLED_TestStereo) {
|
||||
|
||||
273
modules/audio_coding/test/iSACTest.cc
Normal file
273
modules/audio_coding/test/iSACTest.cc
Normal file
@ -0,0 +1,273 @@
|
||||
/*
|
||||
* Copyright (c) 2012 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 "modules/audio_coding/test/iSACTest.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "absl/strings/match.h"
|
||||
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
|
||||
#include "api/audio_codecs/isac/audio_encoder_isac_float.h"
|
||||
#include "rtc_base/strings/string_builder.h"
|
||||
#include "rtc_base/time_utils.h"
|
||||
#include "test/gmock.h"
|
||||
#include "test/gtest.h"
|
||||
#include "test/testsupport/file_utils.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
using ::testing::AnyOf;
|
||||
using ::testing::Eq;
|
||||
using ::testing::StrCaseEq;
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr int kISAC16kPayloadType = 103;
|
||||
constexpr int kISAC32kPayloadType = 104;
|
||||
const SdpAudioFormat kISAC16kFormat = {"ISAC", 16000, 1};
|
||||
const SdpAudioFormat kISAC32kFormat = {"ISAC", 32000, 1};
|
||||
|
||||
AudioEncoderIsacFloat::Config TweakConfig(
|
||||
AudioEncoderIsacFloat::Config config,
|
||||
const ACMTestISACConfig& test_config) {
|
||||
if (test_config.currentRateBitPerSec > 0) {
|
||||
config.bit_rate = test_config.currentRateBitPerSec;
|
||||
}
|
||||
if (test_config.currentFrameSizeMsec != 0) {
|
||||
config.frame_size_ms = test_config.currentFrameSizeMsec;
|
||||
}
|
||||
EXPECT_THAT(config.IsOk(), Eq(true));
|
||||
return config;
|
||||
}
|
||||
|
||||
void SetISACConfigDefault(ACMTestISACConfig& isacConfig) {
|
||||
isacConfig.currentRateBitPerSec = 0;
|
||||
isacConfig.currentFrameSizeMsec = 0;
|
||||
isacConfig.encodingMode = -1;
|
||||
isacConfig.initRateBitPerSec = 0;
|
||||
isacConfig.initFrameSizeInMsec = 0;
|
||||
isacConfig.enforceFrameSize = false;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
ISACTest::ISACTest()
|
||||
: _acmA(AudioCodingModule::Create(
|
||||
AudioCodingModule::Config(CreateBuiltinAudioDecoderFactory()))),
|
||||
_acmB(AudioCodingModule::Create(
|
||||
AudioCodingModule::Config(CreateBuiltinAudioDecoderFactory()))) {}
|
||||
|
||||
ISACTest::~ISACTest() {}
|
||||
|
||||
void ISACTest::Setup() {
|
||||
// Register both iSAC-wb & iSAC-swb in both sides as receiver codecs.
|
||||
std::map<int, SdpAudioFormat> receive_codecs = {
|
||||
{kISAC16kPayloadType, kISAC16kFormat},
|
||||
{kISAC32kPayloadType, kISAC32kFormat}};
|
||||
_acmA->SetReceiveCodecs(receive_codecs);
|
||||
_acmB->SetReceiveCodecs(receive_codecs);
|
||||
|
||||
//--- Set A-to-B channel
|
||||
_channel_A2B.reset(new Channel);
|
||||
EXPECT_EQ(0, _acmA->RegisterTransportCallback(_channel_A2B.get()));
|
||||
_channel_A2B->RegisterReceiverACM(_acmB.get());
|
||||
|
||||
//--- Set B-to-A channel
|
||||
_channel_B2A.reset(new Channel);
|
||||
EXPECT_EQ(0, _acmB->RegisterTransportCallback(_channel_B2A.get()));
|
||||
_channel_B2A->RegisterReceiverACM(_acmA.get());
|
||||
|
||||
file_name_swb_ =
|
||||
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
|
||||
|
||||
_acmB->SetEncoder(AudioEncoderIsacFloat::MakeAudioEncoder(
|
||||
*AudioEncoderIsacFloat::SdpToConfig(kISAC16kFormat),
|
||||
kISAC16kPayloadType));
|
||||
_acmA->SetEncoder(AudioEncoderIsacFloat::MakeAudioEncoder(
|
||||
*AudioEncoderIsacFloat::SdpToConfig(kISAC32kFormat),
|
||||
kISAC32kPayloadType));
|
||||
|
||||
_inFileA.Open(file_name_swb_, 32000, "rb");
|
||||
// Set test length to 500 ms (50 blocks of 10 ms each).
|
||||
_inFileA.SetNum10MsBlocksToRead(50);
|
||||
// Fast-forward 1 second (100 blocks) since the files start with silence.
|
||||
_inFileA.FastForward(100);
|
||||
std::string fileNameA = webrtc::test::OutputPath() + "testisac_a.pcm";
|
||||
std::string fileNameB = webrtc::test::OutputPath() + "testisac_b.pcm";
|
||||
_outFileA.Open(fileNameA, 32000, "wb");
|
||||
_outFileB.Open(fileNameB, 32000, "wb");
|
||||
|
||||
while (!_inFileA.EndOfFile()) {
|
||||
Run10ms();
|
||||
}
|
||||
|
||||
_inFileA.Close();
|
||||
_outFileA.Close();
|
||||
_outFileB.Close();
|
||||
}
|
||||
|
||||
void ISACTest::Perform() {
|
||||
Setup();
|
||||
|
||||
int16_t testNr = 0;
|
||||
ACMTestISACConfig wbISACConfig;
|
||||
ACMTestISACConfig swbISACConfig;
|
||||
|
||||
SetISACConfigDefault(wbISACConfig);
|
||||
SetISACConfigDefault(swbISACConfig);
|
||||
|
||||
wbISACConfig.currentRateBitPerSec = -1;
|
||||
swbISACConfig.currentRateBitPerSec = -1;
|
||||
testNr++;
|
||||
EncodeDecode(testNr, wbISACConfig, swbISACConfig);
|
||||
|
||||
SetISACConfigDefault(wbISACConfig);
|
||||
SetISACConfigDefault(swbISACConfig);
|
||||
testNr++;
|
||||
EncodeDecode(testNr, wbISACConfig, swbISACConfig);
|
||||
|
||||
testNr++;
|
||||
SwitchingSamplingRate(testNr, 4);
|
||||
}
|
||||
|
||||
void ISACTest::Run10ms() {
|
||||
AudioFrame audioFrame;
|
||||
EXPECT_GT(_inFileA.Read10MsData(audioFrame), 0);
|
||||
EXPECT_GE(_acmA->Add10MsData(audioFrame), 0);
|
||||
EXPECT_GE(_acmB->Add10MsData(audioFrame), 0);
|
||||
bool muted;
|
||||
EXPECT_EQ(0, _acmA->PlayoutData10Ms(32000, &audioFrame, &muted));
|
||||
ASSERT_FALSE(muted);
|
||||
_outFileA.Write10MsData(audioFrame);
|
||||
EXPECT_EQ(0, _acmB->PlayoutData10Ms(32000, &audioFrame, &muted));
|
||||
ASSERT_FALSE(muted);
|
||||
_outFileB.Write10MsData(audioFrame);
|
||||
}
|
||||
|
||||
void ISACTest::EncodeDecode(int testNr,
|
||||
ACMTestISACConfig& wbISACConfig,
|
||||
ACMTestISACConfig& swbISACConfig) {
|
||||
// Files in Side A and B
|
||||
_inFileA.Open(file_name_swb_, 32000, "rb", true);
|
||||
_inFileB.Open(file_name_swb_, 32000, "rb", true);
|
||||
|
||||
std::string file_name_out;
|
||||
rtc::StringBuilder file_stream_a;
|
||||
rtc::StringBuilder file_stream_b;
|
||||
file_stream_a << webrtc::test::OutputPath();
|
||||
file_stream_b << webrtc::test::OutputPath();
|
||||
file_stream_a << "out_iSACTest_A_" << testNr << ".pcm";
|
||||
file_stream_b << "out_iSACTest_B_" << testNr << ".pcm";
|
||||
file_name_out = file_stream_a.str();
|
||||
_outFileA.Open(file_name_out, 32000, "wb");
|
||||
file_name_out = file_stream_b.str();
|
||||
_outFileB.Open(file_name_out, 32000, "wb");
|
||||
|
||||
// Side A is sending super-wideband, and side B is sending wideband.
|
||||
_acmA->SetEncoder(AudioEncoderIsacFloat::MakeAudioEncoder(
|
||||
TweakConfig(*AudioEncoderIsacFloat::SdpToConfig(kISAC32kFormat),
|
||||
swbISACConfig),
|
||||
kISAC32kPayloadType));
|
||||
_acmB->SetEncoder(AudioEncoderIsacFloat::MakeAudioEncoder(
|
||||
TweakConfig(*AudioEncoderIsacFloat::SdpToConfig(kISAC16kFormat),
|
||||
wbISACConfig),
|
||||
kISAC16kPayloadType));
|
||||
|
||||
_channel_A2B->ResetStats();
|
||||
_channel_B2A->ResetStats();
|
||||
|
||||
while (!(_inFileA.EndOfFile() || _inFileA.Rewinded())) {
|
||||
Run10ms();
|
||||
}
|
||||
|
||||
_channel_A2B->ResetStats();
|
||||
_channel_B2A->ResetStats();
|
||||
|
||||
_outFileA.Close();
|
||||
_outFileB.Close();
|
||||
_inFileA.Close();
|
||||
_inFileB.Close();
|
||||
}
|
||||
|
||||
void ISACTest::SwitchingSamplingRate(int testNr, int maxSampRateChange) {
|
||||
// Files in Side A
|
||||
_inFileA.Open(file_name_swb_, 32000, "rb");
|
||||
_inFileB.Open(file_name_swb_, 32000, "rb");
|
||||
|
||||
std::string file_name_out;
|
||||
rtc::StringBuilder file_stream_a;
|
||||
rtc::StringBuilder file_stream_b;
|
||||
file_stream_a << webrtc::test::OutputPath();
|
||||
file_stream_b << webrtc::test::OutputPath();
|
||||
file_stream_a << "out_iSACTest_A_" << testNr << ".pcm";
|
||||
file_stream_b << "out_iSACTest_B_" << testNr << ".pcm";
|
||||
file_name_out = file_stream_a.str();
|
||||
_outFileA.Open(file_name_out, 32000, "wb");
|
||||
file_name_out = file_stream_b.str();
|
||||
_outFileB.Open(file_name_out, 32000, "wb");
|
||||
|
||||
// Start with side A sending super-wideband and side B seding wideband.
|
||||
// Toggle sending wideband/super-wideband in this test.
|
||||
_acmA->SetEncoder(AudioEncoderIsacFloat::MakeAudioEncoder(
|
||||
*AudioEncoderIsacFloat::SdpToConfig(kISAC32kFormat),
|
||||
kISAC32kPayloadType));
|
||||
_acmB->SetEncoder(AudioEncoderIsacFloat::MakeAudioEncoder(
|
||||
*AudioEncoderIsacFloat::SdpToConfig(kISAC16kFormat),
|
||||
kISAC16kPayloadType));
|
||||
|
||||
int numSendCodecChanged = 0;
|
||||
while (numSendCodecChanged < (maxSampRateChange << 1)) {
|
||||
Run10ms();
|
||||
if (_inFileA.EndOfFile()) {
|
||||
if (_inFileA.SamplingFrequency() == 16000) {
|
||||
// Switch side A to send super-wideband.
|
||||
_inFileA.Close();
|
||||
_inFileA.Open(file_name_swb_, 32000, "rb");
|
||||
_acmA->SetEncoder(AudioEncoderIsacFloat::MakeAudioEncoder(
|
||||
*AudioEncoderIsacFloat::SdpToConfig(kISAC32kFormat),
|
||||
kISAC32kPayloadType));
|
||||
} else {
|
||||
// Switch side A to send wideband.
|
||||
_inFileA.Close();
|
||||
_inFileA.Open(file_name_swb_, 32000, "rb");
|
||||
_acmA->SetEncoder(AudioEncoderIsacFloat::MakeAudioEncoder(
|
||||
*AudioEncoderIsacFloat::SdpToConfig(kISAC16kFormat),
|
||||
kISAC16kPayloadType));
|
||||
}
|
||||
numSendCodecChanged++;
|
||||
}
|
||||
|
||||
if (_inFileB.EndOfFile()) {
|
||||
if (_inFileB.SamplingFrequency() == 16000) {
|
||||
// Switch side B to send super-wideband.
|
||||
_inFileB.Close();
|
||||
_inFileB.Open(file_name_swb_, 32000, "rb");
|
||||
_acmB->SetEncoder(AudioEncoderIsacFloat::MakeAudioEncoder(
|
||||
*AudioEncoderIsacFloat::SdpToConfig(kISAC32kFormat),
|
||||
kISAC32kPayloadType));
|
||||
} else {
|
||||
// Switch side B to send wideband.
|
||||
_inFileB.Close();
|
||||
_inFileB.Open(file_name_swb_, 32000, "rb");
|
||||
_acmB->SetEncoder(AudioEncoderIsacFloat::MakeAudioEncoder(
|
||||
*AudioEncoderIsacFloat::SdpToConfig(kISAC16kFormat),
|
||||
kISAC16kPayloadType));
|
||||
}
|
||||
numSendCodecChanged++;
|
||||
}
|
||||
}
|
||||
_outFileA.Close();
|
||||
_outFileB.Close();
|
||||
_inFileA.Close();
|
||||
_inFileB.Close();
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
68
modules/audio_coding/test/iSACTest.h
Normal file
68
modules/audio_coding/test/iSACTest.h
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2012 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 MODULES_AUDIO_CODING_TEST_ISACTEST_H_
|
||||
#define MODULES_AUDIO_CODING_TEST_ISACTEST_H_
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "modules/audio_coding/include/audio_coding_module.h"
|
||||
#include "modules/audio_coding/test/Channel.h"
|
||||
#include "modules/audio_coding/test/PCMFile.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
struct ACMTestISACConfig {
|
||||
int32_t currentRateBitPerSec;
|
||||
int16_t currentFrameSizeMsec;
|
||||
int16_t encodingMode;
|
||||
uint32_t initRateBitPerSec;
|
||||
int16_t initFrameSizeInMsec;
|
||||
bool enforceFrameSize;
|
||||
};
|
||||
|
||||
class ISACTest {
|
||||
public:
|
||||
ISACTest();
|
||||
~ISACTest();
|
||||
|
||||
void Perform();
|
||||
|
||||
private:
|
||||
void Setup();
|
||||
|
||||
void Run10ms();
|
||||
|
||||
void EncodeDecode(int testNr,
|
||||
ACMTestISACConfig& wbISACConfig,
|
||||
ACMTestISACConfig& swbISACConfig);
|
||||
|
||||
void SwitchingSamplingRate(int testNr, int maxSampRateChange);
|
||||
|
||||
std::unique_ptr<AudioCodingModule> _acmA;
|
||||
std::unique_ptr<AudioCodingModule> _acmB;
|
||||
|
||||
std::unique_ptr<Channel> _channel_A2B;
|
||||
std::unique_ptr<Channel> _channel_B2A;
|
||||
|
||||
PCMFile _inFileA;
|
||||
PCMFile _inFileB;
|
||||
|
||||
PCMFile _outFileA;
|
||||
PCMFile _outFileB;
|
||||
|
||||
std::string file_name_swb_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // MODULES_AUDIO_CODING_TEST_ISACTEST_H_
|
||||
Reference in New Issue
Block a user