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

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

Issue 1312493004: Add support for external decoders in ACM (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@isac-lock-2
Patch Set: 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) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 } 469 }
470 470
471 return 0; 471 return 0;
472 } 472 }
473 473
474 int32_t AcmReceiver::AddCodec(int acm_codec_id, 474 int32_t AcmReceiver::AddCodec(int acm_codec_id,
475 uint8_t payload_type, 475 uint8_t payload_type,
476 int channels, 476 int channels,
477 int sample_rate_hz, 477 int sample_rate_hz,
478 AudioDecoder* audio_decoder) { 478 AudioDecoder* audio_decoder) {
479 assert(acm_codec_id >= 0); 479 assert(acm_codec_id >= -1); // -1 means external decoder
480 NetEqDecoder neteq_decoder = ACMCodecDB::neteq_decoders_[acm_codec_id]; 480 NetEqDecoder neteq_decoder = (acm_codec_id == -1)
481 ? kDecoderArbitrary
482 : ACMCodecDB::neteq_decoders_[acm_codec_id];
481 483
482 // Make sure the right decoder is registered for Opus. 484 // Make sure the right decoder is registered for Opus.
483 if (neteq_decoder == kDecoderOpus && channels == 2) { 485 if (neteq_decoder == kDecoderOpus && channels == 2) {
484 neteq_decoder = kDecoderOpus_2ch; 486 neteq_decoder = kDecoderOpus_2ch;
485 } 487 }
486 488
487 CriticalSectionScoped lock(crit_sect_.get()); 489 CriticalSectionScoped lock(crit_sect_.get());
488 490
489 // The corresponding NetEq decoder ID. 491 // The corresponding NetEq decoder ID.
490 // If this codec has been registered before. 492 // If this codec has been registered before.
491 auto it = decoders_.find(payload_type); 493 auto it = decoders_.find(payload_type);
492 if (it != decoders_.end()) { 494 if (it != decoders_.end()) {
493 const Decoder& decoder = it->second; 495 const Decoder& decoder = it->second;
494 if (decoder.acm_codec_id == acm_codec_id && decoder.channels == channels && 496 if (acm_codec_id != -1 && decoder.acm_codec_id == acm_codec_id &&
497 decoder.channels == channels &&
495 decoder.sample_rate_hz == sample_rate_hz) { 498 decoder.sample_rate_hz == sample_rate_hz) {
496 // Re-registering the same codec. Do nothing and return. 499 // Re-registering the same codec. Do nothing and return.
497 return 0; 500 return 0;
498 } 501 }
499 502
500 // Changing codec or number of channels. First unregister the old codec, 503 // Changing codec. First unregister the old codec, then register the new
501 // then register the new one. 504 // one.
502 if (neteq_->RemovePayloadType(payload_type) != NetEq::kOK) { 505 if (neteq_->RemovePayloadType(payload_type) != NetEq::kOK) {
503 LOG(LERROR) << "Cannot remove payload " << static_cast<int>(payload_type); 506 LOG(LERROR) << "Cannot remove payload " << static_cast<int>(payload_type);
504 return -1; 507 return -1;
505 } 508 }
506 509
507 decoders_.erase(it); 510 decoders_.erase(it);
508 } 511 }
509 512
510 int ret_val; 513 int ret_val;
511 if (!audio_decoder) { 514 if (!audio_decoder) {
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 839
837 void AcmReceiver::GetDecodingCallStatistics( 840 void AcmReceiver::GetDecodingCallStatistics(
838 AudioDecodingCallStats* stats) const { 841 AudioDecodingCallStats* stats) const {
839 CriticalSectionScoped lock(crit_sect_.get()); 842 CriticalSectionScoped lock(crit_sect_.get());
840 *stats = call_stats_.GetDecodingStatistics(); 843 *stats = call_stats_.GetDecodingStatistics();
841 } 844 }
842 845
843 } // namespace acm2 846 } // namespace acm2
844 847
845 } // namespace webrtc 848 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/main/acm2/acm_receiver.h ('k') | webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698