Reland "Remove CodecInst pt.1"
This is a reland of 056f9738bf7a3d16da45398239656e165c4e0851 Original change's description: > Remove CodecInst pt.1 > > Update audio_coding tests to not use CodecInst. > > Bug: webrtc:7626 > Change-Id: I880fb8d72d7d0a915d274e67feb6106f023697c2 > Reviewed-on: https://webrtc-review.googlesource.com/c/112594 > Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org> > Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#25879} Bug: webrtc:7626 Change-Id: I5d6ca0baf6230bfe9bf95c2c25496d2a56812d90 Reviewed-on: https://webrtc-review.googlesource.com/c/112942 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25902}
This commit is contained in:
committed by
Commit Bot
parent
5b1477839d
commit
657b296ff5
@ -15,9 +15,8 @@
|
||||
#include "absl/strings/match.h"
|
||||
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
|
||||
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
|
||||
#include "modules/audio_coding/codecs/audio_format_conversion.h"
|
||||
#include "modules/audio_coding/include/audio_coding_module_typedefs.h"
|
||||
#include "modules/audio_coding/test/utility.h"
|
||||
#include "modules/include/module_common_types.h"
|
||||
#include "rtc_base/strings/string_builder.h"
|
||||
#include "test/gtest.h"
|
||||
#include "test/testsupport/fileutils.h"
|
||||
@ -32,7 +31,6 @@ TestPackStereo::TestPackStereo()
|
||||
last_in_timestamp_(0),
|
||||
total_bytes_(0),
|
||||
payload_size_(0),
|
||||
codec_mode_(kNotSet),
|
||||
lost_packet_(false) {}
|
||||
|
||||
TestPackStereo::~TestPackStereo() {}
|
||||
@ -98,7 +96,7 @@ void TestPackStereo::set_lost_packet(bool lost) {
|
||||
lost_packet_ = lost;
|
||||
}
|
||||
|
||||
TestStereo::TestStereo(int test_mode)
|
||||
TestStereo::TestStereo()
|
||||
: acm_a_(AudioCodingModule::Create(
|
||||
AudioCodingModule::Config(CreateBuiltinAudioDecoderFactory()))),
|
||||
acm_b_(AudioCodingModule::Create(
|
||||
@ -108,8 +106,6 @@ TestStereo::TestStereo(int test_mode)
|
||||
pack_size_samp_(0),
|
||||
pack_size_bytes_(0),
|
||||
counter_(0) {
|
||||
// test_mode = 0 for silent test (auto test)
|
||||
test_mode_ = test_mode;
|
||||
}
|
||||
|
||||
TestStereo::~TestStereo() {
|
||||
@ -142,27 +138,25 @@ void TestStereo::Perform() {
|
||||
EXPECT_EQ(0, acm_a_->InitializeReceiver());
|
||||
EXPECT_EQ(0, acm_b_->InitializeReceiver());
|
||||
|
||||
// Register all available codes as receiving codecs.
|
||||
uint8_t num_encoders = acm_a_->NumberOfCodecs();
|
||||
CodecInst my_codec_param;
|
||||
for (uint8_t n = 0; n < num_encoders; n++) {
|
||||
EXPECT_EQ(0, acm_b_->Codec(n, &my_codec_param));
|
||||
EXPECT_EQ(true, acm_b_->RegisterReceiveCodec(
|
||||
my_codec_param.pltype, CodecInstToSdp(my_codec_param)));
|
||||
}
|
||||
|
||||
// Test that unregister all receive codecs works.
|
||||
for (uint8_t n = 0; n < num_encoders; n++) {
|
||||
EXPECT_EQ(0, acm_b_->Codec(n, &my_codec_param));
|
||||
EXPECT_EQ(0, acm_b_->UnregisterReceiveCodec(my_codec_param.pltype));
|
||||
}
|
||||
|
||||
// Register all available codes as receiving codecs once more.
|
||||
for (uint8_t n = 0; n < num_encoders; n++) {
|
||||
EXPECT_EQ(0, acm_b_->Codec(n, &my_codec_param));
|
||||
EXPECT_EQ(true, acm_b_->RegisterReceiveCodec(
|
||||
my_codec_param.pltype, CodecInstToSdp(my_codec_param)));
|
||||
}
|
||||
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}},
|
||||
{112, {"L16", 16000, 2}},
|
||||
{113, {"L16", 32000, 2}},
|
||||
{0, {"PCMU", 8000, 1}},
|
||||
{110, {"PCMU", 8000, 2}},
|
||||
{8, {"PCMA", 8000, 1}},
|
||||
{118, {"PCMA", 8000, 2}},
|
||||
{102, {"ILBC", 8000, 1}},
|
||||
{9, {"G722", 8000, 1}},
|
||||
{119, {"G722", 8000, 2}},
|
||||
{120, {"OPUS", 48000, 2, {{"stereo", "1"}}}},
|
||||
{13, {"CN", 8000, 1}},
|
||||
{98, {"CN", 16000, 1}},
|
||||
{99, {"CN", 32000, 1}}});
|
||||
|
||||
// Create and connect the channel.
|
||||
channel_a2b_ = new TestPackStereo;
|
||||
@ -171,9 +165,6 @@ void TestStereo::Perform() {
|
||||
|
||||
char codec_pcma_temp[] = "PCMA";
|
||||
RegisterSendCodec('A', codec_pcma_temp, 8000, 64000, 80, 2);
|
||||
if (test_mode_ != 0) {
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
//
|
||||
// Test Stereo-To-Stereo for all codecs.
|
||||
@ -183,11 +174,6 @@ void TestStereo::Perform() {
|
||||
|
||||
// All codecs are tested for all allowed sampling frequencies, rates and
|
||||
// packet sizes.
|
||||
if (test_mode_ != 0) {
|
||||
printf("===========================================================\n");
|
||||
printf("Test number: %d\n", test_cntr_ + 1);
|
||||
printf("Test type: Stereo-to-stereo\n");
|
||||
}
|
||||
channel_a2b_->set_codec_mode(kStereo);
|
||||
test_cntr_++;
|
||||
OpenOutFile(test_cntr_);
|
||||
@ -206,11 +192,6 @@ void TestStereo::Perform() {
|
||||
Run(channel_a2b_, audio_channels, codec_channels);
|
||||
out_file_.Close();
|
||||
|
||||
if (test_mode_ != 0) {
|
||||
printf("===========================================================\n");
|
||||
printf("Test number: %d\n", test_cntr_ + 1);
|
||||
printf("Test type: Stereo-to-stereo\n");
|
||||
}
|
||||
channel_a2b_->set_codec_mode(kStereo);
|
||||
test_cntr_++;
|
||||
OpenOutFile(test_cntr_);
|
||||
@ -225,11 +206,6 @@ void TestStereo::Perform() {
|
||||
Run(channel_a2b_, audio_channels, codec_channels);
|
||||
out_file_.Close();
|
||||
|
||||
if (test_mode_ != 0) {
|
||||
printf("===========================================================\n");
|
||||
printf("Test number: %d\n", test_cntr_ + 1);
|
||||
printf("Test type: Stereo-to-stereo\n");
|
||||
}
|
||||
test_cntr_++;
|
||||
OpenOutFile(test_cntr_);
|
||||
RegisterSendCodec('A', codec_l16, 16000, 256000, 160, codec_channels);
|
||||
@ -242,11 +218,6 @@ void TestStereo::Perform() {
|
||||
Run(channel_a2b_, audio_channels, codec_channels);
|
||||
out_file_.Close();
|
||||
|
||||
if (test_mode_ != 0) {
|
||||
printf("===========================================================\n");
|
||||
printf("Test number: %d\n", test_cntr_ + 1);
|
||||
printf("Test type: Stereo-to-stereo\n");
|
||||
}
|
||||
test_cntr_++;
|
||||
OpenOutFile(test_cntr_);
|
||||
RegisterSendCodec('A', codec_l16, 32000, 512000, 320, codec_channels);
|
||||
@ -255,11 +226,6 @@ void TestStereo::Perform() {
|
||||
Run(channel_a2b_, audio_channels, codec_channels);
|
||||
out_file_.Close();
|
||||
#ifdef PCMA_AND_PCMU
|
||||
if (test_mode_ != 0) {
|
||||
printf("===========================================================\n");
|
||||
printf("Test number: %d\n", test_cntr_ + 1);
|
||||
printf("Test type: Stereo-to-stereo\n");
|
||||
}
|
||||
channel_a2b_->set_codec_mode(kStereo);
|
||||
audio_channels = 2;
|
||||
codec_channels = 2;
|
||||
@ -278,13 +244,8 @@ void TestStereo::Perform() {
|
||||
Run(channel_a2b_, audio_channels, codec_channels);
|
||||
RegisterSendCodec('A', codec_pcma, 8000, 64000, 480, codec_channels);
|
||||
Run(channel_a2b_, audio_channels, codec_channels);
|
||||
|
||||
out_file_.Close();
|
||||
if (test_mode_ != 0) {
|
||||
printf("===========================================================\n");
|
||||
printf("Test number: %d\n", test_cntr_ + 1);
|
||||
printf("Test type: Stereo-to-stereo\n");
|
||||
}
|
||||
|
||||
test_cntr_++;
|
||||
OpenOutFile(test_cntr_);
|
||||
char codec_pcmu[] = "PCMU";
|
||||
@ -303,11 +264,6 @@ void TestStereo::Perform() {
|
||||
out_file_.Close();
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_OPUS
|
||||
if (test_mode_ != 0) {
|
||||
printf("===========================================================\n");
|
||||
printf("Test number: %d\n", test_cntr_ + 1);
|
||||
printf("Test type: Stereo-to-stereo\n");
|
||||
}
|
||||
channel_a2b_->set_codec_mode(kStereo);
|
||||
audio_channels = 2;
|
||||
codec_channels = 2;
|
||||
@ -340,11 +296,6 @@ void TestStereo::Perform() {
|
||||
audio_channels = 1;
|
||||
codec_channels = 2;
|
||||
|
||||
if (test_mode_ != 0) {
|
||||
printf("===============================================================\n");
|
||||
printf("Test number: %d\n", test_cntr_ + 1);
|
||||
printf("Test type: Mono-to-stereo\n");
|
||||
}
|
||||
test_cntr_++;
|
||||
channel_a2b_->set_codec_mode(kStereo);
|
||||
OpenOutFile(test_cntr_);
|
||||
@ -352,43 +303,25 @@ void TestStereo::Perform() {
|
||||
Run(channel_a2b_, audio_channels, codec_channels);
|
||||
out_file_.Close();
|
||||
|
||||
if (test_mode_ != 0) {
|
||||
printf("===============================================================\n");
|
||||
printf("Test number: %d\n", test_cntr_ + 1);
|
||||
printf("Test type: Mono-to-stereo\n");
|
||||
}
|
||||
test_cntr_++;
|
||||
channel_a2b_->set_codec_mode(kStereo);
|
||||
OpenOutFile(test_cntr_);
|
||||
RegisterSendCodec('A', codec_l16, 8000, 128000, 80, codec_channels);
|
||||
Run(channel_a2b_, audio_channels, codec_channels);
|
||||
out_file_.Close();
|
||||
if (test_mode_ != 0) {
|
||||
printf("===============================================================\n");
|
||||
printf("Test number: %d\n", test_cntr_ + 1);
|
||||
printf("Test type: Mono-to-stereo\n");
|
||||
}
|
||||
|
||||
test_cntr_++;
|
||||
OpenOutFile(test_cntr_);
|
||||
RegisterSendCodec('A', codec_l16, 16000, 256000, 160, codec_channels);
|
||||
Run(channel_a2b_, audio_channels, codec_channels);
|
||||
out_file_.Close();
|
||||
if (test_mode_ != 0) {
|
||||
printf("===============================================================\n");
|
||||
printf("Test number: %d\n", test_cntr_ + 1);
|
||||
printf("Test type: Mono-to-stereo\n");
|
||||
}
|
||||
|
||||
test_cntr_++;
|
||||
OpenOutFile(test_cntr_);
|
||||
RegisterSendCodec('A', codec_l16, 32000, 512000, 320, codec_channels);
|
||||
Run(channel_a2b_, audio_channels, codec_channels);
|
||||
out_file_.Close();
|
||||
#ifdef PCMA_AND_PCMU
|
||||
if (test_mode_ != 0) {
|
||||
printf("===============================================================\n");
|
||||
printf("Test number: %d\n", test_cntr_ + 1);
|
||||
printf("Test type: Mono-to-stereo\n");
|
||||
}
|
||||
test_cntr_++;
|
||||
channel_a2b_->set_codec_mode(kStereo);
|
||||
OpenOutFile(test_cntr_);
|
||||
@ -399,12 +332,6 @@ void TestStereo::Perform() {
|
||||
out_file_.Close();
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_OPUS
|
||||
if (test_mode_ != 0) {
|
||||
printf("===============================================================\n");
|
||||
printf("Test number: %d\n", test_cntr_ + 1);
|
||||
printf("Test type: Mono-to-stereo\n");
|
||||
}
|
||||
|
||||
// Keep encode and decode in stereo.
|
||||
test_cntr_++;
|
||||
channel_a2b_->set_codec_mode(kStereo);
|
||||
@ -426,54 +353,30 @@ void TestStereo::Perform() {
|
||||
channel_a2b_->set_codec_mode(kMono);
|
||||
|
||||
// Run stereo audio and mono codec.
|
||||
if (test_mode_ != 0) {
|
||||
printf("===============================================================\n");
|
||||
printf("Test number: %d\n", test_cntr_ + 1);
|
||||
printf("Test type: Stereo-to-mono\n");
|
||||
}
|
||||
test_cntr_++;
|
||||
OpenOutFile(test_cntr_);
|
||||
RegisterSendCodec('A', codec_g722, 16000, 64000, 160, codec_channels);
|
||||
|
||||
Run(channel_a2b_, audio_channels, codec_channels);
|
||||
out_file_.Close();
|
||||
|
||||
if (test_mode_ != 0) {
|
||||
printf("===============================================================\n");
|
||||
printf("Test number: %d\n", test_cntr_ + 1);
|
||||
printf("Test type: Stereo-to-mono\n");
|
||||
}
|
||||
test_cntr_++;
|
||||
OpenOutFile(test_cntr_);
|
||||
RegisterSendCodec('A', codec_l16, 8000, 128000, 80, codec_channels);
|
||||
Run(channel_a2b_, audio_channels, codec_channels);
|
||||
out_file_.Close();
|
||||
if (test_mode_ != 0) {
|
||||
printf("===============================================================\n");
|
||||
printf("Test number: %d\n", test_cntr_ + 1);
|
||||
printf("Test type: Stereo-to-mono\n");
|
||||
}
|
||||
|
||||
test_cntr_++;
|
||||
OpenOutFile(test_cntr_);
|
||||
RegisterSendCodec('A', codec_l16, 16000, 256000, 160, codec_channels);
|
||||
Run(channel_a2b_, audio_channels, codec_channels);
|
||||
out_file_.Close();
|
||||
if (test_mode_ != 0) {
|
||||
printf("==============================================================\n");
|
||||
printf("Test number: %d\n", test_cntr_ + 1);
|
||||
printf("Test type: Stereo-to-mono\n");
|
||||
}
|
||||
|
||||
test_cntr_++;
|
||||
OpenOutFile(test_cntr_);
|
||||
RegisterSendCodec('A', codec_l16, 32000, 512000, 320, codec_channels);
|
||||
Run(channel_a2b_, audio_channels, codec_channels);
|
||||
out_file_.Close();
|
||||
#ifdef PCMA_AND_PCMU
|
||||
if (test_mode_ != 0) {
|
||||
printf("===============================================================\n");
|
||||
printf("Test number: %d\n", test_cntr_ + 1);
|
||||
printf("Test type: Stereo-to-mono\n");
|
||||
}
|
||||
test_cntr_++;
|
||||
OpenOutFile(test_cntr_);
|
||||
RegisterSendCodec('A', codec_pcmu, 8000, 64000, 80, codec_channels);
|
||||
@ -483,26 +386,11 @@ void TestStereo::Perform() {
|
||||
out_file_.Close();
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_OPUS
|
||||
if (test_mode_ != 0) {
|
||||
printf("===============================================================\n");
|
||||
printf("Test number: %d\n", test_cntr_ + 1);
|
||||
printf("Test type: Stereo-to-mono\n");
|
||||
}
|
||||
test_cntr_++;
|
||||
OpenOutFile(test_cntr_);
|
||||
// Encode and decode in mono.
|
||||
RegisterSendCodec('A', codec_opus, 48000, 32000, 960, codec_channels);
|
||||
CodecInst opus_codec_param;
|
||||
for (uint8_t n = 0; n < num_encoders; n++) {
|
||||
EXPECT_EQ(0, acm_b_->Codec(n, &opus_codec_param));
|
||||
if (!strcmp(opus_codec_param.plname, "opus")) {
|
||||
opus_codec_param.channels = 1;
|
||||
EXPECT_EQ(true,
|
||||
acm_b_->RegisterReceiveCodec(opus_codec_param.pltype,
|
||||
CodecInstToSdp(opus_codec_param)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
acm_b_->SetReceiveCodecs({{120, {"OPUS", 48000, 2}}});
|
||||
Run(channel_a2b_, audio_channels, codec_channels);
|
||||
|
||||
// Encode in stereo, decode in mono.
|
||||
@ -516,65 +404,22 @@ void TestStereo::Perform() {
|
||||
// Decode in mono.
|
||||
test_cntr_++;
|
||||
OpenOutFile(test_cntr_);
|
||||
if (test_mode_ != 0) {
|
||||
// Print out codec and settings
|
||||
printf(
|
||||
"Test number: %d\nCodec: Opus Freq: 48000 Rate :32000 PackSize: 960"
|
||||
" Decode: mono\n",
|
||||
test_cntr_);
|
||||
}
|
||||
Run(channel_a2b_, audio_channels, codec_channels);
|
||||
out_file_.Close();
|
||||
// Decode in stereo.
|
||||
test_cntr_++;
|
||||
OpenOutFile(test_cntr_);
|
||||
if (test_mode_ != 0) {
|
||||
// Print out codec and settings
|
||||
printf(
|
||||
"Test number: %d\nCodec: Opus Freq: 48000 Rate :32000 PackSize: 960"
|
||||
" Decode: stereo\n",
|
||||
test_cntr_);
|
||||
}
|
||||
opus_codec_param.channels = 2;
|
||||
EXPECT_EQ(true,
|
||||
acm_b_->RegisterReceiveCodec(opus_codec_param.pltype,
|
||||
CodecInstToSdp(opus_codec_param)));
|
||||
acm_b_->SetReceiveCodecs({{120, {"OPUS", 48000, 2, {{"stereo", "1"}}}}});
|
||||
Run(channel_a2b_, audio_channels, 2);
|
||||
out_file_.Close();
|
||||
// Decode in mono.
|
||||
test_cntr_++;
|
||||
OpenOutFile(test_cntr_);
|
||||
if (test_mode_ != 0) {
|
||||
// Print out codec and settings
|
||||
printf(
|
||||
"Test number: %d\nCodec: Opus Freq: 48000 Rate :32000 PackSize: 960"
|
||||
" Decode: mono\n",
|
||||
test_cntr_);
|
||||
}
|
||||
opus_codec_param.channels = 1;
|
||||
EXPECT_EQ(true,
|
||||
acm_b_->RegisterReceiveCodec(opus_codec_param.pltype,
|
||||
CodecInstToSdp(opus_codec_param)));
|
||||
acm_b_->SetReceiveCodecs({{120, {"OPUS", 48000, 2}}});
|
||||
Run(channel_a2b_, audio_channels, codec_channels);
|
||||
out_file_.Close();
|
||||
|
||||
#endif
|
||||
|
||||
// Print out which codecs were tested, and which were not, in the run.
|
||||
if (test_mode_ != 0) {
|
||||
printf("\nThe following codecs was INCLUDED in the test:\n");
|
||||
printf(" G.722\n");
|
||||
printf(" PCM16\n");
|
||||
printf(" G.711\n");
|
||||
#ifdef WEBRTC_CODEC_OPUS
|
||||
printf(" Opus\n");
|
||||
#endif
|
||||
printf(
|
||||
"\nTo complete the test, listen to the %d number of output "
|
||||
"files.\n",
|
||||
test_cntr_);
|
||||
}
|
||||
|
||||
// Delete the file pointers.
|
||||
delete in_file_stereo_;
|
||||
delete in_file_mono_;
|
||||
@ -594,12 +439,6 @@ void TestStereo::RegisterSendCodec(char side,
|
||||
int rate,
|
||||
int pack_size,
|
||||
int channels) {
|
||||
if (test_mode_ != 0) {
|
||||
// Print out codec and settings
|
||||
printf("Codec: %s Freq: %d Rate: %d PackSize: %d\n", codec_name,
|
||||
sampling_freq_hz, rate, pack_size);
|
||||
}
|
||||
|
||||
// Store packet size in samples, used to validate the received packet
|
||||
pack_size_samp_ = pack_size;
|
||||
|
||||
@ -719,7 +558,7 @@ void TestStereo::Run(TestPackStereo* channel,
|
||||
}
|
||||
}
|
||||
|
||||
// Run received side of ACM
|
||||
// Run receive side of ACM
|
||||
bool muted;
|
||||
EXPECT_EQ(0, acm_b_->PlayoutData10Ms(out_freq_hz_b, &audio_frame, &muted));
|
||||
ASSERT_FALSE(muted);
|
||||
@ -758,17 +597,4 @@ void TestStereo::OpenOutFile(int16_t test_number) {
|
||||
out_file_.Open(file_name, 32000, "wb");
|
||||
}
|
||||
|
||||
void TestStereo::DisplaySendReceiveCodec() {
|
||||
auto send_codec = acm_a_->SendCodec();
|
||||
if (test_mode_ != 0) {
|
||||
ASSERT_TRUE(send_codec);
|
||||
printf("%s -> ", send_codec->plname);
|
||||
}
|
||||
CodecInst receive_codec;
|
||||
acm_b_->ReceiveCodec(&receive_codec);
|
||||
if (test_mode_ != 0) {
|
||||
printf("%s\n", receive_codec.plname);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
Reference in New Issue
Block a user