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