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

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

Issue 1322973004: Fold AudioEncoderMutable into AudioEncoder (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: review fixes 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) 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 // Sender 224 // Sender
225 // 225 //
226 226
227 // Can be called multiple times for Codec, CNG, RED. 227 // Can be called multiple times for Codec, CNG, RED.
228 int AudioCodingModuleImpl::RegisterSendCodec(const CodecInst& send_codec) { 228 int AudioCodingModuleImpl::RegisterSendCodec(const CodecInst& send_codec) {
229 CriticalSectionScoped lock(acm_crit_sect_.get()); 229 CriticalSectionScoped lock(acm_crit_sect_.get());
230 return codec_manager_.RegisterEncoder(send_codec); 230 return codec_manager_.RegisterEncoder(send_codec);
231 } 231 }
232 232
233 void AudioCodingModuleImpl::RegisterExternalSendCodec( 233 void AudioCodingModuleImpl::RegisterExternalSendCodec(
234 AudioEncoderMutable* external_speech_encoder) { 234 AudioEncoder* external_speech_encoder) {
235 CriticalSectionScoped lock(acm_crit_sect_.get()); 235 CriticalSectionScoped lock(acm_crit_sect_.get());
236 codec_manager_.RegisterEncoder(external_speech_encoder); 236 codec_manager_.RegisterEncoder(external_speech_encoder);
237 } 237 }
238 238
239 // Get current send codec. 239 // Get current send codec.
240 int AudioCodingModuleImpl::SendCodec(CodecInst* current_codec) const { 240 int AudioCodingModuleImpl::SendCodec(CodecInst* current_codec) const {
241 CriticalSectionScoped lock(acm_crit_sect_.get()); 241 CriticalSectionScoped lock(acm_crit_sect_.get());
242 return codec_manager_.GetCodecInst(current_codec); 242 return codec_manager_.GetCodecInst(current_codec);
243 } 243 }
244 244
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 } 478 }
479 479
480 int AudioCodingModuleImpl::SetCodecFEC(bool enable_codec_fec) { 480 int AudioCodingModuleImpl::SetCodecFEC(bool enable_codec_fec) {
481 CriticalSectionScoped lock(acm_crit_sect_.get()); 481 CriticalSectionScoped lock(acm_crit_sect_.get());
482 return codec_manager_.SetCodecFEC(enable_codec_fec); 482 return codec_manager_.SetCodecFEC(enable_codec_fec);
483 } 483 }
484 484
485 int AudioCodingModuleImpl::SetPacketLossRate(int loss_rate) { 485 int AudioCodingModuleImpl::SetPacketLossRate(int loss_rate) {
486 CriticalSectionScoped lock(acm_crit_sect_.get()); 486 CriticalSectionScoped lock(acm_crit_sect_.get());
487 if (HaveValidEncoder("SetPacketLossRate")) { 487 if (HaveValidEncoder("SetPacketLossRate")) {
488 codec_manager_.CurrentSpeechEncoder()->SetProjectedPacketLossRate( 488 codec_manager_.CurrentEncoder()->SetProjectedPacketLossRate(loss_rate /
489 loss_rate / 100.0); 489 100.0);
490 } 490 }
491 return 0; 491 return 0;
492 } 492 }
493 493
494 ///////////////////////////////////////// 494 /////////////////////////////////////////
495 // (VAD) Voice Activity Detection 495 // (VAD) Voice Activity Detection
496 // 496 //
497 int AudioCodingModuleImpl::SetVAD(bool enable_dtx, 497 int AudioCodingModuleImpl::SetVAD(bool enable_dtx,
498 bool enable_vad, 498 bool enable_vad,
499 ACMVADMode mode) { 499 ACMVADMode mode) {
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 } 734 }
735 735
736 // TODO(henrik.lundin): Remove? Only used in tests. Deprecated in VoiceEngine. 736 // TODO(henrik.lundin): Remove? Only used in tests. Deprecated in VoiceEngine.
737 int AudioCodingModuleImpl::SetISACMaxRate(int max_bit_per_sec) { 737 int AudioCodingModuleImpl::SetISACMaxRate(int max_bit_per_sec) {
738 CriticalSectionScoped lock(acm_crit_sect_.get()); 738 CriticalSectionScoped lock(acm_crit_sect_.get());
739 739
740 if (!HaveValidEncoder("SetISACMaxRate")) { 740 if (!HaveValidEncoder("SetISACMaxRate")) {
741 return -1; 741 return -1;
742 } 742 }
743 743
744 codec_manager_.CurrentSpeechEncoder()->SetMaxRate(max_bit_per_sec); 744 codec_manager_.CurrentEncoder()->SetMaxBitrate(max_bit_per_sec);
745 return 0; 745 return 0;
746 } 746 }
747 747
748 // TODO(henrik.lundin): Remove? Only used in tests. Deprecated in VoiceEngine. 748 // TODO(henrik.lundin): Remove? Only used in tests. Deprecated in VoiceEngine.
749 int AudioCodingModuleImpl::SetISACMaxPayloadSize(int max_size_bytes) { 749 int AudioCodingModuleImpl::SetISACMaxPayloadSize(int max_size_bytes) {
750 CriticalSectionScoped lock(acm_crit_sect_.get()); 750 CriticalSectionScoped lock(acm_crit_sect_.get());
751 751
752 if (!HaveValidEncoder("SetISACMaxPayloadSize")) { 752 if (!HaveValidEncoder("SetISACMaxPayloadSize")) {
753 return -1; 753 return -1;
754 } 754 }
755 755
756 codec_manager_.CurrentSpeechEncoder()->SetMaxPayloadSize(max_size_bytes); 756 codec_manager_.CurrentEncoder()->SetMaxPayloadSize(max_size_bytes);
757 return 0; 757 return 0;
758 } 758 }
759 759
760 int AudioCodingModuleImpl::SetOpusApplication(OpusApplicationMode application) { 760 int AudioCodingModuleImpl::SetOpusApplication(OpusApplicationMode application) {
761 CriticalSectionScoped lock(acm_crit_sect_.get()); 761 CriticalSectionScoped lock(acm_crit_sect_.get());
762 if (!HaveValidEncoder("SetOpusApplication")) { 762 if (!HaveValidEncoder("SetOpusApplication")) {
763 return -1; 763 return -1;
764 } 764 }
765 AudioEncoderMutable::Application app; 765 if (!codec_manager_.CurrentEncoderIsOpus())
766 return -1;
767 AudioEncoder::Application app;
766 switch (application) { 768 switch (application) {
767 case kVoip: 769 case kVoip:
768 app = AudioEncoderMutable::kApplicationSpeech; 770 app = AudioEncoder::Application::kSpeech;
769 break; 771 break;
770 case kAudio: 772 case kAudio:
771 app = AudioEncoderMutable::kApplicationAudio; 773 app = AudioEncoder::Application::kAudio;
772 break; 774 break;
773 default: 775 default:
774 FATAL(); 776 FATAL();
775 return 0; 777 return 0;
776 } 778 }
777 return codec_manager_.CurrentSpeechEncoder()->SetApplication(app) ? 0 : -1; 779 return codec_manager_.CurrentEncoder()->SetApplication(app) ? 0 : -1;
778 } 780 }
779 781
780 // Informs Opus encoder of the maximum playback rate the receiver will render. 782 // Informs Opus encoder of the maximum playback rate the receiver will render.
781 int AudioCodingModuleImpl::SetOpusMaxPlaybackRate(int frequency_hz) { 783 int AudioCodingModuleImpl::SetOpusMaxPlaybackRate(int frequency_hz) {
782 CriticalSectionScoped lock(acm_crit_sect_.get()); 784 CriticalSectionScoped lock(acm_crit_sect_.get());
783 if (!HaveValidEncoder("SetOpusMaxPlaybackRate")) { 785 if (!HaveValidEncoder("SetOpusMaxPlaybackRate")) {
784 return -1; 786 return -1;
785 } 787 }
786 return codec_manager_.CurrentSpeechEncoder()->SetMaxPlaybackRate(frequency_hz) 788 if (!codec_manager_.CurrentEncoderIsOpus())
787 ? 0 789 return -1;
788 : -1; 790 return codec_manager_.CurrentEncoder()->SetMaxPlaybackRate(frequency_hz) ? 0
791 : -1;
789 } 792 }
790 793
791 int AudioCodingModuleImpl::EnableOpusDtx() { 794 int AudioCodingModuleImpl::EnableOpusDtx() {
792 CriticalSectionScoped lock(acm_crit_sect_.get()); 795 CriticalSectionScoped lock(acm_crit_sect_.get());
793 if (!HaveValidEncoder("EnableOpusDtx")) { 796 if (!HaveValidEncoder("EnableOpusDtx")) {
794 return -1; 797 return -1;
795 } 798 }
796 return codec_manager_.CurrentSpeechEncoder()->SetDtx(true) ? 0 : -1; 799 if (!codec_manager_.CurrentEncoderIsOpus())
800 return -1;
801 return codec_manager_.CurrentEncoder()->SetDtx(true) ? 0 : -1;
797 } 802 }
798 803
799 int AudioCodingModuleImpl::DisableOpusDtx() { 804 int AudioCodingModuleImpl::DisableOpusDtx() {
800 CriticalSectionScoped lock(acm_crit_sect_.get()); 805 CriticalSectionScoped lock(acm_crit_sect_.get());
801 if (!HaveValidEncoder("DisableOpusDtx")) { 806 if (!HaveValidEncoder("DisableOpusDtx")) {
802 return -1; 807 return -1;
803 } 808 }
804 return codec_manager_.CurrentSpeechEncoder()->SetDtx(false) ? 0 : -1; 809 if (!codec_manager_.CurrentEncoderIsOpus())
810 return -1;
811 return codec_manager_.CurrentEncoder()->SetDtx(false) ? 0 : -1;
805 } 812 }
806 813
807 int AudioCodingModuleImpl::PlayoutTimestamp(uint32_t* timestamp) { 814 int AudioCodingModuleImpl::PlayoutTimestamp(uint32_t* timestamp) {
808 return receiver_.GetPlayoutTimestamp(timestamp) ? 0 : -1; 815 return receiver_.GetPlayoutTimestamp(timestamp) ? 0 : -1;
809 } 816 }
810 817
811 bool AudioCodingModuleImpl::HaveValidEncoder(const char* caller_name) const { 818 bool AudioCodingModuleImpl::HaveValidEncoder(const char* caller_name) const {
812 if (!codec_manager_.CurrentEncoder()) { 819 if (!codec_manager_.CurrentEncoder()) {
813 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, 820 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_,
814 "%s failed: No send codec is registered.", caller_name); 821 "%s failed: No send codec is registered.", caller_name);
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 *channels = 1; 1157 *channels = 1;
1151 break; 1158 break;
1152 #endif 1159 #endif
1153 default: 1160 default:
1154 FATAL() << "Codec type " << codec_type << " not supported."; 1161 FATAL() << "Codec type " << codec_type << " not supported.";
1155 } 1162 }
1156 return true; 1163 return true;
1157 } 1164 }
1158 1165
1159 } // namespace webrtc 1166 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698