| Index: webrtc/modules/audio_coding/neteq/decoder_database.cc
|
| diff --git a/webrtc/modules/audio_coding/neteq/decoder_database.cc b/webrtc/modules/audio_coding/neteq/decoder_database.cc
|
| index 92d4bab1e4a573fb3c84ef53fa724ebfeabe860c..ab619c62f12e66762890c6eb0753d7d25298496c 100644
|
| --- a/webrtc/modules/audio_coding/neteq/decoder_database.cc
|
| +++ b/webrtc/modules/audio_coding/neteq/decoder_database.cc
|
| @@ -20,9 +20,10 @@
|
| namespace webrtc {
|
|
|
| DecoderDatabase::DecoderDatabase()
|
| - : active_decoder_(-1), active_cng_decoder_(-1) {}
|
| + : active_decoder_type_(-1), active_cng_decoder_type_(-1) {
|
| +}
|
|
|
| -DecoderDatabase::~DecoderDatabase() {}
|
| +DecoderDatabase::~DecoderDatabase() = default;
|
|
|
| DecoderDatabase::DecoderInfo::~DecoderInfo() {
|
| if (!external) delete decoder;
|
| @@ -34,8 +35,8 @@ int DecoderDatabase::Size() const { return static_cast<int>(decoders_.size()); }
|
|
|
| void DecoderDatabase::Reset() {
|
| decoders_.clear();
|
| - active_decoder_ = -1;
|
| - active_cng_decoder_ = -1;
|
| + active_decoder_type_ = -1;
|
| + active_cng_decoder_type_ = -1;
|
| }
|
|
|
| int DecoderDatabase::RegisterPayload(uint8_t rtp_payload_type,
|
| @@ -89,11 +90,11 @@ int DecoderDatabase::Remove(uint8_t rtp_payload_type) {
|
| // No decoder with that |rtp_payload_type|.
|
| return kDecoderNotFound;
|
| }
|
| - if (active_decoder_ == rtp_payload_type) {
|
| - active_decoder_ = -1; // No active decoder.
|
| + if (active_decoder_type_ == rtp_payload_type) {
|
| + active_decoder_type_ = -1; // No active decoder.
|
| }
|
| - if (active_cng_decoder_ == rtp_payload_type) {
|
| - active_cng_decoder_ = -1; // No active CNG decoder.
|
| + if (active_cng_decoder_type_ == rtp_payload_type) {
|
| + active_cng_decoder_type_ = -1; // No active CNG decoder.
|
| }
|
| return kOK;
|
| }
|
| @@ -122,7 +123,8 @@ uint8_t DecoderDatabase::GetRtpPayloadType(
|
| }
|
|
|
| AudioDecoder* DecoderDatabase::GetDecoder(uint8_t rtp_payload_type) {
|
| - if (IsDtmf(rtp_payload_type) || IsRed(rtp_payload_type)) {
|
| + if (IsDtmf(rtp_payload_type) || IsRed(rtp_payload_type) ||
|
| + IsComfortNoise(rtp_payload_type)) {
|
| // These are not real decoders.
|
| return NULL;
|
| }
|
| @@ -178,14 +180,15 @@ int DecoderDatabase::SetActiveDecoder(uint8_t rtp_payload_type,
|
| // Decoder not found.
|
| return kDecoderNotFound;
|
| }
|
| + RTC_CHECK(!IsComfortNoise(rtp_payload_type));
|
| assert(new_decoder);
|
| *new_decoder = false;
|
| - if (active_decoder_ < 0) {
|
| + if (active_decoder_type_ < 0) {
|
| // This is the first active decoder.
|
| *new_decoder = true;
|
| - } else if (active_decoder_ != rtp_payload_type) {
|
| + } else if (active_decoder_type_ != rtp_payload_type) {
|
| // Moving from one active decoder to another. Delete the first one.
|
| - DecoderMap::iterator it = decoders_.find(active_decoder_);
|
| + DecoderMap::iterator it = decoders_.find(active_decoder_type_);
|
| if (it == decoders_.end()) {
|
| // Decoder not found. This should not be possible.
|
| assert(false);
|
| @@ -199,16 +202,16 @@ int DecoderDatabase::SetActiveDecoder(uint8_t rtp_payload_type,
|
| }
|
| *new_decoder = true;
|
| }
|
| - active_decoder_ = rtp_payload_type;
|
| + active_decoder_type_ = rtp_payload_type;
|
| return kOK;
|
| }
|
|
|
| AudioDecoder* DecoderDatabase::GetActiveDecoder() {
|
| - if (active_decoder_ < 0) {
|
| + if (active_decoder_type_ < 0) {
|
| // No active decoder.
|
| return NULL;
|
| }
|
| - return GetDecoder(active_decoder_);
|
| + return GetDecoder(active_decoder_type_);
|
| }
|
|
|
| int DecoderDatabase::SetActiveCngDecoder(uint8_t rtp_payload_type) {
|
| @@ -218,31 +221,32 @@ int DecoderDatabase::SetActiveCngDecoder(uint8_t rtp_payload_type) {
|
| // Decoder not found.
|
| return kDecoderNotFound;
|
| }
|
| - if (active_cng_decoder_ >= 0 && active_cng_decoder_ != rtp_payload_type) {
|
| + if (active_cng_decoder_type_ >= 0 &&
|
| + active_cng_decoder_type_ != rtp_payload_type) {
|
| // Moving from one active CNG decoder to another. Delete the first one.
|
| - DecoderMap::iterator it = decoders_.find(active_cng_decoder_);
|
| + DecoderMap::iterator it = decoders_.find(active_cng_decoder_type_);
|
| if (it == decoders_.end()) {
|
| // Decoder not found. This should not be possible.
|
| assert(false);
|
| return kDecoderNotFound;
|
| }
|
| - if (!(*it).second.external) {
|
| - // Delete the AudioDecoder object, unless it is an externally created
|
| - // decoder.
|
| - delete (*it).second.decoder;
|
| - (*it).second.decoder = NULL;
|
| - }
|
| + // The CNG decoder should never be provided externally.
|
| + RTC_CHECK(!it->second.external);
|
| + active_cng_decoder_.reset();
|
| }
|
| - active_cng_decoder_ = rtp_payload_type;
|
| + active_cng_decoder_type_ = rtp_payload_type;
|
| return kOK;
|
| }
|
|
|
| -AudioDecoder* DecoderDatabase::GetActiveCngDecoder() {
|
| - if (active_cng_decoder_ < 0) {
|
| +ComfortNoiseDecoder* DecoderDatabase::GetActiveCngDecoder() {
|
| + if (active_cng_decoder_type_ < 0) {
|
| // No active CNG decoder.
|
| return NULL;
|
| }
|
| - return GetDecoder(active_cng_decoder_);
|
| + if (!active_cng_decoder_) {
|
| + active_cng_decoder_.reset(new ComfortNoiseDecoder);
|
| + }
|
| + return active_cng_decoder_.get();
|
| }
|
|
|
| int DecoderDatabase::CheckPayloadTypes(const PacketList& packet_list) const {
|
|
|