channel.h revision 24045c5a02873ad98232e97857593abacf4c3a56
1/*
2 *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 *
4 *  Use of this source code is governed by a BSD-style license
5 *  that can be found in the LICENSE file in the root of the source
6 *  tree. An additional intellectual property rights grant can be found
7 *  in the file PATENTS.  All contributing project authors may
8 *  be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef WEBRTC_VOICE_ENGINE_CHANNEL_H
12#define WEBRTC_VOICE_ENGINE_CHANNEL_H
13
14#include "webrtc/common_audio/resampler/include/resampler.h"
15#include "webrtc/common_types.h"
16#include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h"
17#include "webrtc/modules/audio_conference_mixer/interface/audio_conference_mixer_defines.h"
18#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h"
19#include "webrtc/modules/utility/interface/file_player.h"
20#include "webrtc/modules/utility/interface/file_recorder.h"
21#include "webrtc/system_wrappers/interface/scoped_ptr.h"
22#include "webrtc/voice_engine/dtmf_inband.h"
23#include "webrtc/voice_engine/dtmf_inband_queue.h"
24#include "webrtc/voice_engine/include/voe_audio_processing.h"
25#include "webrtc/voice_engine/include/voe_network.h"
26#include "webrtc/voice_engine/level_indicator.h"
27#include "webrtc/voice_engine/shared_data.h"
28#include "webrtc/voice_engine/voice_engine_defines.h"
29
30#ifndef WEBRTC_EXTERNAL_TRANSPORT
31#include "webrtc/modules/udp_transport/interface/udp_transport.h"
32#endif
33#ifdef WEBRTC_SRTP
34#include "SrtpModule.h"
35#endif
36#ifdef WEBRTC_DTMF_DETECTION
37#include "voe_dtmf.h" // TelephoneEventDetectionMethods, TelephoneEventObserver
38#endif
39
40namespace webrtc
41{
42class CriticalSectionWrapper;
43class ProcessThread;
44class AudioDeviceModule;
45class RtpRtcp;
46class FileWrapper;
47class RtpDump;
48class VoiceEngineObserver;
49class VoEMediaProcess;
50class VoERTPObserver;
51class VoERTCPObserver;
52
53struct CallStatistics;
54struct ReportBlock;
55struct SenderInfo;
56
57namespace voe
58{
59class Statistics;
60class TransmitMixer;
61class OutputMixer;
62
63
64class Channel:
65    public RtpData,
66    public RtpFeedback,
67    public RtcpFeedback,
68#ifndef WEBRTC_EXTERNAL_TRANSPORT
69    public UdpTransportData, // receiving packet from sockets
70#endif
71    public FileCallback, // receiving notification from file player & recorder
72    public Transport,
73    public RtpAudioFeedback,
74    public AudioPacketizationCallback, // receive encoded packets from the ACM
75    public ACMVADCallback, // receive voice activity from the ACM
76#ifdef WEBRTC_DTMF_DETECTION
77    public AudioCodingFeedback, // inband Dtmf detection in the ACM
78#endif
79    public MixerParticipant // supplies output mixer with audio frames
80{
81public:
82    enum {KNumSocketThreads = 1};
83    enum {KNumberOfSocketBuffers = 8};
84public:
85    virtual ~Channel();
86    static WebRtc_Word32 CreateChannel(Channel*& channel,
87                                       const WebRtc_Word32 channelId,
88                                       const WebRtc_UWord32 instanceId);
89    Channel(const WebRtc_Word32 channelId, const WebRtc_UWord32 instanceId);
90    WebRtc_Word32 Init();
91    WebRtc_Word32 SetEngineInformation(
92        Statistics& engineStatistics,
93        OutputMixer& outputMixer,
94        TransmitMixer& transmitMixer,
95        ProcessThread& moduleProcessThread,
96        AudioDeviceModule& audioDeviceModule,
97        VoiceEngineObserver* voiceEngineObserver,
98        CriticalSectionWrapper* callbackCritSect);
99    WebRtc_Word32 UpdateLocalTimeStamp();
100
101public:
102    // API methods
103
104    // VoEBase
105    WebRtc_Word32 StartPlayout();
106    WebRtc_Word32 StopPlayout();
107    WebRtc_Word32 StartSend();
108    WebRtc_Word32 StopSend();
109    WebRtc_Word32 StartReceiving();
110    WebRtc_Word32 StopReceiving();
111
112#ifndef WEBRTC_EXTERNAL_TRANSPORT
113    WebRtc_Word32 SetLocalReceiver(const WebRtc_UWord16 rtpPort,
114                                   const WebRtc_UWord16 rtcpPort,
115                                   const char ipAddr[64],
116                                   const char multicastIpAddr[64]);
117    WebRtc_Word32 GetLocalReceiver(int& port, int& RTCPport, char ipAddr[]);
118    WebRtc_Word32 SetSendDestination(const WebRtc_UWord16 rtpPort,
119                                     const char ipAddr[64],
120                                     const int sourcePort,
121                                     const WebRtc_UWord16 rtcpPort);
122    WebRtc_Word32 GetSendDestination(int& port, char ipAddr[64],
123                                     int& sourcePort, int& RTCPport);
124#endif
125    WebRtc_Word32 SetNetEQPlayoutMode(NetEqModes mode);
126    WebRtc_Word32 GetNetEQPlayoutMode(NetEqModes& mode);
127    WebRtc_Word32 SetOnHoldStatus(bool enable, OnHoldModes mode);
128    WebRtc_Word32 GetOnHoldStatus(bool& enabled, OnHoldModes& mode);
129    WebRtc_Word32 RegisterVoiceEngineObserver(VoiceEngineObserver& observer);
130    WebRtc_Word32 DeRegisterVoiceEngineObserver();
131
132    // VoECodec
133    WebRtc_Word32 GetSendCodec(CodecInst& codec);
134    WebRtc_Word32 GetRecCodec(CodecInst& codec);
135    WebRtc_Word32 SetSendCodec(const CodecInst& codec);
136    WebRtc_Word32 SetVADStatus(bool enableVAD, ACMVADMode mode,
137                               bool disableDTX);
138    WebRtc_Word32 GetVADStatus(bool& enabledVAD, ACMVADMode& mode,
139                               bool& disabledDTX);
140    WebRtc_Word32 SetRecPayloadType(const CodecInst& codec);
141    WebRtc_Word32 GetRecPayloadType(CodecInst& codec);
142    WebRtc_Word32 SetAMREncFormat(AmrMode mode);
143    WebRtc_Word32 SetAMRDecFormat(AmrMode mode);
144    WebRtc_Word32 SetAMRWbEncFormat(AmrMode mode);
145    WebRtc_Word32 SetAMRWbDecFormat(AmrMode mode);
146    WebRtc_Word32 SetSendCNPayloadType(int type, PayloadFrequencies frequency);
147    WebRtc_Word32 SetISACInitTargetRate(int rateBps, bool useFixedFrameSize);
148    WebRtc_Word32 SetISACMaxRate(int rateBps);
149    WebRtc_Word32 SetISACMaxPayloadSize(int sizeBytes);
150
151    // VoE dual-streaming.
152    int SetSecondarySendCodec(const CodecInst& codec, int red_payload_type);
153    void RemoveSecondarySendCodec();
154    int GetSecondarySendCodec(CodecInst* codec);
155
156    // VoENetwork
157    WebRtc_Word32 RegisterExternalTransport(Transport& transport);
158    WebRtc_Word32 DeRegisterExternalTransport();
159    WebRtc_Word32 ReceivedRTPPacket(const WebRtc_Word8* data,
160                                    WebRtc_Word32 length);
161    WebRtc_Word32 ReceivedRTCPPacket(const WebRtc_Word8* data,
162                                     WebRtc_Word32 length);
163#ifndef WEBRTC_EXTERNAL_TRANSPORT
164    WebRtc_Word32 GetSourceInfo(int& rtpPort, int& rtcpPort, char ipAddr[64]);
165    WebRtc_Word32 EnableIPv6();
166    bool IPv6IsEnabled() const;
167    WebRtc_Word32 SetSourceFilter(int rtpPort, int rtcpPort,
168                                  const char ipAddr[64]);
169    WebRtc_Word32 GetSourceFilter(int& rtpPort, int& rtcpPort, char ipAddr[64]);
170    WebRtc_Word32 SetSendTOS(int DSCP, int priority, bool useSetSockopt);
171    WebRtc_Word32 GetSendTOS(int &DSCP, int& priority, bool &useSetSockopt);
172#if defined(_WIN32)
173    WebRtc_Word32 SetSendGQoS(bool enable, int serviceType, int overrideDSCP);
174    WebRtc_Word32 GetSendGQoS(bool &enabled, int &serviceType,
175                              int &overrideDSCP);
176#endif
177#endif
178    WebRtc_Word32 SetPacketTimeoutNotification(bool enable, int timeoutSeconds);
179    WebRtc_Word32 GetPacketTimeoutNotification(bool& enabled,
180                                               int& timeoutSeconds);
181    WebRtc_Word32 RegisterDeadOrAliveObserver(VoEConnectionObserver& observer);
182    WebRtc_Word32 DeRegisterDeadOrAliveObserver();
183    WebRtc_Word32 SetPeriodicDeadOrAliveStatus(bool enable,
184                                               int sampleTimeSeconds);
185    WebRtc_Word32 GetPeriodicDeadOrAliveStatus(bool& enabled,
186                                               int& sampleTimeSeconds);
187    WebRtc_Word32 SendUDPPacket(const void* data, unsigned int length,
188                                int& transmittedBytes, bool useRtcpSocket);
189
190    // VoEFile
191    int StartPlayingFileLocally(const char* fileName, const bool loop,
192                                const FileFormats format,
193                                const int startPosition,
194                                const float volumeScaling,
195                                const int stopPosition,
196                                const CodecInst* codecInst);
197    int StartPlayingFileLocally(InStream* stream, const FileFormats format,
198                                const int startPosition,
199                                const float volumeScaling,
200                                const int stopPosition,
201                                const CodecInst* codecInst);
202    int StopPlayingFileLocally();
203    int IsPlayingFileLocally() const;
204    int RegisterFilePlayingToMixer();
205    int ScaleLocalFilePlayout(const float scale);
206    int GetLocalPlayoutPosition(int& positionMs);
207    int StartPlayingFileAsMicrophone(const char* fileName, const bool loop,
208                                     const FileFormats format,
209                                     const int startPosition,
210                                     const float volumeScaling,
211                                     const int stopPosition,
212                                     const CodecInst* codecInst);
213    int StartPlayingFileAsMicrophone(InStream* stream,
214                                     const FileFormats format,
215                                     const int startPosition,
216                                     const float volumeScaling,
217                                     const int stopPosition,
218                                     const CodecInst* codecInst);
219    int StopPlayingFileAsMicrophone();
220    int IsPlayingFileAsMicrophone() const;
221    int ScaleFileAsMicrophonePlayout(const float scale);
222    int StartRecordingPlayout(const char* fileName, const CodecInst* codecInst);
223    int StartRecordingPlayout(OutStream* stream, const CodecInst* codecInst);
224    int StopRecordingPlayout();
225
226    void SetMixWithMicStatus(bool mix);
227
228    // VoEExternalMediaProcessing
229    int RegisterExternalMediaProcessing(ProcessingTypes type,
230                                        VoEMediaProcess& processObject);
231    int DeRegisterExternalMediaProcessing(ProcessingTypes type);
232    int SetExternalMixing(bool enabled);
233
234    // VoEVolumeControl
235    int GetSpeechOutputLevel(WebRtc_UWord32& level) const;
236    int GetSpeechOutputLevelFullRange(WebRtc_UWord32& level) const;
237    int SetMute(const bool enable);
238    bool Mute() const;
239    int SetOutputVolumePan(float left, float right);
240    int GetOutputVolumePan(float& left, float& right) const;
241    int SetChannelOutputVolumeScaling(float scaling);
242    int GetChannelOutputVolumeScaling(float& scaling) const;
243
244    // VoECallReport
245    void ResetDeadOrAliveCounters();
246    int ResetRTCPStatistics();
247    int GetRoundTripTimeSummary(StatVal& delaysMs) const;
248    int GetDeadOrAliveCounters(int& countDead, int& countAlive) const;
249
250    // VoENetEqStats
251    int GetNetworkStatistics(NetworkStatistics& stats);
252
253    // VoEVideoSync
254    int GetDelayEstimate(int& delayMs) const;
255    int SetInitialPlayoutDelay(int delay_ms);
256    int SetMinimumPlayoutDelay(int delayMs);
257    int GetPlayoutTimestamp(unsigned int& timestamp);
258    int SetInitTimestamp(unsigned int timestamp);
259    int SetInitSequenceNumber(short sequenceNumber);
260
261    // VoEVideoSyncExtended
262    int GetRtpRtcp(RtpRtcp* &rtpRtcpModule) const;
263
264    // VoEEncryption
265#ifdef WEBRTC_SRTP
266    int EnableSRTPSend(
267            CipherTypes cipherType,
268            int cipherKeyLength,
269            AuthenticationTypes authType,
270            int authKeyLength,
271            int authTagLength,
272            SecurityLevels level,
273            const unsigned char key[kVoiceEngineMaxSrtpKeyLength],
274            bool useForRTCP);
275    int DisableSRTPSend();
276    int EnableSRTPReceive(
277            CipherTypes cipherType,
278            int cipherKeyLength,
279            AuthenticationTypes authType,
280            int authKeyLength,
281            int authTagLength,
282            SecurityLevels level,
283            const unsigned char key[kVoiceEngineMaxSrtpKeyLength],
284            bool useForRTCP);
285    int DisableSRTPReceive();
286#endif
287    int RegisterExternalEncryption(Encryption& encryption);
288    int DeRegisterExternalEncryption();
289
290    // VoEDtmf
291    int SendTelephoneEventOutband(unsigned char eventCode, int lengthMs,
292                                  int attenuationDb, bool playDtmfEvent);
293    int SendTelephoneEventInband(unsigned char eventCode, int lengthMs,
294                                 int attenuationDb, bool playDtmfEvent);
295    int SetDtmfPlayoutStatus(bool enable);
296    bool DtmfPlayoutStatus() const;
297    int SetSendTelephoneEventPayloadType(unsigned char type);
298    int GetSendTelephoneEventPayloadType(unsigned char& type);
299#ifdef WEBRTC_DTMF_DETECTION
300    int RegisterTelephoneEventDetection(
301            TelephoneEventDetectionMethods detectionMethod,
302            VoETelephoneEventObserver& observer);
303    int DeRegisterTelephoneEventDetection();
304    int GetTelephoneEventDetectionStatus(
305            bool& enabled,
306            TelephoneEventDetectionMethods& detectionMethod);
307#endif
308
309    // VoEAudioProcessingImpl
310    int UpdateRxVadDetection(AudioFrame& audioFrame);
311    int RegisterRxVadObserver(VoERxVadCallback &observer);
312    int DeRegisterRxVadObserver();
313    int VoiceActivityIndicator(int &activity);
314#ifdef WEBRTC_VOICE_ENGINE_AGC
315    int SetRxAgcStatus(const bool enable, const AgcModes mode);
316    int GetRxAgcStatus(bool& enabled, AgcModes& mode);
317    int SetRxAgcConfig(const AgcConfig config);
318    int GetRxAgcConfig(AgcConfig& config);
319#endif
320#ifdef WEBRTC_VOICE_ENGINE_NR
321    int SetRxNsStatus(const bool enable, const NsModes mode);
322    int GetRxNsStatus(bool& enabled, NsModes& mode);
323#endif
324
325    // VoERTP_RTCP
326    int RegisterRTPObserver(VoERTPObserver& observer);
327    int DeRegisterRTPObserver();
328    int RegisterRTCPObserver(VoERTCPObserver& observer);
329    int DeRegisterRTCPObserver();
330    int SetLocalSSRC(unsigned int ssrc);
331    int GetLocalSSRC(unsigned int& ssrc);
332    int GetRemoteSSRC(unsigned int& ssrc);
333    int GetRemoteCSRCs(unsigned int arrCSRC[15]);
334    int SetRTPAudioLevelIndicationStatus(bool enable, unsigned char ID);
335    int GetRTPAudioLevelIndicationStatus(bool& enable, unsigned char& ID);
336    int SetRTCPStatus(bool enable);
337    int GetRTCPStatus(bool& enabled);
338    int SetRTCP_CNAME(const char cName[256]);
339    int GetRTCP_CNAME(char cName[256]);
340    int GetRemoteRTCP_CNAME(char cName[256]);
341    int GetRemoteRTCPData(unsigned int& NTPHigh, unsigned int& NTPLow,
342                          unsigned int& timestamp,
343                          unsigned int& playoutTimestamp, unsigned int* jitter,
344                          unsigned short* fractionLost);
345    int SendApplicationDefinedRTCPPacket(const unsigned char subType,
346                                         unsigned int name, const char* data,
347                                         unsigned short dataLengthInBytes);
348    int GetRTPStatistics(unsigned int& averageJitterMs,
349                         unsigned int& maxJitterMs,
350                         unsigned int& discardedPackets);
351    int GetRemoteRTCPSenderInfo(SenderInfo* sender_info);
352    int GetRemoteRTCPReportBlocks(std::vector<ReportBlock>* report_blocks);
353    int GetRTPStatistics(CallStatistics& stats);
354    int SetFECStatus(bool enable, int redPayloadtype);
355    int GetFECStatus(bool& enabled, int& redPayloadtype);
356    int StartRTPDump(const char fileNameUTF8[1024], RTPDirections direction);
357    int StopRTPDump(RTPDirections direction);
358    bool RTPDumpIsActive(RTPDirections direction);
359    int InsertExtraRTPPacket(unsigned char payloadType, bool markerBit,
360                             const char* payloadData,
361                             unsigned short payloadSize);
362    uint32_t LastRemoteTimeStamp() { return _lastRemoteTimeStamp; }
363
364public:
365    // From AudioPacketizationCallback in the ACM
366    WebRtc_Word32 SendData(FrameType frameType,
367                           WebRtc_UWord8 payloadType,
368                           WebRtc_UWord32 timeStamp,
369                           const WebRtc_UWord8* payloadData,
370                           WebRtc_UWord16 payloadSize,
371                           const RTPFragmentationHeader* fragmentation);
372    // From ACMVADCallback in the ACM
373    WebRtc_Word32 InFrameType(WebRtc_Word16 frameType);
374
375#ifdef WEBRTC_DTMF_DETECTION
376public: // From AudioCodingFeedback in the ACM
377    int IncomingDtmf(const WebRtc_UWord8 digitDtmf, const bool end);
378#endif
379
380public:
381    WebRtc_Word32 OnRxVadDetected(const int vadDecision);
382
383public:
384    // From RtpData in the RTP/RTCP module
385    WebRtc_Word32 OnReceivedPayloadData(const WebRtc_UWord8* payloadData,
386                                        const WebRtc_UWord16 payloadSize,
387                                        const WebRtcRTPHeader* rtpHeader);
388
389public:
390    // From RtpFeedback in the RTP/RTCP module
391    WebRtc_Word32 OnInitializeDecoder(
392            const WebRtc_Word32 id,
393            const WebRtc_Word8 payloadType,
394            const char payloadName[RTP_PAYLOAD_NAME_SIZE],
395            const int frequency,
396            const WebRtc_UWord8 channels,
397            const WebRtc_UWord32 rate);
398
399    void OnPacketTimeout(const WebRtc_Word32 id);
400
401    void OnReceivedPacket(const WebRtc_Word32 id,
402                          const RtpRtcpPacketType packetType);
403
404    void OnPeriodicDeadOrAlive(const WebRtc_Word32 id,
405                               const RTPAliveType alive);
406
407    void OnIncomingSSRCChanged(const WebRtc_Word32 id,
408                               const WebRtc_UWord32 SSRC);
409
410    void OnIncomingCSRCChanged(const WebRtc_Word32 id,
411                               const WebRtc_UWord32 CSRC, const bool added);
412
413public:
414    // From RtcpFeedback in the RTP/RTCP module
415    void OnApplicationDataReceived(const WebRtc_Word32 id,
416                                   const WebRtc_UWord8 subType,
417                                   const WebRtc_UWord32 name,
418                                   const WebRtc_UWord16 length,
419                                   const WebRtc_UWord8* data);
420
421public:
422    // From RtpAudioFeedback in the RTP/RTCP module
423    void OnReceivedTelephoneEvent(const WebRtc_Word32 id,
424                                  const WebRtc_UWord8 event,
425                                  const bool endOfEvent);
426
427    void OnPlayTelephoneEvent(const WebRtc_Word32 id,
428                              const WebRtc_UWord8 event,
429                              const WebRtc_UWord16 lengthMs,
430                              const WebRtc_UWord8 volume);
431
432public:
433    // From UdpTransportData in the Socket Transport module
434    void IncomingRTPPacket(const WebRtc_Word8* incomingRtpPacket,
435                           const WebRtc_Word32 rtpPacketLength,
436                           const char* fromIP,
437                           const WebRtc_UWord16 fromPort);
438
439    void IncomingRTCPPacket(const WebRtc_Word8* incomingRtcpPacket,
440                            const WebRtc_Word32 rtcpPacketLength,
441                            const char* fromIP,
442                            const WebRtc_UWord16 fromPort);
443
444public:
445    // From Transport (called by the RTP/RTCP module)
446    int SendPacket(int /*channel*/, const void *data, int len);
447    int SendRTCPPacket(int /*channel*/, const void *data, int len);
448
449public:
450    // From MixerParticipant
451    WebRtc_Word32 GetAudioFrame(const WebRtc_Word32 id,
452                                AudioFrame& audioFrame);
453    WebRtc_Word32 NeededFrequency(const WebRtc_Word32 id);
454
455public:
456    // From MonitorObserver
457    void OnPeriodicProcess();
458
459public:
460    // From FileCallback
461    void PlayNotification(const WebRtc_Word32 id,
462                          const WebRtc_UWord32 durationMs);
463    void RecordNotification(const WebRtc_Word32 id,
464                            const WebRtc_UWord32 durationMs);
465    void PlayFileEnded(const WebRtc_Word32 id);
466    void RecordFileEnded(const WebRtc_Word32 id);
467
468public:
469    WebRtc_UWord32 InstanceId() const
470    {
471        return _instanceId;
472    }
473    WebRtc_Word32 ChannelId() const
474    {
475        return _channelId;
476    }
477    bool Playing() const
478    {
479        return _playing;
480    }
481    bool Sending() const
482    {
483        // A lock is needed because |_sending| is accessed by both
484        // TransmitMixer::PrepareDemux() and StartSend()/StopSend(), which
485        // are called by different threads.
486        CriticalSectionScoped cs(&_callbackCritSect);
487        return _sending;
488    }
489    bool Receiving() const
490    {
491        return _receiving;
492    }
493    bool ExternalTransport() const
494    {
495        return _externalTransport;
496    }
497    bool ExternalMixing() const
498    {
499        return _externalMixing;
500    }
501    bool OutputIsOnHold() const
502    {
503        return _outputIsOnHold;
504    }
505    bool InputIsOnHold() const
506    {
507        return _inputIsOnHold;
508    }
509    RtpRtcp* RtpRtcpModulePtr() const
510    {
511        return _rtpRtcpModule.get();
512    }
513    WebRtc_Word8 OutputEnergyLevel() const
514    {
515        return _outputAudioLevel.Level();
516    }
517#ifndef WEBRTC_EXTERNAL_TRANSPORT
518    bool SendSocketsInitialized() const
519    {
520        return _socketTransportModule.SendSocketsInitialized();
521    }
522    bool ReceiveSocketsInitialized() const
523    {
524        return _socketTransportModule.ReceiveSocketsInitialized();
525    }
526#endif
527    WebRtc_UWord32 Demultiplex(const AudioFrame& audioFrame);
528    WebRtc_UWord32 PrepareEncodeAndSend(int mixingFrequency);
529    WebRtc_UWord32 EncodeAndSend();
530
531private:
532    int InsertInbandDtmfTone();
533    WebRtc_Word32
534            MixOrReplaceAudioWithFile(const int mixingFrequency);
535    WebRtc_Word32 MixAudioWithFile(AudioFrame& audioFrame,
536                                   const int mixingFrequency);
537    WebRtc_Word32 GetPlayoutTimeStamp(WebRtc_UWord32& playoutTimestamp);
538    void UpdateDeadOrAliveCounters(bool alive);
539    WebRtc_Word32 SendPacketRaw(const void *data, int len, bool RTCP);
540    WebRtc_Word32 UpdatePacketDelay(const WebRtc_UWord32 timestamp,
541                                    const WebRtc_UWord16 sequenceNumber);
542    void RegisterReceiveCodecsToRTPModule();
543    int ApmProcessRx(AudioFrame& audioFrame);
544
545    int SetRedPayloadType(int red_payload_type);
546private:
547    CriticalSectionWrapper& _fileCritSect;
548    CriticalSectionWrapper& _callbackCritSect;
549    WebRtc_UWord32 _instanceId;
550    WebRtc_Word32 _channelId;
551
552private:
553    scoped_ptr<RtpRtcp> _rtpRtcpModule;
554    AudioCodingModule& _audioCodingModule;
555#ifndef WEBRTC_EXTERNAL_TRANSPORT
556    WebRtc_UWord8 _numSocketThreads;
557    UdpTransport& _socketTransportModule;
558#endif
559#ifdef WEBRTC_SRTP
560    SrtpModule& _srtpModule;
561#endif
562    RtpDump& _rtpDumpIn;
563    RtpDump& _rtpDumpOut;
564private:
565    AudioLevel _outputAudioLevel;
566    bool _externalTransport;
567    AudioFrame _audioFrame;
568    WebRtc_UWord8 _audioLevel_dBov;
569    FilePlayer* _inputFilePlayerPtr;
570    FilePlayer* _outputFilePlayerPtr;
571    FileRecorder* _outputFileRecorderPtr;
572    int _inputFilePlayerId;
573    int _outputFilePlayerId;
574    int _outputFileRecorderId;
575    bool _inputFilePlaying;
576    bool _outputFilePlaying;
577    bool _outputFileRecording;
578    DtmfInbandQueue _inbandDtmfQueue;
579    DtmfInband _inbandDtmfGenerator;
580    bool _inputExternalMedia;
581    bool _outputExternalMedia;
582    VoEMediaProcess* _inputExternalMediaCallbackPtr;
583    VoEMediaProcess* _outputExternalMediaCallbackPtr;
584    WebRtc_UWord8* _encryptionRTPBufferPtr;
585    WebRtc_UWord8* _decryptionRTPBufferPtr;
586    WebRtc_UWord8* _encryptionRTCPBufferPtr;
587    WebRtc_UWord8* _decryptionRTCPBufferPtr;
588    WebRtc_UWord32 _timeStamp;
589    WebRtc_UWord8 _sendTelephoneEventPayloadType;
590    WebRtc_UWord32 _playoutTimeStampRTP;
591    WebRtc_UWord32 _playoutTimeStampRTCP;
592    WebRtc_UWord32 _numberOfDiscardedPackets;
593private:
594    // uses
595    Statistics* _engineStatisticsPtr;
596    OutputMixer* _outputMixerPtr;
597    TransmitMixer* _transmitMixerPtr;
598    ProcessThread* _moduleProcessThreadPtr;
599    AudioDeviceModule* _audioDeviceModulePtr;
600    VoiceEngineObserver* _voiceEngineObserverPtr; // owned by base
601    CriticalSectionWrapper* _callbackCritSectPtr; // owned by base
602    Transport* _transportPtr; // WebRtc socket or external transport
603    Encryption* _encryptionPtr; // WebRtc SRTP or external encryption
604    scoped_ptr<AudioProcessing> _rtpAudioProc;
605    AudioProcessing* _rxAudioProcessingModulePtr; // far end AudioProcessing
606#ifdef WEBRTC_DTMF_DETECTION
607    VoETelephoneEventObserver* _telephoneEventDetectionPtr;
608#endif
609    VoERxVadCallback* _rxVadObserverPtr;
610    WebRtc_Word32 _oldVadDecision;
611    WebRtc_Word32 _sendFrameType; // Send data is voice, 1-voice, 0-otherwise
612    VoERTPObserver* _rtpObserverPtr;
613    VoERTCPObserver* _rtcpObserverPtr;
614private:
615    // VoEBase
616    bool _outputIsOnHold;
617    bool _externalPlayout;
618    bool _externalMixing;
619    bool _inputIsOnHold;
620    bool _playing;
621    bool _sending;
622    bool _receiving;
623    bool _mixFileWithMicrophone;
624    bool _rtpObserver;
625    bool _rtcpObserver;
626    // VoEVolumeControl
627    bool _mute;
628    float _panLeft;
629    float _panRight;
630    float _outputGain;
631    // VoEEncryption
632    bool _encrypting;
633    bool _decrypting;
634    // VoEDtmf
635    bool _playOutbandDtmfEvent;
636    bool _playInbandDtmfEvent;
637    bool _inbandTelephoneEventDetection;
638    bool _outOfBandTelephoneEventDetecion;
639    // VoeRTP_RTCP
640    WebRtc_UWord8 _extraPayloadType;
641    bool _insertExtraRTPPacket;
642    bool _extraMarkerBit;
643    WebRtc_UWord32 _lastLocalTimeStamp;
644    uint32_t _lastRemoteTimeStamp;
645    WebRtc_Word8 _lastPayloadType;
646    bool _includeAudioLevelIndication;
647    // VoENetwork
648    bool _rtpPacketTimedOut;
649    bool _rtpPacketTimeOutIsEnabled;
650    WebRtc_UWord32 _rtpTimeOutSeconds;
651    bool _connectionObserver;
652    VoEConnectionObserver* _connectionObserverPtr;
653    WebRtc_UWord32 _countAliveDetections;
654    WebRtc_UWord32 _countDeadDetections;
655    AudioFrame::SpeechType _outputSpeechType;
656    // VoEVideoSync
657    WebRtc_UWord32 _averageDelayMs;
658    WebRtc_UWord16 _previousSequenceNumber;
659    WebRtc_UWord32 _previousTimestamp;
660    WebRtc_UWord16 _recPacketDelayMs;
661    // VoEAudioProcessing
662    bool _RxVadDetection;
663    bool _rxApmIsEnabled;
664    bool _rxAgcIsEnabled;
665    bool _rxNsIsEnabled;
666};
667
668} // namespace voe
669
670} // namespace webrtc
671
672#endif  // WEBRTC_VOICE_ENGINE_CHANNEL_H
673