Hide ACMCodecDB::codec_settings_ behind an accessor

BUG=webrtc:5028

Review URL: https://codereview.webrtc.org/1419013005

Cr-Commit-Position: refs/heads/master@{#10494}
This commit is contained in:
kwiberg
2015-11-03 05:46:09 -08:00
committed by Commit bot
parent 373284da06
commit de94d08d57
4 changed files with 20 additions and 3 deletions

View File

@ -100,9 +100,9 @@ class ACMCodecDB {
// samples, and max number of channels that are supported.
// neteq_decoders_ - list of supported decoders in NetEQ.
static const CodecInst database_[kMaxNumCodecs];
static const CodecSettings codec_settings_[kMaxNumCodecs];
private:
static const CodecSettings codec_settings_[kMaxNumCodecs];
static const NetEqDecoder neteq_decoders_[kMaxNumCodecs];
friend class RentACodec;

View File

@ -63,8 +63,14 @@ int IsValidSendCodec(const CodecInst& send_codec, bool is_primary_encoder) {
return -1;
}
if (ACMCodecDB::codec_settings_[codec_id].channel_support <
send_codec.channels) {
const rtc::Maybe<bool> supported_num_channels = [codec_id, &send_codec] {
auto cid = RentACodec::CodecIdFromIndex(codec_id);
return cid ? RentACodec::IsSupportedNumChannels(*cid, send_codec.channels)
: rtc::Maybe<bool>();
}();
if (!supported_num_channels)
return -1;
if (!*supported_num_channels) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, dummy_id,
"%d number of channels not supportedn for %s.",
send_codec.channels, send_codec.plname);

View File

@ -50,6 +50,14 @@ bool RentACodec::IsCodecValid(const CodecInst& codec_inst) {
return ACMCodecDB::CodecNumber(codec_inst) >= 0;
}
rtc::Maybe<bool> RentACodec::IsSupportedNumChannels(CodecId codec_id,
int num_channels) {
auto i = CodecIndexFromId(codec_id);
return i ? rtc::Maybe<bool>(ACMCodecDB::codec_settings_[*i].channel_support >=
num_channels)
: rtc::Maybe<bool>();
}
rtc::ArrayView<const CodecInst> RentACodec::Database() {
return rtc::ArrayView<const CodecInst>(ACMCodecDB::database_,
NumberOfCodecs());

View File

@ -154,6 +154,9 @@ class RentACodec {
static bool IsCodecValid(const CodecInst& codec_inst);
static rtc::ArrayView<const CodecInst> Database();
static rtc::Maybe<bool> IsSupportedNumChannels(CodecId codec_id,
int num_channels);
static rtc::Maybe<NetEqDecoder> NetEqDecoderFromCodecId(CodecId codec_id,
int num_channels);
};