From 4cf61dd116288e9f119209c59e07f1d9439d8d05 Mon Sep 17 00:00:00 2001 From: "henrik.lundin" Date: Wed, 9 Dec 2015 06:20:58 -0800 Subject: [PATCH] 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} --- .../acm2/acm_receive_test_oldapi.cc | 5 +- .../acm2/acm_receive_test_oldapi.h | 5 +- .../modules/audio_coding/acm2/acm_receiver.cc | 9 +-- .../modules/audio_coding/acm2/acm_receiver.h | 4 +- .../acm2/acm_receiver_unittest_oldapi.cc | 16 +++--- .../acm2/audio_coding_module_impl.cc | 11 ++-- .../acm2/audio_coding_module_impl.h | 4 +- .../audio_coding_module_unittest_oldapi.cc | 4 +- .../include/audio_coding_module.h | 7 ++- .../audio_coding/neteq/decoder_database.cc | 14 +++-- .../audio_coding/neteq/decoder_database.h | 44 +++++++++------ .../neteq/decoder_database_unittest.cc | 55 ++++++++++++------- .../audio_coding/neteq/include/neteq.h | 15 +++-- .../neteq/mock/mock_decoder_database.h | 12 ++-- .../neteq/neteq_external_decoder_unittest.cc | 6 +- .../modules/audio_coding/neteq/neteq_impl.cc | 8 ++- .../modules/audio_coding/neteq/neteq_impl.h | 10 ++-- .../audio_coding/neteq/neteq_impl_unittest.cc | 25 +++++---- .../neteq/neteq_stereo_unittest.cc | 7 +-- .../audio_coding/neteq/neteq_unittest.cc | 47 +++++++++------- .../neteq/payload_splitter_unittest.cc | 14 ++--- .../tools/neteq_external_decoder_test.cc | 5 +- .../neteq/tools/neteq_external_decoder_test.h | 3 + .../neteq/tools/neteq_performance_test.cc | 3 +- .../neteq/tools/neteq_quality_test.cc | 3 +- .../audio_coding/neteq/tools/neteq_rtpplay.cc | 47 ++++++++++------ 26 files changed, 232 insertions(+), 151 deletions(-) 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 bb83e77931..8ca77eca84 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 AcmReceiveTestOldApi::RegisterExternalReceiveCodec( 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 091513db46..3010ec72b1 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 + #include "webrtc/base/constructormagic.h" #include "webrtc/base/scoped_ptr.h" #include "webrtc/system_wrappers/include/clock.h" @@ -48,7 +50,8 @@ class AcmReceiveTestOldApi { 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 036877ce11..335c2d6bac 100644 --- a/webrtc/modules/audio_coding/acm2/acm_receiver.cc +++ b/webrtc/modules/audio_coding/acm2/acm_receiver.cc @@ -303,7 +303,8 @@ int32_t AcmReceiver::AddCodec(int acm_codec_id, 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 @@ int32_t AcmReceiver::AddCodec(int acm_codec_id, 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 d5a644d5c8..86fd927c8a 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 +#include #include #include "webrtc/base/array_view.h" @@ -117,7 +118,8 @@ class AcmReceiver { 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 8076687c14..a7dd3d4484 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 @@ class AcmReceiverTestOldApi : public AudioPacketizationCallback, 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 @@ TEST_F(AcmReceiverTestOldApi, DISABLED_ON_ANDROID(AddCodecGetCodec)) { 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 @@ TEST_F(AcmReceiverTestOldApi, DISABLED_ON_ANDROID(AddCodecChangePayloadType)) { // 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 @@ TEST_F(AcmReceiverTestOldApi, DISABLED_ON_ANDROID(AddCodecChangeCodecId)) { // 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 @@ TEST_F(AcmReceiverTestOldApi, DISABLED_ON_ANDROID(AddCodecRemoveCodec)) { 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 @@ TEST_F(AcmReceiverTestOldApi, DISABLED_ON_ANDROID(PostdecodingVad)) { 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 5f61ef695b..0660993a23 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 @@ int AudioCodingModuleImpl::InitializeReceiverSafe() { if (IsCodecRED(db[i]) || IsCodecCN(db[i])) { if (receiver_.AddCodec(static_cast(i), static_cast(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 @@ int AudioCodingModuleImpl::RegisterReceiveCodec(const CodecInst& codec) { // 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 @@ int AudioCodingModuleImpl::RegisterExternalReceiveCodec( } 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 6006c68f5c..a624b23067 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 #include #include "webrtc/base/buffer.h" @@ -123,7 +124,8 @@ class AudioCodingModuleImpl final : public AudioCodingModule { 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 2b745ce429..667527768f 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 @@ class AcmReceiverBitExactnessOldApi : public ::testing::Test { AudioDecoder* external_decoder; int sample_rate_hz; int num_channels; + std::string name; }; void Run(int output_freq_hz, @@ -901,7 +902,7 @@ class AcmReceiverBitExactnessOldApi : public ::testing::Test { 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 @@ TEST_F(AcmReceiverBitExactnessOldApi, ed.external_decoder = &mock_decoder; ed.sample_rate_hz = 8000; ed.num_channels = 1; + ed.name = "MockPCMU"; std::vector external_decoders; external_decoders.push_back(ed); diff --git a/webrtc/modules/audio_coding/include/audio_coding_module.h b/webrtc/modules/audio_coding/include/audio_coding_module.h index 844bd57cd1..f5af65a13d 100644 --- a/webrtc/modules/audio_coding/include/audio_coding_module.h +++ b/webrtc/modules/audio_coding/include/audio_coding_module.h @@ -11,6 +11,7 @@ #ifndef WEBRTC_MODULES_AUDIO_CODING_INCLUDE_AUDIO_CODING_MODULE_H_ #define WEBRTC_MODULES_AUDIO_CODING_INCLUDE_AUDIO_CODING_MODULE_H_ +#include #include #include "webrtc/base/optional.h" @@ -471,10 +472,14 @@ class AudioCodingModule { // virtual int RegisterReceiveCodec(const CodecInst& receive_codec) = 0; + // Registers an external decoder. The name is only used to provide information + // back to the caller about the decoder. Hence, the name is arbitrary, and may + // be empty. virtual int RegisterExternalReceiveCodec(int rtp_payload_type, AudioDecoder* external_decoder, int sample_rate_hz, - int num_channels) = 0; + int num_channels, + const std::string& name) = 0; /////////////////////////////////////////////////////////////////////////// // int32_t UnregisterReceiveCodec() diff --git a/webrtc/modules/audio_coding/neteq/decoder_database.cc b/webrtc/modules/audio_coding/neteq/decoder_database.cc index 41803f754a..92d4bab1e4 100644 --- a/webrtc/modules/audio_coding/neteq/decoder_database.cc +++ b/webrtc/modules/audio_coding/neteq/decoder_database.cc @@ -13,6 +13,7 @@ #include #include // pair +#include "webrtc/base/checks.h" #include "webrtc/base/logging.h" #include "webrtc/modules/audio_coding/codecs/audio_decoder.h" @@ -38,17 +39,17 @@ void DecoderDatabase::Reset() { } int DecoderDatabase::RegisterPayload(uint8_t rtp_payload_type, - NetEqDecoder codec_type) { + NetEqDecoder codec_type, + const std::string& name) { if (rtp_payload_type > 0x7F) { return kInvalidRtpPayloadType; } if (!CodecSupported(codec_type)) { return kCodecNotSupported; } - int fs_hz = CodecSampleRateHz(codec_type); - std::pair ret; - DecoderInfo info(codec_type, fs_hz, NULL, false); - ret = decoders_.insert(std::make_pair(rtp_payload_type, info)); + const int fs_hz = CodecSampleRateHz(codec_type); + DecoderInfo info(codec_type, name, fs_hz, NULL, false); + auto ret = decoders_.insert(std::make_pair(rtp_payload_type, info)); if (ret.second == false) { // Database already contains a decoder with type |rtp_payload_type|. return kDecoderExists; @@ -58,6 +59,7 @@ int DecoderDatabase::RegisterPayload(uint8_t rtp_payload_type, int DecoderDatabase::InsertExternal(uint8_t rtp_payload_type, NetEqDecoder codec_type, + const std::string& codec_name, int fs_hz, AudioDecoder* decoder) { if (rtp_payload_type > 0x7F) { @@ -73,7 +75,7 @@ int DecoderDatabase::InsertExternal(uint8_t rtp_payload_type, return kInvalidPointer; } std::pair ret; - DecoderInfo info(codec_type, fs_hz, decoder, true); + DecoderInfo info(codec_type, codec_name, fs_hz, decoder, true); ret = decoders_.insert(std::make_pair(rtp_payload_type, info)); if (ret.second == false) { // Database already contains a decoder with type |rtp_payload_type|. diff --git a/webrtc/modules/audio_coding/neteq/decoder_database.h b/webrtc/modules/audio_coding/neteq/decoder_database.h index ea70997c14..f34904fda8 100644 --- a/webrtc/modules/audio_coding/neteq/decoder_database.h +++ b/webrtc/modules/audio_coding/neteq/decoder_database.h @@ -12,8 +12,10 @@ #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_DECODER_DATABASE_H_ #include +#include #include "webrtc/base/constructormagic.h" +#include "webrtc/base/scoped_ptr.h" #include "webrtc/common_types.h" // NULL #include "webrtc/modules/audio_coding/neteq/audio_decoder_impl.h" #include "webrtc/modules/audio_coding/neteq/packet.h" @@ -35,25 +37,28 @@ class DecoderDatabase { // Struct used to store decoder info in the database. struct DecoderInfo { - // Constructors. - DecoderInfo() - : codec_type(NetEqDecoder::kDecoderArbitrary), - fs_hz(8000), - decoder(NULL), - external(false) {} + DecoderInfo() = default; DecoderInfo(NetEqDecoder ct, int fs, AudioDecoder* dec, bool ext) + : DecoderInfo(ct, "", fs, dec, ext) {} + DecoderInfo(NetEqDecoder ct, + const std::string& nm, + int fs, + AudioDecoder* dec, + bool ext) : codec_type(ct), + name(nm), fs_hz(fs), + rtp_sample_rate_hz(fs), decoder(dec), - external(ext) { - } - // Destructor. (Defined in decoder_database.cc.) + external(ext) {} ~DecoderInfo(); - NetEqDecoder codec_type; - int fs_hz; - AudioDecoder* decoder; - bool external; + NetEqDecoder codec_type = NetEqDecoder::kDecoderArbitrary; + std::string name; + int fs_hz = 8000; + int rtp_sample_rate_hz = 8000; + AudioDecoder* decoder = nullptr; + bool external = false; }; // Maximum value for 8 bits, and an invalid RTP payload type (since it is @@ -75,16 +80,21 @@ class DecoderDatabase { // using InsertExternal(). virtual void Reset(); - // Registers |rtp_payload_type| as a decoder of type |codec_type|. Returns - // kOK on success; otherwise an error code. + // Registers |rtp_payload_type| as a decoder of type |codec_type|. The |name| + // is only used to populate the name field in the DecoderInfo struct in the + // database, and can be arbitrary (including empty). Returns kOK on success; + // otherwise an error code. virtual int RegisterPayload(uint8_t rtp_payload_type, - NetEqDecoder codec_type); + NetEqDecoder codec_type, + const std::string& name); // Registers an externally created AudioDecoder object, and associates it // as a decoder of type |codec_type| with |rtp_payload_type|. virtual int InsertExternal(uint8_t rtp_payload_type, NetEqDecoder codec_type, - int fs_hz, AudioDecoder* decoder); + const std::string& codec_name, + int fs_hz, + AudioDecoder* decoder); // Removes the entry for |rtp_payload_type| from the database. // Returns kDecoderNotFound or kOK depending on the outcome of the operation. diff --git a/webrtc/modules/audio_coding/neteq/decoder_database_unittest.cc b/webrtc/modules/audio_coding/neteq/decoder_database_unittest.cc index e85d8d32fb..f41a17ae3a 100644 --- a/webrtc/modules/audio_coding/neteq/decoder_database_unittest.cc +++ b/webrtc/modules/audio_coding/neteq/decoder_database_unittest.cc @@ -32,8 +32,10 @@ TEST(DecoderDatabase, CreateAndDestroy) { TEST(DecoderDatabase, InsertAndRemove) { DecoderDatabase db; const uint8_t kPayloadType = 0; - EXPECT_EQ(DecoderDatabase::kOK, - db.RegisterPayload(kPayloadType, NetEqDecoder::kDecoderPCMu)); + const std::string kCodecName = "Robert\'); DROP TABLE Students;"; + EXPECT_EQ( + DecoderDatabase::kOK, + db.RegisterPayload(kPayloadType, NetEqDecoder::kDecoderPCMu, kCodecName)); EXPECT_EQ(1, db.Size()); EXPECT_FALSE(db.Empty()); EXPECT_EQ(DecoderDatabase::kOK, db.Remove(kPayloadType)); @@ -44,14 +46,17 @@ TEST(DecoderDatabase, InsertAndRemove) { TEST(DecoderDatabase, GetDecoderInfo) { DecoderDatabase db; const uint8_t kPayloadType = 0; - EXPECT_EQ(DecoderDatabase::kOK, - db.RegisterPayload(kPayloadType, NetEqDecoder::kDecoderPCMu)); + const std::string kCodecName = "Robert\'); DROP TABLE Students;"; + EXPECT_EQ( + DecoderDatabase::kOK, + db.RegisterPayload(kPayloadType, NetEqDecoder::kDecoderPCMu, kCodecName)); const DecoderDatabase::DecoderInfo* info; info = db.GetDecoderInfo(kPayloadType); ASSERT_TRUE(info != NULL); EXPECT_EQ(NetEqDecoder::kDecoderPCMu, info->codec_type); EXPECT_EQ(NULL, info->decoder); EXPECT_EQ(8000, info->fs_hz); + EXPECT_EQ(kCodecName, info->name); EXPECT_FALSE(info->external); info = db.GetDecoderInfo(kPayloadType + 1); // Other payload type. EXPECT_TRUE(info == NULL); // Should not be found. @@ -60,8 +65,10 @@ TEST(DecoderDatabase, GetDecoderInfo) { TEST(DecoderDatabase, GetRtpPayloadType) { DecoderDatabase db; const uint8_t kPayloadType = 0; - EXPECT_EQ(DecoderDatabase::kOK, - db.RegisterPayload(kPayloadType, NetEqDecoder::kDecoderPCMu)); + const std::string kCodecName = "Robert\'); DROP TABLE Students;"; + EXPECT_EQ( + DecoderDatabase::kOK, + db.RegisterPayload(kPayloadType, NetEqDecoder::kDecoderPCMu, kCodecName)); EXPECT_EQ(kPayloadType, db.GetRtpPayloadType(NetEqDecoder::kDecoderPCMu)); const uint8_t expected_value = DecoderDatabase::kRtpPayloadTypeError; EXPECT_EQ(expected_value, @@ -72,8 +79,10 @@ TEST(DecoderDatabase, GetRtpPayloadType) { TEST(DecoderDatabase, GetDecoder) { DecoderDatabase db; const uint8_t kPayloadType = 0; + const std::string kCodecName = "Robert\'); DROP TABLE Students;"; EXPECT_EQ(DecoderDatabase::kOK, - db.RegisterPayload(kPayloadType, NetEqDecoder::kDecoderPCM16B)); + db.RegisterPayload(kPayloadType, NetEqDecoder::kDecoderPCM16B, + kCodecName)); AudioDecoder* dec = db.GetDecoder(kPayloadType); ASSERT_TRUE(dec != NULL); } @@ -86,14 +95,18 @@ TEST(DecoderDatabase, TypeTests) { const uint8_t kPayloadTypeRed = 101; const uint8_t kPayloadNotUsed = 102; // Load into database. + EXPECT_EQ( + DecoderDatabase::kOK, + db.RegisterPayload(kPayloadTypePcmU, NetEqDecoder::kDecoderPCMu, "pcmu")); EXPECT_EQ(DecoderDatabase::kOK, - db.RegisterPayload(kPayloadTypePcmU, NetEqDecoder::kDecoderPCMu)); - EXPECT_EQ(DecoderDatabase::kOK, - db.RegisterPayload(kPayloadTypeCng, NetEqDecoder::kDecoderCNGnb)); - EXPECT_EQ(DecoderDatabase::kOK, - db.RegisterPayload(kPayloadTypeDtmf, NetEqDecoder::kDecoderAVT)); - EXPECT_EQ(DecoderDatabase::kOK, - db.RegisterPayload(kPayloadTypeRed, NetEqDecoder::kDecoderRED)); + db.RegisterPayload(kPayloadTypeCng, NetEqDecoder::kDecoderCNGnb, + "cng-nb")); + EXPECT_EQ( + DecoderDatabase::kOK, + db.RegisterPayload(kPayloadTypeDtmf, NetEqDecoder::kDecoderAVT, "avt")); + EXPECT_EQ( + DecoderDatabase::kOK, + db.RegisterPayload(kPayloadTypeRed, NetEqDecoder::kDecoderRED, "red")); EXPECT_EQ(4, db.Size()); // Test. EXPECT_FALSE(db.IsComfortNoise(kPayloadNotUsed)); @@ -112,11 +125,12 @@ TEST(DecoderDatabase, TypeTests) { TEST(DecoderDatabase, ExternalDecoder) { DecoderDatabase db; const uint8_t kPayloadType = 0; + const std::string kCodecName = "Robert\'); DROP TABLE Students;"; MockAudioDecoder decoder; // Load into database. EXPECT_EQ(DecoderDatabase::kOK, - db.InsertExternal(kPayloadType, NetEqDecoder::kDecoderPCMu, 8000, - &decoder)); + db.InsertExternal(kPayloadType, NetEqDecoder::kDecoderPCMu, + kCodecName, 8000, &decoder)); EXPECT_EQ(1, db.Size()); // Get decoder and make sure we get the external one. EXPECT_EQ(&decoder, db.GetDecoder(kPayloadType)); @@ -125,6 +139,7 @@ TEST(DecoderDatabase, ExternalDecoder) { info = db.GetDecoderInfo(kPayloadType); ASSERT_TRUE(info != NULL); EXPECT_EQ(NetEqDecoder::kDecoderPCMu, info->codec_type); + EXPECT_EQ(kCodecName, info->name); EXPECT_EQ(&decoder, info->decoder); EXPECT_EQ(8000, info->fs_hz); EXPECT_TRUE(info->external); @@ -146,7 +161,7 @@ TEST(DecoderDatabase, CheckPayloadTypes) { for (uint8_t payload_type = 0; payload_type < kNumPayloads; ++payload_type) { EXPECT_EQ( DecoderDatabase::kOK, - db.RegisterPayload(payload_type, NetEqDecoder::kDecoderArbitrary)); + db.RegisterPayload(payload_type, NetEqDecoder::kDecoderArbitrary, "")); } PacketList packet_list; for (int i = 0; i < kNumPayloads + 1; ++i) { @@ -185,11 +200,11 @@ TEST(DecoderDatabase, IF_ISAC(ActiveDecoders)) { DecoderDatabase db; // Load payload types. ASSERT_EQ(DecoderDatabase::kOK, - db.RegisterPayload(0, NetEqDecoder::kDecoderPCMu)); + db.RegisterPayload(0, NetEqDecoder::kDecoderPCMu, "pcmu")); ASSERT_EQ(DecoderDatabase::kOK, - db.RegisterPayload(103, NetEqDecoder::kDecoderISAC)); + db.RegisterPayload(103, NetEqDecoder::kDecoderISAC, "isac")); ASSERT_EQ(DecoderDatabase::kOK, - db.RegisterPayload(13, NetEqDecoder::kDecoderCNGnb)); + db.RegisterPayload(13, NetEqDecoder::kDecoderCNGnb, "cng-nb")); // Verify that no decoders are active from the start. EXPECT_EQ(NULL, db.GetActiveDecoder()); EXPECT_EQ(NULL, db.GetActiveCngDecoder()); diff --git a/webrtc/modules/audio_coding/neteq/include/neteq.h b/webrtc/modules/audio_coding/neteq/include/neteq.h index 88677d8355..abe09a364b 100644 --- a/webrtc/modules/audio_coding/neteq/include/neteq.h +++ b/webrtc/modules/audio_coding/neteq/include/neteq.h @@ -174,17 +174,24 @@ class NetEq { size_t* samples_per_channel, int* num_channels, NetEqOutputType* type) = 0; - // Associates |rtp_payload_type| with |codec| and stores the information in - // the codec database. Returns 0 on success, -1 on failure. + // Associates |rtp_payload_type| with |codec| and |codec_name|, and stores the + // information in the codec database. Returns 0 on success, -1 on failure. + // The name is only used to provide information back to the caller about the + // decoders. Hence, the name is arbitrary, and may be empty. virtual int RegisterPayloadType(NetEqDecoder codec, + const std::string& codec_name, uint8_t rtp_payload_type) = 0; // Provides an externally created decoder object |decoder| to insert in the // decoder database. The decoder implements a decoder of type |codec| and - // associates it with |rtp_payload_type|. The decoder will produce samples - // at the rate |sample_rate_hz|. Returns kOK on success, kFail on failure. + // associates it with |rtp_payload_type| and |codec_name|. The decoder will + // produce samples at the rate |sample_rate_hz|. Returns kOK on success, kFail + // on failure. + // The name is only used to provide information back to the caller about the + // decoders. Hence, the name is arbitrary, and may be empty. virtual int RegisterExternalDecoder(AudioDecoder* decoder, NetEqDecoder codec, + const std::string& codec_name, uint8_t rtp_payload_type, int sample_rate_hz) = 0; diff --git a/webrtc/modules/audio_coding/neteq/mock/mock_decoder_database.h b/webrtc/modules/audio_coding/neteq/mock/mock_decoder_database.h index d127c5d810..1b4a3c9da5 100644 --- a/webrtc/modules/audio_coding/neteq/mock/mock_decoder_database.h +++ b/webrtc/modules/audio_coding/neteq/mock/mock_decoder_database.h @@ -11,6 +11,8 @@ #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_DECODER_DATABASE_H_ #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_DECODER_DATABASE_H_ +#include + #include "webrtc/modules/audio_coding/neteq/decoder_database.h" #include "testing/gmock/include/gmock/gmock.h" @@ -27,10 +29,12 @@ class MockDecoderDatabase : public DecoderDatabase { int()); MOCK_METHOD0(Reset, void()); - MOCK_METHOD2(RegisterPayload, - int(uint8_t rtp_payload_type, NetEqDecoder codec_type)); - MOCK_METHOD4(InsertExternal, - int(uint8_t rtp_payload_type, NetEqDecoder codec_type, int fs_hz, + MOCK_METHOD3(RegisterPayload, + int(uint8_t rtp_payload_type, NetEqDecoder codec_type, + const std::string& name)); + MOCK_METHOD5(InsertExternal, + int(uint8_t rtp_payload_type, NetEqDecoder codec_type, + const std::string& codec_name, int fs_hz, AudioDecoder* decoder)); MOCK_METHOD1(Remove, int(uint8_t rtp_payload_type)); diff --git a/webrtc/modules/audio_coding/neteq/neteq_external_decoder_unittest.cc b/webrtc/modules/audio_coding/neteq/neteq_external_decoder_unittest.cc index 90f9a10d18..7bf9499778 100644 --- a/webrtc/modules/audio_coding/neteq/neteq_external_decoder_unittest.cc +++ b/webrtc/modules/audio_coding/neteq/neteq_external_decoder_unittest.cc @@ -180,9 +180,9 @@ class NetEqExternalVsInternalDecoderTest : public NetEqExternalDecoderUnitTest, } void SetUp() override { - ASSERT_EQ(NetEq::kOK, - neteq_internal_->RegisterPayloadType( - NetEqDecoder::kDecoderPCM16Bswb32kHz, kPayloadType)); + ASSERT_EQ(NetEq::kOK, neteq_internal_->RegisterPayloadType( + NetEqDecoder::kDecoderPCM16Bswb32kHz, + "pcm16-swb32", kPayloadType)); } void GetAndVerifyOutput() override { diff --git a/webrtc/modules/audio_coding/neteq/neteq_impl.cc b/webrtc/modules/audio_coding/neteq/neteq_impl.cc index ed0c83f08b..0fe911ba3f 100644 --- a/webrtc/modules/audio_coding/neteq/neteq_impl.cc +++ b/webrtc/modules/audio_coding/neteq/neteq_impl.cc @@ -172,12 +172,13 @@ int NetEqImpl::GetAudio(size_t max_length, int16_t* output_audio, } int NetEqImpl::RegisterPayloadType(NetEqDecoder codec, + const std::string& name, uint8_t rtp_payload_type) { CriticalSectionScoped lock(crit_sect_.get()); LOG(LS_VERBOSE) << "RegisterPayloadType " << static_cast(rtp_payload_type) << " " << static_cast(codec); - int ret = decoder_database_->RegisterPayload(rtp_payload_type, codec); + int ret = decoder_database_->RegisterPayload(rtp_payload_type, codec, name); if (ret != DecoderDatabase::kOK) { switch (ret) { case DecoderDatabase::kInvalidRtpPayloadType: @@ -199,6 +200,7 @@ int NetEqImpl::RegisterPayloadType(NetEqDecoder codec, int NetEqImpl::RegisterExternalDecoder(AudioDecoder* decoder, NetEqDecoder codec, + const std::string& codec_name, uint8_t rtp_payload_type, int sample_rate_hz) { CriticalSectionScoped lock(crit_sect_.get()); @@ -210,8 +212,8 @@ int NetEqImpl::RegisterExternalDecoder(AudioDecoder* decoder, assert(false); return kFail; } - int ret = decoder_database_->InsertExternal(rtp_payload_type, codec, - sample_rate_hz, decoder); + int ret = decoder_database_->InsertExternal( + rtp_payload_type, codec, codec_name, sample_rate_hz, decoder); if (ret != DecoderDatabase::kOK) { switch (ret) { case DecoderDatabase::kInvalidRtpPayloadType: diff --git a/webrtc/modules/audio_coding/neteq/neteq_impl.h b/webrtc/modules/audio_coding/neteq/neteq_impl.h index 0fc204f0e8..093c8d5dad 100644 --- a/webrtc/modules/audio_coding/neteq/neteq_impl.h +++ b/webrtc/modules/audio_coding/neteq/neteq_impl.h @@ -11,6 +11,8 @@ #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_NETEQ_IMPL_H_ #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_NETEQ_IMPL_H_ +#include + #include "webrtc/base/constructormagic.h" #include "webrtc/base/scoped_ptr.h" #include "webrtc/base/thread_annotations.h" @@ -108,17 +110,13 @@ class NetEqImpl : public webrtc::NetEq { int* num_channels, NetEqOutputType* type) override; - // Associates |rtp_payload_type| with |codec| and stores the information in - // the codec database. Returns kOK on success, kFail on failure. int RegisterPayloadType(NetEqDecoder codec, + const std::string& codec_name, uint8_t rtp_payload_type) override; - // Provides an externally created decoder object |decoder| to insert in the - // decoder database. The decoder implements a decoder of type |codec| and - // associates it with |rtp_payload_type|. The decoder will produce samples - // at the rate |sample_rate_hz|. Returns kOK on success, kFail on failure. int RegisterExternalDecoder(AudioDecoder* decoder, NetEqDecoder codec, + const std::string& codec_name, uint8_t rtp_payload_type, int sample_rate_hz) override; diff --git a/webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc b/webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc index 4aff5542fc..d3b304ac68 100644 --- a/webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc +++ b/webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc @@ -240,9 +240,10 @@ TEST_F(NetEqImplTest, RegisterPayloadType) { CreateInstance(); uint8_t rtp_payload_type = 0; NetEqDecoder codec_type = NetEqDecoder::kDecoderPCMu; + const std::string kCodecName = "Robert\'); DROP TABLE Students;"; EXPECT_CALL(*mock_decoder_database_, - RegisterPayload(rtp_payload_type, codec_type)); - neteq_->RegisterPayloadType(codec_type, rtp_payload_type); + RegisterPayload(rtp_payload_type, codec_type, kCodecName)); + neteq_->RegisterPayloadType(codec_type, kCodecName, rtp_payload_type); } TEST_F(NetEqImplTest, RemovePayloadType) { @@ -383,7 +384,7 @@ TEST_F(NetEqImplTest, InsertPacketsUntilBufferIsFull) { rtp_header.header.ssrc = 0x87654321; EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType( - NetEqDecoder::kDecoderPCM16B, kPayloadType)); + NetEqDecoder::kDecoderPCM16B, "", kPayloadType)); // Insert packets. The buffer should not flush. for (size_t i = 1; i <= config_.max_packets_in_buffer; ++i) { @@ -455,7 +456,7 @@ TEST_F(NetEqImplTest, VerifyTimestampPropagation) { EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( &decoder_, NetEqDecoder::kDecoderPCM16B, - kPayloadType, kSampleRateHz)); + "dummy name", kPayloadType, kSampleRateHz)); // Insert one packet. EXPECT_EQ(NetEq::kOK, @@ -534,7 +535,7 @@ TEST_F(NetEqImplTest, ReorderedPacket) { Return(kPayloadLengthSamples))); EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( &mock_decoder, NetEqDecoder::kDecoderPCM16B, - kPayloadType, kSampleRateHz)); + "dummy name", kPayloadType, kSampleRateHz)); // Insert one packet. EXPECT_EQ(NetEq::kOK, @@ -633,7 +634,7 @@ TEST_F(NetEqImplTest, FirstPacketUnknown) { // Register the payload type. EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType( - NetEqDecoder::kDecoderPCM16B, kPayloadType)); + NetEqDecoder::kDecoderPCM16B, "", kPayloadType)); // Insert 10 packets. for (size_t i = 0; i < 10; ++i) { @@ -717,7 +718,7 @@ TEST_F(NetEqImplTest, CodecInternalCng) { EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( &mock_decoder, NetEqDecoder::kDecoderOpus, - kPayloadType, kSampleRateKhz * 1000)); + "dummy name", kPayloadType, kSampleRateKhz * 1000)); // Insert one packet (decoder will return speech). EXPECT_EQ(NetEq::kOK, @@ -854,7 +855,7 @@ TEST_F(NetEqImplTest, UnsupportedDecoder) { EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( &decoder_, NetEqDecoder::kDecoderPCM16B, - kPayloadType, kSampleRateHz)); + "dummy name", kPayloadType, kSampleRateHz)); // Insert one packet. payload[0] = kFirstPayloadValue; // This will make Decode() fail. @@ -912,7 +913,7 @@ TEST_F(NetEqImplTest, FloodBufferAndGetNetworkStats) { rtp_header.header.ssrc = 0x87654321; EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType( - NetEqDecoder::kDecoderPCM16B, kPayloadType)); + NetEqDecoder::kDecoderPCM16B, "", kPayloadType)); // Insert packets until the buffer flushes. for (size_t i = 0; i <= config_.max_packets_in_buffer; ++i) { @@ -968,7 +969,7 @@ TEST_F(NetEqImplTest, DecodedPayloadTooShort) { Return(kPayloadLengthSamples - 5))); EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( &mock_decoder, NetEqDecoder::kDecoderPCM16B, - kPayloadType, kSampleRateHz)); + "dummy name", kPayloadType, kSampleRateHz)); // Insert one packet. EXPECT_EQ(NetEq::kOK, @@ -1063,7 +1064,7 @@ TEST_F(NetEqImplTest, DecodingError) { EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( &mock_decoder, NetEqDecoder::kDecoderPCM16B, - kPayloadType, kSampleRateHz)); + "dummy name", kPayloadType, kSampleRateHz)); // Insert packets. for (int i = 0; i < 6; ++i) { @@ -1184,7 +1185,7 @@ TEST_F(NetEqImplTest, DecodingErrorDuringInternalCng) { EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( &mock_decoder, NetEqDecoder::kDecoderPCM16B, - kPayloadType, kSampleRateHz)); + "dummy name", kPayloadType, kSampleRateHz)); // Insert 2 packets. This will make netEq into codec internal CNG mode. for (int i = 0; i < 2; ++i) { diff --git a/webrtc/modules/audio_coding/neteq/neteq_stereo_unittest.cc b/webrtc/modules/audio_coding/neteq/neteq_stereo_unittest.cc index c8ce39310f..e02e92dd8f 100644 --- a/webrtc/modules/audio_coding/neteq/neteq_stereo_unittest.cc +++ b/webrtc/modules/audio_coding/neteq/neteq_stereo_unittest.cc @@ -127,11 +127,10 @@ class NetEqStereoTest : public ::testing::TestWithParam { default: FAIL() << "We shouldn't get here."; } + ASSERT_EQ(NetEq::kOK, neteq_mono_->RegisterPayloadType(mono_decoder, "mono", + kPayloadTypeMono)); ASSERT_EQ(NetEq::kOK, - neteq_mono_->RegisterPayloadType(mono_decoder, - kPayloadTypeMono)); - ASSERT_EQ(NetEq::kOK, - neteq_->RegisterPayloadType(multi_decoder, + neteq_->RegisterPayloadType(multi_decoder, "multi-channel", kPayloadTypeMulti)); } diff --git a/webrtc/modules/audio_coding/neteq/neteq_unittest.cc b/webrtc/modules/audio_coding/neteq/neteq_unittest.cc index 5d75a4ff39..e8ef1ad5ff 100644 --- a/webrtc/modules/audio_coding/neteq/neteq_unittest.cc +++ b/webrtc/modules/audio_coding/neteq/neteq_unittest.cc @@ -304,32 +304,41 @@ void NetEqDecodingTest::TearDown() { void NetEqDecodingTest::LoadDecoders() { // Load PCMu. - ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderPCMu, 0)); + ASSERT_EQ(0, + neteq_->RegisterPayloadType(NetEqDecoder::kDecoderPCMu, "pcmu", 0)); // Load PCMa. - ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderPCMa, 8)); + ASSERT_EQ(0, + neteq_->RegisterPayloadType(NetEqDecoder::kDecoderPCMa, "pcma", 8)); #ifdef WEBRTC_CODEC_ILBC // Load iLBC. - ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderILBC, 102)); + ASSERT_EQ( + 0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderILBC, "ilbc", 102)); #endif #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX) // Load iSAC. - ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderISAC, 103)); + ASSERT_EQ( + 0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderISAC, "isac", 103)); #endif #ifdef WEBRTC_CODEC_ISAC // Load iSAC SWB. - ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderISACswb, 104)); + ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderISACswb, + "isac-swb", 104)); #endif // Load PCM16B nb. - ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderPCM16B, 93)); + ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderPCM16B, + "pcm16-nb", 93)); // Load PCM16B wb. - ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderPCM16Bwb, 94)); + ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderPCM16Bwb, + "pcm16-wb", 94)); // Load PCM16B swb32. - ASSERT_EQ( - 0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderPCM16Bswb32kHz, 95)); + ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderPCM16Bswb32kHz, + "pcm16-swb32", 95)); // Load CNG 8 kHz. - ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderCNGnb, 13)); + ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderCNGnb, + "cng-nb", 13)); // Load CNG 16 kHz. - ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderCNGwb, 98)); + ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderCNGwb, + "cng-wb", 98)); } void NetEqDecodingTest::OpenInputFile(const std::string &rtp_file) { @@ -1087,20 +1096,20 @@ TEST_F(NetEqDecodingTest, IF_ISAC(SyncPacketInsert)) { // Register decoders. ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderPCM16Bwb, - kPcm16WbPayloadType)); + "pcm16-wb", kPcm16WbPayloadType)); ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderCNGnb, - kCngNbPayloadType)); + "cng-nb", kCngNbPayloadType)); ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderCNGwb, - kCngWbPayloadType)); + "cng-wb", kCngWbPayloadType)); ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderCNGswb32kHz, - kCngSwb32PayloadType)); + "cng-swb32", kCngSwb32PayloadType)); ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderCNGswb48kHz, - kCngSwb48PayloadType)); - ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderAVT, + "cng-swb48", kCngSwb48PayloadType)); + ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderAVT, "avt", kAvtPayloadType)); - ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderRED, + ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderRED, "red", kRedPayloadType)); - ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderISAC, + ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderISAC, "isac", kIsacPayloadType)); PopulateRtpInfo(0, 0, &rtp_info); diff --git a/webrtc/modules/audio_coding/neteq/payload_splitter_unittest.cc b/webrtc/modules/audio_coding/neteq/payload_splitter_unittest.cc index bf26a8f517..07c4bac0b6 100644 --- a/webrtc/modules/audio_coding/neteq/payload_splitter_unittest.cc +++ b/webrtc/modules/audio_coding/neteq/payload_splitter_unittest.cc @@ -310,10 +310,10 @@ TEST(RedPayloadSplitter, CheckRedPayloads) { // easier to just register the payload types and let the actual implementation // do its job. DecoderDatabase decoder_database; - decoder_database.RegisterPayload(0, NetEqDecoder::kDecoderCNGnb); - decoder_database.RegisterPayload(1, NetEqDecoder::kDecoderPCMu); - decoder_database.RegisterPayload(2, NetEqDecoder::kDecoderAVT); - decoder_database.RegisterPayload(3, NetEqDecoder::kDecoderILBC); + decoder_database.RegisterPayload(0, NetEqDecoder::kDecoderCNGnb, "cng-nb"); + decoder_database.RegisterPayload(1, NetEqDecoder::kDecoderPCMu, "pcmu"); + decoder_database.RegisterPayload(2, NetEqDecoder::kDecoderAVT, "avt"); + decoder_database.RegisterPayload(3, NetEqDecoder::kDecoderILBC, "ilbc"); PayloadSplitter splitter; splitter.CheckRedPayloads(&packet_list, decoder_database); @@ -745,8 +745,8 @@ TEST(FecPayloadSplitter, MixedPayload) { PacketList packet_list; DecoderDatabase decoder_database; - decoder_database.RegisterPayload(0, NetEqDecoder::kDecoderOpus); - decoder_database.RegisterPayload(1, NetEqDecoder::kDecoderPCMu); + decoder_database.RegisterPayload(0, NetEqDecoder::kDecoderOpus, "opus"); + decoder_database.RegisterPayload(1, NetEqDecoder::kDecoderPCMu, "pcmu"); Packet* packet = CreatePacket(0, 10, 0xFF, true); packet_list.push_back(packet); @@ -802,7 +802,7 @@ TEST(FecPayloadSplitter, EmbedFecInRed) { const int kTimestampOffset = 20 * 48; // 20 ms * 48 kHz. uint8_t payload_types[] = {0, 0}; - decoder_database.RegisterPayload(0, NetEqDecoder::kDecoderOpus); + decoder_database.RegisterPayload(0, NetEqDecoder::kDecoderOpus, "opus"); Packet* packet = CreateRedPayload(2, payload_types, kTimestampOffset, true); packet_list.push_back(packet); diff --git a/webrtc/modules/audio_coding/neteq/tools/neteq_external_decoder_test.cc b/webrtc/modules/audio_coding/neteq/tools/neteq_external_decoder_test.cc index 13b418504a..6becb86ccc 100644 --- a/webrtc/modules/audio_coding/neteq/tools/neteq_external_decoder_test.cc +++ b/webrtc/modules/audio_coding/neteq/tools/neteq_external_decoder_test.cc @@ -29,8 +29,9 @@ NetEqExternalDecoderTest::NetEqExternalDecoderTest(NetEqDecoder codec, } void NetEqExternalDecoderTest::Init() { - ASSERT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( - decoder_, codec_, kPayloadType, sample_rate_hz_)); + ASSERT_EQ(NetEq::kOK, + neteq_->RegisterExternalDecoder(decoder_, codec_, name_, + kPayloadType, sample_rate_hz_)); } void NetEqExternalDecoderTest::InsertPacket( diff --git a/webrtc/modules/audio_coding/neteq/tools/neteq_external_decoder_test.h b/webrtc/modules/audio_coding/neteq/tools/neteq_external_decoder_test.h index 0f71e5df06..383b43ac0c 100644 --- a/webrtc/modules/audio_coding/neteq/tools/neteq_external_decoder_test.h +++ b/webrtc/modules/audio_coding/neteq/tools/neteq_external_decoder_test.h @@ -11,6 +11,8 @@ #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_EXTERNAL_DECODER_TEST_H_ #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_EXTERNAL_DECODER_TEST_H_ +#include + #include "webrtc/base/scoped_ptr.h" #include "webrtc/modules/audio_coding/codecs/audio_decoder.h" #include "webrtc/modules/audio_coding/neteq/include/neteq.h" @@ -49,6 +51,7 @@ class NetEqExternalDecoderTest { private: NetEqDecoder codec_; + std::string name_ = "dummy name"; AudioDecoder* decoder_; int sample_rate_hz_; int channels_; diff --git a/webrtc/modules/audio_coding/neteq/tools/neteq_performance_test.cc b/webrtc/modules/audio_coding/neteq/tools/neteq_performance_test.cc index 8a971c69f3..a979934da6 100644 --- a/webrtc/modules/audio_coding/neteq/tools/neteq_performance_test.cc +++ b/webrtc/modules/audio_coding/neteq/tools/neteq_performance_test.cc @@ -34,6 +34,7 @@ int64_t NetEqPerformanceTest::Run(int runtime_ms, const int kSampRateHz = 32000; const webrtc::NetEqDecoder kDecoderType = webrtc::NetEqDecoder::kDecoderPCM16Bswb32kHz; + const std::string kDecoderName = "pcm16-swb32"; const int kPayloadType = 95; // Initialize NetEq instance. @@ -41,7 +42,7 @@ int64_t NetEqPerformanceTest::Run(int runtime_ms, config.sample_rate_hz = kSampRateHz; NetEq* neteq = NetEq::Create(config); // Register decoder in |neteq|. - if (neteq->RegisterPayloadType(kDecoderType, kPayloadType) != 0) + if (neteq->RegisterPayloadType(kDecoderType, kDecoderName, kPayloadType) != 0) return -1; // Set up AudioLoop object. diff --git a/webrtc/modules/audio_coding/neteq/tools/neteq_quality_test.cc b/webrtc/modules/audio_coding/neteq/tools/neteq_quality_test.cc index 1c560c5d4a..f9b0db37d7 100644 --- a/webrtc/modules/audio_coding/neteq/tools/neteq_quality_test.cc +++ b/webrtc/modules/audio_coding/neteq/tools/neteq_quality_test.cc @@ -292,7 +292,8 @@ bool GilbertElliotLoss::Lost() { } void NetEqQualityTest::SetUp() { - ASSERT_EQ(0, neteq_->RegisterPayloadType(decoder_type_, kPayloadType)); + ASSERT_EQ(0, + neteq_->RegisterPayloadType(decoder_type_, "noname", kPayloadType)); rtp_generator_->set_drift_factor(drift_factor_); int units = block_duration_ms_ / kPacketLossTimeUnitMs; diff --git a/webrtc/modules/audio_coding/neteq/tools/neteq_rtpplay.cc b/webrtc/modules/audio_coding/neteq/tools/neteq_rtpplay.cc index c41ca54301..f1748d53f7 100644 --- a/webrtc/modules/audio_coding/neteq/tools/neteq_rtpplay.cc +++ b/webrtc/modules/audio_coding/neteq/tools/neteq_rtpplay.cc @@ -189,8 +189,9 @@ std::string CodecName(webrtc::NetEqDecoder codec) { void RegisterPayloadType(NetEq* neteq, webrtc::NetEqDecoder codec, + const std::string& name, google::int32 flag) { - if (neteq->RegisterPayloadType(codec, static_cast(flag))) { + if (neteq->RegisterPayloadType(codec, name, static_cast(flag))) { std::cerr << "Cannot register payload type " << flag << " as " << CodecName(codec) << std::endl; exit(1); @@ -200,30 +201,40 @@ void RegisterPayloadType(NetEq* neteq, // Registers all decoders in |neteq|. void RegisterPayloadTypes(NetEq* neteq) { assert(neteq); - RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderPCMu, FLAGS_pcmu); - RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderPCMa, FLAGS_pcma); - RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderILBC, FLAGS_ilbc); - RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderISAC, FLAGS_isac); - RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderISACswb, + RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderPCMu, "pcmu", + FLAGS_pcmu); + RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderPCMa, "pcma", + FLAGS_pcma); + RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderILBC, "ilbc", + FLAGS_ilbc); + RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderISAC, "isac", + FLAGS_isac); + RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderISACswb, "isac-swb", FLAGS_isac_swb); - RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderOpus, FLAGS_opus); - RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderPCM16B, + RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderOpus, "opus", + FLAGS_opus); + RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderPCM16B, "pcm16-nb", FLAGS_pcm16b); - RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderPCM16Bwb, + RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderPCM16Bwb, "pcm16-wb", FLAGS_pcm16b_wb); RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderPCM16Bswb32kHz, - FLAGS_pcm16b_swb32); + "pcm16-swb32", FLAGS_pcm16b_swb32); RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderPCM16Bswb48kHz, - FLAGS_pcm16b_swb48); - RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderG722, FLAGS_g722); - RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderAVT, FLAGS_avt); - RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderRED, FLAGS_red); - RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderCNGnb, FLAGS_cn_nb); - RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderCNGwb, FLAGS_cn_wb); + "pcm16-swb48", FLAGS_pcm16b_swb48); + RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderG722, "g722", + FLAGS_g722); + RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderAVT, "avt", + FLAGS_avt); + RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderRED, "red", + FLAGS_red); + RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderCNGnb, "cng-nb", + FLAGS_cn_nb); + RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderCNGwb, "cng-wb", + FLAGS_cn_wb); RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderCNGswb32kHz, - FLAGS_cn_swb32); + "cng-swb32", FLAGS_cn_swb32); RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderCNGswb48kHz, - FLAGS_cn_swb48); + "cng-swb48", FLAGS_cn_swb48); } void PrintCodecMappingEntry(webrtc::NetEqDecoder codec, google::int32 flag) {