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

Side by Side Diff: webrtc/modules/audio_coding/acm2/rent_a_codec.cc

Issue 1694073002: Replace scoped_ptr with unique_ptr in webrtc/modules/audio_coding/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@up-actest
Patch Set: Created 4 years, 10 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) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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
11 #include "webrtc/modules/audio_coding/acm2/rent_a_codec.h" 11 #include "webrtc/modules/audio_coding/acm2/rent_a_codec.h"
12 12
13 #include <memory>
13 #include <utility> 14 #include <utility>
14 15
15 #include "webrtc/base/logging.h" 16 #include "webrtc/base/logging.h"
16 #include "webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.h" 17 #include "webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.h"
17 #include "webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.h" 18 #include "webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.h"
18 #ifdef WEBRTC_CODEC_G722 19 #ifdef WEBRTC_CODEC_G722
19 #include "webrtc/modules/audio_coding/codecs/g722/audio_encoder_g722.h" 20 #include "webrtc/modules/audio_coding/codecs/g722/audio_encoder_g722.h"
20 #endif 21 #endif
21 #ifdef WEBRTC_CODEC_ILBC 22 #ifdef WEBRTC_CODEC_ILBC
22 #include "webrtc/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h" 23 #include "webrtc/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 return RegistrationResult::kOk; 138 return RegistrationResult::kOk;
138 default: 139 default:
139 return RegistrationResult::kBadFreq; 140 return RegistrationResult::kBadFreq;
140 } 141 }
141 } 142 }
142 143
143 namespace { 144 namespace {
144 145
145 // Returns a new speech encoder, or null on error. 146 // Returns a new speech encoder, or null on error.
146 // TODO(kwiberg): Don't handle errors here (bug 5033) 147 // TODO(kwiberg): Don't handle errors here (bug 5033)
147 rtc::scoped_ptr<AudioEncoder> CreateEncoder( 148 std::unique_ptr<AudioEncoder> CreateEncoder(const CodecInst& speech_inst,
148 const CodecInst& speech_inst, 149 LockedIsacBandwidthInfo* bwinfo) {
149 LockedIsacBandwidthInfo* bwinfo) {
150 #if defined(WEBRTC_CODEC_ISACFX) 150 #if defined(WEBRTC_CODEC_ISACFX)
151 if (STR_CASE_CMP(speech_inst.plname, "isac") == 0) 151 if (STR_CASE_CMP(speech_inst.plname, "isac") == 0)
152 return rtc_make_scoped_ptr(new AudioEncoderIsacFix(speech_inst, bwinfo)); 152 return std::unique_ptr<AudioEncoder>(
153 new AudioEncoderIsacFix(speech_inst, bwinfo));
153 #endif 154 #endif
154 #if defined(WEBRTC_CODEC_ISAC) 155 #if defined(WEBRTC_CODEC_ISAC)
155 if (STR_CASE_CMP(speech_inst.plname, "isac") == 0) 156 if (STR_CASE_CMP(speech_inst.plname, "isac") == 0)
156 return rtc_make_scoped_ptr(new AudioEncoderIsac(speech_inst, bwinfo)); 157 return std::unique_ptr<AudioEncoder>(
158 new AudioEncoderIsac(speech_inst, bwinfo));
157 #endif 159 #endif
158 #ifdef WEBRTC_CODEC_OPUS 160 #ifdef WEBRTC_CODEC_OPUS
159 if (STR_CASE_CMP(speech_inst.plname, "opus") == 0) 161 if (STR_CASE_CMP(speech_inst.plname, "opus") == 0)
160 return rtc_make_scoped_ptr(new AudioEncoderOpus(speech_inst)); 162 return std::unique_ptr<AudioEncoder>(new AudioEncoderOpus(speech_inst));
161 #endif 163 #endif
162 if (STR_CASE_CMP(speech_inst.plname, "pcmu") == 0) 164 if (STR_CASE_CMP(speech_inst.plname, "pcmu") == 0)
163 return rtc_make_scoped_ptr(new AudioEncoderPcmU(speech_inst)); 165 return std::unique_ptr<AudioEncoder>(new AudioEncoderPcmU(speech_inst));
164 if (STR_CASE_CMP(speech_inst.plname, "pcma") == 0) 166 if (STR_CASE_CMP(speech_inst.plname, "pcma") == 0)
165 return rtc_make_scoped_ptr(new AudioEncoderPcmA(speech_inst)); 167 return std::unique_ptr<AudioEncoder>(new AudioEncoderPcmA(speech_inst));
166 if (STR_CASE_CMP(speech_inst.plname, "l16") == 0) 168 if (STR_CASE_CMP(speech_inst.plname, "l16") == 0)
167 return rtc_make_scoped_ptr(new AudioEncoderPcm16B(speech_inst)); 169 return std::unique_ptr<AudioEncoder>(new AudioEncoderPcm16B(speech_inst));
168 #ifdef WEBRTC_CODEC_ILBC 170 #ifdef WEBRTC_CODEC_ILBC
169 if (STR_CASE_CMP(speech_inst.plname, "ilbc") == 0) 171 if (STR_CASE_CMP(speech_inst.plname, "ilbc") == 0)
170 return rtc_make_scoped_ptr(new AudioEncoderIlbc(speech_inst)); 172 return std::unique_ptr<AudioEncoder>(new AudioEncoderIlbc(speech_inst));
171 #endif 173 #endif
172 #ifdef WEBRTC_CODEC_G722 174 #ifdef WEBRTC_CODEC_G722
173 if (STR_CASE_CMP(speech_inst.plname, "g722") == 0) 175 if (STR_CASE_CMP(speech_inst.plname, "g722") == 0)
174 return rtc_make_scoped_ptr(new AudioEncoderG722(speech_inst)); 176 return std::unique_ptr<AudioEncoder>(new AudioEncoderG722(speech_inst));
175 #endif 177 #endif
176 LOG_F(LS_ERROR) << "Could not create encoder of type " << speech_inst.plname; 178 LOG_F(LS_ERROR) << "Could not create encoder of type " << speech_inst.plname;
177 return rtc::scoped_ptr<AudioEncoder>(); 179 return std::unique_ptr<AudioEncoder>();
178 } 180 }
179 181
180 rtc::scoped_ptr<AudioEncoder> CreateRedEncoder(AudioEncoder* encoder, 182 std::unique_ptr<AudioEncoder> CreateRedEncoder(AudioEncoder* encoder,
181 int red_payload_type) { 183 int red_payload_type) {
182 #ifdef WEBRTC_CODEC_RED 184 #ifdef WEBRTC_CODEC_RED
183 AudioEncoderCopyRed::Config config; 185 AudioEncoderCopyRed::Config config;
184 config.payload_type = red_payload_type; 186 config.payload_type = red_payload_type;
185 config.speech_encoder = encoder; 187 config.speech_encoder = encoder;
186 return rtc::scoped_ptr<AudioEncoder>(new AudioEncoderCopyRed(config)); 188 return std::unique_ptr<AudioEncoder>(new AudioEncoderCopyRed(config));
187 #else 189 #else
188 return rtc::scoped_ptr<AudioEncoder>(); 190 return std::unique_ptr<AudioEncoder>();
189 #endif 191 #endif
190 } 192 }
191 193
192 rtc::scoped_ptr<AudioEncoder> CreateCngEncoder(AudioEncoder* encoder, 194 std::unique_ptr<AudioEncoder> CreateCngEncoder(AudioEncoder* encoder,
193 int payload_type, 195 int payload_type,
194 ACMVADMode vad_mode) { 196 ACMVADMode vad_mode) {
195 AudioEncoderCng::Config config; 197 AudioEncoderCng::Config config;
196 config.num_channels = encoder->NumChannels(); 198 config.num_channels = encoder->NumChannels();
197 config.payload_type = payload_type; 199 config.payload_type = payload_type;
198 config.speech_encoder = encoder; 200 config.speech_encoder = encoder;
199 switch (vad_mode) { 201 switch (vad_mode) {
200 case VADNormal: 202 case VADNormal:
201 config.vad_mode = Vad::kVadNormal; 203 config.vad_mode = Vad::kVadNormal;
202 break; 204 break;
203 case VADLowBitrate: 205 case VADLowBitrate:
204 config.vad_mode = Vad::kVadLowBitrate; 206 config.vad_mode = Vad::kVadLowBitrate;
205 break; 207 break;
206 case VADAggr: 208 case VADAggr:
207 config.vad_mode = Vad::kVadAggressive; 209 config.vad_mode = Vad::kVadAggressive;
208 break; 210 break;
209 case VADVeryAggr: 211 case VADVeryAggr:
210 config.vad_mode = Vad::kVadVeryAggressive; 212 config.vad_mode = Vad::kVadVeryAggressive;
211 break; 213 break;
212 default: 214 default:
213 FATAL(); 215 FATAL();
214 } 216 }
215 return rtc::scoped_ptr<AudioEncoder>(new AudioEncoderCng(config)); 217 return std::unique_ptr<AudioEncoder>(new AudioEncoderCng(config));
216 } 218 }
217 219
218 rtc::scoped_ptr<AudioDecoder> CreateIsacDecoder( 220 std::unique_ptr<AudioDecoder> CreateIsacDecoder(
219 LockedIsacBandwidthInfo* bwinfo) { 221 LockedIsacBandwidthInfo* bwinfo) {
220 #if defined(WEBRTC_CODEC_ISACFX) 222 #if defined(WEBRTC_CODEC_ISACFX)
221 return rtc_make_scoped_ptr(new AudioDecoderIsacFix(bwinfo)); 223 return std::unique_ptr<AudioDecoder>(new AudioDecoderIsacFix(bwinfo));
222 #elif defined(WEBRTC_CODEC_ISAC) 224 #elif defined(WEBRTC_CODEC_ISAC)
223 return rtc_make_scoped_ptr(new AudioDecoderIsac(bwinfo)); 225 return std::unique_ptr<AudioDecoder>(new AudioDecoderIsac(bwinfo));
224 #else 226 #else
225 FATAL() << "iSAC is not supported."; 227 FATAL() << "iSAC is not supported.";
226 return rtc::scoped_ptr<AudioDecoder>(); 228 return std::unique_ptr<AudioDecoder>();
227 #endif 229 #endif
228 } 230 }
229 231
230 } // namespace 232 } // namespace
231 233
232 RentACodec::RentACodec() = default; 234 RentACodec::RentACodec() = default;
233 RentACodec::~RentACodec() = default; 235 RentACodec::~RentACodec() = default;
234 236
235 AudioEncoder* RentACodec::RentEncoder(const CodecInst& codec_inst) { 237 AudioEncoder* RentACodec::RentEncoder(const CodecInst& codec_inst) {
236 rtc::scoped_ptr<AudioEncoder> enc = 238 std::unique_ptr<AudioEncoder> enc =
237 CreateEncoder(codec_inst, &isac_bandwidth_info_); 239 CreateEncoder(codec_inst, &isac_bandwidth_info_);
238 if (!enc) 240 if (!enc)
239 return nullptr; 241 return nullptr;
240 speech_encoder_ = std::move(enc); 242 speech_encoder_ = std::move(enc);
241 return speech_encoder_.get(); 243 return speech_encoder_.get();
242 } 244 }
243 245
244 RentACodec::StackParameters::StackParameters() { 246 RentACodec::StackParameters::StackParameters() {
245 // Register the default payload types for RED and CNG. 247 // Register the default payload types for RED and CNG.
246 for (const CodecInst& ci : RentACodec::Database()) { 248 for (const CodecInst& ci : RentACodec::Database()) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 } 300 }
299 301
300 AudioDecoder* RentACodec::RentIsacDecoder() { 302 AudioDecoder* RentACodec::RentIsacDecoder() {
301 if (!isac_decoder_) 303 if (!isac_decoder_)
302 isac_decoder_ = CreateIsacDecoder(&isac_bandwidth_info_); 304 isac_decoder_ = CreateIsacDecoder(&isac_bandwidth_info_);
303 return isac_decoder_.get(); 305 return isac_decoder_.get();
304 } 306 }
305 307
306 } // namespace acm2 308 } // namespace acm2
307 } // namespace webrtc 309 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698