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