blob: b7a7262af74ccb39e59c34b705f031406294619e [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001/*
2 * libjingle
3 * Copyright 2010 Google Inc.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifndef TALK_SESSION_PHONE_FAKEWEBRTCVOICEENGINE_H_
29#define TALK_SESSION_PHONE_FAKEWEBRTCVOICEENGINE_H_
30
31#include <list>
32#include <map>
33#include <vector>
34
henrike@webrtc.org28e20752013-07-10 00:45:36 +000035#include "talk/media/base/codec.h"
buildbot@webrtc.org7e71b772014-06-13 01:14:01 +000036#include "talk/media/base/rtputils.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000037#include "talk/media/webrtc/fakewebrtccommon.h"
38#include "talk/media/webrtc/webrtcvoe.h"
buildbot@webrtc.orga09a9992014-08-13 17:26:08 +000039#include "webrtc/base/basictypes.h"
Fredrik Solenbergd3ddc1b2015-05-07 17:07:34 +020040#include "webrtc/base/checks.h"
buildbot@webrtc.orga09a9992014-08-13 17:26:08 +000041#include "webrtc/base/gunit.h"
42#include "webrtc/base/stringutils.h"
Henrik Lundin64dad832015-05-11 12:44:23 +020043#include "webrtc/config.h"
solenberg26c8c912015-11-27 04:00:25 -080044#include "webrtc/modules/audio_coding/acm2/rent_a_codec.h"
buildbot@webrtc.orga8d8ad22014-07-16 14:23:08 +000045#include "webrtc/modules/audio_processing/include/audio_processing.h"
buildbot@webrtc.orgf875f152014-04-14 16:06:21 +000046
henrike@webrtc.org28e20752013-07-10 00:45:36 +000047namespace cricket {
48
buildbot@webrtc.org5d639b32014-09-10 07:57:12 +000049static const int kOpusBandwidthNb = 4000;
50static const int kOpusBandwidthMb = 6000;
51static const int kOpusBandwidthWb = 8000;
52static const int kOpusBandwidthSwb = 12000;
53static const int kOpusBandwidthFb = 20000;
54
Fredrik Solenbergd3ddc1b2015-05-07 17:07:34 +020055#define WEBRTC_CHECK_CHANNEL(channel) \
56 if (channels_.find(channel) == channels_.end()) return -1;
57
buildbot@webrtc.orga8d8ad22014-07-16 14:23:08 +000058class FakeAudioProcessing : public webrtc::AudioProcessing {
59 public:
60 FakeAudioProcessing() : experimental_ns_enabled_(false) {}
61
62 WEBRTC_STUB(Initialize, ())
63 WEBRTC_STUB(Initialize, (
64 int input_sample_rate_hz,
65 int output_sample_rate_hz,
66 int reverse_sample_rate_hz,
67 webrtc::AudioProcessing::ChannelLayout input_layout,
68 webrtc::AudioProcessing::ChannelLayout output_layout,
69 webrtc::AudioProcessing::ChannelLayout reverse_layout));
Michael Graczyk86c6d332015-07-23 11:41:39 -070070 WEBRTC_STUB(Initialize, (
71 const webrtc::ProcessingConfig& processing_config));
buildbot@webrtc.orga8d8ad22014-07-16 14:23:08 +000072
73 WEBRTC_VOID_FUNC(SetExtraOptions, (const webrtc::Config& config)) {
74 experimental_ns_enabled_ = config.Get<webrtc::ExperimentalNs>().enabled;
75 }
76
buildbot@webrtc.orga8d8ad22014-07-16 14:23:08 +000077 WEBRTC_STUB_CONST(proc_sample_rate_hz, ());
78 WEBRTC_STUB_CONST(proc_split_sample_rate_hz, ());
79 WEBRTC_STUB_CONST(num_input_channels, ());
80 WEBRTC_STUB_CONST(num_output_channels, ());
81 WEBRTC_STUB_CONST(num_reverse_channels, ());
82 WEBRTC_VOID_STUB(set_output_will_be_muted, (bool muted));
buildbot@webrtc.orga8d8ad22014-07-16 14:23:08 +000083 WEBRTC_STUB(ProcessStream, (webrtc::AudioFrame* frame));
84 WEBRTC_STUB(ProcessStream, (
85 const float* const* src,
Peter Kastingdce40cf2015-08-24 14:52:23 -070086 size_t samples_per_channel,
buildbot@webrtc.orga8d8ad22014-07-16 14:23:08 +000087 int input_sample_rate_hz,
88 webrtc::AudioProcessing::ChannelLayout input_layout,
89 int output_sample_rate_hz,
90 webrtc::AudioProcessing::ChannelLayout output_layout,
91 float* const* dest));
Michael Graczyk86c6d332015-07-23 11:41:39 -070092 WEBRTC_STUB(ProcessStream,
93 (const float* const* src,
94 const webrtc::StreamConfig& input_config,
95 const webrtc::StreamConfig& output_config,
96 float* const* dest));
buildbot@webrtc.orga8d8ad22014-07-16 14:23:08 +000097 WEBRTC_STUB(AnalyzeReverseStream, (webrtc::AudioFrame* frame));
ekmeyerson60d9b332015-08-14 10:35:55 -070098 WEBRTC_STUB(ProcessReverseStream, (webrtc::AudioFrame * frame));
buildbot@webrtc.orga8d8ad22014-07-16 14:23:08 +000099 WEBRTC_STUB(AnalyzeReverseStream, (
100 const float* const* data,
Peter Kastingdce40cf2015-08-24 14:52:23 -0700101 size_t samples_per_channel,
buildbot@webrtc.orga8d8ad22014-07-16 14:23:08 +0000102 int sample_rate_hz,
103 webrtc::AudioProcessing::ChannelLayout layout));
ekmeyerson60d9b332015-08-14 10:35:55 -0700104 WEBRTC_STUB(ProcessReverseStream,
105 (const float* const* src,
106 const webrtc::StreamConfig& reverse_input_config,
107 const webrtc::StreamConfig& reverse_output_config,
108 float* const* dest));
buildbot@webrtc.orga8d8ad22014-07-16 14:23:08 +0000109 WEBRTC_STUB(set_stream_delay_ms, (int delay));
110 WEBRTC_STUB_CONST(stream_delay_ms, ());
111 WEBRTC_BOOL_STUB_CONST(was_stream_delay_set, ());
112 WEBRTC_VOID_STUB(set_stream_key_pressed, (bool key_pressed));
buildbot@webrtc.orga8d8ad22014-07-16 14:23:08 +0000113 WEBRTC_VOID_STUB(set_delay_offset_ms, (int offset));
114 WEBRTC_STUB_CONST(delay_offset_ms, ());
115 WEBRTC_STUB(StartDebugRecording, (const char filename[kMaxFilenameSize]));
116 WEBRTC_STUB(StartDebugRecording, (FILE* handle));
117 WEBRTC_STUB(StopDebugRecording, ());
Bjorn Volcker4e7aa432015-07-07 11:50:05 +0200118 WEBRTC_VOID_STUB(UpdateHistogramsOnCallEnd, ());
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000119 webrtc::EchoCancellation* echo_cancellation() const override { return NULL; }
120 webrtc::EchoControlMobile* echo_control_mobile() const override {
buildbot@webrtc.orga8d8ad22014-07-16 14:23:08 +0000121 return NULL;
122 }
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000123 webrtc::GainControl* gain_control() const override { return NULL; }
124 webrtc::HighPassFilter* high_pass_filter() const override { return NULL; }
125 webrtc::LevelEstimator* level_estimator() const override { return NULL; }
126 webrtc::NoiseSuppression* noise_suppression() const override { return NULL; }
127 webrtc::VoiceDetection* voice_detection() const override { return NULL; }
buildbot@webrtc.orga8d8ad22014-07-16 14:23:08 +0000128
129 bool experimental_ns_enabled() {
130 return experimental_ns_enabled_;
131 }
132
133 private:
134 bool experimental_ns_enabled_;
135};
buildbot@webrtc.orga8d8ad22014-07-16 14:23:08 +0000136
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000137class FakeWebRtcVoiceEngine
138 : public webrtc::VoEAudioProcessing,
Fredrik Solenbergb5727682015-12-04 15:22:19 +0100139 public webrtc::VoEBase, public webrtc::VoECodec,
Fredrik Solenberg4f4ec0a2015-10-22 10:49:27 +0200140 public webrtc::VoEHardware,
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000141 public webrtc::VoENetwork, public webrtc::VoERTP_RTCP,
Fredrik Solenberg4f4ec0a2015-10-22 10:49:27 +0200142 public webrtc::VoEVolumeControl {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000143 public:
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000144 struct Channel {
buildbot@webrtc.orgaf6640f2014-04-28 21:31:51 +0000145 explicit Channel()
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000146 : external_transport(false),
147 send(false),
148 playout(false),
149 volume_scale(1.0),
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000150 vad(false),
buildbot@webrtc.orgae740dd2014-06-17 10:56:41 +0000151 codec_fec(false),
buildbot@webrtc.org5d639b32014-09-10 07:57:12 +0000152 max_encoding_bandwidth(0),
minyue@webrtc.org9b2e1142015-03-13 09:38:07 +0000153 opus_dtx(false),
buildbot@webrtc.orgae740dd2014-06-17 10:56:41 +0000154 red(false),
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000155 nack(false),
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000156 cn8_type(13),
157 cn16_type(105),
buildbot@webrtc.orgae740dd2014-06-17 10:56:41 +0000158 red_type(117),
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000159 nack_max_packets(0),
160 send_ssrc(0),
Minyue2013aec2015-05-13 14:14:42 +0200161 associate_send_channel(-1),
solenberg26c8c912015-11-27 04:00:25 -0800162 recv_codecs(),
Henrik Lundin5263b3c2015-06-01 10:29:41 +0200163 neteq_capacity(-1),
164 neteq_fast_accelerate(false) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000165 memset(&send_codec, 0, sizeof(send_codec));
166 }
167 bool external_transport;
168 bool send;
169 bool playout;
170 float volume_scale;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000171 bool vad;
buildbot@webrtc.orgae740dd2014-06-17 10:56:41 +0000172 bool codec_fec;
buildbot@webrtc.org5d639b32014-09-10 07:57:12 +0000173 int max_encoding_bandwidth;
minyue@webrtc.org9b2e1142015-03-13 09:38:07 +0000174 bool opus_dtx;
buildbot@webrtc.orgae740dd2014-06-17 10:56:41 +0000175 bool red;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000176 bool nack;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000177 int cn8_type;
178 int cn16_type;
buildbot@webrtc.orgae740dd2014-06-17 10:56:41 +0000179 int red_type;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000180 int nack_max_packets;
Peter Boström0c4e06b2015-10-07 12:23:21 +0200181 uint32_t send_ssrc;
Minyue2013aec2015-05-13 14:14:42 +0200182 int associate_send_channel;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000183 std::vector<webrtc::CodecInst> recv_codecs;
184 webrtc::CodecInst send_codec;
buildbot@webrtc.orgf875f152014-04-14 16:06:21 +0000185 webrtc::PacketTime last_rtp_packet_time;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000186 std::list<std::string> packets;
Henrik Lundin64dad832015-05-11 12:44:23 +0200187 int neteq_capacity;
Henrik Lundin5263b3c2015-06-01 10:29:41 +0200188 bool neteq_fast_accelerate;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000189 };
190
solenberg26c8c912015-11-27 04:00:25 -0800191 FakeWebRtcVoiceEngine()
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000192 : inited_(false),
193 last_channel_(-1),
194 fail_create_channel_(false),
wu@webrtc.org05e7b442014-04-01 17:44:24 +0000195 num_set_send_codecs_(0),
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000196 ec_enabled_(false),
197 ec_metrics_enabled_(false),
198 cng_enabled_(false),
199 ns_enabled_(false),
200 agc_enabled_(false),
201 highpass_filter_enabled_(false),
202 stereo_swapping_enabled_(false),
203 typing_detection_enabled_(false),
204 ec_mode_(webrtc::kEcDefault),
205 aecm_mode_(webrtc::kAecmSpeakerphone),
206 ns_mode_(webrtc::kNsDefault),
207 agc_mode_(webrtc::kAgcDefault),
208 observer_(NULL),
209 playout_fail_channel_(-1),
210 send_fail_channel_(-1),
wu@webrtc.org97077a32013-10-25 21:18:33 +0000211 recording_sample_rate_(-1),
Fredrik Solenberg7d173362015-09-23 12:23:21 +0200212 playout_sample_rate_(-1) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000213 memset(&agc_config_, 0, sizeof(agc_config_));
214 }
215 ~FakeWebRtcVoiceEngine() {
solenberg26c8c912015-11-27 04:00:25 -0800216 RTC_CHECK(channels_.empty());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000217 }
218
solenberg85a04962015-10-27 03:35:21 -0700219 bool ec_metrics_enabled() const { return ec_metrics_enabled_; }
220
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000221 bool IsInited() const { return inited_; }
222 int GetLastChannel() const { return last_channel_; }
wu@webrtc.org9caf2762013-12-11 18:25:07 +0000223 int GetNumChannels() const { return static_cast<int>(channels_.size()); }
solenberg85a04962015-10-27 03:35:21 -0700224 uint32_t GetLocalSSRC(int channel) {
225 return channels_[channel]->send_ssrc;
226 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000227 bool GetPlayout(int channel) {
228 return channels_[channel]->playout;
229 }
230 bool GetSend(int channel) {
231 return channels_[channel]->send;
232 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000233 bool GetVAD(int channel) {
234 return channels_[channel]->vad;
235 }
Minyue Li7100dcd2015-03-27 05:05:59 +0100236 bool GetOpusDtx(int channel) {
237 return channels_[channel]->opus_dtx;
238 }
buildbot@webrtc.orgae740dd2014-06-17 10:56:41 +0000239 bool GetRED(int channel) {
240 return channels_[channel]->red;
241 }
242 bool GetCodecFEC(int channel) {
243 return channels_[channel]->codec_fec;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000244 }
buildbot@webrtc.org5d639b32014-09-10 07:57:12 +0000245 int GetMaxEncodingBandwidth(int channel) {
246 return channels_[channel]->max_encoding_bandwidth;
247 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000248 bool GetNACK(int channel) {
249 return channels_[channel]->nack;
250 }
251 int GetNACKMaxPackets(int channel) {
252 return channels_[channel]->nack_max_packets;
253 }
buildbot@webrtc.orgf875f152014-04-14 16:06:21 +0000254 const webrtc::PacketTime& GetLastRtpPacketTime(int channel) {
solenberg26c8c912015-11-27 04:00:25 -0800255 RTC_DCHECK(channels_.find(channel) != channels_.end());
buildbot@webrtc.orgf875f152014-04-14 16:06:21 +0000256 return channels_[channel]->last_rtp_packet_time;
257 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000258 int GetSendCNPayloadType(int channel, bool wideband) {
259 return (wideband) ?
260 channels_[channel]->cn16_type :
261 channels_[channel]->cn8_type;
262 }
buildbot@webrtc.orgae740dd2014-06-17 10:56:41 +0000263 int GetSendREDPayloadType(int channel) {
264 return channels_[channel]->red_type;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000265 }
266 bool CheckPacket(int channel, const void* data, size_t len) {
267 bool result = !CheckNoPacket(channel);
268 if (result) {
269 std::string packet = channels_[channel]->packets.front();
270 result = (packet == std::string(static_cast<const char*>(data), len));
271 channels_[channel]->packets.pop_front();
272 }
273 return result;
274 }
275 bool CheckNoPacket(int channel) {
276 return channels_[channel]->packets.empty();
277 }
278 void TriggerCallbackOnError(int channel_num, int err_code) {
henrikg91d6ede2015-09-17 00:24:34 -0700279 RTC_DCHECK(observer_ != NULL);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000280 observer_->CallbackOnError(channel_num, err_code);
281 }
282 void set_playout_fail_channel(int channel) {
283 playout_fail_channel_ = channel;
284 }
285 void set_send_fail_channel(int channel) {
286 send_fail_channel_ = channel;
287 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000288 void set_fail_create_channel(bool fail_create_channel) {
289 fail_create_channel_ = fail_create_channel;
290 }
Henrik Lundin64dad832015-05-11 12:44:23 +0200291 int AddChannel(const webrtc::Config& config) {
wu@webrtc.org364f2042013-11-20 21:49:41 +0000292 if (fail_create_channel_) {
293 return -1;
294 }
buildbot@webrtc.orgaf6640f2014-04-28 21:31:51 +0000295 Channel* ch = new Channel();
solenberg26c8c912015-11-27 04:00:25 -0800296 auto db = webrtc::acm2::RentACodec::Database();
297 ch->recv_codecs.assign(db.begin(), db.end());
Henrik Lundin64dad832015-05-11 12:44:23 +0200298 if (config.Get<webrtc::NetEqCapacityConfig>().enabled) {
299 ch->neteq_capacity = config.Get<webrtc::NetEqCapacityConfig>().capacity;
300 }
Henrik Lundin5263b3c2015-06-01 10:29:41 +0200301 ch->neteq_fast_accelerate =
302 config.Get<webrtc::NetEqFastAccelerate>().enabled;
wu@webrtc.org364f2042013-11-20 21:49:41 +0000303 channels_[++last_channel_] = ch;
304 return last_channel_;
305 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000306
wu@webrtc.org05e7b442014-04-01 17:44:24 +0000307 int GetNumSetSendCodecs() const { return num_set_send_codecs_; }
308
Minyue2013aec2015-05-13 14:14:42 +0200309 int GetAssociateSendChannel(int channel) {
310 return channels_[channel]->associate_send_channel;
311 }
312
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000313 WEBRTC_STUB(Release, ());
314
315 // webrtc::VoEBase
316 WEBRTC_FUNC(RegisterVoiceEngineObserver, (
317 webrtc::VoiceEngineObserver& observer)) {
318 observer_ = &observer;
319 return 0;
320 }
321 WEBRTC_STUB(DeRegisterVoiceEngineObserver, ());
322 WEBRTC_FUNC(Init, (webrtc::AudioDeviceModule* adm,
323 webrtc::AudioProcessing* audioproc)) {
324 inited_ = true;
325 return 0;
326 }
327 WEBRTC_FUNC(Terminate, ()) {
328 inited_ = false;
329 return 0;
330 }
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000331 webrtc::AudioProcessing* audio_processing() override {
buildbot@webrtc.orga8d8ad22014-07-16 14:23:08 +0000332 return &audio_processing_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000333 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000334 WEBRTC_FUNC(CreateChannel, ()) {
Henrik Lundin64dad832015-05-11 12:44:23 +0200335 webrtc::Config empty_config;
336 return AddChannel(empty_config);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000337 }
Henrik Lundin64dad832015-05-11 12:44:23 +0200338 WEBRTC_FUNC(CreateChannel, (const webrtc::Config& config)) {
339 return AddChannel(config);
wu@webrtc.org364f2042013-11-20 21:49:41 +0000340 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000341 WEBRTC_FUNC(DeleteChannel, (int channel)) {
342 WEBRTC_CHECK_CHANNEL(channel);
Minyue2013aec2015-05-13 14:14:42 +0200343 for (const auto& ch : channels_) {
344 if (ch.second->associate_send_channel == channel) {
345 ch.second->associate_send_channel = -1;
346 }
347 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000348 delete channels_[channel];
349 channels_.erase(channel);
350 return 0;
351 }
352 WEBRTC_STUB(StartReceive, (int channel));
353 WEBRTC_FUNC(StartPlayout, (int channel)) {
354 if (playout_fail_channel_ != channel) {
355 WEBRTC_CHECK_CHANNEL(channel);
356 channels_[channel]->playout = true;
357 return 0;
358 } else {
359 // When playout_fail_channel_ == channel, fail the StartPlayout on this
360 // channel.
361 return -1;
362 }
363 }
364 WEBRTC_FUNC(StartSend, (int channel)) {
365 if (send_fail_channel_ != channel) {
366 WEBRTC_CHECK_CHANNEL(channel);
367 channels_[channel]->send = true;
368 return 0;
369 } else {
370 // When send_fail_channel_ == channel, fail the StartSend on this
371 // channel.
372 return -1;
373 }
374 }
375 WEBRTC_STUB(StopReceive, (int channel));
376 WEBRTC_FUNC(StopPlayout, (int channel)) {
377 WEBRTC_CHECK_CHANNEL(channel);
378 channels_[channel]->playout = false;
379 return 0;
380 }
381 WEBRTC_FUNC(StopSend, (int channel)) {
382 WEBRTC_CHECK_CHANNEL(channel);
383 channels_[channel]->send = false;
384 return 0;
385 }
386 WEBRTC_STUB(GetVersion, (char version[1024]));
387 WEBRTC_STUB(LastError, ());
Minyue2013aec2015-05-13 14:14:42 +0200388 WEBRTC_FUNC(AssociateSendChannel, (int channel,
389 int accociate_send_channel)) {
390 WEBRTC_CHECK_CHANNEL(channel);
391 channels_[channel]->associate_send_channel = accociate_send_channel;
392 return 0;
393 }
ivocb04965c2015-09-09 00:09:43 -0700394 webrtc::RtcEventLog* GetEventLog() { return nullptr; }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000395
396 // webrtc::VoECodec
solenberg26c8c912015-11-27 04:00:25 -0800397 WEBRTC_STUB(NumOfCodecs, ());
398 WEBRTC_STUB(GetCodec, (int index, webrtc::CodecInst& codec));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000399 WEBRTC_FUNC(SetSendCodec, (int channel, const webrtc::CodecInst& codec)) {
400 WEBRTC_CHECK_CHANNEL(channel);
henrike@webrtc.org704bf9e2014-02-27 17:52:04 +0000401 // To match the behavior of the real implementation.
402 if (_stricmp(codec.plname, "telephone-event") == 0 ||
403 _stricmp(codec.plname, "audio/telephone-event") == 0 ||
404 _stricmp(codec.plname, "CN") == 0 ||
405 _stricmp(codec.plname, "red") == 0 ) {
406 return -1;
407 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000408 channels_[channel]->send_codec = codec;
wu@webrtc.org05e7b442014-04-01 17:44:24 +0000409 ++num_set_send_codecs_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000410 return 0;
411 }
412 WEBRTC_FUNC(GetSendCodec, (int channel, webrtc::CodecInst& codec)) {
413 WEBRTC_CHECK_CHANNEL(channel);
414 codec = channels_[channel]->send_codec;
415 return 0;
416 }
Ivo Creusenadf89b72015-04-29 16:03:33 +0200417 WEBRTC_STUB(SetBitRate, (int channel, int bitrate_bps));
Fredrik Solenberg4f4ec0a2015-10-22 10:49:27 +0200418 WEBRTC_STUB(GetRecCodec, (int channel, webrtc::CodecInst& codec));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000419 WEBRTC_FUNC(SetRecPayloadType, (int channel,
420 const webrtc::CodecInst& codec)) {
421 WEBRTC_CHECK_CHANNEL(channel);
422 Channel* ch = channels_[channel];
423 if (ch->playout)
424 return -1; // Channel is in use.
425 // Check if something else already has this slot.
426 if (codec.pltype != -1) {
427 for (std::vector<webrtc::CodecInst>::iterator it =
428 ch->recv_codecs.begin(); it != ch->recv_codecs.end(); ++it) {
429 if (it->pltype == codec.pltype &&
430 _stricmp(it->plname, codec.plname) != 0) {
431 return -1;
432 }
433 }
434 }
435 // Otherwise try to find this codec and update its payload type.
solenberg26c8c912015-11-27 04:00:25 -0800436 int result = -1; // not found
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000437 for (std::vector<webrtc::CodecInst>::iterator it = ch->recv_codecs.begin();
438 it != ch->recv_codecs.end(); ++it) {
439 if (strcmp(it->plname, codec.plname) == 0 &&
solenberg26c8c912015-11-27 04:00:25 -0800440 it->plfreq == codec.plfreq &&
441 it->channels == codec.channels) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000442 it->pltype = codec.pltype;
solenberg26c8c912015-11-27 04:00:25 -0800443 result = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000444 }
445 }
solenberg26c8c912015-11-27 04:00:25 -0800446 return result;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000447 }
448 WEBRTC_FUNC(SetSendCNPayloadType, (int channel, int type,
449 webrtc::PayloadFrequencies frequency)) {
450 WEBRTC_CHECK_CHANNEL(channel);
451 if (frequency == webrtc::kFreq8000Hz) {
452 channels_[channel]->cn8_type = type;
453 } else if (frequency == webrtc::kFreq16000Hz) {
454 channels_[channel]->cn16_type = type;
455 }
456 return 0;
457 }
458 WEBRTC_FUNC(GetRecPayloadType, (int channel, webrtc::CodecInst& codec)) {
459 WEBRTC_CHECK_CHANNEL(channel);
460 Channel* ch = channels_[channel];
461 for (std::vector<webrtc::CodecInst>::iterator it = ch->recv_codecs.begin();
462 it != ch->recv_codecs.end(); ++it) {
463 if (strcmp(it->plname, codec.plname) == 0 &&
464 it->plfreq == codec.plfreq &&
465 it->channels == codec.channels &&
466 it->pltype != -1) {
467 codec.pltype = it->pltype;
468 return 0;
469 }
470 }
471 return -1; // not found
472 }
473 WEBRTC_FUNC(SetVADStatus, (int channel, bool enable, webrtc::VadModes mode,
474 bool disableDTX)) {
475 WEBRTC_CHECK_CHANNEL(channel);
476 if (channels_[channel]->send_codec.channels == 2) {
477 // Replicating VoE behavior; VAD cannot be enabled for stereo.
478 return -1;
479 }
480 channels_[channel]->vad = enable;
481 return 0;
482 }
483 WEBRTC_STUB(GetVADStatus, (int channel, bool& enabled,
484 webrtc::VadModes& mode, bool& disabledDTX));
buildbot@webrtc.org5d639b32014-09-10 07:57:12 +0000485
buildbot@webrtc.orgae740dd2014-06-17 10:56:41 +0000486 WEBRTC_FUNC(SetFECStatus, (int channel, bool enable)) {
487 WEBRTC_CHECK_CHANNEL(channel);
buildbot@webrtc.org5d639b32014-09-10 07:57:12 +0000488 if (_stricmp(channels_[channel]->send_codec.plname, "opus") != 0) {
buildbot@webrtc.org3ffa1f92014-07-02 19:51:26 +0000489 // Return -1 if current send codec is not Opus.
490 // TODO(minyue): Excludes other codecs if they support inband FEC.
491 return -1;
492 }
buildbot@webrtc.orgae740dd2014-06-17 10:56:41 +0000493 channels_[channel]->codec_fec = enable;
494 return 0;
495 }
496 WEBRTC_FUNC(GetFECStatus, (int channel, bool& enable)) {
497 WEBRTC_CHECK_CHANNEL(channel);
498 enable = channels_[channel]->codec_fec;
499 return 0;
500 }
buildbot@webrtc.org5d639b32014-09-10 07:57:12 +0000501
502 WEBRTC_FUNC(SetOpusMaxPlaybackRate, (int channel, int frequency_hz)) {
503 WEBRTC_CHECK_CHANNEL(channel);
504 if (_stricmp(channels_[channel]->send_codec.plname, "opus") != 0) {
505 // Return -1 if current send codec is not Opus.
506 return -1;
507 }
508 if (frequency_hz <= 8000)
509 channels_[channel]->max_encoding_bandwidth = kOpusBandwidthNb;
510 else if (frequency_hz <= 12000)
511 channels_[channel]->max_encoding_bandwidth = kOpusBandwidthMb;
512 else if (frequency_hz <= 16000)
513 channels_[channel]->max_encoding_bandwidth = kOpusBandwidthWb;
514 else if (frequency_hz <= 24000)
515 channels_[channel]->max_encoding_bandwidth = kOpusBandwidthSwb;
516 else
517 channels_[channel]->max_encoding_bandwidth = kOpusBandwidthFb;
518 return 0;
519 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000520
minyue@webrtc.org9b2e1142015-03-13 09:38:07 +0000521 WEBRTC_FUNC(SetOpusDtx, (int channel, bool enable_dtx)) {
522 WEBRTC_CHECK_CHANNEL(channel);
523 if (_stricmp(channels_[channel]->send_codec.plname, "opus") != 0) {
524 // Return -1 if current send codec is not Opus.
525 return -1;
526 }
527 channels_[channel]->opus_dtx = enable_dtx;
528 return 0;
529 }
530
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000531 // webrtc::VoEHardware
solenberg246b8172015-12-08 09:50:23 -0800532 WEBRTC_STUB(GetNumOfRecordingDevices, (int& num));
533 WEBRTC_STUB(GetNumOfPlayoutDevices, (int& num));
534 WEBRTC_STUB(GetRecordingDeviceName, (int i, char* name, char* guid));
535 WEBRTC_STUB(GetPlayoutDeviceName, (int i, char* name, char* guid));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000536 WEBRTC_STUB(SetRecordingDevice, (int, webrtc::StereoChannel));
537 WEBRTC_STUB(SetPlayoutDevice, (int));
538 WEBRTC_STUB(SetAudioDeviceLayer, (webrtc::AudioLayers));
539 WEBRTC_STUB(GetAudioDeviceLayer, (webrtc::AudioLayers&));
wu@webrtc.org97077a32013-10-25 21:18:33 +0000540 WEBRTC_FUNC(SetRecordingSampleRate, (unsigned int samples_per_sec)) {
541 recording_sample_rate_ = samples_per_sec;
542 return 0;
543 }
544 WEBRTC_FUNC_CONST(RecordingSampleRate, (unsigned int* samples_per_sec)) {
545 *samples_per_sec = recording_sample_rate_;
546 return 0;
547 }
548 WEBRTC_FUNC(SetPlayoutSampleRate, (unsigned int samples_per_sec)) {
549 playout_sample_rate_ = samples_per_sec;
550 return 0;
551 }
552 WEBRTC_FUNC_CONST(PlayoutSampleRate, (unsigned int* samples_per_sec)) {
553 *samples_per_sec = playout_sample_rate_;
554 return 0;
555 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000556 WEBRTC_STUB(EnableBuiltInAEC, (bool enable));
henrika@webrtc.orga954c072014-12-09 16:22:09 +0000557 virtual bool BuiltInAECIsAvailable() const { return false; }
henrikac14f5ff2015-09-23 14:08:33 +0200558 WEBRTC_STUB(EnableBuiltInAGC, (bool enable));
559 virtual bool BuiltInAGCIsAvailable() const { return false; }
560 WEBRTC_STUB(EnableBuiltInNS, (bool enable));
561 virtual bool BuiltInNSIsAvailable() const { return false; }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000562
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000563 // webrtc::VoENetwork
564 WEBRTC_FUNC(RegisterExternalTransport, (int channel,
565 webrtc::Transport& transport)) {
566 WEBRTC_CHECK_CHANNEL(channel);
567 channels_[channel]->external_transport = true;
568 return 0;
569 }
570 WEBRTC_FUNC(DeRegisterExternalTransport, (int channel)) {
571 WEBRTC_CHECK_CHANNEL(channel);
572 channels_[channel]->external_transport = false;
573 return 0;
574 }
575 WEBRTC_FUNC(ReceivedRTPPacket, (int channel, const void* data,
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +0000576 size_t length)) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000577 WEBRTC_CHECK_CHANNEL(channel);
578 if (!channels_[channel]->external_transport) return -1;
579 channels_[channel]->packets.push_back(
580 std::string(static_cast<const char*>(data), length));
581 return 0;
582 }
buildbot@webrtc.orgf875f152014-04-14 16:06:21 +0000583 WEBRTC_FUNC(ReceivedRTPPacket, (int channel, const void* data,
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +0000584 size_t length,
buildbot@webrtc.orgf875f152014-04-14 16:06:21 +0000585 const webrtc::PacketTime& packet_time)) {
586 WEBRTC_CHECK_CHANNEL(channel);
587 if (ReceivedRTPPacket(channel, data, length) == -1) {
588 return -1;
589 }
590 channels_[channel]->last_rtp_packet_time = packet_time;
591 return 0;
592 }
buildbot@webrtc.orgf875f152014-04-14 16:06:21 +0000593
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000594 WEBRTC_STUB(ReceivedRTCPPacket, (int channel, const void* data,
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +0000595 size_t length));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000596
597 // webrtc::VoERTP_RTCP
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000598 WEBRTC_FUNC(SetLocalSSRC, (int channel, unsigned int ssrc)) {
599 WEBRTC_CHECK_CHANNEL(channel);
600 channels_[channel]->send_ssrc = ssrc;
601 return 0;
602 }
solenberg85a04962015-10-27 03:35:21 -0700603 WEBRTC_STUB(GetLocalSSRC, (int channel, unsigned int& ssrc));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000604 WEBRTC_STUB(GetRemoteSSRC, (int channel, unsigned int& ssrc));
solenberg3a941542015-11-16 07:34:50 -0800605 WEBRTC_STUB(SetSendAudioLevelIndicationStatus, (int channel, bool enable,
606 unsigned char id));
solenberg7add0582015-11-20 09:59:34 -0800607 WEBRTC_STUB(SetReceiveAudioLevelIndicationStatus, (int channel, bool enable,
608 unsigned char id));
solenberg3a941542015-11-16 07:34:50 -0800609 WEBRTC_STUB(SetSendAbsoluteSenderTimeStatus, (int channel, bool enable,
610 unsigned char id));
solenberg7add0582015-11-20 09:59:34 -0800611 WEBRTC_STUB(SetReceiveAbsoluteSenderTimeStatus, (int channel, bool enable,
612 unsigned char id));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000613 WEBRTC_STUB(SetRTCPStatus, (int channel, bool enable));
614 WEBRTC_STUB(GetRTCPStatus, (int channel, bool& enabled));
615 WEBRTC_STUB(SetRTCP_CNAME, (int channel, const char cname[256]));
616 WEBRTC_STUB(GetRTCP_CNAME, (int channel, char cname[256]));
617 WEBRTC_STUB(GetRemoteRTCP_CNAME, (int channel, char* cname));
618 WEBRTC_STUB(GetRemoteRTCPData, (int channel, unsigned int& NTPHigh,
619 unsigned int& NTPLow,
620 unsigned int& timestamp,
621 unsigned int& playoutTimestamp,
622 unsigned int* jitter,
623 unsigned short* fractionLost));
solenberg85a04962015-10-27 03:35:21 -0700624 WEBRTC_STUB(GetRemoteRTCPReportBlocks,
625 (int channel, std::vector<webrtc::ReportBlock>* receive_blocks));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000626 WEBRTC_STUB(GetRTPStatistics, (int channel, unsigned int& averageJitterMs,
627 unsigned int& maxJitterMs,
628 unsigned int& discardedPackets));
solenberg85a04962015-10-27 03:35:21 -0700629 WEBRTC_STUB(GetRTCPStatistics, (int channel, webrtc::CallStatistics& stats));
buildbot@webrtc.orgae740dd2014-06-17 10:56:41 +0000630 WEBRTC_FUNC(SetREDStatus, (int channel, bool enable, int redPayloadtype)) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000631 WEBRTC_CHECK_CHANNEL(channel);
buildbot@webrtc.orgae740dd2014-06-17 10:56:41 +0000632 channels_[channel]->red = enable;
633 channels_[channel]->red_type = redPayloadtype;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000634 return 0;
635 }
buildbot@webrtc.orgae740dd2014-06-17 10:56:41 +0000636 WEBRTC_FUNC(GetREDStatus, (int channel, bool& enable, int& redPayloadtype)) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000637 WEBRTC_CHECK_CHANNEL(channel);
buildbot@webrtc.orgae740dd2014-06-17 10:56:41 +0000638 enable = channels_[channel]->red;
639 redPayloadtype = channels_[channel]->red_type;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000640 return 0;
641 }
642 WEBRTC_FUNC(SetNACKStatus, (int channel, bool enable, int maxNoPackets)) {
643 WEBRTC_CHECK_CHANNEL(channel);
644 channels_[channel]->nack = enable;
645 channels_[channel]->nack_max_packets = maxNoPackets;
646 return 0;
647 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000648
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000649 // webrtc::VoEVolumeControl
650 WEBRTC_STUB(SetSpeakerVolume, (unsigned int));
651 WEBRTC_STUB(GetSpeakerVolume, (unsigned int&));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000652 WEBRTC_STUB(SetMicVolume, (unsigned int));
653 WEBRTC_STUB(GetMicVolume, (unsigned int&));
654 WEBRTC_STUB(SetInputMute, (int, bool));
655 WEBRTC_STUB(GetInputMute, (int, bool&));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000656 WEBRTC_STUB(GetSpeechInputLevel, (unsigned int&));
657 WEBRTC_STUB(GetSpeechOutputLevel, (int, unsigned int&));
658 WEBRTC_STUB(GetSpeechInputLevelFullRange, (unsigned int&));
659 WEBRTC_STUB(GetSpeechOutputLevelFullRange, (int, unsigned int&));
660 WEBRTC_FUNC(SetChannelOutputVolumeScaling, (int channel, float scale)) {
661 WEBRTC_CHECK_CHANNEL(channel);
662 channels_[channel]->volume_scale= scale;
663 return 0;
664 }
665 WEBRTC_FUNC(GetChannelOutputVolumeScaling, (int channel, float& scale)) {
666 WEBRTC_CHECK_CHANNEL(channel);
667 scale = channels_[channel]->volume_scale;
668 return 0;
669 }
solenberg4bac9c52015-10-09 02:32:53 -0700670 WEBRTC_STUB(SetOutputVolumePan, (int channel, float left, float right));
671 WEBRTC_STUB(GetOutputVolumePan, (int channel, float& left, float& right));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000672
673 // webrtc::VoEAudioProcessing
674 WEBRTC_FUNC(SetNsStatus, (bool enable, webrtc::NsModes mode)) {
675 ns_enabled_ = enable;
676 ns_mode_ = mode;
677 return 0;
678 }
679 WEBRTC_FUNC(GetNsStatus, (bool& enabled, webrtc::NsModes& mode)) {
680 enabled = ns_enabled_;
681 mode = ns_mode_;
682 return 0;
683 }
684
685 WEBRTC_FUNC(SetAgcStatus, (bool enable, webrtc::AgcModes mode)) {
686 agc_enabled_ = enable;
687 agc_mode_ = mode;
688 return 0;
689 }
690 WEBRTC_FUNC(GetAgcStatus, (bool& enabled, webrtc::AgcModes& mode)) {
691 enabled = agc_enabled_;
692 mode = agc_mode_;
693 return 0;
694 }
695
696 WEBRTC_FUNC(SetAgcConfig, (webrtc::AgcConfig config)) {
697 agc_config_ = config;
698 return 0;
699 }
700 WEBRTC_FUNC(GetAgcConfig, (webrtc::AgcConfig& config)) {
701 config = agc_config_;
702 return 0;
703 }
704 WEBRTC_FUNC(SetEcStatus, (bool enable, webrtc::EcModes mode)) {
705 ec_enabled_ = enable;
706 ec_mode_ = mode;
707 return 0;
708 }
709 WEBRTC_FUNC(GetEcStatus, (bool& enabled, webrtc::EcModes& mode)) {
710 enabled = ec_enabled_;
711 mode = ec_mode_;
712 return 0;
713 }
714 WEBRTC_STUB(EnableDriftCompensation, (bool enable))
715 WEBRTC_BOOL_STUB(DriftCompensationEnabled, ())
716 WEBRTC_VOID_STUB(SetDelayOffsetMs, (int offset))
717 WEBRTC_STUB(DelayOffsetMs, ());
718 WEBRTC_FUNC(SetAecmMode, (webrtc::AecmModes mode, bool enableCNG)) {
719 aecm_mode_ = mode;
720 cng_enabled_ = enableCNG;
721 return 0;
722 }
723 WEBRTC_FUNC(GetAecmMode, (webrtc::AecmModes& mode, bool& enabledCNG)) {
724 mode = aecm_mode_;
725 enabledCNG = cng_enabled_;
726 return 0;
727 }
728 WEBRTC_STUB(SetRxNsStatus, (int channel, bool enable, webrtc::NsModes mode));
729 WEBRTC_STUB(GetRxNsStatus, (int channel, bool& enabled,
730 webrtc::NsModes& mode));
solenberg0b675462015-10-09 01:37:09 -0700731 WEBRTC_STUB(SetRxAgcStatus, (int channel, bool enable,
732 webrtc::AgcModes mode));
733 WEBRTC_STUB(GetRxAgcStatus, (int channel, bool& enabled,
734 webrtc::AgcModes& mode));
735 WEBRTC_STUB(SetRxAgcConfig, (int channel, webrtc::AgcConfig config));
736 WEBRTC_STUB(GetRxAgcConfig, (int channel, webrtc::AgcConfig& config));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000737
738 WEBRTC_STUB(RegisterRxVadObserver, (int, webrtc::VoERxVadCallback&));
739 WEBRTC_STUB(DeRegisterRxVadObserver, (int channel));
740 WEBRTC_STUB(VoiceActivityIndicator, (int channel));
741 WEBRTC_FUNC(SetEcMetricsStatus, (bool enable)) {
742 ec_metrics_enabled_ = enable;
743 return 0;
744 }
solenberg85a04962015-10-27 03:35:21 -0700745 WEBRTC_STUB(GetEcMetricsStatus, (bool& enabled));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000746 WEBRTC_STUB(GetEchoMetrics, (int& ERL, int& ERLE, int& RERL, int& A_NLP));
bjornv@webrtc.orgcc64a9c2015-02-05 12:52:44 +0000747 WEBRTC_STUB(GetEcDelayMetrics, (int& delay_median, int& delay_std,
748 float& fraction_poor_delays));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000749
750 WEBRTC_STUB(StartDebugRecording, (const char* fileNameUTF8));
wu@webrtc.org9caf2762013-12-11 18:25:07 +0000751 WEBRTC_STUB(StartDebugRecording, (FILE* handle));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000752 WEBRTC_STUB(StopDebugRecording, ());
753
754 WEBRTC_FUNC(SetTypingDetectionStatus, (bool enable)) {
755 typing_detection_enabled_ = enable;
756 return 0;
757 }
758 WEBRTC_FUNC(GetTypingDetectionStatus, (bool& enabled)) {
759 enabled = typing_detection_enabled_;
760 return 0;
761 }
762
763 WEBRTC_STUB(TimeSinceLastTyping, (int& seconds));
764 WEBRTC_STUB(SetTypingDetectionParameters, (int timeWindow,
765 int costPerTyping,
766 int reportingThreshold,
767 int penaltyDecay,
768 int typeEventDelay));
769 int EnableHighPassFilter(bool enable) {
770 highpass_filter_enabled_ = enable;
771 return 0;
772 }
773 bool IsHighPassFilterEnabled() {
774 return highpass_filter_enabled_;
775 }
776 bool IsStereoChannelSwappingEnabled() {
777 return stereo_swapping_enabled_;
778 }
779 void EnableStereoChannelSwapping(bool enable) {
780 stereo_swapping_enabled_ = enable;
781 }
Henrik Lundin64dad832015-05-11 12:44:23 +0200782 int GetNetEqCapacity() const {
783 auto ch = channels_.find(last_channel_);
784 ASSERT(ch != channels_.end());
785 return ch->second->neteq_capacity;
786 }
Henrik Lundin5263b3c2015-06-01 10:29:41 +0200787 bool GetNetEqFastAccelerate() const {
788 auto ch = channels_.find(last_channel_);
789 ASSERT(ch != channels_.end());
790 return ch->second->neteq_fast_accelerate;
791 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000792
793 private:
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000794 bool inited_;
795 int last_channel_;
796 std::map<int, Channel*> channels_;
797 bool fail_create_channel_;
wu@webrtc.org05e7b442014-04-01 17:44:24 +0000798 int num_set_send_codecs_; // how many times we call SetSendCodec().
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000799 bool ec_enabled_;
800 bool ec_metrics_enabled_;
801 bool cng_enabled_;
802 bool ns_enabled_;
803 bool agc_enabled_;
804 bool highpass_filter_enabled_;
805 bool stereo_swapping_enabled_;
806 bool typing_detection_enabled_;
807 webrtc::EcModes ec_mode_;
808 webrtc::AecmModes aecm_mode_;
809 webrtc::NsModes ns_mode_;
810 webrtc::AgcModes agc_mode_;
811 webrtc::AgcConfig agc_config_;
812 webrtc::VoiceEngineObserver* observer_;
813 int playout_fail_channel_;
814 int send_fail_channel_;
wu@webrtc.org97077a32013-10-25 21:18:33 +0000815 int recording_sample_rate_;
816 int playout_sample_rate_;
buildbot@webrtc.orga8d8ad22014-07-16 14:23:08 +0000817 FakeAudioProcessing audio_processing_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000818};
819
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000820} // namespace cricket
821
822#endif // TALK_SESSION_PHONE_FAKEWEBRTCVOICEENGINE_H_