NetEq: Add codec name and RTP timestamp rate to DecoderInfo
The new fields are default-populated for built-in decoders, but for
external decoders, the name can now be given when registering the
decoder.
BUG=webrtc:3520
Review URL: https://codereview.webrtc.org/1484343003
Cr-Commit-Position: refs/heads/master@{#10952}
diff --git a/webrtc/modules/audio_coding/acm2/acm_receive_test_oldapi.cc b/webrtc/modules/audio_coding/acm2/acm_receive_test_oldapi.cc
index bb83e77..8ca77ec 100644
--- a/webrtc/modules/audio_coding/acm2/acm_receive_test_oldapi.cc
+++ b/webrtc/modules/audio_coding/acm2/acm_receive_test_oldapi.cc
@@ -144,9 +144,10 @@
int rtp_payload_type,
AudioDecoder* external_decoder,
int sample_rate_hz,
- int num_channels) {
+ int num_channels,
+ const std::string& name) {
return acm_->RegisterExternalReceiveCodec(rtp_payload_type, external_decoder,
- sample_rate_hz, num_channels);
+ sample_rate_hz, num_channels, name);
}
void AcmReceiveTestOldApi::Run() {
diff --git a/webrtc/modules/audio_coding/acm2/acm_receive_test_oldapi.h b/webrtc/modules/audio_coding/acm2/acm_receive_test_oldapi.h
index 091513d..3010ec7 100644
--- a/webrtc/modules/audio_coding/acm2/acm_receive_test_oldapi.h
+++ b/webrtc/modules/audio_coding/acm2/acm_receive_test_oldapi.h
@@ -11,6 +11,8 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_ACM2_ACM_RECEIVE_TEST_OLDAPI_H_
#define WEBRTC_MODULES_AUDIO_CODING_ACM2_ACM_RECEIVE_TEST_OLDAPI_H_
+#include <string>
+
#include "webrtc/base/constructormagic.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/system_wrappers/include/clock.h"
@@ -48,7 +50,8 @@
int RegisterExternalReceiveCodec(int rtp_payload_type,
AudioDecoder* external_decoder,
int sample_rate_hz,
- int num_channels);
+ int num_channels,
+ const std::string& name);
// Runs the test and returns true if successful.
void Run();
diff --git a/webrtc/modules/audio_coding/acm2/acm_receiver.cc b/webrtc/modules/audio_coding/acm2/acm_receiver.cc
index 036877c..335c2d6 100644
--- a/webrtc/modules/audio_coding/acm2/acm_receiver.cc
+++ b/webrtc/modules/audio_coding/acm2/acm_receiver.cc
@@ -303,7 +303,8 @@
uint8_t payload_type,
int channels,
int sample_rate_hz,
- AudioDecoder* audio_decoder) {
+ AudioDecoder* audio_decoder,
+ const std::string& name) {
const auto neteq_decoder = [acm_codec_id, channels]() -> NetEqDecoder {
if (acm_codec_id == -1)
return NetEqDecoder::kDecoderArbitrary; // External decoder.
@@ -342,10 +343,10 @@
int ret_val;
if (!audio_decoder) {
- ret_val = neteq_->RegisterPayloadType(neteq_decoder, payload_type);
+ ret_val = neteq_->RegisterPayloadType(neteq_decoder, name, payload_type);
} else {
- ret_val = neteq_->RegisterExternalDecoder(audio_decoder, neteq_decoder,
- payload_type, sample_rate_hz);
+ ret_val = neteq_->RegisterExternalDecoder(
+ audio_decoder, neteq_decoder, name, payload_type, sample_rate_hz);
}
if (ret_val != NetEq::kOK) {
LOG(LERROR) << "AcmReceiver::AddCodec " << acm_codec_id
diff --git a/webrtc/modules/audio_coding/acm2/acm_receiver.h b/webrtc/modules/audio_coding/acm2/acm_receiver.h
index d5a644d..86fd927 100644
--- a/webrtc/modules/audio_coding/acm2/acm_receiver.h
+++ b/webrtc/modules/audio_coding/acm2/acm_receiver.h
@@ -12,6 +12,7 @@
#define WEBRTC_MODULES_AUDIO_CODING_ACM2_ACM_RECEIVER_H_
#include <map>
+#include <string>
#include <vector>
#include "webrtc/base/array_view.h"
@@ -117,7 +118,8 @@
uint8_t payload_type,
int channels,
int sample_rate_hz,
- AudioDecoder* audio_decoder);
+ AudioDecoder* audio_decoder,
+ const std::string& name);
//
// Sets a minimum delay for packet buffer. The given delay is maintained,
diff --git a/webrtc/modules/audio_coding/acm2/acm_receiver_unittest_oldapi.cc b/webrtc/modules/audio_coding/acm2/acm_receiver_unittest_oldapi.cc
index 8076687..a7dd3d4 100644
--- a/webrtc/modules/audio_coding/acm2/acm_receiver_unittest_oldapi.cc
+++ b/webrtc/modules/audio_coding/acm2/acm_receiver_unittest_oldapi.cc
@@ -120,7 +120,7 @@
ASSERT_TRUE(i);
ASSERT_EQ(
0, receiver_->AddCodec(*i, codecs_[*i].pltype, codecs_[*i].channels,
- codecs_[*i].plfreq, nullptr));
+ codecs_[*i].plfreq, nullptr, ""));
}
}
@@ -170,7 +170,7 @@
if (n & 0x1) // Just add codecs with odd index.
EXPECT_EQ(0,
receiver_->AddCodec(n, codecs_[n].pltype, codecs_[n].channels,
- codecs_[n].plfreq, NULL));
+ codecs_[n].plfreq, NULL, ""));
}
// Get codec and compare.
for (size_t n = 0; n < codecs_.size(); ++n) {
@@ -197,9 +197,9 @@
// Register the same codec with different payloads.
EXPECT_EQ(0, receiver_->AddCodec(codec1.id, codec1.inst.pltype,
codec1.inst.channels, codec1.inst.plfreq,
- nullptr));
+ nullptr, ""));
EXPECT_EQ(0, receiver_->AddCodec(codec1.id, codec2.pltype, codec2.channels,
- codec2.plfreq, NULL));
+ codec2.plfreq, NULL, ""));
// Both payload types should exist.
EXPECT_EQ(0,
@@ -218,10 +218,10 @@
// Register the same payload type with different codec ID.
EXPECT_EQ(0, receiver_->AddCodec(codec1.id, codec1.inst.pltype,
codec1.inst.channels, codec1.inst.plfreq,
- nullptr));
+ nullptr, ""));
EXPECT_EQ(0, receiver_->AddCodec(codec2.id, codec2.inst.pltype,
codec2.inst.channels, codec2.inst.plfreq,
- nullptr));
+ nullptr, ""));
// Make sure that the last codec is used.
EXPECT_EQ(0,
@@ -234,7 +234,7 @@
const int payload_type = codec.inst.pltype;
EXPECT_EQ(
0, receiver_->AddCodec(codec.id, codec.inst.pltype, codec.inst.channels,
- codec.inst.plfreq, nullptr));
+ codec.inst.plfreq, nullptr, ""));
// Remove non-existing codec should not fail. ACM1 legacy.
EXPECT_EQ(0, receiver_->RemoveCodec(payload_type + 1));
@@ -271,7 +271,7 @@
const CodecIdInst codec(RentACodec::CodecId::kPCM16Bwb);
ASSERT_EQ(
0, receiver_->AddCodec(codec.id, codec.inst.pltype, codec.inst.channels,
- codec.inst.plfreq, nullptr));
+ codec.inst.plfreq, nullptr, ""));
const int kNumPackets = 5;
const int num_10ms_frames = codec.inst.pacsize / (codec.inst.plfreq / 100);
AudioFrame frame;
diff --git a/webrtc/modules/audio_coding/acm2/audio_coding_module_impl.cc b/webrtc/modules/audio_coding/acm2/audio_coding_module_impl.cc
index 5f61ef6..0660993 100644
--- a/webrtc/modules/audio_coding/acm2/audio_coding_module_impl.cc
+++ b/webrtc/modules/audio_coding/acm2/audio_coding_module_impl.cc
@@ -512,7 +512,7 @@
if (IsCodecRED(db[i]) || IsCodecCN(db[i])) {
if (receiver_.AddCodec(static_cast<int>(i),
static_cast<uint8_t>(db[i].pltype), 1,
- db[i].plfreq, nullptr) < 0) {
+ db[i].plfreq, nullptr, db[i].plname) < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_,
"Cannot register master codec.");
return -1;
@@ -566,15 +566,16 @@
// Get |decoder| associated with |codec|. |decoder| is NULL if |codec| does
// not own its decoder.
return receiver_.AddCodec(*codec_index, codec.pltype, codec.channels,
- codec.plfreq,
- codec_manager_.GetAudioDecoder(codec));
+ codec.plfreq, codec_manager_.GetAudioDecoder(codec),
+ codec.plname);
}
int AudioCodingModuleImpl::RegisterExternalReceiveCodec(
int rtp_payload_type,
AudioDecoder* external_decoder,
int sample_rate_hz,
- int num_channels) {
+ int num_channels,
+ const std::string& name) {
CriticalSectionScoped lock(acm_crit_sect_.get());
RTC_DCHECK(receiver_initialized_);
if (num_channels > 2 || num_channels < 0) {
@@ -590,7 +591,7 @@
}
return receiver_.AddCodec(-1 /* external */, rtp_payload_type, num_channels,
- sample_rate_hz, external_decoder);
+ sample_rate_hz, external_decoder, name);
}
// Get current received codec.
diff --git a/webrtc/modules/audio_coding/acm2/audio_coding_module_impl.h b/webrtc/modules/audio_coding/acm2/audio_coding_module_impl.h
index 6006c68..a624b23 100644
--- a/webrtc/modules/audio_coding/acm2/audio_coding_module_impl.h
+++ b/webrtc/modules/audio_coding/acm2/audio_coding_module_impl.h
@@ -11,6 +11,7 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_ACM2_AUDIO_CODING_MODULE_IMPL_H_
#define WEBRTC_MODULES_AUDIO_CODING_ACM2_AUDIO_CODING_MODULE_IMPL_H_
+#include <string>
#include <vector>
#include "webrtc/base/buffer.h"
@@ -123,7 +124,8 @@
int RegisterExternalReceiveCodec(int rtp_payload_type,
AudioDecoder* external_decoder,
int sample_rate_hz,
- int num_channels) override;
+ int num_channels,
+ const std::string& name) override;
// Get current received codec.
int ReceiveCodec(CodecInst* current_codec) const override;
diff --git a/webrtc/modules/audio_coding/acm2/audio_coding_module_unittest_oldapi.cc b/webrtc/modules/audio_coding/acm2/audio_coding_module_unittest_oldapi.cc
index 2b745ce..6675277 100644
--- a/webrtc/modules/audio_coding/acm2/audio_coding_module_unittest_oldapi.cc
+++ b/webrtc/modules/audio_coding/acm2/audio_coding_module_unittest_oldapi.cc
@@ -866,6 +866,7 @@
AudioDecoder* external_decoder;
int sample_rate_hz;
int num_channels;
+ std::string name;
};
void Run(int output_freq_hz,
@@ -901,7 +902,7 @@
for (const auto& ed : external_decoders) {
ASSERT_EQ(0, test.RegisterExternalReceiveCodec(
ed.rtp_payload_type, ed.external_decoder,
- ed.sample_rate_hz, ed.num_channels));
+ ed.sample_rate_hz, ed.num_channels, ed.name));
}
test.Run();
@@ -1026,6 +1027,7 @@
ed.external_decoder = &mock_decoder;
ed.sample_rate_hz = 8000;
ed.num_channels = 1;
+ ed.name = "MockPCMU";
std::vector<ExternalDecoder> external_decoders;
external_decoders.push_back(ed);