From fb3d8b3df272aa05fea5a1f6b7abcd600af1da63 Mon Sep 17 00:00:00 2001 From: kwiberg Date: Fri, 6 Nov 2015 01:24:08 -0800 Subject: [PATCH] Remove ACMCodecDB::CodecFreq BUG=webrtc:5028 Review URL: https://codereview.webrtc.org/1408773005 Cr-Commit-Position: refs/heads/master@{#10536} --- .../audio_coding/main/acm2/acm_codec_database.cc | 8 -------- .../audio_coding/main/acm2/acm_codec_database.h | 11 ----------- webrtc/modules/audio_coding/main/acm2/acm_receiver.cc | 5 ++++- 3 files changed, 4 insertions(+), 20 deletions(-) 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