| 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 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 else | 510 else |
| 511 { | 511 { |
| 512 // Pure stereo mode (we are receiving a stereo signal). | 512 // Pure stereo mode (we are receiving a stereo signal). |
| 513 } | 513 } |
| 514 | 514 |
| 515 assert(_audioFrame.num_channels_ == 2); | 515 assert(_audioFrame.num_channels_ == 2); |
| 516 AudioFrameOperations::Scale(_panLeft, _panRight, _audioFrame); | 516 AudioFrameOperations::Scale(_panLeft, _panRight, _audioFrame); |
| 517 } | 517 } |
| 518 | 518 |
| 519 // --- Far-end Voice Quality Enhancement (AudioProcessing Module) | 519 // --- Far-end Voice Quality Enhancement (AudioProcessing Module) |
| 520 if (feed_data_to_apm) | 520 if (feed_data_to_apm) { |
| 521 APMProcessReverseStream(); | 521 // Convert from mixing to AudioProcessing sample rate, similarly to how it |
| 522 // is done on the send side. Downmix to mono. |
| 523 AudioFrame frame; |
| 524 frame.num_channels_ = 1; |
| 525 frame.sample_rate_hz_ = _audioProcessingModulePtr->input_sample_rate_hz(); |
| 526 RemixAndResample(_audioFrame, &audioproc_resampler_, &frame); |
| 527 |
| 528 if (_audioProcessingModulePtr->AnalyzeReverseStream(&frame) != 0) { |
| 529 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, -1), |
| 530 "AudioProcessingModule::AnalyzeReverseStream() => error"); |
| 531 RTC_DCHECK(false); |
| 532 } |
| 533 } |
| 522 | 534 |
| 523 // --- External media processing | 535 // --- External media processing |
| 524 { | 536 { |
| 525 CriticalSectionScoped cs(&_callbackCritSect); | 537 CriticalSectionScoped cs(&_callbackCritSect); |
| 526 if (_externalMedia) | 538 if (_externalMedia) |
| 527 { | 539 { |
| 528 const bool is_stereo = (_audioFrame.num_channels_ == 2); | 540 const bool is_stereo = (_audioFrame.num_channels_ == 2); |
| 529 if (_externalMediaCallbackPtr) | 541 if (_externalMediaCallbackPtr) |
| 530 { | 542 { |
| 531 _externalMediaCallbackPtr->Process( | 543 _externalMediaCallbackPtr->Process( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 542 // --- Measure audio level (0-9) for the combined signal | 554 // --- Measure audio level (0-9) for the combined signal |
| 543 _audioLevel.ComputeLevel(_audioFrame); | 555 _audioLevel.ComputeLevel(_audioFrame); |
| 544 | 556 |
| 545 return 0; | 557 return 0; |
| 546 } | 558 } |
| 547 | 559 |
| 548 // ---------------------------------------------------------------------------- | 560 // ---------------------------------------------------------------------------- |
| 549 // Private methods | 561 // Private methods |
| 550 // ---------------------------------------------------------------------------- | 562 // ---------------------------------------------------------------------------- |
| 551 | 563 |
| 552 void OutputMixer::APMProcessReverseStream() { | |
| 553 if (_audioProcessingModulePtr->ProcessReverseStream(&_audioFrame) != 0) { | |
| 554 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, -1), | |
| 555 "AudioProcessingModule::ProcessReverseStream() => error"); | |
| 556 } | |
| 557 } | |
| 558 | |
| 559 int | 564 int |
| 560 OutputMixer::InsertInbandDtmfTone() | 565 OutputMixer::InsertInbandDtmfTone() |
| 561 { | 566 { |
| 562 uint16_t sampleRate(0); | 567 uint16_t sampleRate(0); |
| 563 _dtmfGenerator.GetSampleRate(sampleRate); | 568 _dtmfGenerator.GetSampleRate(sampleRate); |
| 564 if (sampleRate != _audioFrame.sample_rate_hz_) | 569 if (sampleRate != _audioFrame.sample_rate_hz_) |
| 565 { | 570 { |
| 566 // Update sample rate of Dtmf tone since the mixing frequency changed. | 571 // Update sample rate of Dtmf tone since the mixing frequency changed. |
| 567 _dtmfGenerator.SetSampleRate( | 572 _dtmfGenerator.SetSampleRate( |
| 568 (uint16_t)(_audioFrame.sample_rate_hz_)); | 573 (uint16_t)(_audioFrame.sample_rate_hz_)); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 595 _audioFrame.data_[2 * i + 1] = 0; | 600 _audioFrame.data_[2 * i + 1] = 0; |
| 596 } | 601 } |
| 597 } | 602 } |
| 598 assert(_audioFrame.samples_per_channel_ == toneSamples); | 603 assert(_audioFrame.samples_per_channel_ == toneSamples); |
| 599 | 604 |
| 600 return 0; | 605 return 0; |
| 601 } | 606 } |
| 602 | 607 |
| 603 } // namespace voe | 608 } // namespace voe |
| 604 } // namespace webrtc | 609 } // namespace webrtc |
| OLD | NEW |