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

Side by Side Diff: webrtc/modules/audio_coding/main/acm2/codec_manager.cc

Issue 1364193002: CodecOwner::SetEncoders: Return error code when given bad arguments (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Add unittest Created 5 years, 3 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
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 274
275 encoder_is_opus_ = IsOpus(send_codec); 275 encoder_is_opus_ = IsOpus(send_codec);
276 276
277 if (new_codec) { 277 if (new_codec) {
278 // This is a new codec. Register it and return. 278 // This is a new codec. Register it and return.
279 RTC_DCHECK(CodecSupported(send_codec)); 279 RTC_DCHECK(CodecSupported(send_codec));
280 if (IsOpus(send_codec)) { 280 if (IsOpus(send_codec)) {
281 // VAD/DTX not supported. 281 // VAD/DTX not supported.
282 dtx_enabled_ = false; 282 dtx_enabled_ = false;
283 } 283 }
284 codec_owner_.SetEncoders( 284 if (!codec_owner_.SetEncoders(
285 send_codec, dtx_enabled_ ? CngPayloadType(send_codec.plfreq) : -1, 285 send_codec, dtx_enabled_ ? CngPayloadType(send_codec.plfreq) : -1,
286 vad_mode_, red_enabled_ ? RedPayloadType(send_codec.plfreq) : -1); 286 vad_mode_, red_enabled_ ? RedPayloadType(send_codec.plfreq) : -1))
287 return -1;
287 RTC_DCHECK(codec_owner_.Encoder()); 288 RTC_DCHECK(codec_owner_.Encoder());
288 289
289 codec_fec_enabled_ = codec_fec_enabled_ && 290 codec_fec_enabled_ = codec_fec_enabled_ &&
290 codec_owner_.Encoder()->SetFec(codec_fec_enabled_); 291 codec_owner_.Encoder()->SetFec(codec_fec_enabled_);
291 292
292 send_codec_inst_ = send_codec; 293 send_codec_inst_ = send_codec;
293 return 0; 294 return 0;
294 } 295 }
295 296
296 // This is an existing codec; re-create it if any parameters have changed. 297 // This is an existing codec; re-create it if any parameters have changed.
297 if (send_codec_inst_.plfreq != send_codec.plfreq || 298 if (send_codec_inst_.plfreq != send_codec.plfreq ||
298 send_codec_inst_.pacsize != send_codec.pacsize || 299 send_codec_inst_.pacsize != send_codec.pacsize ||
299 send_codec_inst_.channels != send_codec.channels) { 300 send_codec_inst_.channels != send_codec.channels) {
300 codec_owner_.SetEncoders( 301 if (!codec_owner_.SetEncoders(
301 send_codec, dtx_enabled_ ? CngPayloadType(send_codec.plfreq) : -1, 302 send_codec, dtx_enabled_ ? CngPayloadType(send_codec.plfreq) : -1,
302 vad_mode_, red_enabled_ ? RedPayloadType(send_codec.plfreq) : -1); 303 vad_mode_, red_enabled_ ? RedPayloadType(send_codec.plfreq) : -1))
304 return -1;
303 RTC_DCHECK(codec_owner_.Encoder()); 305 RTC_DCHECK(codec_owner_.Encoder());
304 } 306 }
305 send_codec_inst_.plfreq = send_codec.plfreq; 307 send_codec_inst_.plfreq = send_codec.plfreq;
306 send_codec_inst_.pacsize = send_codec.pacsize; 308 send_codec_inst_.pacsize = send_codec.pacsize;
307 send_codec_inst_.channels = send_codec.channels; 309 send_codec_inst_.channels = send_codec.channels;
308 send_codec_inst_.pltype = send_codec.pltype; 310 send_codec_inst_.pltype = send_codec.pltype;
309 311
310 // Check if a change in Rate is required. 312 // Check if a change in Rate is required.
311 if (send_codec.rate != send_codec_inst_.rate) { 313 if (send_codec.rate != send_codec_inst_.rate) {
312 codec_owner_.Encoder()->SetTargetBitrate(send_codec.rate); 314 codec_owner_.Encoder()->SetTargetBitrate(send_codec.rate);
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 case 48000: 464 case 48000:
463 return -1; 465 return -1;
464 default: 466 default:
465 FATAL() << sample_rate_hz << " Hz is not supported"; 467 FATAL() << sample_rate_hz << " Hz is not supported";
466 return -1; 468 return -1;
467 } 469 }
468 } 470 }
469 471
470 } // namespace acm2 472 } // namespace acm2
471 } // namespace webrtc 473 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698