OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | |
3 * | |
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 | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #include "webrtc/modules/audio_processing/residual_echo_detector.h" | |
12 #include "webrtc/modules/audio_processing/audio_buffer.h" | |
13 #include "webrtc/modules/audio_processing/echo_detector/echo_detector.h" | |
14 | |
15 namespace webrtc { | |
16 | |
17 ResidualEchoDetector::ResidualEchoDetector() = default; | |
18 | |
19 ResidualEchoDetector::~ResidualEchoDetector() = default; | |
20 | |
21 int ResidualEchoDetector::AnalyzeRenderAudio(const AudioBuffer* audio) const { | |
hlundin-webrtc
2016/10/14 12:36:21
This is clearly not a const method. Remove const,
peah-webrtc
2016/10/14 13:34:48
I proposed this offline. The underlying idea is th
| |
22 RTC_DCHECK_GE(160u, audio->num_frames_per_band()); | |
23 | |
24 render_queue_buffer_.clear(); | |
25 | |
26 // Buffer the samples in the render queue. | |
27 render_queue_buffer_.insert(render_queue_buffer_.end(), | |
28 audio->split_bands_const_f(0)[kBand0To8kHz], | |
29 (audio->split_bands_const_f(0)[kBand0To8kHz] + | |
30 audio->num_frames_per_band())); | |
31 | |
32 // Insert the samples into the queue. | |
33 if (!render_signal_queue_->Insert(&render_queue_buffer_)) { | |
34 // The buffer is full. | |
35 return -1; | |
36 } | |
37 return 0; | |
38 } | |
39 | |
40 void ResidualEchoDetector::AnalyzeCaptureAudio(const AudioBuffer* audio) { | |
41 RTC_DCHECK_GE(160u, audio->num_frames_per_band()); | |
42 | |
43 detector_->Process( | |
44 rtc::ArrayView<const float>(audio->split_bands_const_f(0)[kBand0To8kHz], | |
45 audio->num_frames_per_band())); | |
46 } | |
47 | |
48 void ResidualEchoDetector::Initialize(int sample_rate_hz) { | |
49 RTC_DCHECK(sample_rate_hz == AudioProcessing::kSampleRate8kHz || | |
50 sample_rate_hz == AudioProcessing::kSampleRate16kHz || | |
51 sample_rate_hz == AudioProcessing::kSampleRate32kHz || | |
52 sample_rate_hz == AudioProcessing::kSampleRate48kHz); | |
53 | |
54 detector_->Initialize(sample_rate_hz); | |
55 } | |
56 | |
57 void ResidualEchoDetector::ReadQueuedRenderData() { | |
58 while (render_signal_queue_->Remove(&capture_queue_buffer_)) { | |
59 const size_t num_frames_per_band = capture_queue_buffer_.size(); | |
60 detector_->BufferFarend(rtc::ArrayView<const float>( | |
61 capture_queue_buffer_.data(), num_frames_per_band)); | |
62 } | |
63 } | |
64 | |
65 float ResidualEchoDetector::get_echo_likelihood() const { | |
66 return 0.0f; | |
67 } | |
68 | |
69 } // namespace webrtc | |
OLD | NEW |