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" |
16 #include "webrtc/modules/audio_processing/test/protobuf_utils.h" | 18 #include "webrtc/modules/audio_processing/test/protobuf_utils.h" |
17 #include "webrtc/test/testsupport/trace_to_stderr.h" | 19 #include "webrtc/test/testsupport/trace_to_stderr.h" |
18 | 20 |
19 namespace webrtc { | 21 namespace webrtc { |
20 namespace test { | 22 namespace test { |
21 namespace { | 23 namespace { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 | 64 |
63 } // namespace | 65 } // namespace |
64 | 66 |
65 AecDumpBasedSimulator::AecDumpBasedSimulator(const SimulationSettings& settings) | 67 AecDumpBasedSimulator::AecDumpBasedSimulator(const SimulationSettings& settings) |
66 : AudioProcessingSimulator(settings) {} | 68 : AudioProcessingSimulator(settings) {} |
67 | 69 |
68 AecDumpBasedSimulator::~AecDumpBasedSimulator() = default; | 70 AecDumpBasedSimulator::~AecDumpBasedSimulator() = default; |
69 | 71 |
70 void AecDumpBasedSimulator::PrepareProcessStreamCall( | 72 void AecDumpBasedSimulator::PrepareProcessStreamCall( |
71 const webrtc::audioproc::Stream& msg, | 73 const webrtc::audioproc::Stream& msg, |
72 bool* set_stream_analog_level_called) { | 74 bool* update_analog_level) { |
73 if (msg.has_input_data()) { | 75 if (msg.has_input_data()) { |
74 // Fixed interface processing. | 76 // Fixed interface processing. |
75 // Verify interface invariance. | 77 // Verify interface invariance. |
76 RTC_CHECK(interface_used_ == InterfaceType::kFixedInterface || | 78 RTC_CHECK(interface_used_ == InterfaceType::kFixedInterface || |
77 interface_used_ == InterfaceType::kNotSpecified); | 79 interface_used_ == InterfaceType::kNotSpecified); |
78 interface_used_ = InterfaceType::kFixedInterface; | 80 interface_used_ = InterfaceType::kFixedInterface; |
79 | 81 |
80 // Populate input buffer. | 82 // Populate input buffer. |
81 RTC_CHECK_EQ(sizeof(fwd_frame_.data_[0]) * fwd_frame_.samples_per_channel_ * | 83 RTC_CHECK_EQ(sizeof(fwd_frame_.data_[0]) * fwd_frame_.samples_per_channel_ * |
82 fwd_frame_.num_channels_, | 84 fwd_frame_.num_channels_, |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 if (!settings_.use_ts) { | 153 if (!settings_.use_ts) { |
152 if (msg.has_keypress()) { | 154 if (msg.has_keypress()) { |
153 ap_->set_stream_key_pressed(msg.keypress()); | 155 ap_->set_stream_key_pressed(msg.keypress()); |
154 } | 156 } |
155 } else { | 157 } else { |
156 ap_->set_stream_key_pressed(*settings_.use_ts); | 158 ap_->set_stream_key_pressed(*settings_.use_ts); |
157 } | 159 } |
158 | 160 |
159 // TODO(peah): Add support for controlling the analog level via the | 161 // TODO(peah): Add support for controlling the analog level via the |
160 // command-line. | 162 // command-line. |
161 if (msg.has_level()) { | 163 // If the AECdump does not include a level, AGC was disabled during the call. |
peah-webrtc
2017/04/26 12:54:44
No, I don't think it works like this. msg.has_leve
aleloi
2017/05/04 12:47:13
I just checked, msg->set_level(gain_control()->str
| |
162 RTC_CHECK_EQ(AudioProcessing::kNoError, | 164 // If so and if the analog gain simulation is disabled, inform |
163 ap_->gain_control()->set_stream_analog_level(msg.level())); | 165 // AudioProcessingSimulator::ProcessStream in order not to call |
164 *set_stream_analog_level_called = true; | 166 // GainControl::set_stream_analog_level() and |
165 } else { | 167 // GainControl::stream_analog_level() before and after |
166 *set_stream_analog_level_called = false; | 168 // AudioProcessing::ProcessStream respectively. |
169 *update_analog_level = msg.has_level() || settings_.simulate_mic_gain; | |
170 if (!settings_.simulate_mic_gain && msg.has_level()) { | |
171 // The analog gain simulation is off, use the level stored in the AECdump. | |
172 last_specified_microphone_level_ = msg.level(); | |
peah-webrtc
2017/04/26 12:54:44
I think this CL would be easier to review with an
peah-webrtc
2017/04/26 12:54:44
I think the name last_specified_microphone_level_
aleloi
2017/05/04 12:47:13
Acknowledged.
| |
167 } | 173 } |
168 } | 174 } |
169 | 175 |
170 void AecDumpBasedSimulator::VerifyProcessStreamBitExactness( | 176 void AecDumpBasedSimulator::VerifyProcessStreamBitExactness( |
171 const webrtc::audioproc::Stream& msg) { | 177 const webrtc::audioproc::Stream& msg) { |
172 if (bitexact_output_) { | 178 if (bitexact_output_) { |
173 if (interface_used_ == InterfaceType::kFixedInterface) { | 179 if (interface_used_ == InterfaceType::kFixedInterface) { |
174 bitexact_output_ = VerifyFixedBitExactness(msg, fwd_frame_); | 180 bitexact_output_ = VerifyFixedBitExactness(msg, fwd_frame_); |
175 } else { | 181 } else { |
176 bitexact_output_ = VerifyFloatBitExactness(msg, out_config_, *out_buf_); | 182 bitexact_output_ = VerifyFloatBitExactness(msg, out_config_, *out_buf_); |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
555 } | 561 } |
556 | 562 |
557 SetupBuffersConfigsOutputs( | 563 SetupBuffersConfigsOutputs( |
558 msg.sample_rate(), output_sample_rate, msg.reverse_sample_rate(), | 564 msg.sample_rate(), output_sample_rate, msg.reverse_sample_rate(), |
559 reverse_output_sample_rate, msg.num_input_channels(), num_output_channels, | 565 reverse_output_sample_rate, msg.num_input_channels(), num_output_channels, |
560 msg.num_reverse_channels(), num_reverse_output_channels); | 566 msg.num_reverse_channels(), num_reverse_output_channels); |
561 } | 567 } |
562 | 568 |
563 void AecDumpBasedSimulator::HandleMessage( | 569 void AecDumpBasedSimulator::HandleMessage( |
564 const webrtc::audioproc::Stream& msg) { | 570 const webrtc::audioproc::Stream& msg) { |
565 bool set_stream_analog_level_called = false; | 571 bool update_analog_level = true; |
566 PrepareProcessStreamCall(msg, &set_stream_analog_level_called); | 572 PrepareProcessStreamCall(msg, &update_analog_level); |
aleloi
2017/05/04 12:47:13
I think update_analog_level should be renamed in t
| |
567 ProcessStream(interface_used_ == InterfaceType::kFixedInterface); | 573 ProcessStream(interface_used_ == InterfaceType::kFixedInterface, |
568 if (set_stream_analog_level_called) { | 574 update_analog_level); |
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); | 575 VerifyProcessStreamBitExactness(msg); |
574 } | 576 } |
575 | 577 |
576 void AecDumpBasedSimulator::HandleMessage( | 578 void AecDumpBasedSimulator::HandleMessage( |
577 const webrtc::audioproc::ReverseStream& msg) { | 579 const webrtc::audioproc::ReverseStream& msg) { |
578 PrepareReverseProcessStreamCall(msg); | 580 PrepareReverseProcessStreamCall(msg); |
579 ProcessReverseStream(interface_used_ == InterfaceType::kFixedInterface); | 581 ProcessReverseStream(interface_used_ == InterfaceType::kFixedInterface); |
580 } | 582 } |
581 | 583 |
582 } // namespace test | 584 } // namespace test |
583 } // namespace webrtc | 585 } // namespace webrtc |
OLD | NEW |