blob: 9314e4d013a26603473f5cd944becafb1656316e [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/base/basictypes.h"
wu@webrtc.org9caf2762013-12-11 18:25:07 +000036#include "talk/base/gunit.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000037#include "talk/base/stringutils.h"
38#include "talk/media/base/codec.h"
39#include "talk/media/base/voiceprocessor.h"
40#include "talk/media/webrtc/fakewebrtccommon.h"
41#include "talk/media/webrtc/webrtcvoe.h"
42
buildbot@webrtc.orgf875f152014-04-14 16:06:21 +000043namespace webrtc {
44class ViENetwork;
45}
46
henrike@webrtc.org28e20752013-07-10 00:45:36 +000047namespace cricket {
48
49// Function returning stats will return these values
50// for all values based on type.
51const int kIntStatValue = 123;
52const float kFractionLostStatValue = 0.5;
53
54static const char kFakeDefaultDeviceName[] = "Fake Default";
55static const int kFakeDefaultDeviceId = -1;
56static const char kFakeDeviceName[] = "Fake Device";
57#ifdef WIN32
58static const int kFakeDeviceId = 0;
59#else
60static const int kFakeDeviceId = 1;
61#endif
62
henrike@webrtc.org79047f92014-03-06 23:46:59 +000063// Verify the header extension ID, if enabled, is within the bounds specified in
64// [RFC5285]: 1-14 inclusive.
65#define WEBRTC_CHECK_HEADER_EXTENSION_ID(enable, id) \
66 do { \
67 if (enable && (id < 1 || id > 14)) { \
68 return -1; \
69 } \
70 } while (0);
71
henrike@webrtc.org28e20752013-07-10 00:45:36 +000072class FakeWebRtcVoiceEngine
73 : public webrtc::VoEAudioProcessing,
74 public webrtc::VoEBase, public webrtc::VoECodec, public webrtc::VoEDtmf,
75 public webrtc::VoEFile, public webrtc::VoEHardware,
76 public webrtc::VoEExternalMedia, public webrtc::VoENetEqStats,
77 public webrtc::VoENetwork, public webrtc::VoERTP_RTCP,
78 public webrtc::VoEVideoSync, public webrtc::VoEVolumeControl {
79 public:
80 struct DtmfInfo {
81 DtmfInfo()
82 : dtmf_event_code(-1),
83 dtmf_out_of_band(false),
84 dtmf_length_ms(-1) {}
85 int dtmf_event_code;
86 bool dtmf_out_of_band;
87 int dtmf_length_ms;
88 };
89 struct Channel {
buildbot@webrtc.orgaf6640f2014-04-28 21:31:51 +000090 explicit Channel()
henrike@webrtc.org28e20752013-07-10 00:45:36 +000091 : external_transport(false),
92 send(false),
93 playout(false),
94 volume_scale(1.0),
95 volume_pan_left(1.0),
96 volume_pan_right(1.0),
97 file(false),
98 vad(false),
99 fec(false),
100 nack(false),
101 media_processor_registered(false),
wu@webrtc.org97077a32013-10-25 21:18:33 +0000102 rx_agc_enabled(false),
103 rx_agc_mode(webrtc::kAgcDefault),
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000104 cn8_type(13),
105 cn16_type(105),
106 dtmf_type(106),
107 fec_type(117),
108 nack_max_packets(0),
buildbot@webrtc.orgf875f152014-04-14 16:06:21 +0000109 vie_network(NULL),
110 video_channel(-1),
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000111 send_ssrc(0),
henrike@webrtc.org79047f92014-03-06 23:46:59 +0000112 send_audio_level_ext_(-1),
113 send_absolute_sender_time_ext_(-1),
buildbot@webrtc.orgaf6640f2014-04-28 21:31:51 +0000114 receive_absolute_sender_time_ext_(-1) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000115 memset(&send_codec, 0, sizeof(send_codec));
wu@webrtc.org97077a32013-10-25 21:18:33 +0000116 memset(&rx_agc_config, 0, sizeof(rx_agc_config));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000117 }
118 bool external_transport;
119 bool send;
120 bool playout;
121 float volume_scale;
122 float volume_pan_left;
123 float volume_pan_right;
124 bool file;
125 bool vad;
126 bool fec;
127 bool nack;
128 bool media_processor_registered;
wu@webrtc.org97077a32013-10-25 21:18:33 +0000129 bool rx_agc_enabled;
130 webrtc::AgcModes rx_agc_mode;
131 webrtc::AgcConfig rx_agc_config;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000132 int cn8_type;
133 int cn16_type;
134 int dtmf_type;
135 int fec_type;
136 int nack_max_packets;
buildbot@webrtc.orgf875f152014-04-14 16:06:21 +0000137 webrtc::ViENetwork* vie_network;
138 int video_channel;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000139 uint32 send_ssrc;
henrike@webrtc.org79047f92014-03-06 23:46:59 +0000140 int send_audio_level_ext_;
141 int send_absolute_sender_time_ext_;
142 int receive_absolute_sender_time_ext_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000143 DtmfInfo dtmf_info;
144 std::vector<webrtc::CodecInst> recv_codecs;
145 webrtc::CodecInst send_codec;
buildbot@webrtc.orgf875f152014-04-14 16:06:21 +0000146 webrtc::PacketTime last_rtp_packet_time;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000147 std::list<std::string> packets;
148 };
149
150 FakeWebRtcVoiceEngine(const cricket::AudioCodec* const* codecs,
151 int num_codecs)
152 : inited_(false),
153 last_channel_(-1),
154 fail_create_channel_(false),
155 codecs_(codecs),
156 num_codecs_(num_codecs),
wu@webrtc.org05e7b442014-04-01 17:44:24 +0000157 num_set_send_codecs_(0),
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000158 ec_enabled_(false),
159 ec_metrics_enabled_(false),
160 cng_enabled_(false),
161 ns_enabled_(false),
162 agc_enabled_(false),
163 highpass_filter_enabled_(false),
164 stereo_swapping_enabled_(false),
165 typing_detection_enabled_(false),
166 ec_mode_(webrtc::kEcDefault),
167 aecm_mode_(webrtc::kAecmSpeakerphone),
168 ns_mode_(webrtc::kNsDefault),
169 agc_mode_(webrtc::kAgcDefault),
170 observer_(NULL),
171 playout_fail_channel_(-1),
172 send_fail_channel_(-1),
173 fail_start_recording_microphone_(false),
174 recording_microphone_(false),
wu@webrtc.org97077a32013-10-25 21:18:33 +0000175 recording_sample_rate_(-1),
176 playout_sample_rate_(-1),
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000177 media_processor_(NULL) {
178 memset(&agc_config_, 0, sizeof(agc_config_));
179 }
180 ~FakeWebRtcVoiceEngine() {
181 // Ought to have all been deleted by the WebRtcVoiceMediaChannel
182 // destructors, but just in case ...
183 for (std::map<int, Channel*>::const_iterator i = channels_.begin();
184 i != channels_.end(); ++i) {
185 delete i->second;
186 }
187 }
188
189 bool IsExternalMediaProcessorRegistered() const {
190 return media_processor_ != NULL;
191 }
192 bool IsInited() const { return inited_; }
193 int GetLastChannel() const { return last_channel_; }
wu@webrtc.org9dba5252013-08-05 20:36:57 +0000194 int GetChannelFromLocalSsrc(uint32 local_ssrc) const {
195 for (std::map<int, Channel*>::const_iterator iter = channels_.begin();
196 iter != channels_.end(); ++iter) {
197 if (local_ssrc == iter->second->send_ssrc)
198 return iter->first;
199 }
200 return -1;
201 }
wu@webrtc.org9caf2762013-12-11 18:25:07 +0000202 int GetNumChannels() const { return static_cast<int>(channels_.size()); }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000203 bool GetPlayout(int channel) {
204 return channels_[channel]->playout;
205 }
206 bool GetSend(int channel) {
207 return channels_[channel]->send;
208 }
209 bool GetRecordingMicrophone() {
210 return recording_microphone_;
211 }
212 bool GetVAD(int channel) {
213 return channels_[channel]->vad;
214 }
215 bool GetFEC(int channel) {
216 return channels_[channel]->fec;
217 }
218 bool GetNACK(int channel) {
219 return channels_[channel]->nack;
220 }
221 int GetNACKMaxPackets(int channel) {
222 return channels_[channel]->nack_max_packets;
223 }
buildbot@webrtc.orgf875f152014-04-14 16:06:21 +0000224 webrtc::ViENetwork* GetViENetwork(int channel) {
225 WEBRTC_ASSERT_CHANNEL(channel);
226 return channels_[channel]->vie_network;
227 }
228 int GetVideoChannel(int channel) {
229 WEBRTC_ASSERT_CHANNEL(channel);
230 return channels_[channel]->video_channel;
231 }
232 const webrtc::PacketTime& GetLastRtpPacketTime(int channel) {
233 WEBRTC_ASSERT_CHANNEL(channel);
234 return channels_[channel]->last_rtp_packet_time;
235 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000236 int GetSendCNPayloadType(int channel, bool wideband) {
237 return (wideband) ?
238 channels_[channel]->cn16_type :
239 channels_[channel]->cn8_type;
240 }
241 int GetSendTelephoneEventPayloadType(int channel) {
242 return channels_[channel]->dtmf_type;
243 }
244 int GetSendFECPayloadType(int channel) {
245 return channels_[channel]->fec_type;
246 }
247 bool CheckPacket(int channel, const void* data, size_t len) {
248 bool result = !CheckNoPacket(channel);
249 if (result) {
250 std::string packet = channels_[channel]->packets.front();
251 result = (packet == std::string(static_cast<const char*>(data), len));
252 channels_[channel]->packets.pop_front();
253 }
254 return result;
255 }
256 bool CheckNoPacket(int channel) {
257 return channels_[channel]->packets.empty();
258 }
259 void TriggerCallbackOnError(int channel_num, int err_code) {
260 ASSERT(observer_ != NULL);
261 observer_->CallbackOnError(channel_num, err_code);
262 }
263 void set_playout_fail_channel(int channel) {
264 playout_fail_channel_ = channel;
265 }
266 void set_send_fail_channel(int channel) {
267 send_fail_channel_ = channel;
268 }
269 void set_fail_start_recording_microphone(
270 bool fail_start_recording_microphone) {
271 fail_start_recording_microphone_ = fail_start_recording_microphone;
272 }
273 void set_fail_create_channel(bool fail_create_channel) {
274 fail_create_channel_ = fail_create_channel;
275 }
276 void TriggerProcessPacket(MediaProcessorDirection direction) {
277 webrtc::ProcessingTypes pt =
278 (direction == cricket::MPD_TX) ?
279 webrtc::kRecordingPerChannel : webrtc::kPlaybackAllChannelsMixed;
280 if (media_processor_ != NULL) {
281 media_processor_->Process(0,
282 pt,
283 NULL,
284 0,
285 0,
286 true);
287 }
288 }
buildbot@webrtc.orgaf6640f2014-04-28 21:31:51 +0000289 int AddChannel() {
wu@webrtc.org364f2042013-11-20 21:49:41 +0000290 if (fail_create_channel_) {
291 return -1;
292 }
buildbot@webrtc.orgaf6640f2014-04-28 21:31:51 +0000293 Channel* ch = new Channel();
wu@webrtc.org364f2042013-11-20 21:49:41 +0000294 for (int i = 0; i < NumOfCodecs(); ++i) {
295 webrtc::CodecInst codec;
296 GetCodec(i, codec);
297 ch->recv_codecs.push_back(codec);
298 }
299 channels_[++last_channel_] = ch;
300 return last_channel_;
301 }
henrike@webrtc.org79047f92014-03-06 23:46:59 +0000302 int GetSendAudioLevelId(int channel) {
303 return channels_[channel]->send_audio_level_ext_;
304 }
305 int GetSendAbsoluteSenderTimeId(int channel) {
306 return channels_[channel]->send_absolute_sender_time_ext_;
307 }
308 int GetReceiveAbsoluteSenderTimeId(int channel) {
309 return channels_[channel]->receive_absolute_sender_time_ext_;
310 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000311
wu@webrtc.org05e7b442014-04-01 17:44:24 +0000312 int GetNumSetSendCodecs() const { return num_set_send_codecs_; }
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 }
332 virtual webrtc::AudioProcessing* audio_processing() OVERRIDE {
333 return NULL;
334 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000335 WEBRTC_FUNC(CreateChannel, ()) {
buildbot@webrtc.orgaf6640f2014-04-28 21:31:51 +0000336 return AddChannel();
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000337 }
buildbot@webrtc.orgaf6640f2014-04-28 21:31:51 +0000338 WEBRTC_FUNC(CreateChannel, (const webrtc::Config& /*config*/)) {
339 return AddChannel();
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);
343 delete channels_[channel];
344 channels_.erase(channel);
345 return 0;
346 }
347 WEBRTC_STUB(StartReceive, (int channel));
348 WEBRTC_FUNC(StartPlayout, (int channel)) {
349 if (playout_fail_channel_ != channel) {
350 WEBRTC_CHECK_CHANNEL(channel);
351 channels_[channel]->playout = true;
352 return 0;
353 } else {
354 // When playout_fail_channel_ == channel, fail the StartPlayout on this
355 // channel.
356 return -1;
357 }
358 }
359 WEBRTC_FUNC(StartSend, (int channel)) {
360 if (send_fail_channel_ != channel) {
361 WEBRTC_CHECK_CHANNEL(channel);
362 channels_[channel]->send = true;
363 return 0;
364 } else {
365 // When send_fail_channel_ == channel, fail the StartSend on this
366 // channel.
367 return -1;
368 }
369 }
370 WEBRTC_STUB(StopReceive, (int channel));
371 WEBRTC_FUNC(StopPlayout, (int channel)) {
372 WEBRTC_CHECK_CHANNEL(channel);
373 channels_[channel]->playout = false;
374 return 0;
375 }
376 WEBRTC_FUNC(StopSend, (int channel)) {
377 WEBRTC_CHECK_CHANNEL(channel);
378 channels_[channel]->send = false;
379 return 0;
380 }
381 WEBRTC_STUB(GetVersion, (char version[1024]));
382 WEBRTC_STUB(LastError, ());
383 WEBRTC_STUB(SetOnHoldStatus, (int, bool, webrtc::OnHoldModes));
384 WEBRTC_STUB(GetOnHoldStatus, (int, bool&, webrtc::OnHoldModes&));
385 WEBRTC_STUB(SetNetEQPlayoutMode, (int, webrtc::NetEqModes));
386 WEBRTC_STUB(GetNetEQPlayoutMode, (int, webrtc::NetEqModes&));
387
388 // webrtc::VoECodec
389 WEBRTC_FUNC(NumOfCodecs, ()) {
390 return num_codecs_;
391 }
392 WEBRTC_FUNC(GetCodec, (int index, webrtc::CodecInst& codec)) {
393 if (index < 0 || index >= NumOfCodecs()) {
394 return -1;
395 }
396 const cricket::AudioCodec& c(*codecs_[index]);
397 codec.pltype = c.id;
398 talk_base::strcpyn(codec.plname, sizeof(codec.plname), c.name.c_str());
399 codec.plfreq = c.clockrate;
400 codec.pacsize = 0;
401 codec.channels = c.channels;
402 codec.rate = c.bitrate;
403 return 0;
404 }
405 WEBRTC_FUNC(SetSendCodec, (int channel, const webrtc::CodecInst& codec)) {
406 WEBRTC_CHECK_CHANNEL(channel);
henrike@webrtc.org704bf9e2014-02-27 17:52:04 +0000407 // To match the behavior of the real implementation.
408 if (_stricmp(codec.plname, "telephone-event") == 0 ||
409 _stricmp(codec.plname, "audio/telephone-event") == 0 ||
410 _stricmp(codec.plname, "CN") == 0 ||
411 _stricmp(codec.plname, "red") == 0 ) {
412 return -1;
413 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000414 channels_[channel]->send_codec = codec;
wu@webrtc.org05e7b442014-04-01 17:44:24 +0000415 ++num_set_send_codecs_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000416 return 0;
417 }
418 WEBRTC_FUNC(GetSendCodec, (int channel, webrtc::CodecInst& codec)) {
419 WEBRTC_CHECK_CHANNEL(channel);
420 codec = channels_[channel]->send_codec;
421 return 0;
422 }
423 WEBRTC_STUB(SetSecondarySendCodec, (int channel,
424 const webrtc::CodecInst& codec,
425 int red_payload_type));
426 WEBRTC_STUB(RemoveSecondarySendCodec, (int channel));
427 WEBRTC_STUB(GetSecondarySendCodec, (int channel,
428 webrtc::CodecInst& codec));
429 WEBRTC_STUB(GetRecCodec, (int channel, webrtc::CodecInst& codec));
430 WEBRTC_STUB(SetAMREncFormat, (int channel, webrtc::AmrMode mode));
431 WEBRTC_STUB(SetAMRDecFormat, (int channel, webrtc::AmrMode mode));
432 WEBRTC_STUB(SetAMRWbEncFormat, (int channel, webrtc::AmrMode mode));
433 WEBRTC_STUB(SetAMRWbDecFormat, (int channel, webrtc::AmrMode mode));
434 WEBRTC_STUB(SetISACInitTargetRate, (int channel, int rateBps,
435 bool useFixedFrameSize));
436 WEBRTC_STUB(SetISACMaxRate, (int channel, int rateBps));
437 WEBRTC_STUB(SetISACMaxPayloadSize, (int channel, int sizeBytes));
438 WEBRTC_FUNC(SetRecPayloadType, (int channel,
439 const webrtc::CodecInst& codec)) {
440 WEBRTC_CHECK_CHANNEL(channel);
441 Channel* ch = channels_[channel];
442 if (ch->playout)
443 return -1; // Channel is in use.
444 // Check if something else already has this slot.
445 if (codec.pltype != -1) {
446 for (std::vector<webrtc::CodecInst>::iterator it =
447 ch->recv_codecs.begin(); it != ch->recv_codecs.end(); ++it) {
448 if (it->pltype == codec.pltype &&
449 _stricmp(it->plname, codec.plname) != 0) {
450 return -1;
451 }
452 }
453 }
454 // Otherwise try to find this codec and update its payload type.
455 for (std::vector<webrtc::CodecInst>::iterator it = ch->recv_codecs.begin();
456 it != ch->recv_codecs.end(); ++it) {
457 if (strcmp(it->plname, codec.plname) == 0 &&
458 it->plfreq == codec.plfreq) {
459 it->pltype = codec.pltype;
460 it->channels = codec.channels;
461 return 0;
462 }
463 }
464 return -1; // not found
465 }
466 WEBRTC_FUNC(SetSendCNPayloadType, (int channel, int type,
467 webrtc::PayloadFrequencies frequency)) {
468 WEBRTC_CHECK_CHANNEL(channel);
469 if (frequency == webrtc::kFreq8000Hz) {
470 channels_[channel]->cn8_type = type;
471 } else if (frequency == webrtc::kFreq16000Hz) {
472 channels_[channel]->cn16_type = type;
473 }
474 return 0;
475 }
476 WEBRTC_FUNC(GetRecPayloadType, (int channel, webrtc::CodecInst& codec)) {
477 WEBRTC_CHECK_CHANNEL(channel);
478 Channel* ch = channels_[channel];
479 for (std::vector<webrtc::CodecInst>::iterator it = ch->recv_codecs.begin();
480 it != ch->recv_codecs.end(); ++it) {
481 if (strcmp(it->plname, codec.plname) == 0 &&
482 it->plfreq == codec.plfreq &&
483 it->channels == codec.channels &&
484 it->pltype != -1) {
485 codec.pltype = it->pltype;
486 return 0;
487 }
488 }
489 return -1; // not found
490 }
491 WEBRTC_FUNC(SetVADStatus, (int channel, bool enable, webrtc::VadModes mode,
492 bool disableDTX)) {
493 WEBRTC_CHECK_CHANNEL(channel);
494 if (channels_[channel]->send_codec.channels == 2) {
495 // Replicating VoE behavior; VAD cannot be enabled for stereo.
496 return -1;
497 }
498 channels_[channel]->vad = enable;
499 return 0;
500 }
501 WEBRTC_STUB(GetVADStatus, (int channel, bool& enabled,
502 webrtc::VadModes& mode, bool& disabledDTX));
503
504 // webrtc::VoEDtmf
505 WEBRTC_FUNC(SendTelephoneEvent, (int channel, int event_code,
506 bool out_of_band = true, int length_ms = 160, int attenuation_db = 10)) {
507 channels_[channel]->dtmf_info.dtmf_event_code = event_code;
508 channels_[channel]->dtmf_info.dtmf_out_of_band = out_of_band;
509 channels_[channel]->dtmf_info.dtmf_length_ms = length_ms;
510 return 0;
511 }
512
513 WEBRTC_FUNC(SetSendTelephoneEventPayloadType,
514 (int channel, unsigned char type)) {
515 channels_[channel]->dtmf_type = type;
516 return 0;
517 };
518 WEBRTC_STUB(GetSendTelephoneEventPayloadType,
519 (int channel, unsigned char& type));
520
521 WEBRTC_STUB(SetDtmfFeedbackStatus, (bool enable, bool directFeedback));
522 WEBRTC_STUB(GetDtmfFeedbackStatus, (bool& enabled, bool& directFeedback));
523 WEBRTC_STUB(SetDtmfPlayoutStatus, (int channel, bool enable));
524 WEBRTC_STUB(GetDtmfPlayoutStatus, (int channel, bool& enabled));
525
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000526 WEBRTC_FUNC(PlayDtmfTone,
527 (int event_code, int length_ms = 200, int attenuation_db = 10)) {
528 dtmf_info_.dtmf_event_code = event_code;
529 dtmf_info_.dtmf_length_ms = length_ms;
530 return 0;
531 }
532 WEBRTC_STUB(StartPlayingDtmfTone,
533 (int eventCode, int attenuationDb = 10));
534 WEBRTC_STUB(StopPlayingDtmfTone, ());
535
536 // webrtc::VoEFile
537 WEBRTC_FUNC(StartPlayingFileLocally, (int channel, const char* fileNameUTF8,
538 bool loop, webrtc::FileFormats format,
539 float volumeScaling, int startPointMs,
540 int stopPointMs)) {
541 WEBRTC_CHECK_CHANNEL(channel);
542 channels_[channel]->file = true;
543 return 0;
544 }
545 WEBRTC_FUNC(StartPlayingFileLocally, (int channel, webrtc::InStream* stream,
546 webrtc::FileFormats format,
547 float volumeScaling, int startPointMs,
548 int stopPointMs)) {
549 WEBRTC_CHECK_CHANNEL(channel);
550 channels_[channel]->file = true;
551 return 0;
552 }
553 WEBRTC_FUNC(StopPlayingFileLocally, (int channel)) {
554 WEBRTC_CHECK_CHANNEL(channel);
555 channels_[channel]->file = false;
556 return 0;
557 }
558 WEBRTC_FUNC(IsPlayingFileLocally, (int channel)) {
559 WEBRTC_CHECK_CHANNEL(channel);
560 return (channels_[channel]->file) ? 1 : 0;
561 }
562 WEBRTC_STUB(ScaleLocalFilePlayout, (int channel, float scale));
563 WEBRTC_STUB(StartPlayingFileAsMicrophone, (int channel,
564 const char* fileNameUTF8,
565 bool loop,
566 bool mixWithMicrophone,
567 webrtc::FileFormats format,
568 float volumeScaling));
569 WEBRTC_STUB(StartPlayingFileAsMicrophone, (int channel,
570 webrtc::InStream* stream,
571 bool mixWithMicrophone,
572 webrtc::FileFormats format,
573 float volumeScaling));
574 WEBRTC_STUB(StopPlayingFileAsMicrophone, (int channel));
575 WEBRTC_STUB(IsPlayingFileAsMicrophone, (int channel));
576 WEBRTC_STUB(ScaleFileAsMicrophonePlayout, (int channel, float scale));
577 WEBRTC_STUB(StartRecordingPlayout, (int channel, const char* fileNameUTF8,
578 webrtc::CodecInst* compression,
579 int maxSizeBytes));
580 WEBRTC_STUB(StartRecordingPlayout, (int channel, webrtc::OutStream* stream,
581 webrtc::CodecInst* compression));
582 WEBRTC_STUB(StopRecordingPlayout, (int channel));
583 WEBRTC_FUNC(StartRecordingMicrophone, (const char* fileNameUTF8,
584 webrtc::CodecInst* compression,
585 int maxSizeBytes)) {
586 if (fail_start_recording_microphone_) {
587 return -1;
588 }
589 recording_microphone_ = true;
590 return 0;
591 }
592 WEBRTC_FUNC(StartRecordingMicrophone, (webrtc::OutStream* stream,
593 webrtc::CodecInst* compression)) {
594 if (fail_start_recording_microphone_) {
595 return -1;
596 }
597 recording_microphone_ = true;
598 return 0;
599 }
600 WEBRTC_FUNC(StopRecordingMicrophone, ()) {
601 if (!recording_microphone_) {
602 return -1;
603 }
604 recording_microphone_ = false;
605 return 0;
606 }
607 WEBRTC_STUB(ConvertPCMToWAV, (const char* fileNameInUTF8,
608 const char* fileNameOutUTF8));
609 WEBRTC_STUB(ConvertPCMToWAV, (webrtc::InStream* streamIn,
610 webrtc::OutStream* streamOut));
611 WEBRTC_STUB(ConvertWAVToPCM, (const char* fileNameInUTF8,
612 const char* fileNameOutUTF8));
613 WEBRTC_STUB(ConvertWAVToPCM, (webrtc::InStream* streamIn,
614 webrtc::OutStream* streamOut));
615 WEBRTC_STUB(ConvertPCMToCompressed, (const char* fileNameInUTF8,
616 const char* fileNameOutUTF8,
617 webrtc::CodecInst* compression));
618 WEBRTC_STUB(ConvertPCMToCompressed, (webrtc::InStream* streamIn,
619 webrtc::OutStream* streamOut,
620 webrtc::CodecInst* compression));
621 WEBRTC_STUB(ConvertCompressedToPCM, (const char* fileNameInUTF8,
622 const char* fileNameOutUTF8));
623 WEBRTC_STUB(ConvertCompressedToPCM, (webrtc::InStream* streamIn,
624 webrtc::OutStream* streamOut));
625 WEBRTC_STUB(GetFileDuration, (const char* fileNameUTF8, int& durationMs,
626 webrtc::FileFormats format));
627 WEBRTC_STUB(GetPlaybackPosition, (int channel, int& positionMs));
628
629 // webrtc::VoEHardware
630 WEBRTC_STUB(GetCPULoad, (int&));
631 WEBRTC_FUNC(GetNumOfRecordingDevices, (int& num)) {
632 return GetNumDevices(num);
633 }
634 WEBRTC_FUNC(GetNumOfPlayoutDevices, (int& num)) {
635 return GetNumDevices(num);
636 }
637 WEBRTC_FUNC(GetRecordingDeviceName, (int i, char* name, char* guid)) {
638 return GetDeviceName(i, name, guid);
639 }
640 WEBRTC_FUNC(GetPlayoutDeviceName, (int i, char* name, char* guid)) {
641 return GetDeviceName(i, name, guid);
642 }
643 WEBRTC_STUB(SetRecordingDevice, (int, webrtc::StereoChannel));
644 WEBRTC_STUB(SetPlayoutDevice, (int));
645 WEBRTC_STUB(SetAudioDeviceLayer, (webrtc::AudioLayers));
646 WEBRTC_STUB(GetAudioDeviceLayer, (webrtc::AudioLayers&));
647 WEBRTC_STUB(GetPlayoutDeviceStatus, (bool&));
648 WEBRTC_STUB(GetRecordingDeviceStatus, (bool&));
649 WEBRTC_STUB(ResetAudioDevice, ());
650 WEBRTC_STUB(AudioDeviceControl, (unsigned int, unsigned int, unsigned int));
651 WEBRTC_STUB(SetLoudspeakerStatus, (bool enable));
652 WEBRTC_STUB(GetLoudspeakerStatus, (bool& enabled));
wu@webrtc.org97077a32013-10-25 21:18:33 +0000653 WEBRTC_FUNC(SetRecordingSampleRate, (unsigned int samples_per_sec)) {
654 recording_sample_rate_ = samples_per_sec;
655 return 0;
656 }
657 WEBRTC_FUNC_CONST(RecordingSampleRate, (unsigned int* samples_per_sec)) {
658 *samples_per_sec = recording_sample_rate_;
659 return 0;
660 }
661 WEBRTC_FUNC(SetPlayoutSampleRate, (unsigned int samples_per_sec)) {
662 playout_sample_rate_ = samples_per_sec;
663 return 0;
664 }
665 WEBRTC_FUNC_CONST(PlayoutSampleRate, (unsigned int* samples_per_sec)) {
666 *samples_per_sec = playout_sample_rate_;
667 return 0;
668 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000669 WEBRTC_STUB(EnableBuiltInAEC, (bool enable));
670 virtual bool BuiltInAECIsEnabled() const { return true; }
671
672 // webrtc::VoENetEqStats
673 WEBRTC_STUB(GetNetworkStatistics, (int, webrtc::NetworkStatistics&));
wu@webrtc.org24301a62013-12-13 19:17:43 +0000674 WEBRTC_FUNC_CONST(GetDecodingCallStatistics, (int channel,
675 webrtc::AudioDecodingCallStats*)) {
676 WEBRTC_CHECK_CHANNEL(channel);
677 return 0;
678 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000679
680 // webrtc::VoENetwork
681 WEBRTC_FUNC(RegisterExternalTransport, (int channel,
682 webrtc::Transport& transport)) {
683 WEBRTC_CHECK_CHANNEL(channel);
684 channels_[channel]->external_transport = true;
685 return 0;
686 }
687 WEBRTC_FUNC(DeRegisterExternalTransport, (int channel)) {
688 WEBRTC_CHECK_CHANNEL(channel);
689 channels_[channel]->external_transport = false;
690 return 0;
691 }
692 WEBRTC_FUNC(ReceivedRTPPacket, (int channel, const void* data,
693 unsigned int length)) {
694 WEBRTC_CHECK_CHANNEL(channel);
695 if (!channels_[channel]->external_transport) return -1;
696 channels_[channel]->packets.push_back(
697 std::string(static_cast<const char*>(data), length));
698 return 0;
699 }
buildbot@webrtc.orgf875f152014-04-14 16:06:21 +0000700 WEBRTC_FUNC(ReceivedRTPPacket, (int channel, const void* data,
701 unsigned int length,
702 const webrtc::PacketTime& packet_time)) {
703 WEBRTC_CHECK_CHANNEL(channel);
704 if (ReceivedRTPPacket(channel, data, length) == -1) {
705 return -1;
706 }
707 channels_[channel]->last_rtp_packet_time = packet_time;
708 return 0;
709 }
buildbot@webrtc.orgf875f152014-04-14 16:06:21 +0000710
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000711 WEBRTC_STUB(ReceivedRTCPPacket, (int channel, const void* data,
712 unsigned int length));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000713
714 // webrtc::VoERTP_RTCP
715 WEBRTC_STUB(RegisterRTPObserver, (int channel,
716 webrtc::VoERTPObserver& observer));
717 WEBRTC_STUB(DeRegisterRTPObserver, (int channel));
718 WEBRTC_STUB(RegisterRTCPObserver, (int channel,
719 webrtc::VoERTCPObserver& observer));
720 WEBRTC_STUB(DeRegisterRTCPObserver, (int channel));
721 WEBRTC_FUNC(SetLocalSSRC, (int channel, unsigned int ssrc)) {
722 WEBRTC_CHECK_CHANNEL(channel);
723 channels_[channel]->send_ssrc = ssrc;
724 return 0;
725 }
726 WEBRTC_FUNC(GetLocalSSRC, (int channel, unsigned int& ssrc)) {
727 WEBRTC_CHECK_CHANNEL(channel);
728 ssrc = channels_[channel]->send_ssrc;
729 return 0;
730 }
731 WEBRTC_STUB(GetRemoteSSRC, (int channel, unsigned int& ssrc));
henrike@webrtc.org79047f92014-03-06 23:46:59 +0000732 WEBRTC_FUNC(SetSendAudioLevelIndicationStatus, (int channel, bool enable,
733 unsigned char id)) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000734 WEBRTC_CHECK_CHANNEL(channel);
henrike@webrtc.org79047f92014-03-06 23:46:59 +0000735 WEBRTC_CHECK_HEADER_EXTENSION_ID(enable, id);
736 channels_[channel]->send_audio_level_ext_ = (enable) ? id : -1;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000737 return 0;
738 }
henrike@webrtc.org79047f92014-03-06 23:46:59 +0000739 WEBRTC_FUNC(SetSendAbsoluteSenderTimeStatus, (int channel, bool enable,
740 unsigned char id)) {
741 WEBRTC_CHECK_CHANNEL(channel);
742 WEBRTC_CHECK_HEADER_EXTENSION_ID(enable, id);
743 channels_[channel]->send_absolute_sender_time_ext_ = (enable) ? id : -1;
744 return 0;
745 }
746 WEBRTC_FUNC(SetReceiveAbsoluteSenderTimeStatus, (int channel, bool enable,
747 unsigned char id)) {
748 WEBRTC_CHECK_CHANNEL(channel);
749 WEBRTC_CHECK_HEADER_EXTENSION_ID(enable, id);
750 channels_[channel]->receive_absolute_sender_time_ext_ = (enable) ? id : -1;
751 return 0;
752 }
henrike@webrtc.org79047f92014-03-06 23:46:59 +0000753
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000754 WEBRTC_STUB(GetRemoteCSRCs, (int channel, unsigned int arrCSRC[15]));
755 WEBRTC_STUB(SetRTCPStatus, (int channel, bool enable));
756 WEBRTC_STUB(GetRTCPStatus, (int channel, bool& enabled));
757 WEBRTC_STUB(SetRTCP_CNAME, (int channel, const char cname[256]));
758 WEBRTC_STUB(GetRTCP_CNAME, (int channel, char cname[256]));
759 WEBRTC_STUB(GetRemoteRTCP_CNAME, (int channel, char* cname));
760 WEBRTC_STUB(GetRemoteRTCPData, (int channel, unsigned int& NTPHigh,
761 unsigned int& NTPLow,
762 unsigned int& timestamp,
763 unsigned int& playoutTimestamp,
764 unsigned int* jitter,
765 unsigned short* fractionLost));
766 WEBRTC_STUB(GetRemoteRTCPSenderInfo, (int channel,
767 webrtc::SenderInfo* sender_info));
768 WEBRTC_FUNC(GetRemoteRTCPReportBlocks,
769 (int channel, std::vector<webrtc::ReportBlock>* receive_blocks)) {
770 WEBRTC_CHECK_CHANNEL(channel);
771 webrtc::ReportBlock block;
772 block.source_SSRC = channels_[channel]->send_ssrc;
773 webrtc::CodecInst send_codec = channels_[channel]->send_codec;
774 if (send_codec.pltype >= 0) {
775 block.fraction_lost = (unsigned char)(kFractionLostStatValue * 256);
776 if (send_codec.plfreq / 1000 > 0) {
777 block.interarrival_jitter = kIntStatValue * (send_codec.plfreq / 1000);
778 }
779 block.cumulative_num_packets_lost = kIntStatValue;
780 block.extended_highest_sequence_number = kIntStatValue;
781 receive_blocks->push_back(block);
782 }
783 return 0;
784 }
785 WEBRTC_STUB(SendApplicationDefinedRTCPPacket, (int channel,
786 unsigned char subType,
787 unsigned int name,
788 const char* data,
789 unsigned short dataLength));
790 WEBRTC_STUB(GetRTPStatistics, (int channel, unsigned int& averageJitterMs,
791 unsigned int& maxJitterMs,
792 unsigned int& discardedPackets));
793 WEBRTC_FUNC(GetRTCPStatistics, (int channel, webrtc::CallStatistics& stats)) {
794 WEBRTC_CHECK_CHANNEL(channel);
795 stats.fractionLost = static_cast<int16>(kIntStatValue);
796 stats.cumulativeLost = kIntStatValue;
797 stats.extendedMax = kIntStatValue;
798 stats.jitterSamples = kIntStatValue;
799 stats.rttMs = kIntStatValue;
800 stats.bytesSent = kIntStatValue;
801 stats.packetsSent = kIntStatValue;
802 stats.bytesReceived = kIntStatValue;
803 stats.packetsReceived = kIntStatValue;
804 return 0;
805 }
806 WEBRTC_FUNC(SetFECStatus, (int channel, bool enable, int redPayloadtype)) {
807 WEBRTC_CHECK_CHANNEL(channel);
808 channels_[channel]->fec = enable;
809 channels_[channel]->fec_type = redPayloadtype;
810 return 0;
811 }
812 WEBRTC_FUNC(GetFECStatus, (int channel, bool& enable, int& redPayloadtype)) {
813 WEBRTC_CHECK_CHANNEL(channel);
814 enable = channels_[channel]->fec;
815 redPayloadtype = channels_[channel]->fec_type;
816 return 0;
817 }
818 WEBRTC_FUNC(SetNACKStatus, (int channel, bool enable, int maxNoPackets)) {
819 WEBRTC_CHECK_CHANNEL(channel);
820 channels_[channel]->nack = enable;
821 channels_[channel]->nack_max_packets = maxNoPackets;
822 return 0;
823 }
824 WEBRTC_STUB(StartRTPDump, (int channel, const char* fileNameUTF8,
825 webrtc::RTPDirections direction));
826 WEBRTC_STUB(StopRTPDump, (int channel, webrtc::RTPDirections direction));
827 WEBRTC_STUB(RTPDumpIsActive, (int channel, webrtc::RTPDirections direction));
828 WEBRTC_STUB(InsertExtraRTPPacket, (int channel, unsigned char payloadType,
829 bool markerBit, const char* payloadData,
830 unsigned short payloadSize));
831 WEBRTC_STUB(GetLastRemoteTimeStamp, (int channel,
832 uint32_t* lastRemoteTimeStamp));
buildbot@webrtc.orgf875f152014-04-14 16:06:21 +0000833 WEBRTC_FUNC(SetVideoEngineBWETarget, (int channel,
834 webrtc::ViENetwork* vie_network,
835 int video_channel)) {
836 WEBRTC_CHECK_CHANNEL(channel);
837 channels_[channel]->vie_network = vie_network;
838 channels_[channel]->video_channel = video_channel;
839 return 0;
840 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000841
842 // webrtc::VoEVideoSync
843 WEBRTC_STUB(GetPlayoutBufferSize, (int& bufferMs));
844 WEBRTC_STUB(GetPlayoutTimestamp, (int channel, unsigned int& timestamp));
wu@webrtc.org822fbd82013-08-15 23:38:54 +0000845 WEBRTC_STUB(GetRtpRtcp, (int, webrtc::RtpRtcp**, webrtc::RtpReceiver**));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000846 WEBRTC_STUB(SetInitTimestamp, (int channel, unsigned int timestamp));
847 WEBRTC_STUB(SetInitSequenceNumber, (int channel, short sequenceNumber));
848 WEBRTC_STUB(SetMinimumPlayoutDelay, (int channel, int delayMs));
849 WEBRTC_STUB(SetInitialPlayoutDelay, (int channel, int delay_ms));
850 WEBRTC_STUB(GetDelayEstimate, (int channel, int* jitter_buffer_delay_ms,
851 int* playout_buffer_delay_ms));
852 WEBRTC_STUB_CONST(GetLeastRequiredDelayMs, (int channel));
853
854 // webrtc::VoEVolumeControl
855 WEBRTC_STUB(SetSpeakerVolume, (unsigned int));
856 WEBRTC_STUB(GetSpeakerVolume, (unsigned int&));
857 WEBRTC_STUB(SetSystemOutputMute, (bool));
858 WEBRTC_STUB(GetSystemOutputMute, (bool&));
859 WEBRTC_STUB(SetMicVolume, (unsigned int));
860 WEBRTC_STUB(GetMicVolume, (unsigned int&));
861 WEBRTC_STUB(SetInputMute, (int, bool));
862 WEBRTC_STUB(GetInputMute, (int, bool&));
863 WEBRTC_STUB(SetSystemInputMute, (bool));
864 WEBRTC_STUB(GetSystemInputMute, (bool&));
865 WEBRTC_STUB(GetSpeechInputLevel, (unsigned int&));
866 WEBRTC_STUB(GetSpeechOutputLevel, (int, unsigned int&));
867 WEBRTC_STUB(GetSpeechInputLevelFullRange, (unsigned int&));
868 WEBRTC_STUB(GetSpeechOutputLevelFullRange, (int, unsigned int&));
869 WEBRTC_FUNC(SetChannelOutputVolumeScaling, (int channel, float scale)) {
870 WEBRTC_CHECK_CHANNEL(channel);
871 channels_[channel]->volume_scale= scale;
872 return 0;
873 }
874 WEBRTC_FUNC(GetChannelOutputVolumeScaling, (int channel, float& scale)) {
875 WEBRTC_CHECK_CHANNEL(channel);
876 scale = channels_[channel]->volume_scale;
877 return 0;
878 }
879 WEBRTC_FUNC(SetOutputVolumePan, (int channel, float left, float right)) {
880 WEBRTC_CHECK_CHANNEL(channel);
881 channels_[channel]->volume_pan_left = left;
882 channels_[channel]->volume_pan_right = right;
883 return 0;
884 }
885 WEBRTC_FUNC(GetOutputVolumePan, (int channel, float& left, float& right)) {
886 WEBRTC_CHECK_CHANNEL(channel);
887 left = channels_[channel]->volume_pan_left;
888 right = channels_[channel]->volume_pan_right;
889 return 0;
890 }
891
892 // webrtc::VoEAudioProcessing
893 WEBRTC_FUNC(SetNsStatus, (bool enable, webrtc::NsModes mode)) {
894 ns_enabled_ = enable;
895 ns_mode_ = mode;
896 return 0;
897 }
898 WEBRTC_FUNC(GetNsStatus, (bool& enabled, webrtc::NsModes& mode)) {
899 enabled = ns_enabled_;
900 mode = ns_mode_;
901 return 0;
902 }
903
904 WEBRTC_FUNC(SetAgcStatus, (bool enable, webrtc::AgcModes mode)) {
905 agc_enabled_ = enable;
906 agc_mode_ = mode;
907 return 0;
908 }
909 WEBRTC_FUNC(GetAgcStatus, (bool& enabled, webrtc::AgcModes& mode)) {
910 enabled = agc_enabled_;
911 mode = agc_mode_;
912 return 0;
913 }
914
915 WEBRTC_FUNC(SetAgcConfig, (webrtc::AgcConfig config)) {
916 agc_config_ = config;
917 return 0;
918 }
919 WEBRTC_FUNC(GetAgcConfig, (webrtc::AgcConfig& config)) {
920 config = agc_config_;
921 return 0;
922 }
923 WEBRTC_FUNC(SetEcStatus, (bool enable, webrtc::EcModes mode)) {
924 ec_enabled_ = enable;
925 ec_mode_ = mode;
926 return 0;
927 }
928 WEBRTC_FUNC(GetEcStatus, (bool& enabled, webrtc::EcModes& mode)) {
929 enabled = ec_enabled_;
930 mode = ec_mode_;
931 return 0;
932 }
933 WEBRTC_STUB(EnableDriftCompensation, (bool enable))
934 WEBRTC_BOOL_STUB(DriftCompensationEnabled, ())
935 WEBRTC_VOID_STUB(SetDelayOffsetMs, (int offset))
936 WEBRTC_STUB(DelayOffsetMs, ());
937 WEBRTC_FUNC(SetAecmMode, (webrtc::AecmModes mode, bool enableCNG)) {
938 aecm_mode_ = mode;
939 cng_enabled_ = enableCNG;
940 return 0;
941 }
942 WEBRTC_FUNC(GetAecmMode, (webrtc::AecmModes& mode, bool& enabledCNG)) {
943 mode = aecm_mode_;
944 enabledCNG = cng_enabled_;
945 return 0;
946 }
947 WEBRTC_STUB(SetRxNsStatus, (int channel, bool enable, webrtc::NsModes mode));
948 WEBRTC_STUB(GetRxNsStatus, (int channel, bool& enabled,
949 webrtc::NsModes& mode));
wu@webrtc.org97077a32013-10-25 21:18:33 +0000950 WEBRTC_FUNC(SetRxAgcStatus, (int channel, bool enable,
951 webrtc::AgcModes mode)) {
952 channels_[channel]->rx_agc_enabled = enable;
953 channels_[channel]->rx_agc_mode = mode;
954 return 0;
955 }
956 WEBRTC_FUNC(GetRxAgcStatus, (int channel, bool& enabled,
957 webrtc::AgcModes& mode)) {
958 enabled = channels_[channel]->rx_agc_enabled;
959 mode = channels_[channel]->rx_agc_mode;
960 return 0;
961 }
962
963 WEBRTC_FUNC(SetRxAgcConfig, (int channel, webrtc::AgcConfig config)) {
964 channels_[channel]->rx_agc_config = config;
965 return 0;
966 }
967 WEBRTC_FUNC(GetRxAgcConfig, (int channel, webrtc::AgcConfig& config)) {
968 config = channels_[channel]->rx_agc_config;
969 return 0;
970 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000971
972 WEBRTC_STUB(RegisterRxVadObserver, (int, webrtc::VoERxVadCallback&));
973 WEBRTC_STUB(DeRegisterRxVadObserver, (int channel));
974 WEBRTC_STUB(VoiceActivityIndicator, (int channel));
975 WEBRTC_FUNC(SetEcMetricsStatus, (bool enable)) {
976 ec_metrics_enabled_ = enable;
977 return 0;
978 }
979 WEBRTC_FUNC(GetEcMetricsStatus, (bool& enabled)) {
980 enabled = ec_metrics_enabled_;
981 return 0;
982 }
983 WEBRTC_STUB(GetEchoMetrics, (int& ERL, int& ERLE, int& RERL, int& A_NLP));
984 WEBRTC_STUB(GetEcDelayMetrics, (int& delay_median, int& delay_std));
985
986 WEBRTC_STUB(StartDebugRecording, (const char* fileNameUTF8));
wu@webrtc.org9caf2762013-12-11 18:25:07 +0000987 WEBRTC_STUB(StartDebugRecording, (FILE* handle));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000988 WEBRTC_STUB(StopDebugRecording, ());
989
990 WEBRTC_FUNC(SetTypingDetectionStatus, (bool enable)) {
991 typing_detection_enabled_ = enable;
992 return 0;
993 }
994 WEBRTC_FUNC(GetTypingDetectionStatus, (bool& enabled)) {
995 enabled = typing_detection_enabled_;
996 return 0;
997 }
998
999 WEBRTC_STUB(TimeSinceLastTyping, (int& seconds));
1000 WEBRTC_STUB(SetTypingDetectionParameters, (int timeWindow,
1001 int costPerTyping,
1002 int reportingThreshold,
1003 int penaltyDecay,
1004 int typeEventDelay));
1005 int EnableHighPassFilter(bool enable) {
1006 highpass_filter_enabled_ = enable;
1007 return 0;
1008 }
1009 bool IsHighPassFilterEnabled() {
1010 return highpass_filter_enabled_;
1011 }
1012 bool IsStereoChannelSwappingEnabled() {
1013 return stereo_swapping_enabled_;
1014 }
1015 void EnableStereoChannelSwapping(bool enable) {
1016 stereo_swapping_enabled_ = enable;
1017 }
1018 bool WasSendTelephoneEventCalled(int channel, int event_code, int length_ms) {
1019 return (channels_[channel]->dtmf_info.dtmf_event_code == event_code &&
1020 channels_[channel]->dtmf_info.dtmf_out_of_band == true &&
1021 channels_[channel]->dtmf_info.dtmf_length_ms == length_ms);
1022 }
1023 bool WasPlayDtmfToneCalled(int event_code, int length_ms) {
1024 return (dtmf_info_.dtmf_event_code == event_code &&
1025 dtmf_info_.dtmf_length_ms == length_ms);
1026 }
1027 // webrtc::VoEExternalMedia
1028 WEBRTC_FUNC(RegisterExternalMediaProcessing,
1029 (int channel, webrtc::ProcessingTypes type,
1030 webrtc::VoEMediaProcess& processObject)) {
1031 WEBRTC_CHECK_CHANNEL(channel);
1032 if (channels_[channel]->media_processor_registered) {
1033 return -1;
1034 }
1035 channels_[channel]->media_processor_registered = true;
1036 media_processor_ = &processObject;
1037 return 0;
1038 }
1039 WEBRTC_FUNC(DeRegisterExternalMediaProcessing,
1040 (int channel, webrtc::ProcessingTypes type)) {
1041 WEBRTC_CHECK_CHANNEL(channel);
1042 if (!channels_[channel]->media_processor_registered) {
1043 return -1;
1044 }
1045 channels_[channel]->media_processor_registered = false;
1046 media_processor_ = NULL;
1047 return 0;
1048 }
1049 WEBRTC_STUB(SetExternalRecordingStatus, (bool enable));
1050 WEBRTC_STUB(SetExternalPlayoutStatus, (bool enable));
1051 WEBRTC_STUB(ExternalRecordingInsertData,
1052 (const int16_t speechData10ms[], int lengthSamples,
1053 int samplingFreqHz, int current_delay_ms));
1054 WEBRTC_STUB(ExternalPlayoutGetData,
1055 (int16_t speechData10ms[], int samplingFreqHz,
1056 int current_delay_ms, int& lengthSamples));
1057 WEBRTC_STUB(GetAudioFrame, (int channel, int desired_sample_rate_hz,
1058 webrtc::AudioFrame* frame));
1059 WEBRTC_STUB(SetExternalMixing, (int channel, bool enable));
1060
1061 private:
1062 int GetNumDevices(int& num) {
1063#ifdef WIN32
1064 num = 1;
1065#else
1066 // On non-Windows platforms VE adds a special entry for the default device,
1067 // so if there is one physical device then there are two entries in the
1068 // list.
1069 num = 2;
1070#endif
1071 return 0;
1072 }
1073
1074 int GetDeviceName(int i, char* name, char* guid) {
1075 const char *s;
1076#ifdef WIN32
1077 if (0 == i) {
1078 s = kFakeDeviceName;
1079 } else {
1080 return -1;
1081 }
1082#else
1083 // See comment above.
1084 if (0 == i) {
1085 s = kFakeDefaultDeviceName;
1086 } else if (1 == i) {
1087 s = kFakeDeviceName;
1088 } else {
1089 return -1;
1090 }
1091#endif
1092 strcpy(name, s);
1093 guid[0] = '\0';
1094 return 0;
1095 }
1096
1097 bool inited_;
1098 int last_channel_;
1099 std::map<int, Channel*> channels_;
1100 bool fail_create_channel_;
1101 const cricket::AudioCodec* const* codecs_;
1102 int num_codecs_;
wu@webrtc.org05e7b442014-04-01 17:44:24 +00001103 int num_set_send_codecs_; // how many times we call SetSendCodec().
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001104 bool ec_enabled_;
1105 bool ec_metrics_enabled_;
1106 bool cng_enabled_;
1107 bool ns_enabled_;
1108 bool agc_enabled_;
1109 bool highpass_filter_enabled_;
1110 bool stereo_swapping_enabled_;
1111 bool typing_detection_enabled_;
1112 webrtc::EcModes ec_mode_;
1113 webrtc::AecmModes aecm_mode_;
1114 webrtc::NsModes ns_mode_;
1115 webrtc::AgcModes agc_mode_;
1116 webrtc::AgcConfig agc_config_;
1117 webrtc::VoiceEngineObserver* observer_;
1118 int playout_fail_channel_;
1119 int send_fail_channel_;
1120 bool fail_start_recording_microphone_;
1121 bool recording_microphone_;
wu@webrtc.org97077a32013-10-25 21:18:33 +00001122 int recording_sample_rate_;
1123 int playout_sample_rate_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001124 DtmfInfo dtmf_info_;
1125 webrtc::VoEMediaProcess* media_processor_;
1126};
1127
henrike@webrtc.org79047f92014-03-06 23:46:59 +00001128#undef WEBRTC_CHECK_HEADER_EXTENSION_ID
1129
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001130} // namespace cricket
1131
1132#endif // TALK_SESSION_PHONE_FAKEWEBRTCVOICEENGINE_H_