blob: bf22a290b89673cc245ff05d717ac94d161433e3 [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
peah66085be2015-12-16 02:02:20 -080077 WEBRTC_STUB_CONST(input_sample_rate_hz, ());
buildbot@webrtc.orga8d8ad22014-07-16 14:23:08 +000078 WEBRTC_STUB_CONST(proc_sample_rate_hz, ());
79 WEBRTC_STUB_CONST(proc_split_sample_rate_hz, ());
80 WEBRTC_STUB_CONST(num_input_channels, ());
81 WEBRTC_STUB_CONST(num_output_channels, ());
82 WEBRTC_STUB_CONST(num_reverse_channels, ());
83 WEBRTC_VOID_STUB(set_output_will_be_muted, (bool muted));
buildbot@webrtc.orga8d8ad22014-07-16 14:23:08 +000084 WEBRTC_STUB(ProcessStream, (webrtc::AudioFrame* frame));
85 WEBRTC_STUB(ProcessStream, (
86 const float* const* src,
Peter Kastingdce40cf2015-08-24 14:52:23 -070087 size_t samples_per_channel,
buildbot@webrtc.orga8d8ad22014-07-16 14:23:08 +000088 int input_sample_rate_hz,
89 webrtc::AudioProcessing::ChannelLayout input_layout,
90 int output_sample_rate_hz,
91 webrtc::AudioProcessing::ChannelLayout output_layout,
92 float* const* dest));
Michael Graczyk86c6d332015-07-23 11:41:39 -070093 WEBRTC_STUB(ProcessStream,
94 (const float* const* src,
95 const webrtc::StreamConfig& input_config,
96 const webrtc::StreamConfig& output_config,
97 float* const* dest));
buildbot@webrtc.orga8d8ad22014-07-16 14:23:08 +000098 WEBRTC_STUB(AnalyzeReverseStream, (webrtc::AudioFrame* frame));
ekmeyerson60d9b332015-08-14 10:35:55 -070099 WEBRTC_STUB(ProcessReverseStream, (webrtc::AudioFrame * frame));
buildbot@webrtc.orga8d8ad22014-07-16 14:23:08 +0000100 WEBRTC_STUB(AnalyzeReverseStream, (
101 const float* const* data,
Peter Kastingdce40cf2015-08-24 14:52:23 -0700102 size_t samples_per_channel,
buildbot@webrtc.orga8d8ad22014-07-16 14:23:08 +0000103 int sample_rate_hz,
104 webrtc::AudioProcessing::ChannelLayout layout));
ekmeyerson60d9b332015-08-14 10:35:55 -0700105 WEBRTC_STUB(ProcessReverseStream,
106 (const float* const* src,
107 const webrtc::StreamConfig& reverse_input_config,
108 const webrtc::StreamConfig& reverse_output_config,
109 float* const* dest));
buildbot@webrtc.orga8d8ad22014-07-16 14:23:08 +0000110 WEBRTC_STUB(set_stream_delay_ms, (int delay));
111 WEBRTC_STUB_CONST(stream_delay_ms, ());
112 WEBRTC_BOOL_STUB_CONST(was_stream_delay_set, ());
113 WEBRTC_VOID_STUB(set_stream_key_pressed, (bool key_pressed));
buildbot@webrtc.orga8d8ad22014-07-16 14:23:08 +0000114 WEBRTC_VOID_STUB(set_delay_offset_ms, (int offset));
115 WEBRTC_STUB_CONST(delay_offset_ms, ());
116 WEBRTC_STUB(StartDebugRecording, (const char filename[kMaxFilenameSize]));
117 WEBRTC_STUB(StartDebugRecording, (FILE* handle));
118 WEBRTC_STUB(StopDebugRecording, ());
Bjorn Volcker4e7aa432015-07-07 11:50:05 +0200119 WEBRTC_VOID_STUB(UpdateHistogramsOnCallEnd, ());
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000120 webrtc::EchoCancellation* echo_cancellation() const override { return NULL; }
121 webrtc::EchoControlMobile* echo_control_mobile() const override {
buildbot@webrtc.orga8d8ad22014-07-16 14:23:08 +0000122 return NULL;
123 }
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000124 webrtc::GainControl* gain_control() const override { return NULL; }
125 webrtc::HighPassFilter* high_pass_filter() const override { return NULL; }
126 webrtc::LevelEstimator* level_estimator() const override { return NULL; }
127 webrtc::NoiseSuppression* noise_suppression() const override { return NULL; }
128 webrtc::VoiceDetection* voice_detection() const override { return NULL; }
buildbot@webrtc.orga8d8ad22014-07-16 14:23:08 +0000129
130 bool experimental_ns_enabled() {
131 return experimental_ns_enabled_;
132 }
133
134 private:
135 bool experimental_ns_enabled_;
136};
buildbot@webrtc.orga8d8ad22014-07-16 14:23:08 +0000137
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000138class FakeWebRtcVoiceEngine
139 : public webrtc::VoEAudioProcessing,
Fredrik Solenbergb5727682015-12-04 15:22:19 +0100140 public webrtc::VoEBase, public webrtc::VoECodec,
Fredrik Solenberg4f4ec0a2015-10-22 10:49:27 +0200141 public webrtc::VoEHardware,
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000142 public webrtc::VoENetwork, public webrtc::VoERTP_RTCP,
Fredrik Solenberg4f4ec0a2015-10-22 10:49:27 +0200143 public webrtc::VoEVolumeControl {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000144 public:
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000145 struct Channel {
buildbot@webrtc.orgaf6640f2014-04-28 21:31:51 +0000146 explicit Channel()
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000147 : external_transport(false),
148 send(false),
149 playout(false),
150 volume_scale(1.0),
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000151 vad(false),
buildbot@webrtc.orgae740dd2014-06-17 10:56:41 +0000152 codec_fec(false),
buildbot@webrtc.org5d639b32014-09-10 07:57:12 +0000153 max_encoding_bandwidth(0),
minyue@webrtc.org9b2e1142015-03-13 09:38:07 +0000154 opus_dtx(false),
buildbot@webrtc.orgae740dd2014-06-17 10:56:41 +0000155 red(false),
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000156 nack(false),
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000157 cn8_type(13),
158 cn16_type(105),
buildbot@webrtc.orgae740dd2014-06-17 10:56:41 +0000159 red_type(117),
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000160 nack_max_packets(0),
161 send_ssrc(0),
Minyue2013aec2015-05-13 14:14:42 +0200162 associate_send_channel(-1),
solenberg26c8c912015-11-27 04:00:25 -0800163 recv_codecs(),
Henrik Lundin5263b3c2015-06-01 10:29:41 +0200164 neteq_capacity(-1),
165 neteq_fast_accelerate(false) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000166 memset(&send_codec, 0, sizeof(send_codec));
167 }
168 bool external_transport;
169 bool send;
170 bool playout;
171 float volume_scale;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000172 bool vad;
buildbot@webrtc.orgae740dd2014-06-17 10:56:41 +0000173 bool codec_fec;
buildbot@webrtc.org5d639b32014-09-10 07:57:12 +0000174 int max_encoding_bandwidth;
minyue@webrtc.org9b2e1142015-03-13 09:38:07 +0000175 bool opus_dtx;
buildbot@webrtc.orgae740dd2014-06-17 10:56:41 +0000176 bool red;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000177 bool nack;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000178 int cn8_type;
179 int cn16_type;
buildbot@webrtc.orgae740dd2014-06-17 10:56:41 +0000180 int red_type;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000181 int nack_max_packets;
Peter Boström0c4e06b2015-10-07 12:23:21 +0200182 uint32_t send_ssrc;
Minyue2013aec2015-05-13 14:14:42 +0200183 int associate_send_channel;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000184 std::vector<webrtc::CodecInst> recv_codecs;
185 webrtc::CodecInst send_codec;
buildbot@webrtc.orgf875f152014-04-14 16:06:21 +0000186 webrtc::PacketTime last_rtp_packet_time;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000187 std::list<std::string> packets;
Henrik Lundin64dad832015-05-11 12:44:23 +0200188 int neteq_capacity;
Henrik Lundin5263b3c2015-06-01 10:29:41 +0200189 bool neteq_fast_accelerate;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000190 };
191
solenberg26c8c912015-11-27 04:00:25 -0800192 FakeWebRtcVoiceEngine()
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000193 : inited_(false),
194 last_channel_(-1),
195 fail_create_channel_(false),
wu@webrtc.org05e7b442014-04-01 17:44:24 +0000196 num_set_send_codecs_(0),
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000197 ec_enabled_(false),
198 ec_metrics_enabled_(false),
199 cng_enabled_(false),
200 ns_enabled_(false),
201 agc_enabled_(false),
202 highpass_filter_enabled_(false),
203 stereo_swapping_enabled_(false),
204 typing_detection_enabled_(false),
205 ec_mode_(webrtc::kEcDefault),
206 aecm_mode_(webrtc::kAecmSpeakerphone),
207 ns_mode_(webrtc::kNsDefault),
208 agc_mode_(webrtc::kAgcDefault),
209 observer_(NULL),
210 playout_fail_channel_(-1),
211 send_fail_channel_(-1),
wu@webrtc.org97077a32013-10-25 21:18:33 +0000212 recording_sample_rate_(-1),
Fredrik Solenberg7d173362015-09-23 12:23:21 +0200213 playout_sample_rate_(-1) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000214 memset(&agc_config_, 0, sizeof(agc_config_));
215 }
216 ~FakeWebRtcVoiceEngine() {
solenberg26c8c912015-11-27 04:00:25 -0800217 RTC_CHECK(channels_.empty());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000218 }
219
solenberg85a04962015-10-27 03:35:21 -0700220 bool ec_metrics_enabled() const { return ec_metrics_enabled_; }
221
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000222 bool IsInited() const { return inited_; }
223 int GetLastChannel() const { return last_channel_; }
wu@webrtc.org9caf2762013-12-11 18:25:07 +0000224 int GetNumChannels() const { return static_cast<int>(channels_.size()); }
solenberg85a04962015-10-27 03:35:21 -0700225 uint32_t GetLocalSSRC(int channel) {
226 return channels_[channel]->send_ssrc;
227 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000228 bool GetPlayout(int channel) {
229 return channels_[channel]->playout;
230 }
231 bool GetSend(int channel) {
232 return channels_[channel]->send;
233 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000234 bool GetVAD(int channel) {
235 return channels_[channel]->vad;
236 }
Minyue Li7100dcd2015-03-27 05:05:59 +0100237 bool GetOpusDtx(int channel) {
238 return channels_[channel]->opus_dtx;
239 }
buildbot@webrtc.orgae740dd2014-06-17 10:56:41 +0000240 bool GetRED(int channel) {
241 return channels_[channel]->red;
242 }
243 bool GetCodecFEC(int channel) {
244 return channels_[channel]->codec_fec;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000245 }
buildbot@webrtc.org5d639b32014-09-10 07:57:12 +0000246 int GetMaxEncodingBandwidth(int channel) {
247 return channels_[channel]->max_encoding_bandwidth;
248 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000249 bool GetNACK(int channel) {
250 return channels_[channel]->nack;
251 }
252 int GetNACKMaxPackets(int channel) {
253 return channels_[channel]->nack_max_packets;
254 }
buildbot@webrtc.orgf875f152014-04-14 16:06:21 +0000255 const webrtc::PacketTime& GetLastRtpPacketTime(int channel) {
solenberg26c8c912015-11-27 04:00:25 -0800256 RTC_DCHECK(channels_.find(channel) != channels_.end());
buildbot@webrtc.orgf875f152014-04-14 16:06:21 +0000257 return channels_[channel]->last_rtp_packet_time;
258 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000259 int GetSendCNPayloadType(int channel, bool wideband) {
260 return (wideband) ?
261 channels_[channel]->cn16_type :
262 channels_[channel]->cn8_type;
263 }
buildbot@webrtc.orgae740dd2014-06-17 10:56:41 +0000264 int GetSendREDPayloadType(int channel) {
265 return channels_[channel]->red_type;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000266 }
267 bool CheckPacket(int channel, const void* data, size_t len) {
268 bool result = !CheckNoPacket(channel);
269 if (result) {
270 std::string packet = channels_[channel]->packets.front();
271 result = (packet == std::string(static_cast<const char*>(data), len));
272 channels_[channel]->packets.pop_front();
273 }
274 return result;
275 }
276 bool CheckNoPacket(int channel) {
277 return channels_[channel]->packets.empty();
278 }
279 void TriggerCallbackOnError(int channel_num, int err_code) {
henrikg91d6ede2015-09-17 00:24:34 -0700280 RTC_DCHECK(observer_ != NULL);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000281 observer_->CallbackOnError(channel_num, err_code);
282 }
283 void set_playout_fail_channel(int channel) {
284 playout_fail_channel_ = channel;
285 }
286 void set_send_fail_channel(int channel) {
287 send_fail_channel_ = channel;
288 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000289 void set_fail_create_channel(bool fail_create_channel) {
290 fail_create_channel_ = fail_create_channel;
291 }
Henrik Lundin64dad832015-05-11 12:44:23 +0200292 int AddChannel(const webrtc::Config& config) {
wu@webrtc.org364f2042013-11-20 21:49:41 +0000293 if (fail_create_channel_) {
294 return -1;
295 }
buildbot@webrtc.orgaf6640f2014-04-28 21:31:51 +0000296 Channel* ch = new Channel();
solenberg26c8c912015-11-27 04:00:25 -0800297 auto db = webrtc::acm2::RentACodec::Database();
298 ch->recv_codecs.assign(db.begin(), db.end());
Henrik Lundin64dad832015-05-11 12:44:23 +0200299 if (config.Get<webrtc::NetEqCapacityConfig>().enabled) {
300 ch->neteq_capacity = config.Get<webrtc::NetEqCapacityConfig>().capacity;
301 }
Henrik Lundin5263b3c2015-06-01 10:29:41 +0200302 ch->neteq_fast_accelerate =
303 config.Get<webrtc::NetEqFastAccelerate>().enabled;
wu@webrtc.org364f2042013-11-20 21:49:41 +0000304 channels_[++last_channel_] = ch;
305 return last_channel_;
306 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000307
wu@webrtc.org05e7b442014-04-01 17:44:24 +0000308 int GetNumSetSendCodecs() const { return num_set_send_codecs_; }
309
Minyue2013aec2015-05-13 14:14:42 +0200310 int GetAssociateSendChannel(int channel) {
311 return channels_[channel]->associate_send_channel;
312 }
313
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000314 WEBRTC_STUB(Release, ());
315
316 // webrtc::VoEBase
317 WEBRTC_FUNC(RegisterVoiceEngineObserver, (
318 webrtc::VoiceEngineObserver& observer)) {
319 observer_ = &observer;
320 return 0;
321 }
322 WEBRTC_STUB(DeRegisterVoiceEngineObserver, ());
323 WEBRTC_FUNC(Init, (webrtc::AudioDeviceModule* adm,
324 webrtc::AudioProcessing* audioproc)) {
325 inited_ = true;
326 return 0;
327 }
328 WEBRTC_FUNC(Terminate, ()) {
329 inited_ = false;
330 return 0;
331 }
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000332 webrtc::AudioProcessing* audio_processing() override {
buildbot@webrtc.orga8d8ad22014-07-16 14:23:08 +0000333 return &audio_processing_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000334 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000335 WEBRTC_FUNC(CreateChannel, ()) {
Henrik Lundin64dad832015-05-11 12:44:23 +0200336 webrtc::Config empty_config;
337 return AddChannel(empty_config);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000338 }
Henrik Lundin64dad832015-05-11 12:44:23 +0200339 WEBRTC_FUNC(CreateChannel, (const webrtc::Config& config)) {
340 return AddChannel(config);
wu@webrtc.org364f2042013-11-20 21:49:41 +0000341 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000342 WEBRTC_FUNC(DeleteChannel, (int channel)) {
343 WEBRTC_CHECK_CHANNEL(channel);
Minyue2013aec2015-05-13 14:14:42 +0200344 for (const auto& ch : channels_) {
345 if (ch.second->associate_send_channel == channel) {
346 ch.second->associate_send_channel = -1;
347 }
348 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000349 delete channels_[channel];
350 channels_.erase(channel);
351 return 0;
352 }
353 WEBRTC_STUB(StartReceive, (int channel));
354 WEBRTC_FUNC(StartPlayout, (int channel)) {
355 if (playout_fail_channel_ != channel) {
356 WEBRTC_CHECK_CHANNEL(channel);
357 channels_[channel]->playout = true;
358 return 0;
359 } else {
360 // When playout_fail_channel_ == channel, fail the StartPlayout on this
361 // channel.
362 return -1;
363 }
364 }
365 WEBRTC_FUNC(StartSend, (int channel)) {
366 if (send_fail_channel_ != channel) {
367 WEBRTC_CHECK_CHANNEL(channel);
368 channels_[channel]->send = true;
369 return 0;
370 } else {
371 // When send_fail_channel_ == channel, fail the StartSend on this
372 // channel.
373 return -1;
374 }
375 }
376 WEBRTC_STUB(StopReceive, (int channel));
377 WEBRTC_FUNC(StopPlayout, (int channel)) {
378 WEBRTC_CHECK_CHANNEL(channel);
379 channels_[channel]->playout = false;
380 return 0;
381 }
382 WEBRTC_FUNC(StopSend, (int channel)) {
383 WEBRTC_CHECK_CHANNEL(channel);
384 channels_[channel]->send = false;
385 return 0;
386 }
387 WEBRTC_STUB(GetVersion, (char version[1024]));
388 WEBRTC_STUB(LastError, ());
Minyue2013aec2015-05-13 14:14:42 +0200389 WEBRTC_FUNC(AssociateSendChannel, (int channel,
390 int accociate_send_channel)) {
391 WEBRTC_CHECK_CHANNEL(channel);
392 channels_[channel]->associate_send_channel = accociate_send_channel;
393 return 0;
394 }
ivocb04965c2015-09-09 00:09:43 -0700395 webrtc::RtcEventLog* GetEventLog() { return nullptr; }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000396
397 // webrtc::VoECodec
solenberg26c8c912015-11-27 04:00:25 -0800398 WEBRTC_STUB(NumOfCodecs, ());
399 WEBRTC_STUB(GetCodec, (int index, webrtc::CodecInst& codec));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000400 WEBRTC_FUNC(SetSendCodec, (int channel, const webrtc::CodecInst& codec)) {
401 WEBRTC_CHECK_CHANNEL(channel);
henrike@webrtc.org704bf9e2014-02-27 17:52:04 +0000402 // To match the behavior of the real implementation.
403 if (_stricmp(codec.plname, "telephone-event") == 0 ||
404 _stricmp(codec.plname, "audio/telephone-event") == 0 ||
405 _stricmp(codec.plname, "CN") == 0 ||
406 _stricmp(codec.plname, "red") == 0 ) {
407 return -1;
408 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000409 channels_[channel]->send_codec = codec;
wu@webrtc.org05e7b442014-04-01 17:44:24 +0000410 ++num_set_send_codecs_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000411 return 0;
412 }
413 WEBRTC_FUNC(GetSendCodec, (int channel, webrtc::CodecInst& codec)) {
414 WEBRTC_CHECK_CHANNEL(channel);
415 codec = channels_[channel]->send_codec;
416 return 0;
417 }
Ivo Creusenadf89b72015-04-29 16:03:33 +0200418 WEBRTC_STUB(SetBitRate, (int channel, int bitrate_bps));
Fredrik Solenberg4f4ec0a2015-10-22 10:49:27 +0200419 WEBRTC_STUB(GetRecCodec, (int channel, webrtc::CodecInst& codec));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000420 WEBRTC_FUNC(SetRecPayloadType, (int channel,
421 const webrtc::CodecInst& codec)) {
422 WEBRTC_CHECK_CHANNEL(channel);
423 Channel* ch = channels_[channel];
424 if (ch->playout)
425 return -1; // Channel is in use.
426 // Check if something else already has this slot.
427 if (codec.pltype != -1) {
428 for (std::vector<webrtc::CodecInst>::iterator it =
429 ch->recv_codecs.begin(); it != ch->recv_codecs.end(); ++it) {
430 if (it->pltype == codec.pltype &&
431 _stricmp(it->plname, codec.plname) != 0) {
432 return -1;
433 }
434 }
435 }
436 // Otherwise try to find this codec and update its payload type.
solenberg26c8c912015-11-27 04:00:25 -0800437 int result = -1; // not found
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000438 for (std::vector<webrtc::CodecInst>::iterator it = ch->recv_codecs.begin();
439 it != ch->recv_codecs.end(); ++it) {
440 if (strcmp(it->plname, codec.plname) == 0 &&
solenberg26c8c912015-11-27 04:00:25 -0800441 it->plfreq == codec.plfreq &&
442 it->channels == codec.channels) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000443 it->pltype = codec.pltype;
solenberg26c8c912015-11-27 04:00:25 -0800444 result = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000445 }
446 }
solenberg26c8c912015-11-27 04:00:25 -0800447 return result;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000448 }
449 WEBRTC_FUNC(SetSendCNPayloadType, (int channel, int type,
450 webrtc::PayloadFrequencies frequency)) {
451 WEBRTC_CHECK_CHANNEL(channel);
452 if (frequency == webrtc::kFreq8000Hz) {
453 channels_[channel]->cn8_type = type;
454 } else if (frequency == webrtc::kFreq16000Hz) {
455 channels_[channel]->cn16_type = type;
456 }
457 return 0;
458 }
459 WEBRTC_FUNC(GetRecPayloadType, (int channel, webrtc::CodecInst& codec)) {
460 WEBRTC_CHECK_CHANNEL(channel);
461 Channel* ch = channels_[channel];
462 for (std::vector<webrtc::CodecInst>::iterator it = ch->recv_codecs.begin();
463 it != ch->recv_codecs.end(); ++it) {
464 if (strcmp(it->plname, codec.plname) == 0 &&
465 it->plfreq == codec.plfreq &&
466 it->channels == codec.channels &&
467 it->pltype != -1) {
468 codec.pltype = it->pltype;
469 return 0;
470 }
471 }
472 return -1; // not found
473 }
474 WEBRTC_FUNC(SetVADStatus, (int channel, bool enable, webrtc::VadModes mode,
475 bool disableDTX)) {
476 WEBRTC_CHECK_CHANNEL(channel);
477 if (channels_[channel]->send_codec.channels == 2) {
478 // Replicating VoE behavior; VAD cannot be enabled for stereo.
479 return -1;
480 }
481 channels_[channel]->vad = enable;
482 return 0;
483 }
484 WEBRTC_STUB(GetVADStatus, (int channel, bool& enabled,
485 webrtc::VadModes& mode, bool& disabledDTX));
buildbot@webrtc.org5d639b32014-09-10 07:57:12 +0000486
buildbot@webrtc.orgae740dd2014-06-17 10:56:41 +0000487 WEBRTC_FUNC(SetFECStatus, (int channel, bool enable)) {
488 WEBRTC_CHECK_CHANNEL(channel);
buildbot@webrtc.org5d639b32014-09-10 07:57:12 +0000489 if (_stricmp(channels_[channel]->send_codec.plname, "opus") != 0) {
buildbot@webrtc.org3ffa1f92014-07-02 19:51:26 +0000490 // Return -1 if current send codec is not Opus.
491 // TODO(minyue): Excludes other codecs if they support inband FEC.
492 return -1;
493 }
buildbot@webrtc.orgae740dd2014-06-17 10:56:41 +0000494 channels_[channel]->codec_fec = enable;
495 return 0;
496 }
497 WEBRTC_FUNC(GetFECStatus, (int channel, bool& enable)) {
498 WEBRTC_CHECK_CHANNEL(channel);
499 enable = channels_[channel]->codec_fec;
500 return 0;
501 }
buildbot@webrtc.org5d639b32014-09-10 07:57:12 +0000502
503 WEBRTC_FUNC(SetOpusMaxPlaybackRate, (int channel, int frequency_hz)) {
504 WEBRTC_CHECK_CHANNEL(channel);
505 if (_stricmp(channels_[channel]->send_codec.plname, "opus") != 0) {
506 // Return -1 if current send codec is not Opus.
507 return -1;
508 }
509 if (frequency_hz <= 8000)
510 channels_[channel]->max_encoding_bandwidth = kOpusBandwidthNb;
511 else if (frequency_hz <= 12000)
512 channels_[channel]->max_encoding_bandwidth = kOpusBandwidthMb;
513 else if (frequency_hz <= 16000)
514 channels_[channel]->max_encoding_bandwidth = kOpusBandwidthWb;
515 else if (frequency_hz <= 24000)
516 channels_[channel]->max_encoding_bandwidth = kOpusBandwidthSwb;
517 else
518 channels_[channel]->max_encoding_bandwidth = kOpusBandwidthFb;
519 return 0;
520 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000521
minyue@webrtc.org9b2e1142015-03-13 09:38:07 +0000522 WEBRTC_FUNC(SetOpusDtx, (int channel, bool enable_dtx)) {
523 WEBRTC_CHECK_CHANNEL(channel);
524 if (_stricmp(channels_[channel]->send_codec.plname, "opus") != 0) {
525 // Return -1 if current send codec is not Opus.
526 return -1;
527 }
528 channels_[channel]->opus_dtx = enable_dtx;
529 return 0;
530 }
531
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000532 // webrtc::VoEHardware
solenberg246b8172015-12-08 09:50:23 -0800533 WEBRTC_STUB(GetNumOfRecordingDevices, (int& num));
534 WEBRTC_STUB(GetNumOfPlayoutDevices, (int& num));
535 WEBRTC_STUB(GetRecordingDeviceName, (int i, char* name, char* guid));
536 WEBRTC_STUB(GetPlayoutDeviceName, (int i, char* name, char* guid));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000537 WEBRTC_STUB(SetRecordingDevice, (int, webrtc::StereoChannel));
538 WEBRTC_STUB(SetPlayoutDevice, (int));
539 WEBRTC_STUB(SetAudioDeviceLayer, (webrtc::AudioLayers));
540 WEBRTC_STUB(GetAudioDeviceLayer, (webrtc::AudioLayers&));
wu@webrtc.org97077a32013-10-25 21:18:33 +0000541 WEBRTC_FUNC(SetRecordingSampleRate, (unsigned int samples_per_sec)) {
542 recording_sample_rate_ = samples_per_sec;
543 return 0;
544 }
545 WEBRTC_FUNC_CONST(RecordingSampleRate, (unsigned int* samples_per_sec)) {
546 *samples_per_sec = recording_sample_rate_;
547 return 0;
548 }
549 WEBRTC_FUNC(SetPlayoutSampleRate, (unsigned int samples_per_sec)) {
550 playout_sample_rate_ = samples_per_sec;
551 return 0;
552 }
553 WEBRTC_FUNC_CONST(PlayoutSampleRate, (unsigned int* samples_per_sec)) {
554 *samples_per_sec = playout_sample_rate_;
555 return 0;
556 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000557 WEBRTC_STUB(EnableBuiltInAEC, (bool enable));
henrika@webrtc.orga954c072014-12-09 16:22:09 +0000558 virtual bool BuiltInAECIsAvailable() const { return false; }
henrikac14f5ff2015-09-23 14:08:33 +0200559 WEBRTC_STUB(EnableBuiltInAGC, (bool enable));
560 virtual bool BuiltInAGCIsAvailable() const { return false; }
561 WEBRTC_STUB(EnableBuiltInNS, (bool enable));
562 virtual bool BuiltInNSIsAvailable() const { return false; }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000563
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000564 // webrtc::VoENetwork
565 WEBRTC_FUNC(RegisterExternalTransport, (int channel,
566 webrtc::Transport& transport)) {
567 WEBRTC_CHECK_CHANNEL(channel);
568 channels_[channel]->external_transport = true;
569 return 0;
570 }
571 WEBRTC_FUNC(DeRegisterExternalTransport, (int channel)) {
572 WEBRTC_CHECK_CHANNEL(channel);
573 channels_[channel]->external_transport = false;
574 return 0;
575 }
576 WEBRTC_FUNC(ReceivedRTPPacket, (int channel, const void* data,
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +0000577 size_t length)) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000578 WEBRTC_CHECK_CHANNEL(channel);
579 if (!channels_[channel]->external_transport) return -1;
580 channels_[channel]->packets.push_back(
581 std::string(static_cast<const char*>(data), length));
582 return 0;
583 }
buildbot@webrtc.orgf875f152014-04-14 16:06:21 +0000584 WEBRTC_FUNC(ReceivedRTPPacket, (int channel, const void* data,
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +0000585 size_t length,
buildbot@webrtc.orgf875f152014-04-14 16:06:21 +0000586 const webrtc::PacketTime& packet_time)) {
587 WEBRTC_CHECK_CHANNEL(channel);
588 if (ReceivedRTPPacket(channel, data, length) == -1) {
589 return -1;
590 }
591 channels_[channel]->last_rtp_packet_time = packet_time;
592 return 0;
593 }
buildbot@webrtc.orgf875f152014-04-14 16:06:21 +0000594
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000595 WEBRTC_STUB(ReceivedRTCPPacket, (int channel, const void* data,
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +0000596 size_t length));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000597
598 // webrtc::VoERTP_RTCP
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000599 WEBRTC_FUNC(SetLocalSSRC, (int channel, unsigned int ssrc)) {
600 WEBRTC_CHECK_CHANNEL(channel);
601 channels_[channel]->send_ssrc = ssrc;
602 return 0;
603 }
solenberg85a04962015-10-27 03:35:21 -0700604 WEBRTC_STUB(GetLocalSSRC, (int channel, unsigned int& ssrc));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000605 WEBRTC_STUB(GetRemoteSSRC, (int channel, unsigned int& ssrc));
solenberg3a941542015-11-16 07:34:50 -0800606 WEBRTC_STUB(SetSendAudioLevelIndicationStatus, (int channel, bool enable,
607 unsigned char id));
solenberg7add0582015-11-20 09:59:34 -0800608 WEBRTC_STUB(SetReceiveAudioLevelIndicationStatus, (int channel, bool enable,
609 unsigned char id));
solenberg3a941542015-11-16 07:34:50 -0800610 WEBRTC_STUB(SetSendAbsoluteSenderTimeStatus, (int channel, bool enable,
611 unsigned char id));
solenberg7add0582015-11-20 09:59:34 -0800612 WEBRTC_STUB(SetReceiveAbsoluteSenderTimeStatus, (int channel, bool enable,
613 unsigned char id));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000614 WEBRTC_STUB(SetRTCPStatus, (int channel, bool enable));
615 WEBRTC_STUB(GetRTCPStatus, (int channel, bool& enabled));
616 WEBRTC_STUB(SetRTCP_CNAME, (int channel, const char cname[256]));
617 WEBRTC_STUB(GetRTCP_CNAME, (int channel, char cname[256]));
618 WEBRTC_STUB(GetRemoteRTCP_CNAME, (int channel, char* cname));
619 WEBRTC_STUB(GetRemoteRTCPData, (int channel, unsigned int& NTPHigh,
620 unsigned int& NTPLow,
621 unsigned int& timestamp,
622 unsigned int& playoutTimestamp,
623 unsigned int* jitter,
624 unsigned short* fractionLost));
solenberg85a04962015-10-27 03:35:21 -0700625 WEBRTC_STUB(GetRemoteRTCPReportBlocks,
626 (int channel, std::vector<webrtc::ReportBlock>* receive_blocks));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000627 WEBRTC_STUB(GetRTPStatistics, (int channel, unsigned int& averageJitterMs,
628 unsigned int& maxJitterMs,
629 unsigned int& discardedPackets));
solenberg85a04962015-10-27 03:35:21 -0700630 WEBRTC_STUB(GetRTCPStatistics, (int channel, webrtc::CallStatistics& stats));
buildbot@webrtc.orgae740dd2014-06-17 10:56:41 +0000631 WEBRTC_FUNC(SetREDStatus, (int channel, bool enable, int redPayloadtype)) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000632 WEBRTC_CHECK_CHANNEL(channel);
buildbot@webrtc.orgae740dd2014-06-17 10:56:41 +0000633 channels_[channel]->red = enable;
634 channels_[channel]->red_type = redPayloadtype;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000635 return 0;
636 }
buildbot@webrtc.orgae740dd2014-06-17 10:56:41 +0000637 WEBRTC_FUNC(GetREDStatus, (int channel, bool& enable, int& redPayloadtype)) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000638 WEBRTC_CHECK_CHANNEL(channel);
buildbot@webrtc.orgae740dd2014-06-17 10:56:41 +0000639 enable = channels_[channel]->red;
640 redPayloadtype = channels_[channel]->red_type;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000641 return 0;
642 }
643 WEBRTC_FUNC(SetNACKStatus, (int channel, bool enable, int maxNoPackets)) {
644 WEBRTC_CHECK_CHANNEL(channel);
645 channels_[channel]->nack = enable;
646 channels_[channel]->nack_max_packets = maxNoPackets;
647 return 0;
648 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000649
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000650 // webrtc::VoEVolumeControl
651 WEBRTC_STUB(SetSpeakerVolume, (unsigned int));
652 WEBRTC_STUB(GetSpeakerVolume, (unsigned int&));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000653 WEBRTC_STUB(SetMicVolume, (unsigned int));
654 WEBRTC_STUB(GetMicVolume, (unsigned int&));
655 WEBRTC_STUB(SetInputMute, (int, bool));
656 WEBRTC_STUB(GetInputMute, (int, bool&));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000657 WEBRTC_STUB(GetSpeechInputLevel, (unsigned int&));
658 WEBRTC_STUB(GetSpeechOutputLevel, (int, unsigned int&));
659 WEBRTC_STUB(GetSpeechInputLevelFullRange, (unsigned int&));
660 WEBRTC_STUB(GetSpeechOutputLevelFullRange, (int, unsigned int&));
661 WEBRTC_FUNC(SetChannelOutputVolumeScaling, (int channel, float scale)) {
662 WEBRTC_CHECK_CHANNEL(channel);
663 channels_[channel]->volume_scale= scale;
664 return 0;
665 }
666 WEBRTC_FUNC(GetChannelOutputVolumeScaling, (int channel, float& scale)) {
667 WEBRTC_CHECK_CHANNEL(channel);
668 scale = channels_[channel]->volume_scale;
669 return 0;
670 }
solenberg4bac9c52015-10-09 02:32:53 -0700671 WEBRTC_STUB(SetOutputVolumePan, (int channel, float left, float right));
672 WEBRTC_STUB(GetOutputVolumePan, (int channel, float& left, float& right));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000673
674 // webrtc::VoEAudioProcessing
675 WEBRTC_FUNC(SetNsStatus, (bool enable, webrtc::NsModes mode)) {
676 ns_enabled_ = enable;
677 ns_mode_ = mode;
678 return 0;
679 }
680 WEBRTC_FUNC(GetNsStatus, (bool& enabled, webrtc::NsModes& mode)) {
681 enabled = ns_enabled_;
682 mode = ns_mode_;
683 return 0;
684 }
685
686 WEBRTC_FUNC(SetAgcStatus, (bool enable, webrtc::AgcModes mode)) {
687 agc_enabled_ = enable;
688 agc_mode_ = mode;
689 return 0;
690 }
691 WEBRTC_FUNC(GetAgcStatus, (bool& enabled, webrtc::AgcModes& mode)) {
692 enabled = agc_enabled_;
693 mode = agc_mode_;
694 return 0;
695 }
696
697 WEBRTC_FUNC(SetAgcConfig, (webrtc::AgcConfig config)) {
698 agc_config_ = config;
699 return 0;
700 }
701 WEBRTC_FUNC(GetAgcConfig, (webrtc::AgcConfig& config)) {
702 config = agc_config_;
703 return 0;
704 }
705 WEBRTC_FUNC(SetEcStatus, (bool enable, webrtc::EcModes mode)) {
706 ec_enabled_ = enable;
707 ec_mode_ = mode;
708 return 0;
709 }
710 WEBRTC_FUNC(GetEcStatus, (bool& enabled, webrtc::EcModes& mode)) {
711 enabled = ec_enabled_;
712 mode = ec_mode_;
713 return 0;
714 }
715 WEBRTC_STUB(EnableDriftCompensation, (bool enable))
716 WEBRTC_BOOL_STUB(DriftCompensationEnabled, ())
717 WEBRTC_VOID_STUB(SetDelayOffsetMs, (int offset))
718 WEBRTC_STUB(DelayOffsetMs, ());
719 WEBRTC_FUNC(SetAecmMode, (webrtc::AecmModes mode, bool enableCNG)) {
720 aecm_mode_ = mode;
721 cng_enabled_ = enableCNG;
722 return 0;
723 }
724 WEBRTC_FUNC(GetAecmMode, (webrtc::AecmModes& mode, bool& enabledCNG)) {
725 mode = aecm_mode_;
726 enabledCNG = cng_enabled_;
727 return 0;
728 }
729 WEBRTC_STUB(SetRxNsStatus, (int channel, bool enable, webrtc::NsModes mode));
730 WEBRTC_STUB(GetRxNsStatus, (int channel, bool& enabled,
731 webrtc::NsModes& mode));
solenberg0b675462015-10-09 01:37:09 -0700732 WEBRTC_STUB(SetRxAgcStatus, (int channel, bool enable,
733 webrtc::AgcModes mode));
734 WEBRTC_STUB(GetRxAgcStatus, (int channel, bool& enabled,
735 webrtc::AgcModes& mode));
736 WEBRTC_STUB(SetRxAgcConfig, (int channel, webrtc::AgcConfig config));
737 WEBRTC_STUB(GetRxAgcConfig, (int channel, webrtc::AgcConfig& config));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000738
739 WEBRTC_STUB(RegisterRxVadObserver, (int, webrtc::VoERxVadCallback&));
740 WEBRTC_STUB(DeRegisterRxVadObserver, (int channel));
741 WEBRTC_STUB(VoiceActivityIndicator, (int channel));
742 WEBRTC_FUNC(SetEcMetricsStatus, (bool enable)) {
743 ec_metrics_enabled_ = enable;
744 return 0;
745 }
solenberg85a04962015-10-27 03:35:21 -0700746 WEBRTC_STUB(GetEcMetricsStatus, (bool& enabled));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000747 WEBRTC_STUB(GetEchoMetrics, (int& ERL, int& ERLE, int& RERL, int& A_NLP));
bjornv@webrtc.orgcc64a9c2015-02-05 12:52:44 +0000748 WEBRTC_STUB(GetEcDelayMetrics, (int& delay_median, int& delay_std,
749 float& fraction_poor_delays));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000750
751 WEBRTC_STUB(StartDebugRecording, (const char* fileNameUTF8));
wu@webrtc.org9caf2762013-12-11 18:25:07 +0000752 WEBRTC_STUB(StartDebugRecording, (FILE* handle));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000753 WEBRTC_STUB(StopDebugRecording, ());
754
755 WEBRTC_FUNC(SetTypingDetectionStatus, (bool enable)) {
756 typing_detection_enabled_ = enable;
757 return 0;
758 }
759 WEBRTC_FUNC(GetTypingDetectionStatus, (bool& enabled)) {
760 enabled = typing_detection_enabled_;
761 return 0;
762 }
763
764 WEBRTC_STUB(TimeSinceLastTyping, (int& seconds));
765 WEBRTC_STUB(SetTypingDetectionParameters, (int timeWindow,
766 int costPerTyping,
767 int reportingThreshold,
768 int penaltyDecay,
769 int typeEventDelay));
770 int EnableHighPassFilter(bool enable) {
771 highpass_filter_enabled_ = enable;
772 return 0;
773 }
774 bool IsHighPassFilterEnabled() {
775 return highpass_filter_enabled_;
776 }
777 bool IsStereoChannelSwappingEnabled() {
778 return stereo_swapping_enabled_;
779 }
780 void EnableStereoChannelSwapping(bool enable) {
781 stereo_swapping_enabled_ = enable;
782 }
Henrik Lundin64dad832015-05-11 12:44:23 +0200783 int GetNetEqCapacity() const {
784 auto ch = channels_.find(last_channel_);
785 ASSERT(ch != channels_.end());
786 return ch->second->neteq_capacity;
787 }
Henrik Lundin5263b3c2015-06-01 10:29:41 +0200788 bool GetNetEqFastAccelerate() const {
789 auto ch = channels_.find(last_channel_);
790 ASSERT(ch != channels_.end());
791 return ch->second->neteq_fast_accelerate;
792 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000793
794 private:
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000795 bool inited_;
796 int last_channel_;
797 std::map<int, Channel*> channels_;
798 bool fail_create_channel_;
wu@webrtc.org05e7b442014-04-01 17:44:24 +0000799 int num_set_send_codecs_; // how many times we call SetSendCodec().
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000800 bool ec_enabled_;
801 bool ec_metrics_enabled_;
802 bool cng_enabled_;
803 bool ns_enabled_;
804 bool agc_enabled_;
805 bool highpass_filter_enabled_;
806 bool stereo_swapping_enabled_;
807 bool typing_detection_enabled_;
808 webrtc::EcModes ec_mode_;
809 webrtc::AecmModes aecm_mode_;
810 webrtc::NsModes ns_mode_;
811 webrtc::AgcModes agc_mode_;
812 webrtc::AgcConfig agc_config_;
813 webrtc::VoiceEngineObserver* observer_;
814 int playout_fail_channel_;
815 int send_fail_channel_;
wu@webrtc.org97077a32013-10-25 21:18:33 +0000816 int recording_sample_rate_;
817 int playout_sample_rate_;
buildbot@webrtc.orga8d8ad22014-07-16 14:23:08 +0000818 FakeAudioProcessing audio_processing_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000819};
820
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000821} // namespace cricket
822
823#endif // TALK_SESSION_PHONE_FAKEWEBRTCVOICEENGINE_H_