| 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 } | 192 } |
| 193 previous_pltype = previous_pltype_; // Read it while we have the critsect. | 193 previous_pltype = previous_pltype_; // Read it while we have the critsect. |
| 194 | 194 |
| 195 RTPFragmentationHeader my_fragmentation; | 195 RTPFragmentationHeader my_fragmentation; |
| 196 ConvertEncodedInfoToFragmentationHeader(encoded_info, &my_fragmentation); | 196 ConvertEncodedInfoToFragmentationHeader(encoded_info, &my_fragmentation); |
| 197 FrameType frame_type; | 197 FrameType frame_type; |
| 198 if (encode_buffer_.size() == 0 && encoded_info.send_even_if_empty) { | 198 if (encode_buffer_.size() == 0 && encoded_info.send_even_if_empty) { |
| 199 frame_type = kFrameEmpty; | 199 frame_type = kFrameEmpty; |
| 200 encoded_info.payload_type = previous_pltype; | 200 encoded_info.payload_type = previous_pltype; |
| 201 } else { | 201 } else { |
| 202 DCHECK_GT(encode_buffer_.size(), 0u); | 202 RTC_DCHECK_GT(encode_buffer_.size(), 0u); |
| 203 frame_type = encoded_info.speech ? kAudioFrameSpeech : kAudioFrameCN; | 203 frame_type = encoded_info.speech ? kAudioFrameSpeech : kAudioFrameCN; |
| 204 } | 204 } |
| 205 | 205 |
| 206 { | 206 { |
| 207 CriticalSectionScoped lock(callback_crit_sect_.get()); | 207 CriticalSectionScoped lock(callback_crit_sect_.get()); |
| 208 if (packetization_callback_) { | 208 if (packetization_callback_) { |
| 209 packetization_callback_->SendData( | 209 packetization_callback_->SendData( |
| 210 frame_type, encoded_info.payload_type, encoded_info.encoded_timestamp, | 210 frame_type, encoded_info.payload_type, encoded_info.encoded_timestamp, |
| 211 encode_buffer_.data(), encode_buffer_.size(), | 211 encode_buffer_.data(), encode_buffer_.size(), |
| 212 my_fragmentation.fragmentationVectorSize > 0 ? &my_fragmentation | 212 my_fragmentation.fragmentationVectorSize > 0 ? &my_fragmentation |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 return 0; | 493 return 0; |
| 494 } | 494 } |
| 495 | 495 |
| 496 ///////////////////////////////////////// | 496 ///////////////////////////////////////// |
| 497 // (VAD) Voice Activity Detection | 497 // (VAD) Voice Activity Detection |
| 498 // | 498 // |
| 499 int AudioCodingModuleImpl::SetVAD(bool enable_dtx, | 499 int AudioCodingModuleImpl::SetVAD(bool enable_dtx, |
| 500 bool enable_vad, | 500 bool enable_vad, |
| 501 ACMVADMode mode) { | 501 ACMVADMode mode) { |
| 502 // Note: |enable_vad| is not used; VAD is enabled based on the DTX setting. | 502 // Note: |enable_vad| is not used; VAD is enabled based on the DTX setting. |
| 503 DCHECK_EQ(enable_dtx, enable_vad); | 503 RTC_DCHECK_EQ(enable_dtx, enable_vad); |
| 504 CriticalSectionScoped lock(acm_crit_sect_.get()); | 504 CriticalSectionScoped lock(acm_crit_sect_.get()); |
| 505 return codec_manager_.SetVAD(enable_dtx, mode); | 505 return codec_manager_.SetVAD(enable_dtx, mode); |
| 506 } | 506 } |
| 507 | 507 |
| 508 // Get VAD/DTX settings. | 508 // Get VAD/DTX settings. |
| 509 int AudioCodingModuleImpl::VAD(bool* dtx_enabled, bool* vad_enabled, | 509 int AudioCodingModuleImpl::VAD(bool* dtx_enabled, bool* vad_enabled, |
| 510 ACMVADMode* mode) const { | 510 ACMVADMode* mode) const { |
| 511 CriticalSectionScoped lock(acm_crit_sect_.get()); | 511 CriticalSectionScoped lock(acm_crit_sect_.get()); |
| 512 codec_manager_.VAD(dtx_enabled, vad_enabled, mode); | 512 codec_manager_.VAD(dtx_enabled, vad_enabled, mode); |
| 513 return 0; | 513 return 0; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 | 573 |
| 574 CriticalSectionScoped lock(acm_crit_sect_.get()); | 574 CriticalSectionScoped lock(acm_crit_sect_.get()); |
| 575 | 575 |
| 576 return receiver_.current_sample_rate_hz(); | 576 return receiver_.current_sample_rate_hz(); |
| 577 } | 577 } |
| 578 | 578 |
| 579 // Register possible receive codecs, can be called multiple times, | 579 // Register possible receive codecs, can be called multiple times, |
| 580 // for codecs, CNG (NB, WB and SWB), DTMF, RED. | 580 // for codecs, CNG (NB, WB and SWB), DTMF, RED. |
| 581 int AudioCodingModuleImpl::RegisterReceiveCodec(const CodecInst& codec) { | 581 int AudioCodingModuleImpl::RegisterReceiveCodec(const CodecInst& codec) { |
| 582 CriticalSectionScoped lock(acm_crit_sect_.get()); | 582 CriticalSectionScoped lock(acm_crit_sect_.get()); |
| 583 DCHECK(receiver_initialized_); | 583 RTC_DCHECK(receiver_initialized_); |
| 584 if (codec.channels > 2 || codec.channels < 0) { | 584 if (codec.channels > 2 || codec.channels < 0) { |
| 585 LOG_F(LS_ERROR) << "Unsupported number of channels: " << codec.channels; | 585 LOG_F(LS_ERROR) << "Unsupported number of channels: " << codec.channels; |
| 586 return -1; | 586 return -1; |
| 587 } | 587 } |
| 588 | 588 |
| 589 int codec_id = ACMCodecDB::ReceiverCodecNumber(codec); | 589 int codec_id = ACMCodecDB::ReceiverCodecNumber(codec); |
| 590 if (codec_id < 0 || codec_id >= ACMCodecDB::kNumCodecs) { | 590 if (codec_id < 0 || codec_id >= ACMCodecDB::kNumCodecs) { |
| 591 LOG_F(LS_ERROR) << "Wrong codec params to be registered as receive codec"; | 591 LOG_F(LS_ERROR) << "Wrong codec params to be registered as receive codec"; |
| 592 return -1; | 592 return -1; |
| 593 } | 593 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 605 codec.plfreq, | 605 codec.plfreq, |
| 606 codec_manager_.GetAudioDecoder(codec)); | 606 codec_manager_.GetAudioDecoder(codec)); |
| 607 } | 607 } |
| 608 | 608 |
| 609 int AudioCodingModuleImpl::RegisterExternalReceiveCodec( | 609 int AudioCodingModuleImpl::RegisterExternalReceiveCodec( |
| 610 int rtp_payload_type, | 610 int rtp_payload_type, |
| 611 AudioDecoder* external_decoder, | 611 AudioDecoder* external_decoder, |
| 612 int sample_rate_hz, | 612 int sample_rate_hz, |
| 613 int num_channels) { | 613 int num_channels) { |
| 614 CriticalSectionScoped lock(acm_crit_sect_.get()); | 614 CriticalSectionScoped lock(acm_crit_sect_.get()); |
| 615 DCHECK(receiver_initialized_); | 615 RTC_DCHECK(receiver_initialized_); |
| 616 if (num_channels > 2 || num_channels < 0) { | 616 if (num_channels > 2 || num_channels < 0) { |
| 617 LOG_F(LS_ERROR) << "Unsupported number of channels: " << num_channels; | 617 LOG_F(LS_ERROR) << "Unsupported number of channels: " << num_channels; |
| 618 return -1; | 618 return -1; |
| 619 } | 619 } |
| 620 | 620 |
| 621 // Check if the payload-type is valid. | 621 // Check if the payload-type is valid. |
| 622 if (!ACMCodecDB::ValidPayloadType(rtp_payload_type)) { | 622 if (!ACMCodecDB::ValidPayloadType(rtp_payload_type)) { |
| 623 LOG_F(LS_ERROR) << "Invalid payload-type " << rtp_payload_type | 623 LOG_F(LS_ERROR) << "Invalid payload-type " << rtp_payload_type |
| 624 << " for external decoder."; | 624 << " for external decoder."; |
| 625 return -1; | 625 return -1; |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 *sample_rate_hz = 8000; | 1135 *sample_rate_hz = 8000; |
| 1136 *channels = 1; | 1136 *channels = 1; |
| 1137 break; | 1137 break; |
| 1138 default: | 1138 default: |
| 1139 FATAL() << "Codec type " << codec_type << " not supported."; | 1139 FATAL() << "Codec type " << codec_type << " not supported."; |
| 1140 } | 1140 } |
| 1141 return true; | 1141 return true; |
| 1142 } | 1142 } |
| 1143 | 1143 |
| 1144 } // namespace webrtc | 1144 } // namespace webrtc |
| OLD | NEW |