Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Unified Diff: webrtc/modules/audio_coding/main/acm2/acm_receiver.cc

Issue 1412683006: RentACodec: New class that takes over part of ACMCodecDB's job (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_coding/main/acm2/acm_receiver.cc
diff --git a/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc b/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc
index bfcf76ce724d84c01a845183edea6bd7dd3f9416..bc6c0f34068e09d82248b0c20b972b4f3a99b331 100644
--- a/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc
+++ b/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc
@@ -111,9 +111,13 @@ void SetAudioFrameActivityAndType(bool vad_enabled,
}
// Is the given codec a CNG codec?
+// TODO(kwiberg): Move to RentACodec.
bool IsCng(int codec_id) {
- return (codec_id == ACMCodecDB::kCNNB || codec_id == ACMCodecDB::kCNWB ||
- codec_id == ACMCodecDB::kCNSWB || codec_id == ACMCodecDB::kCNFB);
+ auto i = RentACodec::CodecIdFromIndex(codec_id);
+ return (i && (*i == RentACodec::CodecId::kCNNB ||
+ *i == RentACodec::CodecId::kCNWB ||
+ *i == RentACodec::CodecId::kCNSWB ||
+ *i == RentACodec::CodecId::kCNFB));
}
} // namespace
@@ -241,7 +245,8 @@ int AcmReceiver::InsertPacket(const WebRtcRTPHeader& rtp_header,
if (last_audio_decoder_ && last_audio_decoder_->channels > 1)
return 0;
packet_type = InitialDelayManager::kCngPacket;
- } else if (decoder->acm_codec_id == ACMCodecDB::kAVT) {
+ } else if (decoder->acm_codec_id ==
+ *RentACodec::CodecIndexFromId(RentACodec::CodecId::kAVT)) {
packet_type = InitialDelayManager::kAvtPacket;
} else {
if (decoder != last_audio_decoder_) {
@@ -566,11 +571,13 @@ int AcmReceiver::last_audio_codec_id() const {
}
int AcmReceiver::RedPayloadType() const {
- if (ACMCodecDB::kRED >= 0) { // This ensures that RED is defined in WebRTC.
+ const auto red_index =
+ RentACodec::CodecIndexFromId(RentACodec::CodecId::kRED);
+ if (red_index) {
CriticalSectionScoped lock(crit_sect_.get());
for (const auto& decoder_pair : decoders_) {
const Decoder& decoder = decoder_pair.second;
- if (decoder.acm_codec_id == ACMCodecDB::kRED)
+ if (decoder.acm_codec_id == *red_index)
return decoder.payload_type;
}
}
@@ -737,8 +744,11 @@ const AcmReceiver::Decoder* AcmReceiver::RtpHeaderToDecoder(
const RTPHeader& rtp_header,
const uint8_t* payload) const {
auto it = decoders_.find(rtp_header.payloadType);
- if (ACMCodecDB::kRED >= 0 && // This ensures that RED is defined in WebRTC.
- it != decoders_.end() && ACMCodecDB::kRED == it->second.acm_codec_id) {
+ const auto red_index =
+ RentACodec::CodecIndexFromId(RentACodec::CodecId::kRED);
+ if (red_index && // This ensures that RED is defined in WebRTC.
+ it != decoders_.end() &&
+ it->second.acm_codec_id == *red_index) {
// This is a RED packet, get the payload of the audio codec.
it = decoders_.find(payload[0] & 0x7F);
}

Powered by Google App Engine
This is Rietveld 408576698