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:
parent
88b7074745
commit
da2bf4e150
3
.gn
3
.gn
@ -22,6 +22,9 @@ secondary_source = "//build/secondary/"
|
||||
check_targets = [
|
||||
"//webrtc/api:audio_mixer_api",
|
||||
"//webrtc/api:rtc_stats_api",
|
||||
"//webrtc/modules/audio_coding:audio_decoder_factory_interface",
|
||||
"//webrtc/modules/audio_coding:audio_format",
|
||||
"//webrtc/modules/audio_coding:audio_format_conversion",
|
||||
"//webrtc/modules/audio_coding:g711_test",
|
||||
"//webrtc/modules/audio_coding:g722_test",
|
||||
"//webrtc/modules/audio_coding:ilbc_test",
|
||||
|
||||
@ -63,6 +63,7 @@ if (rtc_include_tests) {
|
||||
"..:webrtc_common",
|
||||
"../common_video",
|
||||
"../modules/audio_coding",
|
||||
"../modules/audio_coding:audio_format_conversion",
|
||||
"../modules/rtp_rtcp",
|
||||
"../modules/utility",
|
||||
"../modules/video_coding",
|
||||
|
||||
@ -39,14 +39,36 @@ audio_coding_deps = audio_codec_deps + [
|
||||
"../../system_wrappers",
|
||||
]
|
||||
|
||||
rtc_static_library("audio_decoder_factory_interface") {
|
||||
rtc_static_library("audio_format") {
|
||||
sources = [
|
||||
"codecs/audio_decoder_factory.h",
|
||||
"codecs/audio_format.cc",
|
||||
"codecs/audio_format.h",
|
||||
]
|
||||
deps = [
|
||||
"../..:webrtc_common",
|
||||
"//webrtc:webrtc_common",
|
||||
]
|
||||
}
|
||||
|
||||
rtc_static_library("audio_format_conversion") {
|
||||
sources = [
|
||||
"codecs/audio_format_conversion.cc",
|
||||
"codecs/audio_format_conversion.h",
|
||||
]
|
||||
deps = [
|
||||
":audio_format",
|
||||
"//webrtc:webrtc_common",
|
||||
"//webrtc/base:rtc_base_approved",
|
||||
]
|
||||
}
|
||||
|
||||
rtc_source_set("audio_decoder_factory_interface") {
|
||||
sources = [
|
||||
"codecs/audio_decoder_factory.h",
|
||||
]
|
||||
deps = [
|
||||
":audio_decoder_interface",
|
||||
":audio_format",
|
||||
"//webrtc/base:rtc_base_approved",
|
||||
]
|
||||
}
|
||||
|
||||
@ -934,6 +956,7 @@ if (rtc_include_tests) {
|
||||
|
||||
deps = [
|
||||
":audio_coding",
|
||||
":audio_format_conversion",
|
||||
"../../:webrtc_common",
|
||||
"../../system_wrappers",
|
||||
"../../system_wrappers:system_wrappers_default",
|
||||
@ -959,6 +982,7 @@ if (rtc_include_tests) {
|
||||
|
||||
deps = [
|
||||
":audio_coding",
|
||||
":audio_format_conversion",
|
||||
"../../:webrtc_common",
|
||||
"../../system_wrappers",
|
||||
"../../system_wrappers:system_wrappers_default",
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#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/include/audio_coding_module.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/tools/audio_sink.h"
|
||||
@ -132,7 +133,9 @@ void AcmReceiveTestOldApi::RegisterDefaultCodecs() {
|
||||
for (int n = 0; n < acm_->NumberOfCodecs(); n++) {
|
||||
ASSERT_EQ(0, acm_->Codec(n, &my_codec_param)) << "Failed to get codec.";
|
||||
if (ModifyAndUseThisCodec(&my_codec_param)) {
|
||||
ASSERT_EQ(0, acm_->RegisterReceiveCodec(my_codec_param))
|
||||
ASSERT_EQ(true,
|
||||
acm_->RegisterReceiveCodec(my_codec_param.pltype,
|
||||
CodecInstToSdp(my_codec_param)))
|
||||
<< "Couldn't register receive codec.\n";
|
||||
}
|
||||
}
|
||||
@ -151,22 +154,14 @@ void AcmReceiveTestOldApi::RegisterNetEqTestCodecs() {
|
||||
my_codec_param.plfreq,
|
||||
my_codec_param.channels,
|
||||
&my_codec_param.pltype)) {
|
||||
ASSERT_EQ(0, acm_->RegisterReceiveCodec(my_codec_param))
|
||||
ASSERT_EQ(true,
|
||||
acm_->RegisterReceiveCodec(my_codec_param.pltype,
|
||||
CodecInstToSdp(my_codec_param)))
|
||||
<< "Couldn't register receive codec.\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int AcmReceiveTestOldApi::RegisterExternalReceiveCodec(
|
||||
int rtp_payload_type,
|
||||
AudioDecoder* external_decoder,
|
||||
int sample_rate_hz,
|
||||
int num_channels,
|
||||
const std::string& name) {
|
||||
return acm_->RegisterExternalReceiveCodec(rtp_payload_type, external_decoder,
|
||||
sample_rate_hz, num_channels, name);
|
||||
}
|
||||
|
||||
void AcmReceiveTestOldApi::Run() {
|
||||
for (std::unique_ptr<Packet> packet(packet_source_->NextPacket()); packet;
|
||||
packet = packet_source_->NextPacket()) {
|
||||
|
||||
@ -50,12 +50,6 @@ class AcmReceiveTestOldApi {
|
||||
// files.
|
||||
void RegisterNetEqTestCodecs();
|
||||
|
||||
int RegisterExternalReceiveCodec(int rtp_payload_type,
|
||||
AudioDecoder* external_decoder,
|
||||
int sample_rate_hz,
|
||||
int num_channels,
|
||||
const std::string& name);
|
||||
|
||||
// Runs the test and returns true if successful.
|
||||
void Run();
|
||||
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
#include "webrtc/modules/audio_coding/acm2/acm_send_test.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/audio_encoder.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/g711/audio_decoder_pcm.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_encoder_isac.h"
|
||||
@ -777,7 +778,8 @@ class AcmReRegisterIsacMtTestOldApi : public AudioCodingModuleTestOldApi {
|
||||
// Register iSAC codec in ACM, effectively unregistering the PCM16B codec
|
||||
// registered in AudioCodingModuleTestOldApi::SetUp();
|
||||
// Only register the decoder for now. The encoder is registered later.
|
||||
ASSERT_EQ(0, acm_->RegisterReceiveCodec(codec_));
|
||||
ASSERT_EQ(true, acm_->RegisterReceiveCodec(codec_.pltype,
|
||||
CodecInstToSdp(codec_)));
|
||||
}
|
||||
|
||||
void StartThreads() {
|
||||
|
||||
@ -87,6 +87,8 @@
|
||||
'codecs/audio_decoder_factory.h',
|
||||
'codecs/audio_format.cc',
|
||||
'codecs/audio_format.h',
|
||||
'codecs/audio_format_conversion.cc',
|
||||
'codecs/audio_format_conversion.h',
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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/codecs/audio_format_conversion.h"
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/safe_conversions.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
SdpAudioFormat CodecInstToSdp(const CodecInst& ci) {
|
||||
if (STR_CASE_CMP(ci.plname, "g722") == 0 && ci.plfreq == 16000) {
|
||||
RTC_CHECK(ci.channels == 1 || ci.channels == 2);
|
||||
return {"g722", 8000, static_cast<int>(ci.channels)};
|
||||
} else if (STR_CASE_CMP(ci.plname, "opus") == 0 && ci.plfreq == 48000) {
|
||||
RTC_CHECK(ci.channels == 1 || ci.channels == 2);
|
||||
return {"opus", 48000, 2, {{"stereo", ci.channels == 1 ? "0" : "1"}}};
|
||||
} else {
|
||||
return {ci.plname, ci.plfreq, rtc::checked_cast<int>(ci.channels)};
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
23
webrtc/modules/audio_coding/codecs/audio_format_conversion.h
Normal file
23
webrtc/modules/audio_coding/codecs/audio_format_conversion.h
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* 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_CODECS_AUDIO_FORMAT_CONVERSION_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_CODECS_AUDIO_FORMAT_CONVERSION_H_
|
||||
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/audio_format.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
SdpAudioFormat CodecInstToSdp(const CodecInst& codec_inst);
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_AUDIO_FORMAT_CONVERSION_H_
|
||||
@ -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);
|
||||
|
||||
@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
*/
|
||||
|
||||
#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/include/module_common_types.h"
|
||||
#include "webrtc/modules/utility/source/coder.h"
|
||||
@ -45,9 +46,8 @@ int32_t AudioCoder::SetEncodeCodec(const CodecInst& codec_inst) {
|
||||
}
|
||||
|
||||
int32_t AudioCoder::SetDecodeCodec(const CodecInst& codec_inst) {
|
||||
if (acm_->RegisterReceiveCodec(codec_inst, [&] {
|
||||
return rent_a_codec_.RentIsacDecoder(codec_inst.plfreq);
|
||||
}) == -1) {
|
||||
if (!acm_->RegisterReceiveCodec(codec_inst.pltype,
|
||||
CodecInstToSdp(codec_inst))) {
|
||||
return -1;
|
||||
}
|
||||
memcpy(&receive_codec_, &codec_inst, sizeof(CodecInst));
|
||||
|
||||
@ -93,6 +93,7 @@ rtc_static_library("voice_engine") {
|
||||
"../common_audio",
|
||||
"../logging:rtc_event_log_api",
|
||||
"../modules/audio_coding:audio_decoder_factory_interface",
|
||||
"../modules/audio_coding:audio_format_conversion",
|
||||
"../modules/audio_coding:builtin_audio_decoder_factory",
|
||||
"../modules/audio_coding:rent_a_codec",
|
||||
"../modules/audio_conference_mixer",
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
#include "webrtc/base/timeutils.h"
|
||||
#include "webrtc/config.h"
|
||||
#include "webrtc/logging/rtc_event_log/rtc_event_log.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h"
|
||||
#include "webrtc/modules/audio_device/include/audio_device.h"
|
||||
#include "webrtc/modules/audio_processing/include/audio_processing.h"
|
||||
#include "webrtc/modules/include/module_common_types.h"
|
||||
@ -48,14 +49,6 @@ namespace {
|
||||
constexpr int64_t kMaxRetransmissionWindowMs = 1000;
|
||||
constexpr int64_t kMinRetransmissionWindowMs = 30;
|
||||
|
||||
bool RegisterReceiveCodec(std::unique_ptr<AudioCodingModule>* acm,
|
||||
acm2::RentACodec* rac,
|
||||
const CodecInst& ci) {
|
||||
const int result = (*acm)->RegisterReceiveCodec(
|
||||
ci, [&] { return rac->RentIsacDecoder(ci.plfreq); });
|
||||
return result == 0;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
const int kTelephoneEventAttenuationdB = 10;
|
||||
@ -498,7 +491,8 @@ int32_t Channel::OnInitializeDecoder(
|
||||
receiveCodec.pacsize = dummyCodec.pacsize;
|
||||
|
||||
// Register the new codec to the ACM
|
||||
if (!RegisterReceiveCodec(&audio_coding_, &rent_a_codec_, receiveCodec)) {
|
||||
if (!audio_coding_->RegisterReceiveCodec(receiveCodec.pltype,
|
||||
CodecInstToSdp(receiveCodec))) {
|
||||
WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId),
|
||||
"Channel::OnInitializeDecoder() invalid codec ("
|
||||
"pt=%d, name=%s) received - 1",
|
||||
@ -1066,7 +1060,8 @@ int32_t Channel::Init() {
|
||||
// Register default PT for outband 'telephone-event'
|
||||
if (!STR_CASE_CMP(codec.plname, "telephone-event")) {
|
||||
if (_rtpRtcpModule->RegisterSendPayload(codec) == -1 ||
|
||||
!RegisterReceiveCodec(&audio_coding_, &rent_a_codec_, codec)) {
|
||||
!audio_coding_->RegisterReceiveCodec(codec.pltype,
|
||||
CodecInstToSdp(codec))) {
|
||||
WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId),
|
||||
"Channel::Init() failed to register outband "
|
||||
"'telephone-event' (%d/%d) correctly",
|
||||
@ -1077,7 +1072,8 @@ int32_t Channel::Init() {
|
||||
if (!STR_CASE_CMP(codec.plname, "CN")) {
|
||||
if (!codec_manager_.RegisterEncoder(codec) ||
|
||||
!codec_manager_.MakeEncoder(&rent_a_codec_, audio_coding_.get()) ||
|
||||
!RegisterReceiveCodec(&audio_coding_, &rent_a_codec_, codec) ||
|
||||
!audio_coding_->RegisterReceiveCodec(codec.pltype,
|
||||
CodecInstToSdp(codec)) ||
|
||||
_rtpRtcpModule->RegisterSendPayload(codec) == -1) {
|
||||
WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId),
|
||||
"Channel::Init() failed to register CN (%d/%d) "
|
||||
@ -1425,9 +1421,11 @@ int32_t Channel::SetRecPayloadType(const CodecInst& codec) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (!RegisterReceiveCodec(&audio_coding_, &rent_a_codec_, codec)) {
|
||||
if (!audio_coding_->RegisterReceiveCodec(codec.pltype,
|
||||
CodecInstToSdp(codec))) {
|
||||
audio_coding_->UnregisterReceiveCodec(codec.pltype);
|
||||
if (!RegisterReceiveCodec(&audio_coding_, &rent_a_codec_, codec)) {
|
||||
if (!audio_coding_->RegisterReceiveCodec(codec.pltype,
|
||||
CodecInstToSdp(codec))) {
|
||||
_engineStatisticsPtr->SetLastError(
|
||||
VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
|
||||
"SetRecPayloadType() ACM registration failed - 1");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user