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