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

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

Issue 2365653004: AudioCodingModule: Specify decoders using SdpAudioFormat (Closed)
Patch Set: 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 return STR_CASE_CMP(audio_format_.name.c_str(), name) == 0; 88 return STR_CASE_CMP(audio_format_.name.c_str(), name) == 0;
89 } 89 }
90 90
91 bool DecoderDatabase::DecoderInfo::IsType(const std::string& name) const { 91 bool DecoderDatabase::DecoderInfo::IsType(const std::string& name) const {
92 return IsType(name.c_str()); 92 return IsType(name.c_str());
93 } 93 }
94 94
95 rtc::Optional<DecoderDatabase::DecoderInfo::CngDecoder> 95 rtc::Optional<DecoderDatabase::DecoderInfo::CngDecoder>
96 DecoderDatabase::DecoderInfo::CngDecoder::Create(const SdpAudioFormat& format) { 96 DecoderDatabase::DecoderInfo::CngDecoder::Create(const SdpAudioFormat& format) {
97 if (STR_CASE_CMP(format.name.c_str(), "CN") == 0) { 97 if (STR_CASE_CMP(format.name.c_str(), "CN") == 0) {
98 return rtc::Optional<CngDecoder>({format.clockrate_hz}); 98 // CN has a 1:1 RTP clock rate to sample rate ratio.
99 const int sample_rate_hz = format.clockrate_hz;
100 RTC_DCHECK(sample_rate_hz == 8000 || sample_rate_hz == 16000 ||
101 sample_rate_hz == 32000 || sample_rate_hz == 48000);
102 return rtc::Optional<DecoderDatabase::DecoderInfo::CngDecoder>(
103 {sample_rate_hz});
99 } else { 104 } else {
100 return rtc::Optional<CngDecoder>(); 105 return rtc::Optional<CngDecoder>();
101 } 106 }
102 } 107 }
103 108
104 bool DecoderDatabase::Empty() const { return decoders_.empty(); } 109 bool DecoderDatabase::Empty() const { return decoders_.empty(); }
105 110
106 int DecoderDatabase::Size() const { return static_cast<int>(decoders_.size()); } 111 int DecoderDatabase::Size() const { return static_cast<int>(decoders_.size()); }
107 112
108 void DecoderDatabase::Reset() { 113 void DecoderDatabase::Reset() {
(...skipping 22 matching lines...) Expand all
131 info.name = name; 136 info.name = name;
132 auto ret = 137 auto ret =
133 decoders_.insert(std::make_pair(rtp_payload_type, std::move(info))); 138 decoders_.insert(std::make_pair(rtp_payload_type, std::move(info)));
134 if (ret.second == false) { 139 if (ret.second == false) {
135 // Database already contains a decoder with type |rtp_payload_type|. 140 // Database already contains a decoder with type |rtp_payload_type|.
136 return kDecoderExists; 141 return kDecoderExists;
137 } 142 }
138 return kOK; 143 return kOK;
139 } 144 }
140 145
146 int DecoderDatabase::RegisterPayload(int rtp_payload_type,
147 const SdpAudioFormat& audio_format) {
148 if (rtp_payload_type > 0x7f) {
ossu 2016/09/28 14:12:28 Since rtp_payload_type is an int in this overload,
kwiberg-webrtc 2016/09/29 12:38:35 Done.
149 return kInvalidRtpPayloadType;
150 }
151 const auto ret = decoders_.insert(std::make_pair(
152 rtp_payload_type, DecoderInfo(audio_format, decoder_factory_.get())));
153 if (ret.second == false) {
154 // Database already contains a decoder with type |rtp_payload_type|.
155 return kDecoderExists;
156 }
157 return kOK;
158 }
159
141 int DecoderDatabase::InsertExternal(uint8_t rtp_payload_type, 160 int DecoderDatabase::InsertExternal(uint8_t rtp_payload_type,
142 NetEqDecoder codec_type, 161 NetEqDecoder codec_type,
143 const std::string& codec_name, 162 const std::string& codec_name,
144 AudioDecoder* decoder) { 163 AudioDecoder* decoder) {
145 if (rtp_payload_type > 0x7F) { 164 if (rtp_payload_type > 0x7F) {
146 return kInvalidRtpPayloadType; 165 return kInvalidRtpPayloadType;
147 } 166 }
148 if (!decoder) { 167 if (!decoder) {
149 return kInvalidPointer; 168 return kInvalidPointer;
150 } 169 }
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 // Payload type is not found. 311 // Payload type is not found.
293 LOG(LS_WARNING) << "CheckPayloadTypes: unknown RTP payload type " 312 LOG(LS_WARNING) << "CheckPayloadTypes: unknown RTP payload type "
294 << static_cast<int>((*it)->header.payloadType); 313 << static_cast<int>((*it)->header.payloadType);
295 return kDecoderNotFound; 314 return kDecoderNotFound;
296 } 315 }
297 } 316 }
298 return kOK; 317 return kOK;
299 } 318 }
300 319
301 } // namespace webrtc 320 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698