Chromium Code Reviews| 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 <algorithm> | |
| 11 #include <iostream> | 12 #include <iostream> |
| 13 #include <utility> | |
| 12 | 14 |
| 13 #include "webrtc/modules/audio_processing/test/aec_dump_based_simulator.h" | 15 #include "webrtc/modules/audio_processing/test/aec_dump_based_simulator.h" |
| 14 | 16 |
| 15 #include "webrtc/base/checks.h" | 17 #include "webrtc/base/checks.h" |
| 18 #include "webrtc/base/logging.h" | |
| 16 #include "webrtc/modules/audio_processing/test/protobuf_utils.h" | 19 #include "webrtc/modules/audio_processing/test/protobuf_utils.h" |
| 17 #include "webrtc/test/testsupport/trace_to_stderr.h" | 20 #include "webrtc/test/testsupport/trace_to_stderr.h" |
| 18 | 21 |
| 19 namespace webrtc { | 22 namespace webrtc { |
| 20 namespace test { | 23 namespace test { |
| 21 namespace { | 24 namespace { |
| 22 | 25 |
| 23 // Verify output bitexactness for the fixed interface. | 26 // Verify output bitexactness for the fixed interface. |
| 24 // TODO(peah): Check whether it would make sense to add a threshold | 27 // TODO(peah): Check whether it would make sense to add a threshold |
| 25 // to use for checking the bitexactness in a soft manner. | 28 // to use for checking the bitexactness in a soft manner. |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 56 } | 59 } |
| 57 } | 60 } |
| 58 } | 61 } |
| 59 } | 62 } |
| 60 return true; | 63 return true; |
| 61 } | 64 } |
| 62 | 65 |
| 63 } // namespace | 66 } // namespace |
| 64 | 67 |
| 65 AecDumpBasedSimulator::AecDumpBasedSimulator(const SimulationSettings& settings) | 68 AecDumpBasedSimulator::AecDumpBasedSimulator(const SimulationSettings& settings) |
| 66 : AudioProcessingSimulator(settings) {} | 69 : AudioProcessingSimulator(settings) { |
| 70 if (settings_.simulate_mic_gain) { | |
| 71 LOG(LS_VERBOSE) << "Setting mic gain undo level from AEC dump"; | |
|
peah-webrtc
2017/05/05 20:25:21
I think that the log line is a bit unclear.
What
AleBzk
2017/05/16 08:53:02
I see your point, it comes out of the blue as it i
| |
| 72 } | |
| 73 } | |
| 67 | 74 |
| 68 AecDumpBasedSimulator::~AecDumpBasedSimulator() = default; | 75 AecDumpBasedSimulator::~AecDumpBasedSimulator() = default; |
| 69 | 76 |
| 70 void AecDumpBasedSimulator::PrepareProcessStreamCall( | 77 void AecDumpBasedSimulator::PrepareProcessStreamCall( |
| 71 const webrtc::audioproc::Stream& msg, | 78 const webrtc::audioproc::Stream& msg) { |
| 72 bool* set_stream_analog_level_called) { | |
| 73 if (msg.has_input_data()) { | 79 if (msg.has_input_data()) { |
| 74 // Fixed interface processing. | 80 // Fixed interface processing. |
| 75 // Verify interface invariance. | 81 // Verify interface invariance. |
| 76 RTC_CHECK(interface_used_ == InterfaceType::kFixedInterface || | 82 RTC_CHECK(interface_used_ == InterfaceType::kFixedInterface || |
| 77 interface_used_ == InterfaceType::kNotSpecified); | 83 interface_used_ == InterfaceType::kNotSpecified); |
| 78 interface_used_ = InterfaceType::kFixedInterface; | 84 interface_used_ = InterfaceType::kFixedInterface; |
| 79 | 85 |
| 80 // Populate input buffer. | 86 // Populate input buffer. |
| 81 RTC_CHECK_EQ(sizeof(fwd_frame_.data_[0]) * fwd_frame_.samples_per_channel_ * | 87 RTC_CHECK_EQ(sizeof(fwd_frame_.data_[0]) * fwd_frame_.samples_per_channel_ * |
| 82 fwd_frame_.num_channels_, | 88 fwd_frame_.num_channels_, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 } | 155 } |
| 150 | 156 |
| 151 if (!settings_.use_ts) { | 157 if (!settings_.use_ts) { |
| 152 if (msg.has_keypress()) { | 158 if (msg.has_keypress()) { |
| 153 ap_->set_stream_key_pressed(msg.keypress()); | 159 ap_->set_stream_key_pressed(msg.keypress()); |
| 154 } | 160 } |
| 155 } else { | 161 } else { |
| 156 ap_->set_stream_key_pressed(*settings_.use_ts); | 162 ap_->set_stream_key_pressed(*settings_.use_ts); |
| 157 } | 163 } |
| 158 | 164 |
| 159 // TODO(peah): Add support for controlling the analog level via the | 165 // Level is always logged in AEC dumps. |
| 160 // command-line. | 166 RTC_CHECK(msg.has_level()); |
| 161 if (msg.has_level()) { | 167 |
| 162 RTC_CHECK_EQ(AudioProcessing::kNoError, | 168 if (settings_.simulate_mic_gain) { |
| 163 ap_->gain_control()->set_stream_analog_level(msg.level())); | 169 // When the analog gain is simulated, set the undo level to |msg.level()| to |
| 164 *set_stream_analog_level_called = true; | 170 // virtually restore the unmodified microphone signal level. |
| 171 real_recording_device_level_ = msg.level(); | |
| 165 } else { | 172 } else { |
| 166 *set_stream_analog_level_called = false; | 173 // When the analog gain is not simulated, the AEC dump level has to be used |
| 174 // in AudioProcessingSimulator::ProcessStream(). | |
| 175 if (last_specified_microphone_level_ != msg.level()) { | |
| 176 LOG(LS_VERBOSE) << "AEC dump overriding AGC suggested level to " | |
|
peah-webrtc
2017/05/05 20:25:21
(last_specified_microphone_level_ != msg.level())
AleBzk
2017/05/16 08:53:03
At that point of code, there's no simulation of th
| |
| 177 << msg.level(); | |
| 178 } | |
| 179 last_specified_microphone_level_ = msg.level(); | |
| 167 } | 180 } |
| 168 } | 181 } |
| 169 | 182 |
| 170 void AecDumpBasedSimulator::VerifyProcessStreamBitExactness( | 183 void AecDumpBasedSimulator::VerifyProcessStreamBitExactness( |
| 171 const webrtc::audioproc::Stream& msg) { | 184 const webrtc::audioproc::Stream& msg) { |
| 172 if (bitexact_output_) { | 185 if (bitexact_output_) { |
| 173 if (interface_used_ == InterfaceType::kFixedInterface) { | 186 if (interface_used_ == InterfaceType::kFixedInterface) { |
| 174 bitexact_output_ = VerifyFixedBitExactness(msg, fwd_frame_); | 187 bitexact_output_ = VerifyFixedBitExactness(msg, fwd_frame_); |
| 175 } else { | 188 } else { |
| 176 bitexact_output_ = VerifyFloatBitExactness(msg, out_config_, *out_buf_); | 189 bitexact_output_ = VerifyFloatBitExactness(msg, out_config_, *out_buf_); |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 555 } | 568 } |
| 556 | 569 |
| 557 SetupBuffersConfigsOutputs( | 570 SetupBuffersConfigsOutputs( |
| 558 msg.sample_rate(), output_sample_rate, msg.reverse_sample_rate(), | 571 msg.sample_rate(), output_sample_rate, msg.reverse_sample_rate(), |
| 559 reverse_output_sample_rate, msg.num_input_channels(), num_output_channels, | 572 reverse_output_sample_rate, msg.num_input_channels(), num_output_channels, |
| 560 msg.num_reverse_channels(), num_reverse_output_channels); | 573 msg.num_reverse_channels(), num_reverse_output_channels); |
| 561 } | 574 } |
| 562 | 575 |
| 563 void AecDumpBasedSimulator::HandleMessage( | 576 void AecDumpBasedSimulator::HandleMessage( |
| 564 const webrtc::audioproc::Stream& msg) { | 577 const webrtc::audioproc::Stream& msg) { |
| 565 bool set_stream_analog_level_called = false; | 578 PrepareProcessStreamCall(msg); |
| 566 PrepareProcessStreamCall(msg, &set_stream_analog_level_called); | |
| 567 ProcessStream(interface_used_ == InterfaceType::kFixedInterface); | 579 ProcessStream(interface_used_ == InterfaceType::kFixedInterface); |
| 568 if (set_stream_analog_level_called) { | |
| 569 // Call stream analog level to ensure that any side-effects are triggered. | |
| 570 (void)ap_->gain_control()->stream_analog_level(); | |
| 571 } | |
| 572 | |
| 573 VerifyProcessStreamBitExactness(msg); | 580 VerifyProcessStreamBitExactness(msg); |
| 574 } | 581 } |
| 575 | 582 |
| 576 void AecDumpBasedSimulator::HandleMessage( | 583 void AecDumpBasedSimulator::HandleMessage( |
| 577 const webrtc::audioproc::ReverseStream& msg) { | 584 const webrtc::audioproc::ReverseStream& msg) { |
| 578 PrepareReverseProcessStreamCall(msg); | 585 PrepareReverseProcessStreamCall(msg); |
| 579 ProcessReverseStream(interface_used_ == InterfaceType::kFixedInterface); | 586 ProcessReverseStream(interface_used_ == InterfaceType::kFixedInterface); |
| 580 } | 587 } |
| 581 | 588 |
| 582 } // namespace test | 589 } // namespace test |
| 583 } // namespace webrtc | 590 } // namespace webrtc |
| OLD | NEW |