3
* Copyright 2010, Google Inc.
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions are met:
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.
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.
28
#ifndef TALK_SESSION_PHONE_FAKEWEBRTCVOICEENGINE_H_
29
#define TALK_SESSION_PHONE_FAKEWEBRTCVOICEENGINE_H_
35
#include "talk/base/basictypes.h"
36
#include "talk/base/stringutils.h"
37
#include "talk/session/phone/codec.h"
38
#include "talk/session/phone/fakewebrtccommon.h"
39
#include "talk/session/phone/voiceprocessor.h"
40
#include "talk/session/phone/webrtcvoe.h"
44
static const char kFakeDefaultDeviceName[] = "Fake Default";
45
static const int kFakeDefaultDeviceId = -1;
46
static const char kFakeDeviceName[] = "Fake Device";
48
static const int kFakeDeviceId = 0;
50
static const int kFakeDeviceId = 1;
53
class FakeWebRtcVoiceEngine
54
: public webrtc::VoEAudioProcessing,
55
public webrtc::VoEBase, public webrtc::VoECodec, public webrtc::VoEDtmf,
56
public webrtc::VoEFile, public webrtc::VoEHardware,
57
public webrtc::VoEExternalMedia, public webrtc::VoENetEqStats,
58
public webrtc::VoENetwork, public webrtc::VoERTP_RTCP,
59
public webrtc::VoEVideoSync, public webrtc::VoEVolumeControl {
63
: external_transport(false),
69
media_processor_registered(false),
75
level_header_ext_(-1) {
76
memset(&send_codec, 0, sizeof(send_codec));
78
bool external_transport;
84
bool media_processor_registered;
90
int level_header_ext_;
91
std::vector<webrtc::CodecInst> recv_codecs;
92
webrtc::CodecInst send_codec;
93
std::list<std::string> packets;
96
FakeWebRtcVoiceEngine(const cricket::AudioCodec* const* codecs,
100
fail_create_channel_(false),
102
num_codecs_(num_codecs),
105
ec_mode_(webrtc::kEcDefault),
106
ns_mode_(webrtc::kNsDefault),
108
playout_fail_channel_(-1),
109
send_fail_channel_(-1),
110
fail_start_recording_microphone_(false),
111
recording_microphone_(false),
112
media_processor_(NULL) {
113
memset(&agc_config_, 0, sizeof(agc_config_));
115
~FakeWebRtcVoiceEngine() {
116
// Ought to have all been deleted by the WebRtcVoiceMediaChannel
117
// destructors, but just in case ...
118
for (std::map<int, Channel*>::const_iterator i = channels_.begin();
119
i != channels_.end(); ++i) {
123
bool IsExternalMediaProcessorRegistered() const {
124
return media_processor_ != NULL;
126
bool IsInited() const { return inited_; }
127
int GetLastChannel() const { return last_channel_; }
128
int GetNumChannels() const { return channels_.size(); }
129
bool GetPlayout(int channel) {
130
return channels_[channel]->playout;
132
bool GetSend(int channel) {
133
return channels_[channel]->send;
135
bool GetRecordingMicrophone() {
136
return recording_microphone_;
138
bool GetVAD(int channel) {
139
return channels_[channel]->vad;
141
bool GetFEC(int channel) {
142
return channels_[channel]->fec;
144
int GetSendCNPayloadType(int channel, bool wideband) {
146
channels_[channel]->cn16_type :
147
channels_[channel]->cn8_type;
149
int GetSendTelephoneEventPayloadType(int channel) {
150
return channels_[channel]->dtmf_type;
152
int GetSendFECPayloadType(int channel) {
153
return channels_[channel]->fec_type;
155
bool CheckPacket(int channel, const void* data, size_t len) {
156
bool result = !CheckNoPacket(channel);
158
std::string packet = channels_[channel]->packets.front();
159
result = (packet == std::string(static_cast<const char*>(data), len));
160
channels_[channel]->packets.pop_front();
164
bool CheckNoPacket(int channel) {
165
return channels_[channel]->packets.empty();
167
void TriggerCallbackOnError(int channel_num, int err_code) {
168
ASSERT(observer_ != NULL);
169
observer_->CallbackOnError(channel_num, err_code);
171
void set_playout_fail_channel(int channel) {
172
playout_fail_channel_ = channel;
174
void set_send_fail_channel(int channel) {
175
send_fail_channel_ = channel;
177
void set_fail_start_recording_microphone(
178
bool fail_start_recording_microphone) {
179
fail_start_recording_microphone_ = fail_start_recording_microphone;
181
void set_fail_create_channel(bool fail_create_channel) {
182
fail_create_channel_ = fail_create_channel;
184
void TriggerProcessPacket(MediaProcessorDirection direction) {
185
webrtc::ProcessingTypes pt =
186
(direction == cricket::MPD_TX) ?
187
webrtc::kRecordingPerChannel : webrtc::kPlaybackPerChannel;
188
if (media_processor_ != NULL) {
189
media_processor_->Process(0,
198
WEBRTC_STUB(Release, ());
201
WEBRTC_FUNC(RegisterVoiceEngineObserver, (
202
webrtc::VoiceEngineObserver& observer)) {
203
observer_ = &observer;
206
WEBRTC_STUB(DeRegisterVoiceEngineObserver, ());
207
WEBRTC_STUB(RegisterAudioDeviceModule, (webrtc::AudioDeviceModule& adm));
208
WEBRTC_STUB(DeRegisterAudioDeviceModule, ());
210
WEBRTC_FUNC(Init, (webrtc::AudioDeviceModule* adm)) {
214
WEBRTC_FUNC(Terminate, ()) {
218
WEBRTC_STUB(MaxNumOfChannels, ());
219
WEBRTC_FUNC(CreateChannel, ()) {
220
if (fail_create_channel_) {
223
Channel* ch = new Channel();
224
for (int i = 0; i < NumOfCodecs(); ++i) {
225
webrtc::CodecInst codec;
227
ch->recv_codecs.push_back(codec);
229
channels_[++last_channel_] = ch;
230
return last_channel_;
232
WEBRTC_FUNC(DeleteChannel, (int channel)) {
233
WEBRTC_CHECK_CHANNEL(channel);
234
delete channels_[channel];
235
channels_.erase(channel);
238
WEBRTC_STUB(SetLocalReceiver, (int channel, int port, int RTCPport,
239
const char ipaddr[64],
240
const char multiCastAddr[64]));
241
WEBRTC_STUB(GetLocalReceiver, (int channel, int& port, int& RTCPport,
243
WEBRTC_STUB(SetSendDestination, (int channel, int port,
244
const char ipaddr[64],
245
int sourcePort, int RTCPport));
246
WEBRTC_STUB(GetSendDestination, (int channel, int& port, char ipaddr[64],
247
int& sourcePort, int& RTCPport));
248
WEBRTC_STUB(StartReceive, (int channel));
249
WEBRTC_FUNC(StartPlayout, (int channel)) {
250
if (playout_fail_channel_ != channel) {
251
WEBRTC_CHECK_CHANNEL(channel);
252
channels_[channel]->playout = true;
255
// When playout_fail_channel_ == channel, fail the StartPlayout on this
260
WEBRTC_FUNC(StartSend, (int channel)) {
261
if (send_fail_channel_ != channel) {
262
WEBRTC_CHECK_CHANNEL(channel);
263
channels_[channel]->send = true;
266
// When send_fail_channel_ == channel, fail the StartSend on this
271
WEBRTC_STUB(StopReceive, (int channel));
272
WEBRTC_FUNC(StopPlayout, (int channel)) {
273
WEBRTC_CHECK_CHANNEL(channel);
274
channels_[channel]->playout = false;
277
WEBRTC_FUNC(StopSend, (int channel)) {
278
WEBRTC_CHECK_CHANNEL(channel);
279
channels_[channel]->send = false;
282
WEBRTC_STUB(GetVersion, (char version[1024]));
283
WEBRTC_STUB(LastError, ());
284
WEBRTC_STUB(SetOnHoldStatus, (int, bool, webrtc::OnHoldModes));
285
WEBRTC_STUB(GetOnHoldStatus, (int, bool&, webrtc::OnHoldModes&));
286
WEBRTC_STUB(SetNetEQPlayoutMode, (int, webrtc::NetEqModes));
287
WEBRTC_STUB(GetNetEQPlayoutMode, (int, webrtc::NetEqModes&));
288
WEBRTC_STUB(SetNetEQBGNMode, (int, webrtc::NetEqBgnModes));
289
WEBRTC_STUB(GetNetEQBGNMode, (int, webrtc::NetEqBgnModes&));
292
WEBRTC_FUNC(NumOfCodecs, ()) {
295
WEBRTC_FUNC(GetCodec, (int index, webrtc::CodecInst& codec)) {
296
if (index < 0 || index >= NumOfCodecs()) {
299
const cricket::AudioCodec& c(*codecs_[index]);
301
talk_base::strcpyn(codec.plname, sizeof(codec.plname), c.name.c_str());
302
codec.plfreq = c.clockrate;
304
codec.channels = c.channels;
305
codec.rate = c.bitrate;
308
WEBRTC_FUNC(SetSendCodec, (int channel, const webrtc::CodecInst& codec)) {
309
WEBRTC_CHECK_CHANNEL(channel);
310
channels_[channel]->send_codec = codec;
313
WEBRTC_FUNC(GetSendCodec, (int channel, webrtc::CodecInst& codec)) {
314
WEBRTC_CHECK_CHANNEL(channel);
315
codec = channels_[channel]->send_codec;
318
WEBRTC_STUB(GetRecCodec, (int channel, webrtc::CodecInst& codec));
319
WEBRTC_STUB(SetAMREncFormat, (int channel, webrtc::AmrMode mode));
320
WEBRTC_STUB(SetAMRDecFormat, (int channel, webrtc::AmrMode mode));
321
WEBRTC_STUB(SetAMRWbEncFormat, (int channel, webrtc::AmrMode mode));
322
WEBRTC_STUB(SetAMRWbDecFormat, (int channel, webrtc::AmrMode mode));
323
WEBRTC_STUB(SetISACInitTargetRate, (int channel, int rateBps,
324
bool useFixedFrameSize));
325
WEBRTC_STUB(SetISACMaxRate, (int channel, int rateBps));
326
WEBRTC_STUB(SetISACMaxPayloadSize, (int channel, int sizeBytes));
327
WEBRTC_FUNC(SetRecPayloadType, (int channel,
328
const webrtc::CodecInst& codec)) {
329
WEBRTC_CHECK_CHANNEL(channel);
330
Channel* ch = channels_[channel];
331
// Check if something else already has this slot.
332
if (codec.pltype != -1) {
333
for (std::vector<webrtc::CodecInst>::iterator it =
334
ch->recv_codecs.begin(); it != ch->recv_codecs.end(); ++it) {
335
if (it->pltype == codec.pltype) {
340
// Otherwise try to find this codec and update its payload type.
341
for (std::vector<webrtc::CodecInst>::iterator it = ch->recv_codecs.begin();
342
it != ch->recv_codecs.end(); ++it) {
343
if (strcmp(it->plname, codec.plname) == 0 &&
344
it->plfreq == codec.plfreq) {
345
it->pltype = codec.pltype;
349
return -1; // not found
351
WEBRTC_FUNC(SetSendCNPayloadType, (int channel, int type,
352
webrtc::PayloadFrequencies frequency)) {
353
WEBRTC_CHECK_CHANNEL(channel);
354
if (frequency == webrtc::kFreq8000Hz) {
355
channels_[channel]->cn8_type = type;
356
} else if (frequency == webrtc::kFreq16000Hz) {
357
channels_[channel]->cn16_type = type;
361
WEBRTC_FUNC(GetRecPayloadType, (int channel, webrtc::CodecInst& codec)) {
362
WEBRTC_CHECK_CHANNEL(channel);
363
Channel* ch = channels_[channel];
364
for (std::vector<webrtc::CodecInst>::iterator it = ch->recv_codecs.begin();
365
it != ch->recv_codecs.end(); ++it) {
366
if (strcmp(it->plname, codec.plname) == 0 &&
367
it->plfreq == codec.plfreq &&
369
codec.pltype = it->pltype;
373
return -1; // not found
375
WEBRTC_FUNC(SetVADStatus, (int channel, bool enable, webrtc::VadModes mode,
377
WEBRTC_CHECK_CHANNEL(channel);
378
channels_[channel]->vad = enable;
381
WEBRTC_STUB(GetVADStatus, (int channel, bool& enabled,
382
webrtc::VadModes& mode, bool& disabledDTX));
385
WEBRTC_STUB(SendTelephoneEvent, (int channel, int eventCode,
386
bool outOfBand = true, int lengthMs = 160, int attenuationDb = 10));
388
WEBRTC_FUNC(SetSendTelephoneEventPayloadType,
389
(int channel, unsigned char type)) {
390
channels_[channel]->dtmf_type = type;
393
WEBRTC_STUB(GetSendTelephoneEventPayloadType,
394
(int channel, unsigned char& type));
396
WEBRTC_STUB(SetDtmfFeedbackStatus, (bool enable, bool directFeedback));
397
WEBRTC_STUB(GetDtmfFeedbackStatus, (bool& enabled, bool& directFeedback));
398
WEBRTC_STUB(RegisterTelephoneEventDetection, (int channel,
399
webrtc::TelephoneEventDetectionMethods detectionMethod,
400
webrtc::VoETelephoneEventObserver& observer));
401
WEBRTC_STUB(DeRegisterTelephoneEventDetection, (int channel));
402
WEBRTC_STUB(SetDtmfPlayoutStatus, (int channel, bool enable));
403
WEBRTC_STUB(GetDtmfPlayoutStatus, (int channel, bool& enabled));
406
WEBRTC_STUB(PlayDtmfTone,
407
(int eventCode, int lengthMs = 200, int attenuationDb = 10));
408
WEBRTC_STUB(StartPlayingDtmfTone,
409
(int eventCode, int attenuationDb = 10));
410
WEBRTC_STUB(StopPlayingDtmfTone, ());
411
WEBRTC_STUB(GetTelephoneEventDetectionStatus, (int channel,
412
bool& enabled, webrtc::TelephoneEventDetectionMethods& detectionMethod));
415
WEBRTC_FUNC(StartPlayingFileLocally, (int channel, const char* fileNameUTF8,
416
bool loop, webrtc::FileFormats format,
417
float volumeScaling, int startPointMs,
419
WEBRTC_CHECK_CHANNEL(channel);
420
channels_[channel]->file = true;
423
WEBRTC_FUNC(StartPlayingFileLocally, (int channel, webrtc::InStream* stream,
424
webrtc::FileFormats format,
425
float volumeScaling, int startPointMs,
427
WEBRTC_CHECK_CHANNEL(channel);
428
channels_[channel]->file = true;
431
WEBRTC_FUNC(StopPlayingFileLocally, (int channel)) {
432
WEBRTC_CHECK_CHANNEL(channel);
433
channels_[channel]->file = false;
436
WEBRTC_FUNC(IsPlayingFileLocally, (int channel)) {
437
WEBRTC_CHECK_CHANNEL(channel);
438
return (channels_[channel]->file) ? 1 : 0;
440
WEBRTC_STUB(ScaleLocalFilePlayout, (int channel, float scale));
441
WEBRTC_STUB(StartPlayingFileAsMicrophone, (int channel,
442
const char* fileNameUTF8,
444
bool mixWithMicrophone,
445
webrtc::FileFormats format,
446
float volumeScaling));
447
WEBRTC_STUB(StartPlayingFileAsMicrophone, (int channel,
448
webrtc::InStream* stream,
449
bool mixWithMicrophone,
450
webrtc::FileFormats format,
451
float volumeScaling));
452
WEBRTC_STUB(StopPlayingFileAsMicrophone, (int channel));
453
WEBRTC_STUB(IsPlayingFileAsMicrophone, (int channel));
454
WEBRTC_STUB(ScaleFileAsMicrophonePlayout, (int channel, float scale));
455
WEBRTC_STUB(StartRecordingPlayout, (int channel, const char* fileNameUTF8,
456
webrtc::CodecInst* compression,
458
WEBRTC_STUB(StartRecordingPlayout, (int channel, webrtc::OutStream* stream,
459
webrtc::CodecInst* compression));
460
WEBRTC_STUB(StopRecordingPlayout, (int channel));
461
WEBRTC_FUNC(StartRecordingMicrophone, (const char* fileNameUTF8,
462
webrtc::CodecInst* compression,
464
if (fail_start_recording_microphone_) {
467
recording_microphone_ = true;
470
WEBRTC_FUNC(StartRecordingMicrophone, (webrtc::OutStream* stream,
471
webrtc::CodecInst* compression)) {
472
if (fail_start_recording_microphone_) {
475
recording_microphone_ = true;
478
WEBRTC_FUNC(StopRecordingMicrophone, ()) {
479
if (!recording_microphone_) {
482
recording_microphone_ = false;
485
WEBRTC_STUB(ConvertPCMToWAV, (const char* fileNameInUTF8,
486
const char* fileNameOutUTF8));
487
WEBRTC_STUB(ConvertPCMToWAV, (webrtc::InStream* streamIn,
488
webrtc::OutStream* streamOut));
489
WEBRTC_STUB(ConvertWAVToPCM, (const char* fileNameInUTF8,
490
const char* fileNameOutUTF8));
491
WEBRTC_STUB(ConvertWAVToPCM, (webrtc::InStream* streamIn,
492
webrtc::OutStream* streamOut));
493
WEBRTC_STUB(ConvertPCMToCompressed, (const char* fileNameInUTF8,
494
const char* fileNameOutUTF8,
495
webrtc::CodecInst* compression));
496
WEBRTC_STUB(ConvertPCMToCompressed, (webrtc::InStream* streamIn,
497
webrtc::OutStream* streamOut,
498
webrtc::CodecInst* compression));
499
WEBRTC_STUB(ConvertCompressedToPCM, (const char* fileNameInUTF8,
500
const char* fileNameOutUTF8));
501
WEBRTC_STUB(ConvertCompressedToPCM, (webrtc::InStream* streamIn,
502
webrtc::OutStream* streamOut));
503
WEBRTC_STUB(GetFileDuration, (const char* fileNameUTF8, int& durationMs,
504
webrtc::FileFormats format));
505
WEBRTC_STUB(GetPlaybackPosition, (int channel, int& positionMs));
507
// webrtc::VoEHardware
508
WEBRTC_STUB(GetCPULoad, (int&));
509
WEBRTC_STUB(GetSystemCPULoad, (int&));
510
WEBRTC_FUNC(GetNumOfRecordingDevices, (int& num)) {
511
return GetNumDevices(num);
513
WEBRTC_FUNC(GetNumOfPlayoutDevices, (int& num)) {
514
return GetNumDevices(num);
516
WEBRTC_FUNC(GetRecordingDeviceName, (int i, char* name, char* guid)) {
517
return GetDeviceName(i, name, guid);
519
WEBRTC_FUNC(GetPlayoutDeviceName, (int i, char* name, char* guid)) {
520
return GetDeviceName(i, name, guid);
522
WEBRTC_STUB(SetRecordingDevice, (int, webrtc::StereoChannel));
523
WEBRTC_STUB(SetPlayoutDevice, (int));
524
WEBRTC_STUB(SetAudioDeviceLayer, (webrtc::AudioLayers));
525
WEBRTC_STUB(GetAudioDeviceLayer, (webrtc::AudioLayers&));
526
WEBRTC_STUB(GetPlayoutDeviceStatus, (bool&));
527
WEBRTC_STUB(GetRecordingDeviceStatus, (bool&));
528
WEBRTC_STUB(ResetAudioDevice, ());
529
WEBRTC_STUB(AudioDeviceControl, (unsigned int, unsigned int, unsigned int));
530
WEBRTC_STUB(NeedMorePlayData, (short int*, int, int, int, int&));
531
WEBRTC_STUB(RecordedDataIsAvailable, (short int*, int, int, int, int&));
532
WEBRTC_STUB(GetDevice, (char*, unsigned int));
533
WEBRTC_STUB(GetPlatform, (char*, unsigned int));
534
WEBRTC_STUB(GetOS, (char*, unsigned int));
535
WEBRTC_STUB(SetGrabPlayout, (bool));
536
WEBRTC_STUB(SetGrabRecording, (bool));
537
WEBRTC_STUB(SetLoudspeakerStatus, (bool enable));
538
WEBRTC_STUB(GetLoudspeakerStatus, (bool& enabled));
539
WEBRTC_STUB(EnableBuiltInAEC, (bool enable));
540
virtual bool BuiltInAECIsEnabled() const { return true; }
541
WEBRTC_STUB(SetSamplingRate, (int));
542
WEBRTC_STUB(GetSamplingRate, (int&));
544
// webrtc::VoENetEqStats
545
WEBRTC_STUB(GetNetworkStatistics, (int, webrtc::NetworkStatistics&));
546
WEBRTC_STUB(GetPreferredBufferSize, (int, short unsigned int&));
547
WEBRTC_STUB(ResetJitterStatistics, (int));
549
// webrtc::VoENetwork
550
WEBRTC_FUNC(RegisterExternalTransport, (int channel,
551
webrtc::Transport& transport)) {
552
WEBRTC_CHECK_CHANNEL(channel);
553
channels_[channel]->external_transport = true;
556
WEBRTC_FUNC(DeRegisterExternalTransport, (int channel)) {
557
WEBRTC_CHECK_CHANNEL(channel);
558
channels_[channel]->external_transport = false;
561
WEBRTC_FUNC(ReceivedRTPPacket, (int channel, const void* data,
562
unsigned int length)) {
563
WEBRTC_CHECK_CHANNEL(channel);
564
if (!channels_[channel]->external_transport) return -1;
565
channels_[channel]->packets.push_back(
566
std::string(static_cast<const char*>(data), length));
569
WEBRTC_STUB(ReceivedRTCPPacket, (int channel, const void* data,
570
unsigned int length));
571
WEBRTC_STUB(GetSourceInfo, (int channel, int& rtpPort, int& rtcpPort,
573
WEBRTC_STUB(GetLocalIP, (char ipaddr[64], bool ipv6));
574
WEBRTC_STUB(EnableIPv6, (int channel));
575
// Not using WEBRTC_STUB due to bool return value
576
virtual bool IPv6IsEnabled(int channel) { return true; }
577
WEBRTC_STUB(SetSourceFilter, (int channel, int rtpPort, int rtcpPort,
578
const char ipaddr[64]));
579
WEBRTC_STUB(GetSourceFilter, (int channel, int& rtpPort, int& rtcpPort,
581
WEBRTC_STUB(SetSendTOS, (int channel, int priority,
582
int DSCP, bool useSetSockopt));
583
WEBRTC_STUB(GetSendTOS, (int channel, int& priority,
584
int& DSCP, bool& useSetSockopt));
585
WEBRTC_STUB(SetSendGQoS, (int channel, bool enable, int serviceType,
587
WEBRTC_STUB(GetSendGQoS, (int channel, bool& enabled, int& serviceType,
589
WEBRTC_STUB(SetPacketTimeoutNotification, (int channel, bool enable,
590
int timeoutSeconds));
591
WEBRTC_STUB(GetPacketTimeoutNotification, (int channel, bool& enable,
592
int& timeoutSeconds));
593
WEBRTC_STUB(RegisterDeadOrAliveObserver, (int channel,
594
webrtc::VoEConnectionObserver& observer));
595
WEBRTC_STUB(DeRegisterDeadOrAliveObserver, (int channel));
596
WEBRTC_STUB(GetPeriodicDeadOrAliveStatus, (int channel, bool& enabled,
597
int& sampleTimeSeconds));
598
WEBRTC_STUB(SetPeriodicDeadOrAliveStatus, (int channel, bool enable,
599
int sampleTimeSeconds));
600
WEBRTC_STUB(SendUDPPacket, (int channel, const void* data,
601
unsigned int length, int& transmittedBytes,
602
bool useRtcpSocket));
604
// webrtc::VoERTP_RTCP
605
WEBRTC_STUB(RegisterRTPObserver, (int channel,
606
webrtc::VoERTPObserver& observer));
607
WEBRTC_STUB(DeRegisterRTPObserver, (int channel));
608
WEBRTC_STUB(RegisterRTCPObserver, (int channel,
609
webrtc::VoERTCPObserver& observer));
610
WEBRTC_STUB(DeRegisterRTCPObserver, (int channel));
611
WEBRTC_FUNC(SetLocalSSRC, (int channel, unsigned int ssrc)) {
612
WEBRTC_CHECK_CHANNEL(channel);
613
channels_[channel]->send_ssrc = ssrc;
616
WEBRTC_FUNC(GetLocalSSRC, (int channel, unsigned int& ssrc)) {
617
WEBRTC_CHECK_CHANNEL(channel);
618
ssrc = channels_[channel]->send_ssrc;
621
WEBRTC_STUB(GetRemoteSSRC, (int channel, unsigned int& ssrc));
622
WEBRTC_FUNC(SetRTPAudioLevelIndicationStatus, (int channel, bool enable,
624
WEBRTC_CHECK_CHANNEL(channel);
625
channels_[channel]->level_header_ext_ = (enable) ? ID : -1;
628
WEBRTC_FUNC(GetRTPAudioLevelIndicationStatus, (int channel, bool& enabled,
629
unsigned char& ID)) {
630
WEBRTC_CHECK_CHANNEL(channel);
631
enabled = (channels_[channel]->level_header_ext_ != -1);
632
ID = channels_[channel]->level_header_ext_;
635
WEBRTC_STUB(GetRemoteCSRCs, (int channel, unsigned int arrCSRC[15]));
636
WEBRTC_STUB(GetRemoteEnergy, (int channel, unsigned char arrEnergy[15]));
637
WEBRTC_STUB(SetRTCPStatus, (int channel, bool enable));
638
WEBRTC_STUB(GetRTCPStatus, (int channel, bool& enabled));
639
WEBRTC_STUB(SetRTCP_CNAME, (int channel, const char cname[256]));
640
WEBRTC_STUB(GetRTCP_CNAME, (int channel, char cname[256]));
641
WEBRTC_STUB(GetRemoteRTCP_CNAME, (int channel, char* cname));
642
WEBRTC_STUB(GetRemoteRTCPData, (int channel, unsigned int& NTPHigh,
643
unsigned int& NTPLow,
644
unsigned int& timestamp,
645
unsigned int& playoutTimestamp,
646
unsigned int* jitter,
647
unsigned short* fractionLost));
648
WEBRTC_STUB(SendApplicationDefinedRTCPPacket, (int channel,
649
const unsigned char subType,
652
unsigned short dataLength));
653
WEBRTC_STUB(GetRTPStatistics, (int channel, unsigned int& averageJitterMs,
654
unsigned int& maxJitterMs,
655
unsigned int& discardedPackets));
656
WEBRTC_STUB(GetRTCPStatistics, (int channel, unsigned short& fractionLost,
657
unsigned int& cumulativeLost,
658
unsigned int& extendedMax,
659
unsigned int& jitterSamples, int& rttMs));
660
WEBRTC_STUB(GetRTCPStatistics, (int channel, webrtc::CallStatistics& stats));
661
WEBRTC_FUNC(SetFECStatus, (int channel, bool enable, int redPayloadtype)) {
662
WEBRTC_CHECK_CHANNEL(channel);
663
channels_[channel]->fec = enable;
664
channels_[channel]->fec_type = redPayloadtype;
667
WEBRTC_FUNC(GetFECStatus, (int channel, bool& enable, int& redPayloadtype)) {
668
WEBRTC_CHECK_CHANNEL(channel);
669
enable = channels_[channel]->fec;
670
redPayloadtype = channels_[channel]->fec_type;
673
WEBRTC_STUB(SetRTPKeepaliveStatus, (int channel, bool enable,
674
int unknownPayloadType,
675
int deltaTransmitTimeSeconds));
676
WEBRTC_STUB(GetRTPKeepaliveStatus, (int channel, bool& enabled,
677
int& unknownPayloadType,
678
int& deltaTransmitTimeSeconds));
679
WEBRTC_STUB(StartRTPDump, (int channel, const char* fileNameUTF8,
680
webrtc::RTPDirections direction));
681
WEBRTC_STUB(StopRTPDump, (int channel, webrtc::RTPDirections direction));
682
WEBRTC_STUB(RTPDumpIsActive, (int channel, webrtc::RTPDirections direction));
683
WEBRTC_STUB(InsertExtraRTPPacket, (int channel, unsigned char payloadType,
684
bool markerBit, const char* payloadData,
685
unsigned short payloadSize));
687
// webrtc::VoEVideoSync
688
WEBRTC_STUB(GetPlayoutBufferSize, (int& bufferMs));
689
WEBRTC_STUB(GetPlayoutTimestamp, (int channel, unsigned int& timestamp));
690
WEBRTC_STUB(GetRtpRtcp, (int, webrtc::RtpRtcp*&));
691
WEBRTC_STUB(SetInitTimestamp, (int channel, unsigned int timestamp));
692
WEBRTC_STUB(SetInitSequenceNumber, (int channel, short sequenceNumber));
693
WEBRTC_STUB(SetMinimumPlayoutDelay, (int channel, int delayMs));
694
WEBRTC_STUB(GetDelayEstimate, (int channel, int& delayMs));
695
WEBRTC_STUB(GetSoundcardBufferSize, (int& bufferMs));
697
// webrtc::VoEVolumeControl
698
WEBRTC_STUB(SetSpeakerVolume, (unsigned int));
699
WEBRTC_STUB(GetSpeakerVolume, (unsigned int&));
700
WEBRTC_STUB(SetSystemOutputMute, (bool));
701
WEBRTC_STUB(GetSystemOutputMute, (bool&));
702
WEBRTC_STUB(SetMicVolume, (unsigned int));
703
WEBRTC_STUB(GetMicVolume, (unsigned int&));
704
WEBRTC_STUB(SetInputMute, (int, bool));
705
WEBRTC_STUB(GetInputMute, (int, bool&));
706
WEBRTC_STUB(SetSystemInputMute, (bool));
707
WEBRTC_STUB(GetSystemInputMute, (bool&));
708
WEBRTC_STUB(GetSpeechInputLevel, (unsigned int&));
709
WEBRTC_STUB(GetSpeechOutputLevel, (int, unsigned int&));
710
WEBRTC_STUB(GetSpeechInputLevelFullRange, (unsigned int&));
711
WEBRTC_STUB(GetSpeechOutputLevelFullRange, (int, unsigned int&));
712
WEBRTC_STUB(SetChannelOutputVolumeScaling, (int, float));
713
WEBRTC_STUB(GetChannelOutputVolumeScaling, (int, float&));
714
WEBRTC_STUB(SetOutputVolumePan, (int, float, float));
715
WEBRTC_STUB(GetOutputVolumePan, (int, float&, float&));
717
// webrtc::VoEAudioProcessing
718
WEBRTC_FUNC(SetNsStatus, (bool enable, webrtc::NsModes mode)) {
719
ns_enabled_ = enable;
723
WEBRTC_FUNC(GetNsStatus, (bool& enabled, webrtc::NsModes& mode)) {
724
enabled = ns_enabled_;
728
WEBRTC_STUB(SetAgcStatus, (bool enable, webrtc::AgcModes mode));
729
WEBRTC_STUB(GetAgcStatus, (bool& enabled, webrtc::AgcModes& mode));
731
WEBRTC_FUNC(SetAgcConfig, (const webrtc::AgcConfig config)) {
732
agc_config_ = config;
735
WEBRTC_FUNC(GetAgcConfig, (webrtc::AgcConfig& config)) {
736
config = agc_config_;
739
WEBRTC_FUNC(SetEcStatus, (bool enable, webrtc::EcModes mode)) {
740
ec_enabled_ = enable;
744
WEBRTC_FUNC(GetEcStatus, (bool& enabled, webrtc::EcModes& mode)) {
745
enabled = ec_enabled_;
749
virtual void SetDelayOffsetMs(int offset) {}
750
WEBRTC_STUB(DelayOffsetMs, ());
751
WEBRTC_STUB(SetAecmMode, (webrtc::AecmModes mode, bool enableCNG));
752
WEBRTC_STUB(GetAecmMode, (webrtc::AecmModes& mode, bool& enabledCNG));
753
WEBRTC_STUB(SetRxNsStatus, (int channel, bool enable, webrtc::NsModes mode));
754
WEBRTC_STUB(GetRxNsStatus, (int channel, bool& enabled,
755
webrtc::NsModes& mode));
756
WEBRTC_STUB(SetRxAgcStatus, (int channel, bool enable,
757
webrtc::AgcModes mode));
758
WEBRTC_STUB(GetRxAgcStatus, (int channel, bool& enabled,
759
webrtc::AgcModes& mode));
760
WEBRTC_STUB(SetRxAgcConfig, (int channel, const webrtc::AgcConfig config));
761
WEBRTC_STUB(GetRxAgcConfig, (int channel, webrtc::AgcConfig& config));
763
WEBRTC_STUB(RegisterRxVadObserver, (int, webrtc::VoERxVadCallback&));
764
WEBRTC_STUB(DeRegisterRxVadObserver, (int channel));
765
WEBRTC_STUB(VoiceActivityIndicator, (int channel));
766
WEBRTC_STUB(SetEcMetricsStatus, (bool enable));
767
WEBRTC_STUB(GetEcMetricsStatus, (bool& enable));
768
WEBRTC_STUB(GetEchoMetrics, (int& ERL, int& ERLE, int& RERL, int& A_NLP));
769
WEBRTC_STUB(GetEcDelayMetrics, (int& delay_median, int& delay_std));
771
WEBRTC_STUB(StartDebugRecording, (const char* fileNameUTF8));
772
WEBRTC_STUB(StopDebugRecording, ());
774
WEBRTC_STUB(SetTypingDetectionStatus, (bool enable));
775
WEBRTC_STUB(GetTypingDetectionStatus, (bool& enabled));
777
// webrtc::VoEExternalMedia
778
WEBRTC_FUNC(RegisterExternalMediaProcessing,
779
(int channel, webrtc::ProcessingTypes type,
780
webrtc::VoEMediaProcess& processObject)) {
781
WEBRTC_CHECK_CHANNEL(channel);
782
if (channels_[channel]->media_processor_registered) {
785
channels_[channel]->media_processor_registered = true;
786
media_processor_ = &processObject;
789
WEBRTC_FUNC(DeRegisterExternalMediaProcessing,
790
(int channel, webrtc::ProcessingTypes type)) {
791
WEBRTC_CHECK_CHANNEL(channel);
792
if (!channels_[channel]->media_processor_registered) {
795
channels_[channel]->media_processor_registered = false;
796
media_processor_ = NULL;
799
WEBRTC_STUB(SetExternalRecordingStatus, (bool enable));
800
WEBRTC_STUB(SetExternalPlayoutStatus, (bool enable));
801
WEBRTC_STUB(ExternalRecordingInsertData,
802
(const WebRtc_Word16 speechData10ms[], int lengthSamples,
803
int samplingFreqHz, int current_delay_ms));
804
WEBRTC_STUB(ExternalPlayoutGetData,
805
(WebRtc_Word16 speechData10ms[], int samplingFreqHz,
806
int current_delay_ms, int& lengthSamples));
809
int GetNumDevices(int& num) {
813
// On non-Windows platforms VE adds a special entry for the default device,
814
// so if there is one physical device then there are two entries in the
821
int GetDeviceName(int i, char* name, char* guid) {
830
// See comment above.
832
s = kFakeDefaultDeviceName;
846
std::map<int, Channel*> channels_;
847
bool fail_create_channel_;
848
const cricket::AudioCodec* const* codecs_;
852
webrtc::EcModes ec_mode_;
853
webrtc::NsModes ns_mode_;
854
webrtc::AgcConfig agc_config_;
855
webrtc::VoiceEngineObserver* observer_;
856
int playout_fail_channel_;
857
int send_fail_channel_;
858
bool fail_start_recording_microphone_;
859
bool recording_microphone_;
860
webrtc::VoEMediaProcess* media_processor_;
863
} // namespace cricket
865
#endif // TALK_SESSION_PHONE_FAKEWEBRTCVOICEENGINE_H_