blob: f3e936185f624d5d79563d239bc9cf736760f059 [file] [log] [blame]
andrew@webrtc.orgc83a00a2013-03-25 21:20:38 +00001/*
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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_AUDIO_PROCESSING_INCLUDE_MOCK_AUDIO_PROCESSING_H_
12#define MODULES_AUDIO_PROCESSING_INCLUDE_MOCK_AUDIO_PROCESSING_H_
andrew@webrtc.orgc83a00a2013-03-25 21:20:38 +000013
kwiberg88788ad2016-02-19 07:04:49 -080014#include <memory>
15
Per Åhgren0aefbf02019-08-23 21:29:17 +020016#include "modules/audio_processing/audio_buffer.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020017#include "modules/audio_processing/include/aec_dump.h"
18#include "modules/audio_processing/include/audio_processing.h"
Ivo Creusen56d46092017-11-24 17:29:59 +010019#include "modules/audio_processing/include/audio_processing_statistics.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020020#include "test/gmock.h"
andrew@webrtc.orgc83a00a2013-03-25 21:20:38 +000021
22namespace webrtc {
23
solenberg059fb442016-10-26 05:12:24 -070024namespace test {
Alex Loiko5825aa62017-12-18 16:02:40 +010025class MockCustomProcessing : public CustomProcessing {
Sam Zackrisson0beac582017-09-25 12:04:02 +020026 public:
Alex Loiko5825aa62017-12-18 16:02:40 +010027 virtual ~MockCustomProcessing() {}
Sam Zackrisson0beac582017-09-25 12:04:02 +020028 MOCK_METHOD2(Initialize, void(int sample_rate_hz, int num_channels));
29 MOCK_METHOD1(Process, void(AudioBuffer* audio));
Alex Loiko73ec0192018-05-15 10:52:28 +020030 MOCK_METHOD1(SetRuntimeSetting,
31 void(AudioProcessing::RuntimeSetting setting));
Sam Zackrisson0beac582017-09-25 12:04:02 +020032 MOCK_CONST_METHOD0(ToString, std::string());
33};
34
Valeriia Nemychnikovaf06eb572018-08-29 10:37:09 +020035class MockCustomAudioAnalyzer : public CustomAudioAnalyzer {
36 public:
37 virtual ~MockCustomAudioAnalyzer() {}
38 MOCK_METHOD2(Initialize, void(int sample_rate_hz, int num_channels));
39 MOCK_METHOD1(Analyze, void(const AudioBuffer* audio));
40 MOCK_CONST_METHOD0(ToString, std::string());
41};
42
Gustaf Ullberg002ef282017-10-12 15:13:17 +020043class MockEchoControl : public EchoControl {
44 public:
45 virtual ~MockEchoControl() {}
46 MOCK_METHOD1(AnalyzeRender, void(AudioBuffer* render));
47 MOCK_METHOD1(AnalyzeCapture, void(AudioBuffer* capture));
48 MOCK_METHOD2(ProcessCapture,
49 void(AudioBuffer* capture, bool echo_path_change));
Per Åhgrenc20a19c2019-11-13 11:12:29 +010050 MOCK_METHOD3(ProcessCapture,
51 void(AudioBuffer* capture,
52 AudioBuffer* linear_output,
53 bool echo_path_change));
Gustaf Ullberg332150d2017-11-22 14:17:39 +010054 MOCK_CONST_METHOD0(GetMetrics, Metrics());
Gustaf Ullberg3cb61042019-10-24 15:52:10 +020055 MOCK_METHOD1(SetAudioBufferDelay, void(int delay_ms));
Gustaf Ullberg8675eee2019-10-09 13:34:36 +020056 MOCK_CONST_METHOD0(ActiveProcessing, bool());
Gustaf Ullberg002ef282017-10-12 15:13:17 +020057};
58
Mirko Bonadei6a489f22019-04-09 15:11:12 +020059class MockAudioProcessing : public ::testing::NiceMock<AudioProcessing> {
andrew@webrtc.orgc83a00a2013-03-25 21:20:38 +000060 public:
saza0bad15f2019-10-16 11:46:11 +020061 MockAudioProcessing() {}
andrew@webrtc.orgc83a00a2013-03-25 21:20:38 +000062
solenberg059fb442016-10-26 05:12:24 -070063 virtual ~MockAudioProcessing() {}
andrew@webrtc.orgc83a00a2013-03-25 21:20:38 +000064
solenberg059fb442016-10-26 05:12:24 -070065 MOCK_METHOD0(Initialize, int());
Yves Gerey665174f2018-06-19 15:03:05 +020066 MOCK_METHOD6(Initialize,
67 int(int capture_input_sample_rate_hz,
68 int capture_output_sample_rate_hz,
69 int render_sample_rate_hz,
70 ChannelLayout capture_input_layout,
71 ChannelLayout capture_output_layout,
72 ChannelLayout render_input_layout));
solenberg059fb442016-10-26 05:12:24 -070073 MOCK_METHOD1(Initialize, int(const ProcessingConfig& processing_config));
peah88ac8532016-09-12 16:47:25 -070074 MOCK_METHOD1(ApplyConfig, void(const Config& config));
75 MOCK_METHOD1(SetExtraOptions, void(const webrtc::Config& config));
solenberg059fb442016-10-26 05:12:24 -070076 MOCK_CONST_METHOD0(proc_sample_rate_hz, int());
77 MOCK_CONST_METHOD0(proc_split_sample_rate_hz, int());
78 MOCK_CONST_METHOD0(num_input_channels, size_t());
79 MOCK_CONST_METHOD0(num_proc_channels, size_t());
80 MOCK_CONST_METHOD0(num_output_channels, size_t());
81 MOCK_CONST_METHOD0(num_reverse_channels, size_t());
82 MOCK_METHOD1(set_output_will_be_muted, void(bool muted));
Alessio Bazzicac054e782018-04-16 12:10:09 +020083 MOCK_METHOD1(SetRuntimeSetting, void(RuntimeSetting setting));
solenberg059fb442016-10-26 05:12:24 -070084 MOCK_METHOD1(ProcessStream, int(AudioFrame* frame));
Per Åhgrendc5522b2020-03-19 14:55:58 +010085 MOCK_METHOD4(ProcessStream,
Per Åhgren645f24c2020-03-16 12:06:02 +010086 int(const int16_t* const src,
87 const StreamConfig& input_config,
88 const StreamConfig& output_config,
Per Åhgrendc5522b2020-03-19 14:55:58 +010089 int16_t* const dest));
Yves Gerey665174f2018-06-19 15:03:05 +020090 MOCK_METHOD7(ProcessStream,
91 int(const float* const* src,
92 size_t samples_per_channel,
93 int input_sample_rate_hz,
94 ChannelLayout input_layout,
95 int output_sample_rate_hz,
96 ChannelLayout output_layout,
97 float* const* dest));
98 MOCK_METHOD4(ProcessStream,
99 int(const float* const* src,
100 const StreamConfig& input_config,
101 const StreamConfig& output_config,
102 float* const* dest));
ekmeyerson60d9b332015-08-14 10:35:55 -0700103 MOCK_METHOD1(ProcessReverseStream, int(AudioFrame* frame));
Per Åhgren645f24c2020-03-16 12:06:02 +0100104 MOCK_METHOD4(ProcessReverseStream,
105 int(const int16_t* const src,
106 const StreamConfig& input_config,
107 const StreamConfig& output_config,
108 int16_t* const dest));
Yves Gerey665174f2018-06-19 15:03:05 +0200109 MOCK_METHOD4(AnalyzeReverseStream,
110 int(const float* const* data,
111 size_t samples_per_channel,
112 int sample_rate_hz,
113 ChannelLayout layout));
Gustaf Ullberg8c51f2e2019-10-22 15:21:31 +0200114 MOCK_METHOD2(AnalyzeReverseStream,
115 int(const float* const* data,
116 const StreamConfig& reverse_config));
Yves Gerey665174f2018-06-19 15:03:05 +0200117 MOCK_METHOD4(ProcessReverseStream,
118 int(const float* const* src,
119 const StreamConfig& input_config,
120 const StreamConfig& output_config,
121 float* const* dest));
Per Åhgrenc20a19c2019-11-13 11:12:29 +0100122 MOCK_CONST_METHOD1(
123 GetLinearAecOutput,
124 bool(rtc::ArrayView<std::array<float, 160>> linear_output));
solenberg059fb442016-10-26 05:12:24 -0700125 MOCK_METHOD1(set_stream_delay_ms, int(int delay));
126 MOCK_CONST_METHOD0(stream_delay_ms, int());
127 MOCK_CONST_METHOD0(was_stream_delay_set, bool());
128 MOCK_METHOD1(set_stream_key_pressed, void(bool key_pressed));
129 MOCK_METHOD1(set_delay_offset_ms, void(int offset));
130 MOCK_CONST_METHOD0(delay_offset_ms, int());
Sam Zackrissonf0d1c032019-03-27 13:28:08 +0100131 MOCK_METHOD1(set_stream_analog_level, void(int));
132 MOCK_CONST_METHOD0(recommended_stream_analog_level, int());
aleloi868f32f2017-05-23 07:20:05 -0700133
134 virtual void AttachAecDump(std::unique_ptr<AecDump> aec_dump) {}
135 MOCK_METHOD0(DetachAecDump, void());
136
Sam Zackrisson4d364492018-03-02 16:03:21 +0100137 virtual void AttachPlayoutAudioGenerator(
138 std::unique_ptr<AudioGenerator> audio_generator) {}
139 MOCK_METHOD0(DetachPlayoutAudioGenerator, void());
140
Bjorn Volcker4e7aa432015-07-07 11:50:05 +0200141 MOCK_METHOD0(UpdateHistogramsOnCallEnd, void());
Per Åhgrencf4c8722019-12-30 14:32:14 +0100142 MOCK_METHOD0(GetStatistics, AudioProcessingStats());
143 MOCK_METHOD1(GetStatistics, AudioProcessingStats(bool));
andrew@webrtc.orgc83a00a2013-03-25 21:20:38 +0000144
henrik.lundinadf06352017-04-05 05:48:24 -0700145 MOCK_CONST_METHOD0(GetConfig, AudioProcessing::Config());
andrew@webrtc.orgc83a00a2013-03-25 21:20:38 +0000146};
147
solenberg059fb442016-10-26 05:12:24 -0700148} // namespace test
andrew@webrtc.orgc83a00a2013-03-25 21:20:38 +0000149} // namespace webrtc
150
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200151#endif // MODULES_AUDIO_PROCESSING_INCLUDE_MOCK_AUDIO_PROCESSING_H_