Hide ACMCodecDB::database_ behind accessors
BUG=webrtc:5028 Review URL: https://codereview.webrtc.org/1425233003 Cr-Commit-Position: refs/heads/master@{#10498}
This commit is contained in:
@ -29,11 +29,6 @@ namespace acm2 {
|
||||
|
||||
namespace {
|
||||
|
||||
// Checks if the bitrate is valid for the codec.
|
||||
bool IsRateValid(int codec_id, int rate) {
|
||||
return ACMCodecDB::database_[codec_id].rate == rate;
|
||||
}
|
||||
|
||||
// Checks if the bitrate is valid for iSAC.
|
||||
bool IsISACRateValid(int rate) {
|
||||
return (rate == -1) || ((rate <= 56000) && (rate >= 10000));
|
||||
@ -298,8 +293,7 @@ int ACMCodecDB::CodecNumber(const CodecInst& codec_inst) {
|
||||
? codec_id : kInvalidRate;
|
||||
}
|
||||
|
||||
return IsRateValid(codec_id, codec_inst.rate) ?
|
||||
codec_id : kInvalidRate;
|
||||
return database_[codec_id].rate == codec_inst.rate ? codec_id : kInvalidRate;
|
||||
}
|
||||
|
||||
// Looks for a matching payload name, frequency, and channels in the
|
||||
|
||||
@ -91,6 +91,7 @@ class ACMCodecDB {
|
||||
// [payload_type] - payload type.
|
||||
static bool ValidPayloadType(int payload_type);
|
||||
|
||||
private:
|
||||
// Databases with information about the supported codecs
|
||||
// database_ - stored information about all codecs: payload type, name,
|
||||
// sampling frequency, packet size in samples, default channel
|
||||
@ -100,8 +101,6 @@ class ACMCodecDB {
|
||||
// samples, and max number of channels that are supported.
|
||||
// neteq_decoders_ - list of supported decoders in NetEQ.
|
||||
static const CodecInst database_[kMaxNumCodecs];
|
||||
|
||||
private:
|
||||
static const CodecSettings codec_settings_[kMaxNumCodecs];
|
||||
static const NetEqDecoder neteq_decoders_[kMaxNumCodecs];
|
||||
|
||||
|
||||
@ -439,8 +439,8 @@ int AcmReceiver::LastAudioCodec(CodecInst* codec) const {
|
||||
if (!last_audio_decoder_) {
|
||||
return -1;
|
||||
}
|
||||
memcpy(codec, &ACMCodecDB::database_[last_audio_decoder_->acm_codec_id],
|
||||
sizeof(CodecInst));
|
||||
*codec = *RentACodec::CodecInstById(
|
||||
*RentACodec::CodecIdFromIndex(last_audio_decoder_->acm_codec_id));
|
||||
codec->pltype = last_audio_decoder_->payload_type;
|
||||
codec->channels = last_audio_decoder_->channels;
|
||||
codec->plfreq = last_audio_decoder_->sample_rate_hz;
|
||||
@ -480,8 +480,8 @@ int AcmReceiver::DecoderByPayloadType(uint8_t payload_type,
|
||||
return -1;
|
||||
}
|
||||
const Decoder& decoder = it->second;
|
||||
memcpy(codec, &ACMCodecDB::database_[decoder.acm_codec_id],
|
||||
sizeof(CodecInst));
|
||||
*codec = *RentACodec::CodecInstById(
|
||||
*RentACodec::CodecIdFromIndex(decoder.acm_codec_id));
|
||||
codec->pltype = decoder.payload_type;
|
||||
codec->channels = decoder.channels;
|
||||
codec->plfreq = decoder.sample_rate_hz;
|
||||
|
||||
@ -528,10 +528,9 @@ int AudioCodingModuleImpl::ReceiveFrequency() const {
|
||||
|
||||
CriticalSectionScoped lock(acm_crit_sect_.get());
|
||||
|
||||
int codec_id = receiver_.last_audio_codec_id();
|
||||
|
||||
return codec_id < 0 ? receiver_.current_sample_rate_hz() :
|
||||
ACMCodecDB::database_[codec_id].plfreq;
|
||||
auto codec_id = RentACodec::CodecIdFromIndex(receiver_.last_audio_codec_id());
|
||||
return codec_id ? RentACodec::CodecInstById(*codec_id)->plfreq
|
||||
: receiver_.current_sample_rate_hz();
|
||||
}
|
||||
|
||||
// Get current playout frequency.
|
||||
|
||||
Reference in New Issue
Block a user