Stop using old AudioCodingModule::RegisterReceiveCodec overloads

BUG=webrtc:5801

Review-Url: https://codereview.webrtc.org/2388153004
Cr-Commit-Position: refs/heads/master@{#14753}
This commit is contained in:
kwiberg
2016-10-24 13:47:09 -07:00
committed by Commit bot
parent 88b7074745
commit da2bf4e150
24 changed files with 202 additions and 78 deletions

View File

@ -23,6 +23,7 @@
#include "webrtc/base/timeutils.h"
#include "webrtc/common_types.h"
#include "webrtc/modules/audio_coding/acm2/acm_common_defs.h"
#include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h"
#include "webrtc/modules/audio_coding/test/utility.h"
#include "webrtc/system_wrappers/include/event_wrapper.h"
#include "webrtc/system_wrappers/include/trace.h"
@ -141,7 +142,8 @@ int16_t APITest::SetUp() {
// Check registration with an already occupied payload type
int currentPayloadType = dummyCodec.pltype;
dummyCodec.pltype = 97; //lastPayloadType;
CHECK_ERROR(_acmB->RegisterReceiveCodec(dummyCodec));
EXPECT_EQ(true, _acmB->RegisterReceiveCodec(dummyCodec.pltype,
CodecInstToSdp(dummyCodec)));
dummyCodec.pltype = currentPayloadType;
}
@ -152,7 +154,8 @@ int16_t APITest::SetUp() {
AudioCodingModule::Codec(n + 1, &nextCodec);
dummyCodec.pltype = nextCodec.pltype;
if (!FixedPayloadTypeCodec(nextCodec.plname)) {
_acmB->RegisterReceiveCodec(dummyCodec);
_acmB->RegisterReceiveCodec(dummyCodec.pltype,
CodecInstToSdp(dummyCodec));
}
dummyCodec.pltype = currentPayloadType;
}
@ -163,14 +166,17 @@ int16_t APITest::SetUp() {
AudioCodingModule::Codec(n + 1, &nextCodec);
nextCodec.pltype = dummyCodec.pltype;
if (!FixedPayloadTypeCodec(nextCodec.plname)) {
CHECK_ERROR_MT(_acmA->RegisterReceiveCodec(nextCodec));
EXPECT_EQ(true, _acmA->RegisterReceiveCodec(nextCodec.pltype,
CodecInstToSdp(nextCodec)));
CHECK_ERROR_MT(_acmA->UnregisterReceiveCodec(nextCodec.pltype));
}
}
CHECK_ERROR_MT(_acmA->RegisterReceiveCodec(dummyCodec));
EXPECT_EQ(true, _acmA->RegisterReceiveCodec(dummyCodec.pltype,
CodecInstToSdp(dummyCodec)));
printf(" side A done!");
CHECK_ERROR_MT(_acmB->RegisterReceiveCodec(dummyCodec));
EXPECT_EQ(true, _acmB->RegisterReceiveCodec(dummyCodec.pltype,
CodecInstToSdp(dummyCodec)));
printf(" side B done!\n");
if (!strcmp(dummyCodec.plname, "CN")) {
@ -871,7 +877,8 @@ void APITest::TestRegisteration(char sendSide) {
"Register receive codec with default Payload, AUDIO BACK.\n");
fflush (stdout);
}
CHECK_ERROR_MT(receiveACM->RegisterReceiveCodec(*myCodec));
EXPECT_EQ(true, receiveACM->RegisterReceiveCodec(
myCodec->pltype, CodecInstToSdp(*myCodec)));
//CHECK_ERROR_MT(sendACM->RegisterSendCodec(*myCodec));
myEvent->Wait(20);
{
@ -884,7 +891,8 @@ void APITest::TestRegisteration(char sendSide) {
}
}
if (i == 32) {
CHECK_ERROR_MT(receiveACM->RegisterReceiveCodec(*myCodec));
EXPECT_EQ(true, receiveACM->RegisterReceiveCodec(
myCodec->pltype, CodecInstToSdp(*myCodec)));
{
WriteLockScoped wl(_apiTestRWLock);
*thereIsDecoder = true;
@ -896,7 +904,8 @@ void APITest::TestRegisteration(char sendSide) {
"Register receive codec with fixed Payload, AUDIO BACK.\n");
fflush (stdout);
}
CHECK_ERROR_MT(receiveACM->RegisterReceiveCodec(*myCodec));
EXPECT_EQ(true, receiveACM->RegisterReceiveCodec(myCodec->pltype,
CodecInstToSdp(*myCodec)));
//CHECK_ERROR_MT(receiveACM->UnregisterReceiveCodec(myCodec->pltype));
//CHECK_ERROR_MT(receiveACM->RegisterReceiveCodec(*myCodec));
myEvent->Wait(20);

View File

@ -17,6 +17,7 @@
#include "webrtc/common_types.h"
#include "webrtc/modules/audio_coding/acm2/acm_common_defs.h"
#include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h"
#include "webrtc/modules/audio_coding/include/audio_coding_module.h"
#include "webrtc/modules/audio_coding/test/utility.h"
#include "webrtc/system_wrappers/include/trace.h"
@ -132,11 +133,13 @@ void Receiver::Setup(AudioCodingModule *acm, RTPStream *rtpStream,
for (int i = 0; i < noOfCodecs; i++) {
EXPECT_EQ(0, acm->Codec(i, &recvCodec));
if (recvCodec.channels == channels)
EXPECT_EQ(0, acm->RegisterReceiveCodec(recvCodec));
EXPECT_EQ(true, acm->RegisterReceiveCodec(recvCodec.pltype,
CodecInstToSdp(recvCodec)));
// Forces mono/stereo for Opus.
if (!strcmp(recvCodec.plname, "opus")) {
recvCodec.channels = channels;
EXPECT_EQ(0, acm->RegisterReceiveCodec(recvCodec));
EXPECT_EQ(true, acm->RegisterReceiveCodec(recvCodec.pltype,
CodecInstToSdp(recvCodec)));
}
}

View File

@ -15,6 +15,7 @@
#include <string>
#include "webrtc/common_types.h"
#include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h"
#include "webrtc/modules/audio_coding/include/audio_coding_module.h"
#include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h"
#include "webrtc/modules/audio_coding/test/utility.h"
@ -141,7 +142,8 @@ void TestAllCodecs::Perform() {
if (!strcmp(my_codec_param.plname, "opus")) {
my_codec_param.channels = 1;
}
acm_b_->RegisterReceiveCodec(my_codec_param);
acm_b_->RegisterReceiveCodec(my_codec_param.pltype,
CodecInstToSdp(my_codec_param));
}
// Create and connect the channel

View File

@ -13,6 +13,7 @@
#include <assert.h>
#include "webrtc/common_types.h"
#include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h"
#include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h"
#include "webrtc/modules/audio_coding/test/utility.h"
#include "webrtc/system_wrappers/include/trace.h"
@ -77,7 +78,8 @@ void TestRedFec::Perform() {
if (!strcmp(myCodecParam.plname, "opus")) {
myCodecParam.channels = 1;
}
EXPECT_EQ(0, _acmB->RegisterReceiveCodec(myCodecParam));
EXPECT_EQ(true, _acmB->RegisterReceiveCodec(myCodecParam.pltype,
CodecInstToSdp(myCodecParam)));
}
// Create and connect the channel

View File

@ -15,6 +15,7 @@
#include <string>
#include "webrtc/common_types.h"
#include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h"
#include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h"
#include "webrtc/modules/audio_coding/test/utility.h"
#include "webrtc/system_wrappers/include/trace.h"
@ -171,7 +172,8 @@ void TestStereo::Perform() {
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(0, acm_b_->RegisterReceiveCodec(my_codec_param));
EXPECT_EQ(true, acm_b_->RegisterReceiveCodec(
my_codec_param.pltype, CodecInstToSdp(my_codec_param)));
}
// Test that unregister all receive codecs works.
@ -183,7 +185,8 @@ void TestStereo::Perform() {
// 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(0, acm_b_->RegisterReceiveCodec(my_codec_param));
EXPECT_EQ(true, acm_b_->RegisterReceiveCodec(
my_codec_param.pltype, CodecInstToSdp(my_codec_param)));
}
// Create and connect the channel.
@ -597,7 +600,9 @@ void TestStereo::Perform() {
EXPECT_EQ(0, acm_b_->Codec(n, &opus_codec_param));
if (!strcmp(opus_codec_param.plname, "opus")) {
opus_codec_param.channels = 1;
EXPECT_EQ(0, acm_b_->RegisterReceiveCodec(opus_codec_param));
EXPECT_EQ(true,
acm_b_->RegisterReceiveCodec(opus_codec_param.pltype,
CodecInstToSdp(opus_codec_param)));
break;
}
}
@ -630,7 +635,9 @@ void TestStereo::Perform() {
" Decode: stereo\n", test_cntr_);
}
opus_codec_param.channels = 2;
EXPECT_EQ(0, acm_b_->RegisterReceiveCodec(opus_codec_param));
EXPECT_EQ(true,
acm_b_->RegisterReceiveCodec(opus_codec_param.pltype,
CodecInstToSdp(opus_codec_param)));
Run(channel_a2b_, audio_channels, 2);
out_file_.Close();
// Decode in mono.
@ -642,7 +649,9 @@ void TestStereo::Perform() {
" Decode: mono\n", test_cntr_);
}
opus_codec_param.channels = 1;
EXPECT_EQ(0, acm_b_->RegisterReceiveCodec(opus_codec_param));
EXPECT_EQ(true,
acm_b_->RegisterReceiveCodec(opus_codec_param.pltype,
CodecInstToSdp(opus_codec_param)));
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();

View File

@ -12,6 +12,7 @@
#include <string>
#include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h"
#include "webrtc/modules/audio_coding/test/PCMFile.h"
#include "webrtc/modules/audio_coding/test/utility.h"
#include "webrtc/test/testsupport/fileutils.h"
@ -73,7 +74,8 @@ TestVadDtx::TestVadDtx()
void TestVadDtx::RegisterCodec(CodecInst codec_param) {
// Set the codec for sending and receiving.
EXPECT_EQ(0, acm_send_->RegisterSendCodec(codec_param));
EXPECT_EQ(0, acm_receive_->RegisterReceiveCodec(codec_param));
EXPECT_EQ(true, acm_receive_->RegisterReceiveCodec(
codec_param.pltype, CodecInstToSdp(codec_param)));
channel_->SetIsStereo(codec_param.channels > 1);
}

View File

@ -21,6 +21,7 @@
#endif
#include "webrtc/common_types.h"
#include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h"
#include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h"
#include "webrtc/modules/audio_coding/test/PCMFile.h"
#include "webrtc/modules/audio_coding/test/utility.h"
@ -97,18 +98,22 @@ void TwoWayCommunication::SetUp() {
//--- Set A codecs
EXPECT_EQ(0, _acmA->RegisterSendCodec(codecInst_A));
EXPECT_EQ(0, _acmA->RegisterReceiveCodec(codecInst_B));
EXPECT_EQ(true, _acmA->RegisterReceiveCodec(codecInst_B.pltype,
CodecInstToSdp(codecInst_B)));
//--- Set ref-A codecs
EXPECT_EQ(0, _acmRefA->RegisterSendCodec(codecInst_A));
EXPECT_EQ(0, _acmRefA->RegisterReceiveCodec(codecInst_B));
EXPECT_EQ(true, _acmRefA->RegisterReceiveCodec(codecInst_B.pltype,
CodecInstToSdp(codecInst_B)));
//--- Set B codecs
EXPECT_EQ(0, _acmB->RegisterSendCodec(codecInst_B));
EXPECT_EQ(0, _acmB->RegisterReceiveCodec(codecInst_A));
EXPECT_EQ(true, _acmB->RegisterReceiveCodec(codecInst_A.pltype,
CodecInstToSdp(codecInst_A)));
//--- Set ref-B codecs
EXPECT_EQ(0, _acmRefB->RegisterSendCodec(codecInst_B));
EXPECT_EQ(0, _acmRefB->RegisterReceiveCodec(codecInst_A));
EXPECT_EQ(true, _acmRefB->RegisterReceiveCodec(codecInst_A.pltype,
CodecInstToSdp(codecInst_A)));
uint16_t frequencyHz;
@ -174,19 +179,23 @@ void TwoWayCommunication::SetUpAutotest() {
//--- Set A codecs
EXPECT_EQ(0, _acmA->RegisterSendCodec(codecInst_A));
EXPECT_EQ(0, _acmA->RegisterReceiveCodec(codecInst_B));
EXPECT_EQ(true, _acmA->RegisterReceiveCodec(codecInst_B.pltype,
CodecInstToSdp(codecInst_B)));
//--- Set ref-A codecs
EXPECT_GT(_acmRefA->RegisterSendCodec(codecInst_A), -1);
EXPECT_GT(_acmRefA->RegisterReceiveCodec(codecInst_B), -1);
EXPECT_EQ(true, _acmRefA->RegisterReceiveCodec(codecInst_B.pltype,
CodecInstToSdp(codecInst_B)));
//--- Set B codecs
EXPECT_GT(_acmB->RegisterSendCodec(codecInst_B), -1);
EXPECT_GT(_acmB->RegisterReceiveCodec(codecInst_A), -1);
EXPECT_EQ(true, _acmB->RegisterReceiveCodec(codecInst_A.pltype,
CodecInstToSdp(codecInst_A)));
//--- Set ref-B codecs
EXPECT_EQ(0, _acmRefB->RegisterSendCodec(codecInst_B));
EXPECT_EQ(0, _acmRefB->RegisterReceiveCodec(codecInst_A));
EXPECT_EQ(true, _acmRefB->RegisterReceiveCodec(codecInst_A.pltype,
CodecInstToSdp(codecInst_A)));
uint16_t frequencyHz;
@ -292,7 +301,8 @@ void TwoWayCommunication::Perform() {
EXPECT_EQ(0, _acmA->InitializeReceiver());
// Re-register codec on side A.
if (((secPassed % 7) == 6) && (msecPassed >= 990)) {
EXPECT_EQ(0, _acmA->RegisterReceiveCodec(*codecInst_B));
EXPECT_EQ(true, _acmA->RegisterReceiveCodec(
codecInst_B->pltype, CodecInstToSdp(*codecInst_B)));
}
}
}

View File

@ -17,6 +17,7 @@
#include "gflags/gflags.h"
#include "webrtc/common_types.h"
#include "webrtc/modules/audio_coding/acm2/acm_common_defs.h"
#include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h"
#include "webrtc/modules/audio_coding/include/audio_coding_module.h"
#include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h"
#include "webrtc/modules/audio_coding/test/Channel.h"
@ -107,8 +108,9 @@ class DelayTest {
continue;
if (STR_CASE_CMP(my_codec_param.plname, "telephone-event") == 0)
continue;
ASSERT_EQ(0, acm_b_->RegisterReceiveCodec(my_codec_param)) <<
"Couldn't register receive codec.\n";
ASSERT_EQ(true,
acm_b_->RegisterReceiveCodec(my_codec_param.pltype,
CodecInstToSdp(my_codec_param)));
}
// Create and connect the channel

View File

@ -24,6 +24,7 @@
#endif
#include "webrtc/modules/audio_coding/acm2/acm_common_defs.h"
#include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h"
#include "webrtc/modules/audio_coding/test/utility.h"
#include "webrtc/system_wrappers/include/event_wrapper.h"
#include "webrtc/system_wrappers/include/trace.h"
@ -94,10 +95,14 @@ void ISACTest::Setup() {
}
// Register both iSAC-wb & iSAC-swb in both sides as receiver codecs.
EXPECT_EQ(0, _acmA->RegisterReceiveCodec(_paramISAC16kHz));
EXPECT_EQ(0, _acmA->RegisterReceiveCodec(_paramISAC32kHz));
EXPECT_EQ(0, _acmB->RegisterReceiveCodec(_paramISAC16kHz));
EXPECT_EQ(0, _acmB->RegisterReceiveCodec(_paramISAC32kHz));
EXPECT_EQ(true, _acmA->RegisterReceiveCodec(_paramISAC16kHz.pltype,
CodecInstToSdp(_paramISAC16kHz)));
EXPECT_EQ(true, _acmA->RegisterReceiveCodec(_paramISAC32kHz.pltype,
CodecInstToSdp(_paramISAC32kHz)));
EXPECT_EQ(true, _acmB->RegisterReceiveCodec(_paramISAC16kHz.pltype,
CodecInstToSdp(_paramISAC16kHz)));
EXPECT_EQ(true, _acmB->RegisterReceiveCodec(_paramISAC32kHz.pltype,
CodecInstToSdp(_paramISAC32kHz)));
//--- Set A-to-B channel
_channel_A2B.reset(new Channel);

View File

@ -14,6 +14,7 @@
#include "gflags/gflags.h"
#include "webrtc/common_types.h"
#include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h"
#include "webrtc/modules/audio_coding/include/audio_coding_module.h"
#include "webrtc/modules/audio_coding/test/Channel.h"
#include "webrtc/modules/audio_coding/test/PCMFile.h"
@ -94,7 +95,8 @@ class InsertPacketWithTiming {
FLAGS_codec_channels));
ASSERT_EQ(0, receive_acm_->InitializeReceiver());
ASSERT_EQ(0, send_acm_->RegisterSendCodec(codec));
ASSERT_EQ(0, receive_acm_->RegisterReceiveCodec(codec));
ASSERT_EQ(true, receive_acm_->RegisterReceiveCodec(codec.pltype,
CodecInstToSdp(codec)));
// Set codec-dependent parameters.
samples_in_1ms_ = codec.plfreq / 1000;

View File

@ -15,6 +15,7 @@
#include <string>
#include "webrtc/common_types.h"
#include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h"
#include "webrtc/modules/audio_coding/codecs/opus/opus_interface.h"
#include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h"
#include "webrtc/modules/audio_coding/test/TestStereo.h"
@ -94,7 +95,9 @@ void OpusTest::Perform() {
int codec_id = acm_receiver_->Codec("opus", 48000, 2);
EXPECT_EQ(0, acm_receiver_->Codec(codec_id, &opus_codec_param));
payload_type_ = opus_codec_param.pltype;
EXPECT_EQ(0, acm_receiver_->RegisterReceiveCodec(opus_codec_param));
EXPECT_EQ(true,
acm_receiver_->RegisterReceiveCodec(
opus_codec_param.pltype, CodecInstToSdp(opus_codec_param)));
// Create and connect the channel.
channel_a2b_ = new TestPackStereo;
@ -159,7 +162,9 @@ void OpusTest::Perform() {
// Register Opus mono as receiving codec.
opus_codec_param.channels = 1;
EXPECT_EQ(0, acm_receiver_->RegisterReceiveCodec(opus_codec_param));
EXPECT_EQ(true,
acm_receiver_->RegisterReceiveCodec(
opus_codec_param.pltype, CodecInstToSdp(opus_codec_param)));
// Run Opus with 2.5 ms frame size.
Run(channel_a2b_, audio_channels, 32000, 120);

View File

@ -30,12 +30,12 @@ class TargetDelayTest : public ::testing::Test {
void SetUp() {
EXPECT_TRUE(acm_.get() != NULL);
CodecInst codec;
ASSERT_EQ(0, AudioCodingModule::Codec("L16", &codec, kSampleRateHz, 1));
ASSERT_EQ(0, acm_->InitializeReceiver());
ASSERT_EQ(0, acm_->RegisterReceiveCodec(codec));
constexpr int pltype = 108;
ASSERT_EQ(true,
acm_->RegisterReceiveCodec(pltype, {"L16", kSampleRateHz, 1}));
rtp_info_.header.payloadType = codec.pltype;
rtp_info_.header.payloadType = pltype;
rtp_info_.header.timestamp = 0;
rtp_info_.header.ssrc = 0x12345678;
rtp_info_.header.markerBit = false;