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

Side by Side Diff: webrtc/modules/audio_coding/neteq/decoder_database.cc

Issue 2365653004: AudioCodingModule: Specify decoders using SdpAudioFormat (Closed)
Patch Set: rebase Created 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 return STR_CASE_CMP(audio_format_.name.c_str(), name) == 0; 78 return STR_CASE_CMP(audio_format_.name.c_str(), name) == 0;
79 } 79 }
80 80
81 bool DecoderDatabase::DecoderInfo::IsType(const std::string& name) const { 81 bool DecoderDatabase::DecoderInfo::IsType(const std::string& name) const {
82 return IsType(name.c_str()); 82 return IsType(name.c_str());
83 } 83 }
84 84
85 rtc::Optional<DecoderDatabase::DecoderInfo::CngDecoder> 85 rtc::Optional<DecoderDatabase::DecoderInfo::CngDecoder>
86 DecoderDatabase::DecoderInfo::CngDecoder::Create(const SdpAudioFormat& format) { 86 DecoderDatabase::DecoderInfo::CngDecoder::Create(const SdpAudioFormat& format) {
87 if (STR_CASE_CMP(format.name.c_str(), "CN") == 0) { 87 if (STR_CASE_CMP(format.name.c_str(), "CN") == 0) {
88 return rtc::Optional<CngDecoder>({format.clockrate_hz}); 88 // CN has a 1:1 RTP clock rate to sample rate ratio.
89 const int sample_rate_hz = format.clockrate_hz;
90 RTC_DCHECK(sample_rate_hz == 8000 || sample_rate_hz == 16000 ||
91 sample_rate_hz == 32000 || sample_rate_hz == 48000);
92 return rtc::Optional<DecoderDatabase::DecoderInfo::CngDecoder>(
93 {sample_rate_hz});
89 } else { 94 } else {
90 return rtc::Optional<CngDecoder>(); 95 return rtc::Optional<CngDecoder>();
91 } 96 }
92 } 97 }
93 98
94 DecoderDatabase::DecoderInfo::Subtype 99 DecoderDatabase::DecoderInfo::Subtype
95 DecoderDatabase::DecoderInfo::SubtypeFromFormat(const SdpAudioFormat& format) { 100 DecoderDatabase::DecoderInfo::SubtypeFromFormat(const SdpAudioFormat& format) {
96 if (STR_CASE_CMP(format.name.c_str(), "CN") == 0) { 101 if (STR_CASE_CMP(format.name.c_str(), "CN") == 0) {
97 return Subtype::kComfortNoise; 102 return Subtype::kComfortNoise;
98 } else if (STR_CASE_CMP(format.name.c_str(), "telephone-event") == 0) { 103 } else if (STR_CASE_CMP(format.name.c_str(), "telephone-event") == 0) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 info.name = name; 139 info.name = name;
135 auto ret = 140 auto ret =
136 decoders_.insert(std::make_pair(rtp_payload_type, std::move(info))); 141 decoders_.insert(std::make_pair(rtp_payload_type, std::move(info)));
137 if (ret.second == false) { 142 if (ret.second == false) {
138 // Database already contains a decoder with type |rtp_payload_type|. 143 // Database already contains a decoder with type |rtp_payload_type|.
139 return kDecoderExists; 144 return kDecoderExists;
140 } 145 }
141 return kOK; 146 return kOK;
142 } 147 }
143 148
149 int DecoderDatabase::RegisterPayload(int rtp_payload_type,
150 const SdpAudioFormat& audio_format) {
151 if (rtp_payload_type < 0 || rtp_payload_type > 0x7f) {
152 return kInvalidRtpPayloadType;
153 }
154 const auto ret = decoders_.insert(std::make_pair(
155 rtp_payload_type, DecoderInfo(audio_format, decoder_factory_.get())));
156 if (ret.second == false) {
157 // Database already contains a decoder with type |rtp_payload_type|.
158 return kDecoderExists;
159 }
160 return kOK;
161 }
162
144 int DecoderDatabase::InsertExternal(uint8_t rtp_payload_type, 163 int DecoderDatabase::InsertExternal(uint8_t rtp_payload_type,
145 NetEqDecoder codec_type, 164 NetEqDecoder codec_type,
146 const std::string& codec_name, 165 const std::string& codec_name,
147 AudioDecoder* decoder) { 166 AudioDecoder* decoder) {
148 if (rtp_payload_type > 0x7F) { 167 if (rtp_payload_type > 0x7F) {
149 return kInvalidRtpPayloadType; 168 return kInvalidRtpPayloadType;
150 } 169 }
151 if (!decoder) { 170 if (!decoder) {
152 return kInvalidPointer; 171 return kInvalidPointer;
153 } 172 }
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 // Payload type is not found. 314 // Payload type is not found.
296 LOG(LS_WARNING) << "CheckPayloadTypes: unknown RTP payload type " 315 LOG(LS_WARNING) << "CheckPayloadTypes: unknown RTP payload type "
297 << static_cast<int>((*it)->header.payloadType); 316 << static_cast<int>((*it)->header.payloadType);
298 return kDecoderNotFound; 317 return kDecoderNotFound;
299 } 318 }
300 } 319 }
301 return kOK; 320 return kOK;
302 } 321 }
303 322
304 } // namespace webrtc 323 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698