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

Side by Side Diff: webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.cc

Issue 2123923004: Updated AudioDecoderFactory to list AudioCodecSpecs instead of SdpAudioFormats. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@audio-decoder-factory-usage
Patch Set: Created 4 years, 5 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) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 return format.clockrate_hz == 48000 && format.num_channels == 2 && 122 return format.clockrate_hz == 48000 && format.num_channels == 2 &&
123 num_channels 123 num_channels
124 ? Unique(new AudioDecoderOpus(*num_channels)) 124 ? Unique(new AudioDecoderOpus(*num_channels))
125 : nullptr; 125 : nullptr;
126 }}, 126 }},
127 #endif 127 #endif
128 }; 128 };
129 129
130 class BuiltinAudioDecoderFactory : public AudioDecoderFactory { 130 class BuiltinAudioDecoderFactory : public AudioDecoderFactory {
131 public: 131 public:
132 std::vector<SdpAudioFormat> GetSupportedFormats() override { 132 std::vector<AudioCodecSpec> GetSupportedDecoders() override {
133 static std::vector<SdpAudioFormat> formats = { 133 static std::vector<AudioCodecSpec> specs = {
134 { "opus", 48000, 2, { 134 { { "opus", 48000, 2, {
135 {"minptime", "10" }, 135 {"minptime", "10" },
136 {"useinbandfec", "1" } 136 {"useinbandfec", "1" }
137 } 137 }
138 }, false
138 }, 139 },
139 { "isac", 16000, 1 }, 140 { { "isac", 16000, 1 }, true },
140 { "isac", 32000, 1 }, 141 { { "isac", 32000, 1 }, true },
141 { "G722", 8000, 1 }, 142 { { "G722", 8000, 1 }, true },
142 { "iLBC", 8000, 1 }, 143 { { "iLBC", 8000, 1 }, true },
143 { "PCMU", 8000, 1 }, 144 { { "PCMU", 8000, 1 }, true },
144 { "PCMA", 8000, 1 } 145 { { "PCMA", 8000, 1 }, true }
145 }; 146 };
146 147
147 return formats; 148 return specs;
148 } 149 }
149 150
150 std::unique_ptr<AudioDecoder> MakeAudioDecoder( 151 std::unique_ptr<AudioDecoder> MakeAudioDecoder(
151 const SdpAudioFormat& format) override { 152 const SdpAudioFormat& format) override {
152 for (const auto& dc : decoder_constructors) { 153 for (const auto& dc : decoder_constructors) {
153 if (STR_CASE_CMP(format.name.c_str(), dc.name) == 0) { 154 if (STR_CASE_CMP(format.name.c_str(), dc.name) == 0) {
154 std::unique_ptr<AudioDecoder> dec = dc.constructor(format); 155 std::unique_ptr<AudioDecoder> dec = dc.constructor(format);
155 if (dec) { 156 if (dec) {
156 const int expected_sample_rate_hz = 157 const int expected_sample_rate_hz =
157 STR_CASE_CMP(format.name.c_str(), "g722") == 0 158 STR_CASE_CMP(format.name.c_str(), "g722") == 0
158 ? 2 * format.clockrate_hz 159 ? 2 * format.clockrate_hz
159 : format.clockrate_hz; 160 : format.clockrate_hz;
160 RTC_CHECK_EQ(expected_sample_rate_hz, dec->SampleRateHz()); 161 RTC_CHECK_EQ(expected_sample_rate_hz, dec->SampleRateHz());
161 } 162 }
162 return dec; 163 return dec;
163 } 164 }
164 } 165 }
165 return nullptr; 166 return nullptr;
166 } 167 }
167 }; 168 };
168 169
169 } // namespace 170 } // namespace
170 171
171 rtc::scoped_refptr<AudioDecoderFactory> CreateBuiltinAudioDecoderFactory() { 172 rtc::scoped_refptr<AudioDecoderFactory> CreateBuiltinAudioDecoderFactory() {
172 return rtc::scoped_refptr<AudioDecoderFactory>( 173 return rtc::scoped_refptr<AudioDecoderFactory>(
173 new rtc::RefCountedObject<BuiltinAudioDecoderFactory>); 174 new rtc::RefCountedObject<BuiltinAudioDecoderFactory>);
174 } 175 }
175 176
176 } // namespace webrtc 177 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698