2013-03-25 21:20:38 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_MOCK_AUDIO_PROCESSING_H_
|
|
|
|
|
#define WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_MOCK_AUDIO_PROCESSING_H_
|
|
|
|
|
|
2015-02-26 14:34:55 +00:00
|
|
|
#include "webrtc/base/scoped_ptr.h"
|
2013-03-25 21:20:38 +00:00
|
|
|
#include "webrtc/modules/audio_processing/include/audio_processing.h"
|
|
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
class MockEchoCancellation : public EchoCancellation {
|
|
|
|
|
public:
|
|
|
|
|
MOCK_METHOD1(Enable,
|
|
|
|
|
int(bool enable));
|
|
|
|
|
MOCK_CONST_METHOD0(is_enabled,
|
|
|
|
|
bool());
|
|
|
|
|
MOCK_METHOD1(enable_drift_compensation,
|
|
|
|
|
int(bool enable));
|
|
|
|
|
MOCK_CONST_METHOD0(is_drift_compensation_enabled,
|
|
|
|
|
bool());
|
|
|
|
|
MOCK_METHOD1(set_stream_drift_samples,
|
|
|
|
|
void(int drift));
|
|
|
|
|
MOCK_CONST_METHOD0(stream_drift_samples,
|
|
|
|
|
int());
|
|
|
|
|
MOCK_METHOD1(set_suppression_level,
|
|
|
|
|
int(SuppressionLevel level));
|
|
|
|
|
MOCK_CONST_METHOD0(suppression_level,
|
|
|
|
|
SuppressionLevel());
|
|
|
|
|
MOCK_CONST_METHOD0(stream_has_echo,
|
|
|
|
|
bool());
|
|
|
|
|
MOCK_METHOD1(enable_metrics,
|
|
|
|
|
int(bool enable));
|
|
|
|
|
MOCK_CONST_METHOD0(are_metrics_enabled,
|
|
|
|
|
bool());
|
|
|
|
|
MOCK_METHOD1(GetMetrics,
|
|
|
|
|
int(Metrics* metrics));
|
|
|
|
|
MOCK_METHOD1(enable_delay_logging,
|
|
|
|
|
int(bool enable));
|
|
|
|
|
MOCK_CONST_METHOD0(is_delay_logging_enabled,
|
|
|
|
|
bool());
|
|
|
|
|
MOCK_METHOD2(GetDelayMetrics,
|
|
|
|
|
int(int* median, int* std));
|
2015-02-03 06:06:26 +00:00
|
|
|
MOCK_METHOD3(GetDelayMetrics,
|
|
|
|
|
int(int* median, int* std, float* fraction_poor_delays));
|
2013-03-25 21:20:38 +00:00
|
|
|
MOCK_CONST_METHOD0(aec_core,
|
|
|
|
|
struct AecCore*());
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class MockEchoControlMobile : public EchoControlMobile {
|
|
|
|
|
public:
|
|
|
|
|
MOCK_METHOD1(Enable,
|
|
|
|
|
int(bool enable));
|
|
|
|
|
MOCK_CONST_METHOD0(is_enabled,
|
|
|
|
|
bool());
|
|
|
|
|
MOCK_METHOD1(set_routing_mode,
|
|
|
|
|
int(RoutingMode mode));
|
|
|
|
|
MOCK_CONST_METHOD0(routing_mode,
|
|
|
|
|
RoutingMode());
|
|
|
|
|
MOCK_METHOD1(enable_comfort_noise,
|
|
|
|
|
int(bool enable));
|
|
|
|
|
MOCK_CONST_METHOD0(is_comfort_noise_enabled,
|
|
|
|
|
bool());
|
|
|
|
|
MOCK_METHOD2(SetEchoPath,
|
|
|
|
|
int(const void* echo_path, size_t size_bytes));
|
|
|
|
|
MOCK_CONST_METHOD2(GetEchoPath,
|
|
|
|
|
int(void* echo_path, size_t size_bytes));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class MockGainControl : public GainControl {
|
|
|
|
|
public:
|
|
|
|
|
MOCK_METHOD1(Enable,
|
|
|
|
|
int(bool enable));
|
|
|
|
|
MOCK_CONST_METHOD0(is_enabled,
|
|
|
|
|
bool());
|
|
|
|
|
MOCK_METHOD1(set_stream_analog_level,
|
|
|
|
|
int(int level));
|
|
|
|
|
MOCK_METHOD0(stream_analog_level,
|
|
|
|
|
int());
|
|
|
|
|
MOCK_METHOD1(set_mode,
|
|
|
|
|
int(Mode mode));
|
|
|
|
|
MOCK_CONST_METHOD0(mode,
|
|
|
|
|
Mode());
|
|
|
|
|
MOCK_METHOD1(set_target_level_dbfs,
|
|
|
|
|
int(int level));
|
|
|
|
|
MOCK_CONST_METHOD0(target_level_dbfs,
|
|
|
|
|
int());
|
|
|
|
|
MOCK_METHOD1(set_compression_gain_db,
|
|
|
|
|
int(int gain));
|
|
|
|
|
MOCK_CONST_METHOD0(compression_gain_db,
|
|
|
|
|
int());
|
|
|
|
|
MOCK_METHOD1(enable_limiter,
|
|
|
|
|
int(bool enable));
|
|
|
|
|
MOCK_CONST_METHOD0(is_limiter_enabled,
|
|
|
|
|
bool());
|
|
|
|
|
MOCK_METHOD2(set_analog_level_limits,
|
|
|
|
|
int(int minimum, int maximum));
|
|
|
|
|
MOCK_CONST_METHOD0(analog_level_minimum,
|
|
|
|
|
int());
|
|
|
|
|
MOCK_CONST_METHOD0(analog_level_maximum,
|
|
|
|
|
int());
|
|
|
|
|
MOCK_CONST_METHOD0(stream_is_saturated,
|
|
|
|
|
bool());
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class MockHighPassFilter : public HighPassFilter {
|
|
|
|
|
public:
|
|
|
|
|
MOCK_METHOD1(Enable,
|
|
|
|
|
int(bool enable));
|
|
|
|
|
MOCK_CONST_METHOD0(is_enabled,
|
|
|
|
|
bool());
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class MockLevelEstimator : public LevelEstimator {
|
|
|
|
|
public:
|
|
|
|
|
MOCK_METHOD1(Enable,
|
|
|
|
|
int(bool enable));
|
|
|
|
|
MOCK_CONST_METHOD0(is_enabled,
|
|
|
|
|
bool());
|
|
|
|
|
MOCK_METHOD0(RMS,
|
|
|
|
|
int());
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class MockNoiseSuppression : public NoiseSuppression {
|
|
|
|
|
public:
|
|
|
|
|
MOCK_METHOD1(Enable,
|
|
|
|
|
int(bool enable));
|
|
|
|
|
MOCK_CONST_METHOD0(is_enabled,
|
|
|
|
|
bool());
|
|
|
|
|
MOCK_METHOD1(set_level,
|
|
|
|
|
int(Level level));
|
|
|
|
|
MOCK_CONST_METHOD0(level,
|
|
|
|
|
Level());
|
|
|
|
|
MOCK_CONST_METHOD0(speech_probability,
|
|
|
|
|
float());
|
2016-02-09 11:24:32 -08:00
|
|
|
MOCK_METHOD0(NoiseEstimate, std::vector<float>());
|
2013-03-25 21:20:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class MockVoiceDetection : public VoiceDetection {
|
|
|
|
|
public:
|
|
|
|
|
MOCK_METHOD1(Enable,
|
|
|
|
|
int(bool enable));
|
|
|
|
|
MOCK_CONST_METHOD0(is_enabled,
|
|
|
|
|
bool());
|
|
|
|
|
MOCK_CONST_METHOD0(stream_has_voice,
|
|
|
|
|
bool());
|
|
|
|
|
MOCK_METHOD1(set_stream_has_voice,
|
|
|
|
|
int(bool has_voice));
|
|
|
|
|
MOCK_METHOD1(set_likelihood,
|
|
|
|
|
int(Likelihood likelihood));
|
|
|
|
|
MOCK_CONST_METHOD0(likelihood,
|
|
|
|
|
Likelihood());
|
|
|
|
|
MOCK_METHOD1(set_frame_size_ms,
|
|
|
|
|
int(int size));
|
|
|
|
|
MOCK_CONST_METHOD0(frame_size_ms,
|
|
|
|
|
int());
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class MockAudioProcessing : public AudioProcessing {
|
|
|
|
|
public:
|
|
|
|
|
MockAudioProcessing()
|
|
|
|
|
: echo_cancellation_(new MockEchoCancellation),
|
|
|
|
|
echo_control_mobile_(new MockEchoControlMobile),
|
|
|
|
|
gain_control_(new MockGainControl),
|
|
|
|
|
high_pass_filter_(new MockHighPassFilter),
|
|
|
|
|
level_estimator_(new MockLevelEstimator),
|
|
|
|
|
noise_suppression_(new MockNoiseSuppression),
|
|
|
|
|
voice_detection_(new MockVoiceDetection) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual ~MockAudioProcessing() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MOCK_METHOD0(Initialize,
|
|
|
|
|
int());
|
2014-04-22 21:00:04 +00:00
|
|
|
MOCK_METHOD6(Initialize,
|
2014-03-10 22:26:12 +00:00
|
|
|
int(int sample_rate_hz,
|
2014-04-22 21:00:04 +00:00
|
|
|
int output_sample_rate_hz,
|
2014-03-10 22:26:12 +00:00
|
|
|
int reverse_sample_rate_hz,
|
2014-04-22 21:00:04 +00:00
|
|
|
ChannelLayout input_layout,
|
|
|
|
|
ChannelLayout output_layout,
|
|
|
|
|
ChannelLayout reverse_layout));
|
2015-07-23 11:41:39 -07:00
|
|
|
MOCK_METHOD1(Initialize,
|
|
|
|
|
int(const ProcessingConfig& processing_config));
|
2013-07-25 18:28:29 +00:00
|
|
|
MOCK_METHOD1(SetExtraOptions,
|
|
|
|
|
void(const Config& config));
|
2013-03-25 21:20:38 +00:00
|
|
|
MOCK_METHOD1(set_sample_rate_hz,
|
|
|
|
|
int(int rate));
|
2014-04-22 21:00:04 +00:00
|
|
|
MOCK_CONST_METHOD0(input_sample_rate_hz,
|
|
|
|
|
int());
|
2014-04-23 03:33:54 +00:00
|
|
|
MOCK_CONST_METHOD0(sample_rate_hz,
|
|
|
|
|
int());
|
2014-04-22 21:00:04 +00:00
|
|
|
MOCK_CONST_METHOD0(proc_sample_rate_hz,
|
2013-03-25 21:20:38 +00:00
|
|
|
int());
|
2014-04-22 21:00:04 +00:00
|
|
|
MOCK_CONST_METHOD0(proc_split_sample_rate_hz,
|
2014-02-27 22:23:17 +00:00
|
|
|
int());
|
2013-03-25 21:20:38 +00:00
|
|
|
MOCK_CONST_METHOD0(num_input_channels,
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
size_t());
|
2013-03-25 21:20:38 +00:00
|
|
|
MOCK_CONST_METHOD0(num_output_channels,
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
size_t());
|
2013-03-25 21:20:38 +00:00
|
|
|
MOCK_CONST_METHOD0(num_reverse_channels,
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
size_t());
|
2014-02-12 22:28:31 +00:00
|
|
|
MOCK_METHOD1(set_output_will_be_muted,
|
|
|
|
|
void(bool muted));
|
|
|
|
|
MOCK_CONST_METHOD0(output_will_be_muted,
|
|
|
|
|
bool());
|
2013-03-25 21:20:38 +00:00
|
|
|
MOCK_METHOD1(ProcessStream,
|
|
|
|
|
int(AudioFrame* frame));
|
2014-04-22 21:00:04 +00:00
|
|
|
MOCK_METHOD7(ProcessStream,
|
|
|
|
|
int(const float* const* src,
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t samples_per_channel,
|
2014-04-22 21:00:04 +00:00
|
|
|
int input_sample_rate_hz,
|
2014-03-04 20:58:13 +00:00
|
|
|
ChannelLayout input_layout,
|
2014-04-22 21:00:04 +00:00
|
|
|
int output_sample_rate_hz,
|
|
|
|
|
ChannelLayout output_layout,
|
|
|
|
|
float* const* dest));
|
2015-07-23 11:41:39 -07:00
|
|
|
MOCK_METHOD4(ProcessStream,
|
|
|
|
|
int(const float* const* src,
|
|
|
|
|
const StreamConfig& input_config,
|
|
|
|
|
const StreamConfig& output_config,
|
|
|
|
|
float* const* dest));
|
2013-03-25 21:20:38 +00:00
|
|
|
MOCK_METHOD1(AnalyzeReverseStream,
|
|
|
|
|
int(AudioFrame* frame));
|
2015-08-14 10:35:55 -07:00
|
|
|
MOCK_METHOD1(ProcessReverseStream, int(AudioFrame* frame));
|
2014-03-04 20:58:13 +00:00
|
|
|
MOCK_METHOD4(AnalyzeReverseStream,
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
int(const float* const* data, size_t frames, int sample_rate_hz,
|
2014-03-04 20:58:13 +00:00
|
|
|
ChannelLayout input_layout));
|
2015-08-14 10:35:55 -07:00
|
|
|
MOCK_METHOD4(ProcessReverseStream,
|
|
|
|
|
int(const float* const* src,
|
|
|
|
|
const StreamConfig& input_config,
|
|
|
|
|
const StreamConfig& output_config,
|
|
|
|
|
float* const* dest));
|
2013-03-25 21:20:38 +00:00
|
|
|
MOCK_METHOD1(set_stream_delay_ms,
|
|
|
|
|
int(int delay));
|
|
|
|
|
MOCK_CONST_METHOD0(stream_delay_ms,
|
|
|
|
|
int());
|
2014-02-27 22:23:17 +00:00
|
|
|
MOCK_CONST_METHOD0(was_stream_delay_set,
|
|
|
|
|
bool());
|
2014-02-11 20:52:30 +00:00
|
|
|
MOCK_METHOD1(set_stream_key_pressed,
|
|
|
|
|
void(bool key_pressed));
|
|
|
|
|
MOCK_CONST_METHOD0(stream_key_pressed,
|
|
|
|
|
bool());
|
2013-03-25 21:20:38 +00:00
|
|
|
MOCK_METHOD1(set_delay_offset_ms,
|
|
|
|
|
void(int offset));
|
|
|
|
|
MOCK_CONST_METHOD0(delay_offset_ms,
|
|
|
|
|
int());
|
2016-01-15 03:06:36 -08:00
|
|
|
MOCK_METHOD2(StartDebugRecording,
|
|
|
|
|
int(const char filename[kMaxFilenameSize],
|
|
|
|
|
int64_t max_log_size_bytes));
|
|
|
|
|
MOCK_METHOD2(StartDebugRecording,
|
|
|
|
|
int(FILE* handle, int64_t max_log_size_bytes));
|
2013-03-25 21:20:38 +00:00
|
|
|
MOCK_METHOD0(StopDebugRecording,
|
|
|
|
|
int());
|
2015-07-07 11:50:05 +02:00
|
|
|
MOCK_METHOD0(UpdateHistogramsOnCallEnd, void());
|
2013-03-25 21:20:38 +00:00
|
|
|
virtual MockEchoCancellation* echo_cancellation() const {
|
|
|
|
|
return echo_cancellation_.get();
|
|
|
|
|
}
|
|
|
|
|
virtual MockEchoControlMobile* echo_control_mobile() const {
|
|
|
|
|
return echo_control_mobile_.get();
|
|
|
|
|
}
|
|
|
|
|
virtual MockGainControl* gain_control() const {
|
|
|
|
|
return gain_control_.get();
|
|
|
|
|
}
|
|
|
|
|
virtual MockHighPassFilter* high_pass_filter() const {
|
|
|
|
|
return high_pass_filter_.get();
|
2014-03-04 20:58:13 +00:00
|
|
|
}
|
2013-03-25 21:20:38 +00:00
|
|
|
virtual MockLevelEstimator* level_estimator() const {
|
|
|
|
|
return level_estimator_.get();
|
2014-03-04 20:58:13 +00:00
|
|
|
}
|
2013-03-25 21:20:38 +00:00
|
|
|
virtual MockNoiseSuppression* noise_suppression() const {
|
|
|
|
|
return noise_suppression_.get();
|
2014-03-04 20:58:13 +00:00
|
|
|
}
|
2013-03-25 21:20:38 +00:00
|
|
|
virtual MockVoiceDetection* voice_detection() const {
|
|
|
|
|
return voice_detection_.get();
|
2014-03-04 20:58:13 +00:00
|
|
|
}
|
2013-03-25 21:20:38 +00:00
|
|
|
|
|
|
|
|
private:
|
2015-02-26 14:34:55 +00:00
|
|
|
rtc::scoped_ptr<MockEchoCancellation> echo_cancellation_;
|
|
|
|
|
rtc::scoped_ptr<MockEchoControlMobile> echo_control_mobile_;
|
|
|
|
|
rtc::scoped_ptr<MockGainControl> gain_control_;
|
|
|
|
|
rtc::scoped_ptr<MockHighPassFilter> high_pass_filter_;
|
|
|
|
|
rtc::scoped_ptr<MockLevelEstimator> level_estimator_;
|
|
|
|
|
rtc::scoped_ptr<MockNoiseSuppression> noise_suppression_;
|
|
|
|
|
rtc::scoped_ptr<MockVoiceDetection> voice_detection_;
|
2013-03-25 21:20:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
|
|
|
|
#endif // WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_MOCK_AUDIO_PROCESSING_H_
|