| 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 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TEST_AUDIO_PROCESSING_SIMULATOR_H_ |   11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TEST_AUDIO_PROCESSING_SIMULATOR_H_ | 
|   12 #define WEBRTC_MODULES_AUDIO_PROCESSING_TEST_AUDIO_PROCESSING_SIMULATOR_H_ |   12 #define WEBRTC_MODULES_AUDIO_PROCESSING_TEST_AUDIO_PROCESSING_SIMULATOR_H_ | 
|   13  |   13  | 
|   14 #include <algorithm> |   14 #include <algorithm> | 
|   15 #include <fstream> |   15 #include <fstream> | 
|   16 #include <limits> |   16 #include <limits> | 
|   17 #include <memory> |   17 #include <memory> | 
|   18 #include <string> |   18 #include <string> | 
|   19  |   19  | 
|   20 #include "webrtc/base/timeutils.h" |   20 #include "webrtc/base/timeutils.h" | 
|   21 #include "webrtc/base/constructormagic.h" |   21 #include "webrtc/base/constructormagic.h" | 
|   22 #include "webrtc/base/optional.h" |   22 #include "webrtc/base/optional.h" | 
|   23 #include "webrtc/common_audio/channel_buffer.h" |   23 #include "webrtc/common_audio/channel_buffer.h" | 
|   24 #include "webrtc/modules/audio_processing/include/audio_processing.h" |   24 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 
|   25 #include "webrtc/modules/audio_processing/test/test_utils.h" |   25 #include "webrtc/modules/audio_processing/test/test_utils.h" | 
|   26  |   26  | 
|   27 namespace webrtc { |   27 namespace webrtc { | 
|   28 namespace test { |   28 namespace test { | 
|   29  |   29  | 
 |   30 // TODO(alessiob): Check what initial value makes sense, 100 was used in | 
 |   31 // WavBasedSimulator::last_specified_microphone_level_. | 
 |   32 constexpr int kInitialMicrophoneGainLevel = 100; | 
 |   33  | 
|   30 // Holds all the parameters available for controlling the simulation. |   34 // Holds all the parameters available for controlling the simulation. | 
|   31 struct SimulationSettings { |   35 struct SimulationSettings { | 
|   32   SimulationSettings(); |   36   SimulationSettings(); | 
|   33   SimulationSettings(const SimulationSettings&); |   37   SimulationSettings(const SimulationSettings&); | 
|   34   ~SimulationSettings(); |   38   ~SimulationSettings(); | 
|   35   rtc::Optional<int> stream_delay; |   39   rtc::Optional<int> stream_delay; | 
|   36   rtc::Optional<int> stream_drift_samples; |   40   rtc::Optional<int> stream_drift_samples; | 
|   37   rtc::Optional<int> output_sample_rate_hz; |   41   rtc::Optional<int> output_sample_rate_hz; | 
|   38   rtc::Optional<int> output_num_channels; |   42   rtc::Optional<int> output_num_channels; | 
|   39   rtc::Optional<int> reverse_output_sample_rate_hz; |   43   rtc::Optional<int> reverse_output_sample_rate_hz; | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
|   67   rtc::Optional<bool> use_experimental_agc; |   71   rtc::Optional<bool> use_experimental_agc; | 
|   68   rtc::Optional<int> aecm_routing_mode; |   72   rtc::Optional<int> aecm_routing_mode; | 
|   69   rtc::Optional<bool> use_aecm_comfort_noise; |   73   rtc::Optional<bool> use_aecm_comfort_noise; | 
|   70   rtc::Optional<int> agc_mode; |   74   rtc::Optional<int> agc_mode; | 
|   71   rtc::Optional<int> agc_target_level; |   75   rtc::Optional<int> agc_target_level; | 
|   72   rtc::Optional<bool> use_agc_limiter; |   76   rtc::Optional<bool> use_agc_limiter; | 
|   73   rtc::Optional<int> agc_compression_gain; |   77   rtc::Optional<int> agc_compression_gain; | 
|   74   rtc::Optional<int> vad_likelihood; |   78   rtc::Optional<int> vad_likelihood; | 
|   75   rtc::Optional<int> ns_level; |   79   rtc::Optional<int> ns_level; | 
|   76   rtc::Optional<bool> use_refined_adaptive_filter; |   80   rtc::Optional<bool> use_refined_adaptive_filter; | 
 |   81   bool simulate_mic_gain = false; | 
|   77   bool report_performance = false; |   82   bool report_performance = false; | 
|   78   bool report_bitexactness = false; |   83   bool report_bitexactness = false; | 
|   79   bool use_verbose_logging = false; |   84   bool use_verbose_logging = false; | 
|   80   bool discard_all_settings_in_aecdump = true; |   85   bool discard_all_settings_in_aecdump = true; | 
|   81   rtc::Optional<std::string> aec_dump_input_filename; |   86   rtc::Optional<std::string> aec_dump_input_filename; | 
|   82   rtc::Optional<std::string> aec_dump_output_filename; |   87   rtc::Optional<std::string> aec_dump_output_filename; | 
|   83   bool fixed_interface = false; |   88   bool fixed_interface = false; | 
|   84   bool store_intermediate_output = false; |   89   bool store_intermediate_output = false; | 
|   85   rtc::Optional<std::string> custom_call_order_filename; |   90   rtc::Optional<std::string> custom_call_order_filename; | 
|   86 }; |   91 }; | 
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  128         : proc_time_(proc_time), start_time_(rtc::TimeNanos()) {} |  133         : proc_time_(proc_time), start_time_(rtc::TimeNanos()) {} | 
|  129  |  134  | 
|  130     ~ScopedTimer(); |  135     ~ScopedTimer(); | 
|  131  |  136  | 
|  132    private: |  137    private: | 
|  133     TickIntervalStats* const proc_time_; |  138     TickIntervalStats* const proc_time_; | 
|  134     int64_t start_time_; |  139     int64_t start_time_; | 
|  135   }; |  140   }; | 
|  136  |  141  | 
|  137   TickIntervalStats* mutable_proc_time() { return &proc_time_; } |  142   TickIntervalStats* mutable_proc_time() { return &proc_time_; } | 
|  138   void ProcessStream(bool fixed_interface); |  143   void ProcessStream(bool fixed_interface, | 
 |  144                      bool update_analog_level = true); | 
|  139   void ProcessReverseStream(bool fixed_interface); |  145   void ProcessReverseStream(bool fixed_interface); | 
|  140   void CreateAudioProcessor(); |  146   void CreateAudioProcessor(); | 
|  141   void DestroyAudioProcessor(); |  147   void DestroyAudioProcessor(); | 
|  142   void SetupBuffersConfigsOutputs(int input_sample_rate_hz, |  148   void SetupBuffersConfigsOutputs(int input_sample_rate_hz, | 
|  143                                   int output_sample_rate_hz, |  149                                   int output_sample_rate_hz, | 
|  144                                   int reverse_input_sample_rate_hz, |  150                                   int reverse_input_sample_rate_hz, | 
|  145                                   int reverse_output_sample_rate_hz, |  151                                   int reverse_output_sample_rate_hz, | 
|  146                                   int input_num_channels, |  152                                   int input_num_channels, | 
|  147                                   int output_num_channels, |  153                                   int output_num_channels, | 
|  148                                   int reverse_input_num_channels, |  154                                   int reverse_input_num_channels, | 
|  149                                   int reverse_output_num_channels); |  155                                   int reverse_output_num_channels); | 
|  150  |  156  | 
|  151   const SimulationSettings settings_; |  157   const SimulationSettings settings_; | 
|  152   std::unique_ptr<AudioProcessing> ap_; |  158   std::unique_ptr<AudioProcessing> ap_; | 
|  153  |  159  | 
|  154   std::unique_ptr<ChannelBuffer<float>> in_buf_; |  160   std::unique_ptr<ChannelBuffer<float>> in_buf_; | 
|  155   std::unique_ptr<ChannelBuffer<float>> out_buf_; |  161   std::unique_ptr<ChannelBuffer<float>> out_buf_; | 
|  156   std::unique_ptr<ChannelBuffer<float>> reverse_in_buf_; |  162   std::unique_ptr<ChannelBuffer<float>> reverse_in_buf_; | 
|  157   std::unique_ptr<ChannelBuffer<float>> reverse_out_buf_; |  163   std::unique_ptr<ChannelBuffer<float>> reverse_out_buf_; | 
|  158   StreamConfig in_config_; |  164   StreamConfig in_config_; | 
|  159   StreamConfig out_config_; |  165   StreamConfig out_config_; | 
|  160   StreamConfig reverse_in_config_; |  166   StreamConfig reverse_in_config_; | 
|  161   StreamConfig reverse_out_config_; |  167   StreamConfig reverse_out_config_; | 
|  162   std::unique_ptr<ChannelBufferWavReader> buffer_reader_; |  168   std::unique_ptr<ChannelBufferWavReader> buffer_reader_; | 
|  163   std::unique_ptr<ChannelBufferWavReader> reverse_buffer_reader_; |  169   std::unique_ptr<ChannelBufferWavReader> reverse_buffer_reader_; | 
|  164   AudioFrame rev_frame_; |  170   AudioFrame rev_frame_; | 
|  165   AudioFrame fwd_frame_; |  171   AudioFrame fwd_frame_; | 
|  166   bool bitexact_output_ = true; |  172   bool bitexact_output_ = true; | 
 |  173   int last_specified_microphone_level_ = kInitialMicrophoneGainLevel; | 
|  167  |  174  | 
|  168  private: |  175  private: | 
|  169   void SetupOutput(); |  176   void SetupOutput(); | 
|  170  |  177  | 
|  171   size_t num_process_stream_calls_ = 0; |  178   size_t num_process_stream_calls_ = 0; | 
|  172   size_t num_reverse_process_stream_calls_ = 0; |  179   size_t num_reverse_process_stream_calls_ = 0; | 
|  173   size_t output_reset_counter_ = 0; |  180   size_t output_reset_counter_ = 0; | 
|  174   std::unique_ptr<ChannelBufferWavWriter> buffer_writer_; |  181   std::unique_ptr<ChannelBufferWavWriter> buffer_writer_; | 
|  175   std::unique_ptr<ChannelBufferWavWriter> reverse_buffer_writer_; |  182   std::unique_ptr<ChannelBufferWavWriter> reverse_buffer_writer_; | 
|  176   TickIntervalStats proc_time_; |  183   TickIntervalStats proc_time_; | 
|  177   std::ofstream residual_echo_likelihood_graph_writer_; |  184   std::ofstream residual_echo_likelihood_graph_writer_; | 
|  178  |  185  | 
|  179   RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(AudioProcessingSimulator); |  186   RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(AudioProcessingSimulator); | 
|  180 }; |  187 }; | 
|  181  |  188  | 
|  182 }  // namespace test |  189 }  // namespace test | 
|  183 }  // namespace webrtc |  190 }  // namespace webrtc | 
|  184  |  191  | 
|  185 #endif  // WEBRTC_MODULES_AUDIO_PROCESSING_TEST_AUDIO_PROCESSING_SIMULATOR_H_ |  192 #endif  // WEBRTC_MODULES_AUDIO_PROCESSING_TEST_AUDIO_PROCESSING_SIMULATOR_H_ | 
| OLD | NEW |