OLD | NEW |
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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 } | 400 } |
401 void Reset() override { return enc_->Reset(); } | 401 void Reset() override { return enc_->Reset(); } |
402 bool SetFec(bool enable) override { return enc_->SetFec(enable); } | 402 bool SetFec(bool enable) override { return enc_->SetFec(enable); } |
403 bool SetDtx(bool enable) override { return enc_->SetDtx(enable); } | 403 bool SetDtx(bool enable) override { return enc_->SetDtx(enable); } |
404 bool SetApplication(Application application) override { | 404 bool SetApplication(Application application) override { |
405 return enc_->SetApplication(application); | 405 return enc_->SetApplication(application); |
406 } | 406 } |
407 void SetMaxPlaybackRate(int frequency_hz) override { | 407 void SetMaxPlaybackRate(int frequency_hz) override { |
408 return enc_->SetMaxPlaybackRate(frequency_hz); | 408 return enc_->SetMaxPlaybackRate(frequency_hz); |
409 } | 409 } |
| 410 void SetProjectedPacketLossRate(double fraction) override { |
| 411 return enc_->SetProjectedPacketLossRate(fraction); |
| 412 } |
| 413 void SetTargetBitrate(int target_bps) override { |
| 414 return enc_->SetTargetBitrate(target_bps); |
| 415 } |
410 | 416 |
411 private: | 417 private: |
412 AudioEncoder* enc_; | 418 AudioEncoder* enc_; |
413 }; | 419 }; |
414 | 420 |
415 // Return false on error. | 421 // Return false on error. |
416 bool CreateSpeechEncoderIfNecessary(EncoderFactory* ef) { | 422 bool CreateSpeechEncoderIfNecessary(EncoderFactory* ef) { |
417 auto* sp = ef->codec_manager.GetStackParams(); | 423 auto* sp = ef->codec_manager.GetStackParams(); |
418 if (sp->speech_encoder) { | 424 if (sp->speech_encoder) { |
419 // Do nothing; we already have a speech encoder. | 425 // Do nothing; we already have a speech encoder. |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 "SendFrequency Failed, no codec is registered"); | 647 "SendFrequency Failed, no codec is registered"); |
642 return -1; | 648 return -1; |
643 } | 649 } |
644 | 650 |
645 return encoder_stack_->SampleRateHz(); | 651 return encoder_stack_->SampleRateHz(); |
646 } | 652 } |
647 | 653 |
648 void AudioCodingModuleImpl::SetBitRate(int bitrate_bps) { | 654 void AudioCodingModuleImpl::SetBitRate(int bitrate_bps) { |
649 rtc::CritScope lock(&acm_crit_sect_); | 655 rtc::CritScope lock(&acm_crit_sect_); |
650 if (encoder_stack_) { | 656 if (encoder_stack_) { |
651 encoder_stack_->OnReceivedTargetAudioBitrate(bitrate_bps); | 657 encoder_stack_->SetTargetBitrate(bitrate_bps); |
652 } | 658 } |
653 } | 659 } |
654 | 660 |
655 // Register a transport callback which will be called to deliver | 661 // Register a transport callback which will be called to deliver |
656 // the encoded buffers. | 662 // the encoded buffers. |
657 int AudioCodingModuleImpl::RegisterTransportCallback( | 663 int AudioCodingModuleImpl::RegisterTransportCallback( |
658 AudioPacketizationCallback* transport) { | 664 AudioPacketizationCallback* transport) { |
659 rtc::CritScope lock(&callback_crit_sect_); | 665 rtc::CritScope lock(&callback_crit_sect_); |
660 packetization_callback_ = transport; | 666 packetization_callback_ = transport; |
661 return 0; | 667 return 0; |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 return sp->use_codec_fec ? 0 : -1; | 899 return sp->use_codec_fec ? 0 : -1; |
894 } else { | 900 } else { |
895 RTC_DCHECK(!sp->use_codec_fec); | 901 RTC_DCHECK(!sp->use_codec_fec); |
896 return 0; | 902 return 0; |
897 } | 903 } |
898 } | 904 } |
899 | 905 |
900 int AudioCodingModuleImpl::SetPacketLossRate(int loss_rate) { | 906 int AudioCodingModuleImpl::SetPacketLossRate(int loss_rate) { |
901 rtc::CritScope lock(&acm_crit_sect_); | 907 rtc::CritScope lock(&acm_crit_sect_); |
902 if (HaveValidEncoder("SetPacketLossRate")) { | 908 if (HaveValidEncoder("SetPacketLossRate")) { |
903 encoder_stack_->OnReceivedUplinkPacketLossFraction(loss_rate / 100.0); | 909 encoder_stack_->SetProjectedPacketLossRate(loss_rate / 100.0); |
904 } | 910 } |
905 return 0; | 911 return 0; |
906 } | 912 } |
907 | 913 |
908 ///////////////////////////////////////// | 914 ///////////////////////////////////////// |
909 // (VAD) Voice Activity Detection | 915 // (VAD) Voice Activity Detection |
910 // | 916 // |
911 int AudioCodingModuleImpl::SetVAD(bool enable_dtx, | 917 int AudioCodingModuleImpl::SetVAD(bool enable_dtx, |
912 bool enable_vad, | 918 bool enable_vad, |
913 ACMVADMode mode) { | 919 ACMVADMode mode) { |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1375 // Checks the validity of the parameters of the given codec | 1381 // Checks the validity of the parameters of the given codec |
1376 bool AudioCodingModule::IsCodecValid(const CodecInst& codec) { | 1382 bool AudioCodingModule::IsCodecValid(const CodecInst& codec) { |
1377 bool valid = acm2::RentACodec::IsCodecValid(codec); | 1383 bool valid = acm2::RentACodec::IsCodecValid(codec); |
1378 if (!valid) | 1384 if (!valid) |
1379 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, -1, | 1385 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, -1, |
1380 "Invalid codec setting"); | 1386 "Invalid codec setting"); |
1381 return valid; | 1387 return valid; |
1382 } | 1388 } |
1383 | 1389 |
1384 } // namespace webrtc | 1390 } // namespace webrtc |
OLD | NEW |