OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 |
11 #include "webrtc/modules/audio_processing/test/audio_processing_simulator.h" | 11 #include "webrtc/modules/audio_processing/test/audio_processing_simulator.h" |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
14 #include <iostream> | 14 #include <iostream> |
15 #include <sstream> | 15 #include <sstream> |
16 #include <string> | 16 #include <string> |
17 #include <utility> | |
17 #include <vector> | 18 #include <vector> |
18 | 19 |
19 #include "webrtc/base/checks.h" | 20 #include "webrtc/base/checks.h" |
20 #include "webrtc/base/stringutils.h" | 21 #include "webrtc/base/stringutils.h" |
21 #include "webrtc/common_audio/include/audio_util.h" | 22 #include "webrtc/common_audio/include/audio_util.h" |
22 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 23 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
23 | 24 |
24 namespace webrtc { | 25 namespace webrtc { |
25 namespace test { | 26 namespace test { |
26 namespace { | 27 namespace { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 } | 96 } |
96 } | 97 } |
97 | 98 |
98 AudioProcessingSimulator::ScopedTimer::~ScopedTimer() { | 99 AudioProcessingSimulator::ScopedTimer::~ScopedTimer() { |
99 int64_t interval = rtc::TimeNanos() - start_time_; | 100 int64_t interval = rtc::TimeNanos() - start_time_; |
100 proc_time_->sum += interval; | 101 proc_time_->sum += interval; |
101 proc_time_->max = std::max(proc_time_->max, interval); | 102 proc_time_->max = std::max(proc_time_->max, interval); |
102 proc_time_->min = std::min(proc_time_->min, interval); | 103 proc_time_->min = std::min(proc_time_->min, interval); |
103 } | 104 } |
104 | 105 |
105 void AudioProcessingSimulator::ProcessStream(bool fixed_interface) { | 106 void AudioProcessingSimulator::ProcessStream(bool fixed_interface, |
107 bool update_analog_level) { | |
peah-webrtc
2017/04/26 12:54:44
I think the naming of the update_analog_level coul
| |
108 if (update_analog_level) { | |
109 RTC_CHECK_EQ(AudioProcessing::kNoError, | |
110 ap_->gain_control()->set_stream_analog_level( | |
111 last_specified_microphone_level_)); | |
112 } | |
106 if (fixed_interface) { | 113 if (fixed_interface) { |
107 { | 114 { |
108 const auto st = ScopedTimer(mutable_proc_time()); | 115 const auto st = ScopedTimer(mutable_proc_time()); |
116 // TODO(alessiob): Apply last_specified_microphone_level_ to fwd_frame_ | |
peah-webrtc
2017/04/26 12:54:44
I think the approach to apply the microphone level
| |
117 // simulating a mic with analog gain. | |
109 RTC_CHECK_EQ(AudioProcessing::kNoError, ap_->ProcessStream(&fwd_frame_)); | 118 RTC_CHECK_EQ(AudioProcessing::kNoError, ap_->ProcessStream(&fwd_frame_)); |
110 } | 119 } |
111 CopyFromAudioFrame(fwd_frame_, out_buf_.get()); | 120 CopyFromAudioFrame(fwd_frame_, out_buf_.get()); |
112 } else { | 121 } else { |
113 const auto st = ScopedTimer(mutable_proc_time()); | 122 const auto st = ScopedTimer(mutable_proc_time()); |
123 // TODO(alessiob): Apply last_specified_microphone_level_ to | |
124 // in_buf_->channels() simulating a mic with analog gain. | |
114 RTC_CHECK_EQ(AudioProcessing::kNoError, | 125 RTC_CHECK_EQ(AudioProcessing::kNoError, |
115 ap_->ProcessStream(in_buf_->channels(), in_config_, | 126 ap_->ProcessStream(in_buf_->channels(), in_config_, |
116 out_config_, out_buf_->channels())); | 127 out_config_, out_buf_->channels())); |
117 } | 128 } |
129 // Update last_specified_microphone_level_ using the value suggested by AGC | |
peah-webrtc
2017/04/26 12:54:44
the AGC
| |
130 // or the default if settings_.simulate_mic_gain is false. | |
131 if (update_analog_level) { | |
132 last_specified_microphone_level_ = settings_.simulate_mic_gain ? | |
hlundin-webrtc
2017/04/26 12:11:37
This is confusing. If update_analog_level is true,
peah-webrtc
2017/04/26 12:54:44
This is not correct. If you don't simulate the mic
| |
133 ap_->gain_control()->stream_analog_level() | |
134 : kInitialMicrophoneGainLevel; | |
135 } | |
118 | 136 |
119 if (buffer_writer_) { | 137 if (buffer_writer_) { |
120 buffer_writer_->Write(*out_buf_); | 138 buffer_writer_->Write(*out_buf_); |
121 } | 139 } |
122 | 140 |
123 if (residual_echo_likelihood_graph_writer_.is_open()) { | 141 if (residual_echo_likelihood_graph_writer_.is_open()) { |
124 auto stats = ap_->GetStatistics(); | 142 auto stats = ap_->GetStatistics(); |
125 residual_echo_likelihood_graph_writer_ << stats.residual_echo_likelihood | 143 residual_echo_likelihood_graph_writer_ << stats.residual_echo_likelihood |
126 << ", "; | 144 << ", "; |
127 } | 145 } |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
388 size_t kMaxFilenameSize = AudioProcessing::kMaxFilenameSize; | 406 size_t kMaxFilenameSize = AudioProcessing::kMaxFilenameSize; |
389 RTC_CHECK_LE(settings_.aec_dump_output_filename->size(), kMaxFilenameSize); | 407 RTC_CHECK_LE(settings_.aec_dump_output_filename->size(), kMaxFilenameSize); |
390 RTC_CHECK_EQ(AudioProcessing::kNoError, | 408 RTC_CHECK_EQ(AudioProcessing::kNoError, |
391 ap_->StartDebugRecording( | 409 ap_->StartDebugRecording( |
392 settings_.aec_dump_output_filename->c_str(), -1)); | 410 settings_.aec_dump_output_filename->c_str(), -1)); |
393 } | 411 } |
394 } | 412 } |
395 | 413 |
396 } // namespace test | 414 } // namespace test |
397 } // namespace webrtc | 415 } // namespace webrtc |
OLD | NEW |