diff --git a/webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc b/webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc index b69f5457c1..0855dd648a 100644 --- a/webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc +++ b/webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc @@ -340,14 +340,6 @@ int ACMCodecDB::ReceiverCodecNumber(const CodecInst& codec_inst) { return CodecId(codec_inst); } -// Returns the codec sampling frequency for codec with id = "codec_id" in -// database. -int ACMCodecDB::CodecFreq(int codec_id) { - const size_t i = static_cast(codec_id); - const auto db = RentACodec::Database(); - return i < db.size() ? db[i].plfreq : -1; -} - } // namespace acm2 } // namespace webrtc diff --git a/webrtc/modules/audio_coding/main/acm2/acm_codec_database.h b/webrtc/modules/audio_coding/main/acm2/acm_codec_database.h index ede0e6bccd..e462e45265 100644 --- a/webrtc/modules/audio_coding/main/acm2/acm_codec_database.h +++ b/webrtc/modules/audio_coding/main/acm2/acm_codec_database.h @@ -74,17 +74,6 @@ class ACMCodecDB { static int CodecId(const char* payload_name, int frequency, int channels); static int ReceiverCodecNumber(const CodecInst& codec_inst); - // Returns the codec sampling frequency for codec with id = "codec_id" in - // database. - // TODO(tlegrand): Check if function is needed, or if we can change - // to access database directly. - // Input: - // [codec_id] - number that specifies at what position in the database to - // get the information. - // Return: - // codec sampling frequency if successful, otherwise -1. - static int CodecFreq(int codec_id); - private: // Databases with information about the supported codecs // database_ - stored information about all codecs: payload type, name, diff --git a/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc b/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc index b8e8b9d4bc..34726ccb20 100644 --- a/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc +++ b/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc @@ -178,7 +178,10 @@ int AcmReceiver::InsertPacket(const WebRtcRTPHeader& rtp_header, << " is not registered."; return -1; } - const int sample_rate_hz = ACMCodecDB::CodecFreq(decoder->acm_codec_id); + const int sample_rate_hz = [&decoder] { + const auto ci = RentACodec::CodecIdFromIndex(decoder->acm_codec_id); + return ci ? RentACodec::CodecInstById(*ci)->plfreq : -1; + }(); receive_timestamp = NowInTimestamp(sample_rate_hz); // If this is a CNG while the audio codec is not mono, skip pushing in