Home | History | Annotate | Download | only in include
      1 /*
      2  *  Copyright (c) 2013 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 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_MOCK_AUDIO_PROCESSING_H_
     12 #define WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_MOCK_AUDIO_PROCESSING_H_
     13 
     14 #include "webrtc/modules/audio_processing/include/audio_processing.h"
     15 #include "webrtc/system_wrappers/interface/scoped_ptr.h"
     16 
     17 namespace webrtc {
     18 
     19 class MockEchoCancellation : public EchoCancellation {
     20  public:
     21   MOCK_METHOD1(Enable,
     22       int(bool enable));
     23   MOCK_CONST_METHOD0(is_enabled,
     24       bool());
     25   MOCK_METHOD1(enable_drift_compensation,
     26       int(bool enable));
     27   MOCK_CONST_METHOD0(is_drift_compensation_enabled,
     28       bool());
     29   MOCK_METHOD1(set_stream_drift_samples,
     30       void(int drift));
     31   MOCK_CONST_METHOD0(stream_drift_samples,
     32       int());
     33   MOCK_METHOD1(set_suppression_level,
     34       int(SuppressionLevel level));
     35   MOCK_CONST_METHOD0(suppression_level,
     36       SuppressionLevel());
     37   MOCK_CONST_METHOD0(stream_has_echo,
     38       bool());
     39   MOCK_METHOD1(enable_metrics,
     40       int(bool enable));
     41   MOCK_CONST_METHOD0(are_metrics_enabled,
     42       bool());
     43   MOCK_METHOD1(GetMetrics,
     44       int(Metrics* metrics));
     45   MOCK_METHOD1(enable_delay_logging,
     46       int(bool enable));
     47   MOCK_CONST_METHOD0(is_delay_logging_enabled,
     48       bool());
     49   MOCK_METHOD2(GetDelayMetrics,
     50       int(int* median, int* std));
     51   MOCK_CONST_METHOD0(aec_core,
     52       struct AecCore*());
     53 };
     54 
     55 class MockEchoControlMobile : public EchoControlMobile {
     56  public:
     57   MOCK_METHOD1(Enable,
     58       int(bool enable));
     59   MOCK_CONST_METHOD0(is_enabled,
     60       bool());
     61   MOCK_METHOD1(set_routing_mode,
     62       int(RoutingMode mode));
     63   MOCK_CONST_METHOD0(routing_mode,
     64       RoutingMode());
     65   MOCK_METHOD1(enable_comfort_noise,
     66       int(bool enable));
     67   MOCK_CONST_METHOD0(is_comfort_noise_enabled,
     68       bool());
     69   MOCK_METHOD2(SetEchoPath,
     70       int(const void* echo_path, size_t size_bytes));
     71   MOCK_CONST_METHOD2(GetEchoPath,
     72       int(void* echo_path, size_t size_bytes));
     73 };
     74 
     75 class MockGainControl : public GainControl {
     76  public:
     77   MOCK_METHOD1(Enable,
     78       int(bool enable));
     79   MOCK_CONST_METHOD0(is_enabled,
     80       bool());
     81   MOCK_METHOD1(set_stream_analog_level,
     82       int(int level));
     83   MOCK_METHOD0(stream_analog_level,
     84       int());
     85   MOCK_METHOD1(set_mode,
     86       int(Mode mode));
     87   MOCK_CONST_METHOD0(mode,
     88       Mode());
     89   MOCK_METHOD1(set_target_level_dbfs,
     90       int(int level));
     91   MOCK_CONST_METHOD0(target_level_dbfs,
     92       int());
     93   MOCK_METHOD1(set_compression_gain_db,
     94       int(int gain));
     95   MOCK_CONST_METHOD0(compression_gain_db,
     96       int());
     97   MOCK_METHOD1(enable_limiter,
     98       int(bool enable));
     99   MOCK_CONST_METHOD0(is_limiter_enabled,
    100       bool());
    101   MOCK_METHOD2(set_analog_level_limits,
    102       int(int minimum, int maximum));
    103   MOCK_CONST_METHOD0(analog_level_minimum,
    104       int());
    105   MOCK_CONST_METHOD0(analog_level_maximum,
    106       int());
    107   MOCK_CONST_METHOD0(stream_is_saturated,
    108       bool());
    109 };
    110 
    111 class MockHighPassFilter : public HighPassFilter {
    112  public:
    113   MOCK_METHOD1(Enable,
    114       int(bool enable));
    115   MOCK_CONST_METHOD0(is_enabled,
    116       bool());
    117 };
    118 
    119 class MockLevelEstimator : public LevelEstimator {
    120  public:
    121   MOCK_METHOD1(Enable,
    122       int(bool enable));
    123   MOCK_CONST_METHOD0(is_enabled,
    124       bool());
    125   MOCK_METHOD0(RMS,
    126       int());
    127 };
    128 
    129 class MockNoiseSuppression : public NoiseSuppression {
    130  public:
    131   MOCK_METHOD1(Enable,
    132       int(bool enable));
    133   MOCK_CONST_METHOD0(is_enabled,
    134       bool());
    135   MOCK_METHOD1(set_level,
    136       int(Level level));
    137   MOCK_CONST_METHOD0(level,
    138       Level());
    139   MOCK_CONST_METHOD0(speech_probability,
    140       float());
    141 };
    142 
    143 class MockVoiceDetection : public VoiceDetection {
    144  public:
    145   MOCK_METHOD1(Enable,
    146       int(bool enable));
    147   MOCK_CONST_METHOD0(is_enabled,
    148       bool());
    149   MOCK_CONST_METHOD0(stream_has_voice,
    150       bool());
    151   MOCK_METHOD1(set_stream_has_voice,
    152       int(bool has_voice));
    153   MOCK_METHOD1(set_likelihood,
    154       int(Likelihood likelihood));
    155   MOCK_CONST_METHOD0(likelihood,
    156       Likelihood());
    157   MOCK_METHOD1(set_frame_size_ms,
    158       int(int size));
    159   MOCK_CONST_METHOD0(frame_size_ms,
    160       int());
    161 };
    162 
    163 class MockAudioProcessing : public AudioProcessing {
    164  public:
    165   MockAudioProcessing()
    166       : echo_cancellation_(new MockEchoCancellation),
    167         echo_control_mobile_(new MockEchoControlMobile),
    168         gain_control_(new MockGainControl),
    169         high_pass_filter_(new MockHighPassFilter),
    170         level_estimator_(new MockLevelEstimator),
    171         noise_suppression_(new MockNoiseSuppression),
    172         voice_detection_(new MockVoiceDetection) {
    173   }
    174 
    175   virtual ~MockAudioProcessing() {
    176   }
    177 
    178   MOCK_METHOD0(Initialize,
    179       int());
    180   MOCK_METHOD6(Initialize,
    181       int(int sample_rate_hz,
    182           int output_sample_rate_hz,
    183           int reverse_sample_rate_hz,
    184           ChannelLayout input_layout,
    185           ChannelLayout output_layout,
    186           ChannelLayout reverse_layout));
    187   MOCK_METHOD1(SetExtraOptions,
    188       void(const Config& config));
    189   MOCK_METHOD1(set_sample_rate_hz,
    190       int(int rate));
    191   MOCK_CONST_METHOD0(input_sample_rate_hz,
    192       int());
    193   MOCK_CONST_METHOD0(sample_rate_hz,
    194       int());
    195   MOCK_CONST_METHOD0(proc_sample_rate_hz,
    196       int());
    197   MOCK_CONST_METHOD0(proc_split_sample_rate_hz,
    198       int());
    199   MOCK_CONST_METHOD0(num_input_channels,
    200       int());
    201   MOCK_CONST_METHOD0(num_output_channels,
    202       int());
    203   MOCK_CONST_METHOD0(num_reverse_channels,
    204       int());
    205   MOCK_METHOD1(set_output_will_be_muted,
    206       void(bool muted));
    207   MOCK_CONST_METHOD0(output_will_be_muted,
    208       bool());
    209   MOCK_METHOD1(ProcessStream,
    210       int(AudioFrame* frame));
    211   MOCK_METHOD7(ProcessStream,
    212       int(const float* const* src,
    213           int samples_per_channel,
    214           int input_sample_rate_hz,
    215           ChannelLayout input_layout,
    216           int output_sample_rate_hz,
    217           ChannelLayout output_layout,
    218           float* const* dest));
    219   MOCK_METHOD1(AnalyzeReverseStream,
    220       int(AudioFrame* frame));
    221   MOCK_METHOD4(AnalyzeReverseStream,
    222       int(const float* const* data, int frames, int sample_rate_hz,
    223           ChannelLayout input_layout));
    224   MOCK_METHOD1(set_stream_delay_ms,
    225       int(int delay));
    226   MOCK_CONST_METHOD0(stream_delay_ms,
    227       int());
    228   MOCK_CONST_METHOD0(was_stream_delay_set,
    229       bool());
    230   MOCK_METHOD1(set_stream_key_pressed,
    231       void(bool key_pressed));
    232   MOCK_CONST_METHOD0(stream_key_pressed,
    233       bool());
    234   MOCK_METHOD1(set_delay_offset_ms,
    235       void(int offset));
    236   MOCK_CONST_METHOD0(delay_offset_ms,
    237       int());
    238   MOCK_METHOD1(StartDebugRecording,
    239       int(const char filename[kMaxFilenameSize]));
    240   MOCK_METHOD1(StartDebugRecording,
    241       int(FILE* handle));
    242   MOCK_METHOD0(StopDebugRecording,
    243       int());
    244   virtual MockEchoCancellation* echo_cancellation() const {
    245     return echo_cancellation_.get();
    246   }
    247   virtual MockEchoControlMobile* echo_control_mobile() const {
    248     return echo_control_mobile_.get();
    249   }
    250   virtual MockGainControl* gain_control() const {
    251     return gain_control_.get();
    252   }
    253   virtual MockHighPassFilter* high_pass_filter() const {
    254     return high_pass_filter_.get();
    255   }
    256   virtual MockLevelEstimator* level_estimator() const {
    257     return level_estimator_.get();
    258   }
    259   virtual MockNoiseSuppression* noise_suppression() const {
    260     return noise_suppression_.get();
    261   }
    262   virtual MockVoiceDetection* voice_detection() const {
    263     return voice_detection_.get();
    264   }
    265 
    266  private:
    267   scoped_ptr<MockEchoCancellation> echo_cancellation_;
    268   scoped_ptr<MockEchoControlMobile> echo_control_mobile_;
    269   scoped_ptr<MockGainControl> gain_control_;
    270   scoped_ptr<MockHighPassFilter> high_pass_filter_;
    271   scoped_ptr<MockLevelEstimator> level_estimator_;
    272   scoped_ptr<MockNoiseSuppression> noise_suppression_;
    273   scoped_ptr<MockVoiceDetection> voice_detection_;
    274 };
    275 
    276 }  // namespace webrtc
    277 
    278 #endif  // WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_MOCK_AUDIO_PROCESSING_H_
    279