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