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