NetEq decoder database: Don't keep track of sample rate for builtin decoders

This allows us to get rid of the function that computes it, which gets
us one step closer to getting rid of the NetEqDecoder type.

BUG=webrtc:5801

Review-Url: https://codereview.webrtc.org/2021063002
Cr-Commit-Position: refs/heads/master@{#12974}
This commit is contained in:
kwiberg
2016-05-31 06:28:03 -07:00
committed by Commit bot
parent 799467d753
commit c0f2dcf9ed
15 changed files with 157 additions and 198 deletions

View File

@ -41,9 +41,10 @@ class DecoderDatabase {
// Class that stores decoder info in the database.
class DecoderInfo {
public:
DecoderInfo(NetEqDecoder ct, const std::string& nm);
DecoderInfo(NetEqDecoder ct,
const std::string& nm,
int fs,
int sample_rate_hz,
AudioDecoder* ext_dec);
DecoderInfo(DecoderInfo&&);
~DecoderInfo();
@ -55,14 +56,35 @@ class DecoderDatabase {
// always recreate it later if we need it.)
void DropDecoder() { decoder_.reset(); }
int SampleRateHz() const {
RTC_DCHECK_EQ(1, !!decoder_ + !!external_decoder + !!cng_decoder_);
return decoder_ ? decoder_->SampleRateHz()
: external_decoder ? external_decoder->sample_rate_hz
: cng_decoder_->sample_rate_hz;
}
const NetEqDecoder codec_type;
const std::string name;
const int fs_hz;
AudioDecoder* const external_decoder;
private:
const rtc::Optional<SdpAudioFormat> audio_format_;
std::unique_ptr<AudioDecoder> decoder_;
// Set iff this is an external decoder.
struct ExternalDecoder {
// TODO(kwiberg): Remove sample_rate_hz once we can trust all decoders to
// implement SampleRateHz().
int sample_rate_hz;
AudioDecoder* decoder;
};
const rtc::Optional<ExternalDecoder> external_decoder;
// Set iff this is a comfort noise decoder.
struct CngDecoder {
static rtc::Optional<CngDecoder> Create(NetEqDecoder ct);
int sample_rate_hz;
};
const rtc::Optional<CngDecoder> cng_decoder_;
};
// Maximum value for 8 bits, and an invalid RTP payload type (since it is