blob: 391415620d97b7168fd3361c693d36b61513ff2e [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
leozwang@webrtc.org813e4b02012-03-01 18:34:25 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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
turaj@webrtc.org6388c3e2013-02-12 21:42:18 +000014#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"
niklase@google.com470e71d2011-07-07 08:21:25 +000029
niklase@google.com470e71d2011-07-07 08:21:25 +000030#ifdef WEBRTC_DTMF_DETECTION
pbos@webrtc.org956aa7e2013-05-21 13:52:32 +000031// TelephoneEventDetectionMethods, TelephoneEventObserver
32#include "webrtc/voice_engine/include/voe_dtmf.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000033#endif
34
35namespace webrtc
36{
37class CriticalSectionWrapper;
38class ProcessThread;
39class AudioDeviceModule;
40class RtpRtcp;
41class FileWrapper;
42class RtpDump;
43class VoiceEngineObserver;
44class VoEMediaProcess;
45class VoERTPObserver;
46class VoERTCPObserver;
47
48struct CallStatistics;
henrika@webrtc.org8a2fc882012-08-22 08:53:55 +000049struct ReportBlock;
50struct SenderInfo;
niklase@google.com470e71d2011-07-07 08:21:25 +000051
52namespace voe
53{
54class Statistics;
55class TransmitMixer;
56class OutputMixer;
57
58
59class Channel:
60 public RtpData,
61 public RtpFeedback,
62 public RtcpFeedback,
niklase@google.com470e71d2011-07-07 08:21:25 +000063 public FileCallback, // receiving notification from file player & recorder
64 public Transport,
65 public RtpAudioFeedback,
66 public AudioPacketizationCallback, // receive encoded packets from the ACM
67 public ACMVADCallback, // receive voice activity from the ACM
niklase@google.com470e71d2011-07-07 08:21:25 +000068 public MixerParticipant // supplies output mixer with audio frames
69{
70public:
71 enum {KNumSocketThreads = 1};
72 enum {KNumberOfSocketBuffers = 8};
niklase@google.com470e71d2011-07-07 08:21:25 +000073public:
74 virtual ~Channel();
pbos@webrtc.org6141e132013-04-09 10:09:10 +000075 static int32_t CreateChannel(Channel*& channel,
pbos@webrtc.org92135212013-05-14 08:31:39 +000076 int32_t channelId,
77 uint32_t instanceId);
78 Channel(int32_t channelId, uint32_t instanceId);
pbos@webrtc.org6141e132013-04-09 10:09:10 +000079 int32_t Init();
80 int32_t SetEngineInformation(
niklase@google.com470e71d2011-07-07 08:21:25 +000081 Statistics& engineStatistics,
82 OutputMixer& outputMixer,
83 TransmitMixer& transmitMixer,
84 ProcessThread& moduleProcessThread,
85 AudioDeviceModule& audioDeviceModule,
86 VoiceEngineObserver* voiceEngineObserver,
87 CriticalSectionWrapper* callbackCritSect);
pbos@webrtc.org6141e132013-04-09 10:09:10 +000088 int32_t UpdateLocalTimeStamp();
niklase@google.com470e71d2011-07-07 08:21:25 +000089
90public:
91 // API methods
92
93 // VoEBase
pbos@webrtc.org6141e132013-04-09 10:09:10 +000094 int32_t StartPlayout();
95 int32_t StopPlayout();
96 int32_t StartSend();
97 int32_t StopSend();
98 int32_t StartReceiving();
99 int32_t StopReceiving();
niklase@google.com470e71d2011-07-07 08:21:25 +0000100
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000101 int32_t SetNetEQPlayoutMode(NetEqModes mode);
102 int32_t GetNetEQPlayoutMode(NetEqModes& mode);
103 int32_t SetOnHoldStatus(bool enable, OnHoldModes mode);
104 int32_t GetOnHoldStatus(bool& enabled, OnHoldModes& mode);
105 int32_t RegisterVoiceEngineObserver(VoiceEngineObserver& observer);
106 int32_t DeRegisterVoiceEngineObserver();
niklase@google.com470e71d2011-07-07 08:21:25 +0000107
108 // VoECodec
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000109 int32_t GetSendCodec(CodecInst& codec);
110 int32_t GetRecCodec(CodecInst& codec);
111 int32_t SetSendCodec(const CodecInst& codec);
112 int32_t SetVADStatus(bool enableVAD, ACMVADMode mode, bool disableDTX);
113 int32_t GetVADStatus(bool& enabledVAD, ACMVADMode& mode, bool& disabledDTX);
114 int32_t SetRecPayloadType(const CodecInst& codec);
115 int32_t GetRecPayloadType(CodecInst& codec);
116 int32_t SetAMREncFormat(AmrMode mode);
117 int32_t SetAMRDecFormat(AmrMode mode);
118 int32_t SetAMRWbEncFormat(AmrMode mode);
119 int32_t SetAMRWbDecFormat(AmrMode mode);
120 int32_t SetSendCNPayloadType(int type, PayloadFrequencies frequency);
121 int32_t SetISACInitTargetRate(int rateBps, bool useFixedFrameSize);
122 int32_t SetISACMaxRate(int rateBps);
123 int32_t SetISACMaxPayloadSize(int sizeBytes);
niklase@google.com470e71d2011-07-07 08:21:25 +0000124
turaj@webrtc.org42259e72012-12-11 02:15:12 +0000125 // VoE dual-streaming.
126 int SetSecondarySendCodec(const CodecInst& codec, int red_payload_type);
127 void RemoveSecondarySendCodec();
128 int GetSecondarySendCodec(CodecInst* codec);
129
niklase@google.com470e71d2011-07-07 08:21:25 +0000130 // VoENetwork
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000131 int32_t RegisterExternalTransport(Transport& transport);
132 int32_t DeRegisterExternalTransport();
133 int32_t ReceivedRTPPacket(const int8_t* data, int32_t length);
134 int32_t ReceivedRTCPPacket(const int8_t* data, int32_t length);
135 int32_t SetPacketTimeoutNotification(bool enable, int timeoutSeconds);
136 int32_t GetPacketTimeoutNotification(bool& enabled, int& timeoutSeconds);
137 int32_t RegisterDeadOrAliveObserver(VoEConnectionObserver& observer);
138 int32_t DeRegisterDeadOrAliveObserver();
139 int32_t SetPeriodicDeadOrAliveStatus(bool enable, int sampleTimeSeconds);
140 int32_t GetPeriodicDeadOrAliveStatus(bool& enabled, int& sampleTimeSeconds);
pwestin@webrtc.org684f0572013-03-13 23:20:57 +0000141
niklase@google.com470e71d2011-07-07 08:21:25 +0000142 // VoEFile
pbos@webrtc.org92135212013-05-14 08:31:39 +0000143 int StartPlayingFileLocally(const char* fileName, bool loop,
144 FileFormats format,
145 int startPosition,
146 float volumeScaling,
147 int stopPosition,
niklase@google.com470e71d2011-07-07 08:21:25 +0000148 const CodecInst* codecInst);
pbos@webrtc.org92135212013-05-14 08:31:39 +0000149 int StartPlayingFileLocally(InStream* stream, FileFormats format,
150 int startPosition,
151 float volumeScaling,
152 int stopPosition,
niklase@google.com470e71d2011-07-07 08:21:25 +0000153 const CodecInst* codecInst);
154 int StopPlayingFileLocally();
155 int IsPlayingFileLocally() const;
braveyao@webrtc.orgab129902012-06-04 03:26:39 +0000156 int RegisterFilePlayingToMixer();
pbos@webrtc.org92135212013-05-14 08:31:39 +0000157 int ScaleLocalFilePlayout(float scale);
niklase@google.com470e71d2011-07-07 08:21:25 +0000158 int GetLocalPlayoutPosition(int& positionMs);
pbos@webrtc.org92135212013-05-14 08:31:39 +0000159 int StartPlayingFileAsMicrophone(const char* fileName, bool loop,
160 FileFormats format,
161 int startPosition,
162 float volumeScaling,
163 int stopPosition,
niklase@google.com470e71d2011-07-07 08:21:25 +0000164 const CodecInst* codecInst);
165 int StartPlayingFileAsMicrophone(InStream* stream,
pbos@webrtc.org92135212013-05-14 08:31:39 +0000166 FileFormats format,
167 int startPosition,
168 float volumeScaling,
169 int stopPosition,
niklase@google.com470e71d2011-07-07 08:21:25 +0000170 const CodecInst* codecInst);
171 int StopPlayingFileAsMicrophone();
172 int IsPlayingFileAsMicrophone() const;
pbos@webrtc.org92135212013-05-14 08:31:39 +0000173 int ScaleFileAsMicrophonePlayout(float scale);
niklase@google.com470e71d2011-07-07 08:21:25 +0000174 int StartRecordingPlayout(const char* fileName, const CodecInst* codecInst);
175 int StartRecordingPlayout(OutStream* stream, const CodecInst* codecInst);
176 int StopRecordingPlayout();
177
178 void SetMixWithMicStatus(bool mix);
179
180 // VoEExternalMediaProcessing
181 int RegisterExternalMediaProcessing(ProcessingTypes type,
182 VoEMediaProcess& processObject);
183 int DeRegisterExternalMediaProcessing(ProcessingTypes type);
roosa@google.com1b60ceb2012-12-12 23:00:29 +0000184 int SetExternalMixing(bool enabled);
niklase@google.com470e71d2011-07-07 08:21:25 +0000185
186 // VoEVolumeControl
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000187 int GetSpeechOutputLevel(uint32_t& level) const;
188 int GetSpeechOutputLevelFullRange(uint32_t& level) const;
pbos@webrtc.org92135212013-05-14 08:31:39 +0000189 int SetMute(bool enable);
niklase@google.com470e71d2011-07-07 08:21:25 +0000190 bool Mute() const;
191 int SetOutputVolumePan(float left, float right);
192 int GetOutputVolumePan(float& left, float& right) const;
193 int SetChannelOutputVolumeScaling(float scaling);
194 int GetChannelOutputVolumeScaling(float& scaling) const;
195
196 // VoECallReport
197 void ResetDeadOrAliveCounters();
198 int ResetRTCPStatistics();
199 int GetRoundTripTimeSummary(StatVal& delaysMs) const;
200 int GetDeadOrAliveCounters(int& countDead, int& countAlive) const;
201
202 // VoENetEqStats
203 int GetNetworkStatistics(NetworkStatistics& stats);
niklase@google.com470e71d2011-07-07 08:21:25 +0000204
205 // VoEVideoSync
pwestin@webrtc.org1de01352013-04-11 20:23:35 +0000206 bool GetDelayEstimate(int* jitter_buffer_delay_ms,
207 int* playout_buffer_delay_ms) const;
turaj@webrtc.org6388c3e2013-02-12 21:42:18 +0000208 int SetInitialPlayoutDelay(int delay_ms);
niklase@google.com470e71d2011-07-07 08:21:25 +0000209 int SetMinimumPlayoutDelay(int delayMs);
210 int GetPlayoutTimestamp(unsigned int& timestamp);
pwestin@webrtc.org1de01352013-04-11 20:23:35 +0000211 void UpdatePlayoutTimestamp(bool rtcp);
niklase@google.com470e71d2011-07-07 08:21:25 +0000212 int SetInitTimestamp(unsigned int timestamp);
213 int SetInitSequenceNumber(short sequenceNumber);
214
215 // VoEVideoSyncExtended
216 int GetRtpRtcp(RtpRtcp* &rtpRtcpModule) const;
217
218 // VoEEncryption
niklase@google.com470e71d2011-07-07 08:21:25 +0000219 int RegisterExternalEncryption(Encryption& encryption);
220 int DeRegisterExternalEncryption();
221
222 // VoEDtmf
223 int SendTelephoneEventOutband(unsigned char eventCode, int lengthMs,
224 int attenuationDb, bool playDtmfEvent);
225 int SendTelephoneEventInband(unsigned char eventCode, int lengthMs,
226 int attenuationDb, bool playDtmfEvent);
227 int SetDtmfPlayoutStatus(bool enable);
228 bool DtmfPlayoutStatus() const;
229 int SetSendTelephoneEventPayloadType(unsigned char type);
230 int GetSendTelephoneEventPayloadType(unsigned char& type);
niklase@google.com470e71d2011-07-07 08:21:25 +0000231
232 // VoEAudioProcessingImpl
233 int UpdateRxVadDetection(AudioFrame& audioFrame);
234 int RegisterRxVadObserver(VoERxVadCallback &observer);
235 int DeRegisterRxVadObserver();
236 int VoiceActivityIndicator(int &activity);
237#ifdef WEBRTC_VOICE_ENGINE_AGC
pbos@webrtc.org92135212013-05-14 08:31:39 +0000238 int SetRxAgcStatus(bool enable, AgcModes mode);
niklase@google.com470e71d2011-07-07 08:21:25 +0000239 int GetRxAgcStatus(bool& enabled, AgcModes& mode);
pbos@webrtc.org92135212013-05-14 08:31:39 +0000240 int SetRxAgcConfig(AgcConfig config);
niklase@google.com470e71d2011-07-07 08:21:25 +0000241 int GetRxAgcConfig(AgcConfig& config);
242#endif
243#ifdef WEBRTC_VOICE_ENGINE_NR
pbos@webrtc.org92135212013-05-14 08:31:39 +0000244 int SetRxNsStatus(bool enable, NsModes mode);
niklase@google.com470e71d2011-07-07 08:21:25 +0000245 int GetRxNsStatus(bool& enabled, NsModes& mode);
246#endif
247
248 // VoERTP_RTCP
249 int RegisterRTPObserver(VoERTPObserver& observer);
250 int DeRegisterRTPObserver();
251 int RegisterRTCPObserver(VoERTCPObserver& observer);
252 int DeRegisterRTCPObserver();
253 int SetLocalSSRC(unsigned int ssrc);
254 int GetLocalSSRC(unsigned int& ssrc);
255 int GetRemoteSSRC(unsigned int& ssrc);
256 int GetRemoteCSRCs(unsigned int arrCSRC[15]);
257 int SetRTPAudioLevelIndicationStatus(bool enable, unsigned char ID);
258 int GetRTPAudioLevelIndicationStatus(bool& enable, unsigned char& ID);
259 int SetRTCPStatus(bool enable);
260 int GetRTCPStatus(bool& enabled);
261 int SetRTCP_CNAME(const char cName[256]);
262 int GetRTCP_CNAME(char cName[256]);
263 int GetRemoteRTCP_CNAME(char cName[256]);
264 int GetRemoteRTCPData(unsigned int& NTPHigh, unsigned int& NTPLow,
265 unsigned int& timestamp,
266 unsigned int& playoutTimestamp, unsigned int* jitter,
267 unsigned short* fractionLost);
pbos@webrtc.org92135212013-05-14 08:31:39 +0000268 int SendApplicationDefinedRTCPPacket(unsigned char subType,
niklase@google.com470e71d2011-07-07 08:21:25 +0000269 unsigned int name, const char* data,
270 unsigned short dataLengthInBytes);
271 int GetRTPStatistics(unsigned int& averageJitterMs,
272 unsigned int& maxJitterMs,
273 unsigned int& discardedPackets);
henrika@webrtc.org8a2fc882012-08-22 08:53:55 +0000274 int GetRemoteRTCPSenderInfo(SenderInfo* sender_info);
275 int GetRemoteRTCPReportBlocks(std::vector<ReportBlock>* report_blocks);
niklase@google.com470e71d2011-07-07 08:21:25 +0000276 int GetRTPStatistics(CallStatistics& stats);
277 int SetFECStatus(bool enable, int redPayloadtype);
278 int GetFECStatus(bool& enabled, int& redPayloadtype);
niklase@google.com470e71d2011-07-07 08:21:25 +0000279 int StartRTPDump(const char fileNameUTF8[1024], RTPDirections direction);
280 int StopRTPDump(RTPDirections direction);
281 bool RTPDumpIsActive(RTPDirections direction);
282 int InsertExtraRTPPacket(unsigned char payloadType, bool markerBit,
283 const char* payloadData,
284 unsigned short payloadSize);
roosa@google.com0870f022012-12-12 21:31:41 +0000285 uint32_t LastRemoteTimeStamp() { return _lastRemoteTimeStamp; }
niklase@google.com470e71d2011-07-07 08:21:25 +0000286
287public:
288 // From AudioPacketizationCallback in the ACM
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000289 int32_t SendData(FrameType frameType,
290 uint8_t payloadType,
291 uint32_t timeStamp,
292 const uint8_t* payloadData,
293 uint16_t payloadSize,
294 const RTPFragmentationHeader* fragmentation);
niklase@google.com470e71d2011-07-07 08:21:25 +0000295 // From ACMVADCallback in the ACM
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000296 int32_t InFrameType(int16_t frameType);
niklase@google.com470e71d2011-07-07 08:21:25 +0000297
niklase@google.com470e71d2011-07-07 08:21:25 +0000298public:
pbos@webrtc.org92135212013-05-14 08:31:39 +0000299 int32_t OnRxVadDetected(int vadDecision);
niklase@google.com470e71d2011-07-07 08:21:25 +0000300
301public:
302 // From RtpData in the RTP/RTCP module
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000303 int32_t OnReceivedPayloadData(const uint8_t* payloadData,
pbos@webrtc.org92135212013-05-14 08:31:39 +0000304 uint16_t payloadSize,
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000305 const WebRtcRTPHeader* rtpHeader);
niklase@google.com470e71d2011-07-07 08:21:25 +0000306
307public:
308 // From RtpFeedback in the RTP/RTCP module
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000309 int32_t OnInitializeDecoder(
pbos@webrtc.org92135212013-05-14 08:31:39 +0000310 int32_t id,
311 int8_t payloadType,
leozwang@webrtc.org813e4b02012-03-01 18:34:25 +0000312 const char payloadName[RTP_PAYLOAD_NAME_SIZE],
pbos@webrtc.org92135212013-05-14 08:31:39 +0000313 int frequency,
314 uint8_t channels,
315 uint32_t rate);
niklase@google.com470e71d2011-07-07 08:21:25 +0000316
pbos@webrtc.org92135212013-05-14 08:31:39 +0000317 void OnPacketTimeout(int32_t id);
niklase@google.com470e71d2011-07-07 08:21:25 +0000318
pbos@webrtc.org92135212013-05-14 08:31:39 +0000319 void OnReceivedPacket(int32_t id, RtpRtcpPacketType packetType);
niklase@google.com470e71d2011-07-07 08:21:25 +0000320
pbos@webrtc.org92135212013-05-14 08:31:39 +0000321 void OnPeriodicDeadOrAlive(int32_t id,
322 RTPAliveType alive);
niklase@google.com470e71d2011-07-07 08:21:25 +0000323
pbos@webrtc.org92135212013-05-14 08:31:39 +0000324 void OnIncomingSSRCChanged(int32_t id,
325 uint32_t SSRC);
niklase@google.com470e71d2011-07-07 08:21:25 +0000326
pbos@webrtc.org92135212013-05-14 08:31:39 +0000327 void OnIncomingCSRCChanged(int32_t id,
328 uint32_t CSRC, bool added);
niklase@google.com470e71d2011-07-07 08:21:25 +0000329
330public:
331 // From RtcpFeedback in the RTP/RTCP module
pbos@webrtc.org92135212013-05-14 08:31:39 +0000332 void OnApplicationDataReceived(int32_t id,
333 uint8_t subType,
334 uint32_t name,
335 uint16_t length,
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000336 const uint8_t* data);
niklase@google.com470e71d2011-07-07 08:21:25 +0000337
niklase@google.com470e71d2011-07-07 08:21:25 +0000338public:
339 // From RtpAudioFeedback in the RTP/RTCP module
pbos@webrtc.org92135212013-05-14 08:31:39 +0000340 void OnReceivedTelephoneEvent(int32_t id,
341 uint8_t event,
342 bool endOfEvent);
niklase@google.com470e71d2011-07-07 08:21:25 +0000343
pbos@webrtc.org92135212013-05-14 08:31:39 +0000344 void OnPlayTelephoneEvent(int32_t id,
345 uint8_t event,
346 uint16_t lengthMs,
347 uint8_t volume);
niklase@google.com470e71d2011-07-07 08:21:25 +0000348
349public:
niklase@google.com470e71d2011-07-07 08:21:25 +0000350 // From Transport (called by the RTP/RTCP module)
351 int SendPacket(int /*channel*/, const void *data, int len);
352 int SendRTCPPacket(int /*channel*/, const void *data, int len);
353
354public:
355 // From MixerParticipant
pbos@webrtc.org92135212013-05-14 08:31:39 +0000356 int32_t GetAudioFrame(int32_t id, AudioFrame& audioFrame);
357 int32_t NeededFrequency(int32_t id);
niklase@google.com470e71d2011-07-07 08:21:25 +0000358
359public:
360 // From MonitorObserver
361 void OnPeriodicProcess();
362
363public:
364 // From FileCallback
pbos@webrtc.org92135212013-05-14 08:31:39 +0000365 void PlayNotification(int32_t id,
366 uint32_t durationMs);
367 void RecordNotification(int32_t id,
368 uint32_t durationMs);
369 void PlayFileEnded(int32_t id);
370 void RecordFileEnded(int32_t id);
niklase@google.com470e71d2011-07-07 08:21:25 +0000371
372public:
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000373 uint32_t InstanceId() const
niklase@google.com470e71d2011-07-07 08:21:25 +0000374 {
375 return _instanceId;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000376 }
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000377 int32_t ChannelId() const
niklase@google.com470e71d2011-07-07 08:21:25 +0000378 {
379 return _channelId;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000380 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000381 bool Playing() const
382 {
383 return _playing;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000384 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000385 bool Sending() const
386 {
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000387 // A lock is needed because |_sending| is accessed by both
388 // TransmitMixer::PrepareDemux() and StartSend()/StopSend(), which
389 // are called by different threads.
mflodman@webrtc.org9a065d12012-03-07 08:12:21 +0000390 CriticalSectionScoped cs(&_callbackCritSect);
niklase@google.com470e71d2011-07-07 08:21:25 +0000391 return _sending;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000392 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000393 bool Receiving() const
394 {
395 return _receiving;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000396 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000397 bool ExternalTransport() const
398 {
399 return _externalTransport;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000400 }
roosa@google.com1b60ceb2012-12-12 23:00:29 +0000401 bool ExternalMixing() const
402 {
403 return _externalMixing;
404 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000405 bool OutputIsOnHold() const
406 {
407 return _outputIsOnHold;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000408 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000409 bool InputIsOnHold() const
410 {
411 return _inputIsOnHold;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000412 }
andrew@webrtc.orgf81f9f82011-08-19 22:56:22 +0000413 RtpRtcp* RtpRtcpModulePtr() const
niklase@google.com470e71d2011-07-07 08:21:25 +0000414 {
pwestin@webrtc.org2853dde2012-05-11 11:08:54 +0000415 return _rtpRtcpModule.get();
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000416 }
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000417 int8_t OutputEnergyLevel() const
niklase@google.com470e71d2011-07-07 08:21:25 +0000418 {
419 return _outputAudioLevel.Level();
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000420 }
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000421 uint32_t Demultiplex(const AudioFrame& audioFrame);
422 uint32_t PrepareEncodeAndSend(int mixingFrequency);
423 uint32_t EncodeAndSend();
niklase@google.com470e71d2011-07-07 08:21:25 +0000424
425private:
426 int InsertInbandDtmfTone();
pbos@webrtc.org92135212013-05-14 08:31:39 +0000427 int32_t MixOrReplaceAudioWithFile(int mixingFrequency);
428 int32_t MixAudioWithFile(AudioFrame& audioFrame, int mixingFrequency);
niklase@google.com470e71d2011-07-07 08:21:25 +0000429 void UpdateDeadOrAliveCounters(bool alive);
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000430 int32_t SendPacketRaw(const void *data, int len, bool RTCP);
pwestin@webrtc.org1de01352013-04-11 20:23:35 +0000431 void UpdatePacketDelay(uint32_t timestamp,
432 uint16_t sequenceNumber);
niklase@google.com470e71d2011-07-07 08:21:25 +0000433 void RegisterReceiveCodecsToRTPModule();
434 int ApmProcessRx(AudioFrame& audioFrame);
435
turaj@webrtc.org42259e72012-12-11 02:15:12 +0000436 int SetRedPayloadType(int red_payload_type);
niklase@google.com470e71d2011-07-07 08:21:25 +0000437private:
438 CriticalSectionWrapper& _fileCritSect;
439 CriticalSectionWrapper& _callbackCritSect;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000440 uint32_t _instanceId;
441 int32_t _channelId;
niklase@google.com470e71d2011-07-07 08:21:25 +0000442
443private:
pwestin@webrtc.org2853dde2012-05-11 11:08:54 +0000444 scoped_ptr<RtpRtcp> _rtpRtcpModule;
niklase@google.com470e71d2011-07-07 08:21:25 +0000445 AudioCodingModule& _audioCodingModule;
niklase@google.com470e71d2011-07-07 08:21:25 +0000446 RtpDump& _rtpDumpIn;
447 RtpDump& _rtpDumpOut;
448private:
449 AudioLevel _outputAudioLevel;
450 bool _externalTransport;
451 AudioFrame _audioFrame;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000452 uint8_t _audioLevel_dBov;
niklase@google.com470e71d2011-07-07 08:21:25 +0000453 FilePlayer* _inputFilePlayerPtr;
454 FilePlayer* _outputFilePlayerPtr;
455 FileRecorder* _outputFileRecorderPtr;
xians@google.com0b0665a2011-08-08 08:18:44 +0000456 int _inputFilePlayerId;
457 int _outputFilePlayerId;
458 int _outputFileRecorderId;
niklase@google.com470e71d2011-07-07 08:21:25 +0000459 bool _inputFilePlaying;
460 bool _outputFilePlaying;
461 bool _outputFileRecording;
462 DtmfInbandQueue _inbandDtmfQueue;
463 DtmfInband _inbandDtmfGenerator;
niklase@google.com470e71d2011-07-07 08:21:25 +0000464 bool _inputExternalMedia;
xians@google.com22963ab2011-08-03 12:40:23 +0000465 bool _outputExternalMedia;
niklase@google.com470e71d2011-07-07 08:21:25 +0000466 VoEMediaProcess* _inputExternalMediaCallbackPtr;
467 VoEMediaProcess* _outputExternalMediaCallbackPtr;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000468 uint8_t* _encryptionRTPBufferPtr;
469 uint8_t* _decryptionRTPBufferPtr;
470 uint8_t* _encryptionRTCPBufferPtr;
471 uint8_t* _decryptionRTCPBufferPtr;
472 uint32_t _timeStamp;
473 uint8_t _sendTelephoneEventPayloadType;
pwestin@webrtc.org1de01352013-04-11 20:23:35 +0000474 uint32_t playout_timestamp_rtp_;
475 uint32_t playout_timestamp_rtcp_;
476 uint32_t playout_delay_ms_;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000477 uint32_t _numberOfDiscardedPackets;
pwestin@webrtc.org1de01352013-04-11 20:23:35 +0000478
479 private:
niklase@google.com470e71d2011-07-07 08:21:25 +0000480 // uses
481 Statistics* _engineStatisticsPtr;
482 OutputMixer* _outputMixerPtr;
483 TransmitMixer* _transmitMixerPtr;
484 ProcessThread* _moduleProcessThreadPtr;
485 AudioDeviceModule* _audioDeviceModulePtr;
486 VoiceEngineObserver* _voiceEngineObserverPtr; // owned by base
487 CriticalSectionWrapper* _callbackCritSectPtr; // owned by base
488 Transport* _transportPtr; // WebRtc socket or external transport
489 Encryption* _encryptionPtr; // WebRtc SRTP or external encryption
andrew@webrtc.org755b04a2011-11-15 16:57:56 +0000490 scoped_ptr<AudioProcessing> _rtpAudioProc;
niklase@google.com470e71d2011-07-07 08:21:25 +0000491 AudioProcessing* _rxAudioProcessingModulePtr; // far end AudioProcessing
niklase@google.com470e71d2011-07-07 08:21:25 +0000492 VoERxVadCallback* _rxVadObserverPtr;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000493 int32_t _oldVadDecision;
494 int32_t _sendFrameType; // Send data is voice, 1-voice, 0-otherwise
niklase@google.com470e71d2011-07-07 08:21:25 +0000495 VoERTPObserver* _rtpObserverPtr;
496 VoERTCPObserver* _rtcpObserverPtr;
497private:
498 // VoEBase
499 bool _outputIsOnHold;
500 bool _externalPlayout;
roosa@google.com1b60ceb2012-12-12 23:00:29 +0000501 bool _externalMixing;
niklase@google.com470e71d2011-07-07 08:21:25 +0000502 bool _inputIsOnHold;
503 bool _playing;
504 bool _sending;
505 bool _receiving;
506 bool _mixFileWithMicrophone;
507 bool _rtpObserver;
508 bool _rtcpObserver;
509 // VoEVolumeControl
510 bool _mute;
511 float _panLeft;
512 float _panRight;
513 float _outputGain;
514 // VoEEncryption
515 bool _encrypting;
516 bool _decrypting;
517 // VoEDtmf
518 bool _playOutbandDtmfEvent;
519 bool _playInbandDtmfEvent;
niklase@google.com470e71d2011-07-07 08:21:25 +0000520 // VoeRTP_RTCP
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000521 uint8_t _extraPayloadType;
niklase@google.com470e71d2011-07-07 08:21:25 +0000522 bool _insertExtraRTPPacket;
523 bool _extraMarkerBit;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000524 uint32_t _lastLocalTimeStamp;
roosa@google.com0870f022012-12-12 21:31:41 +0000525 uint32_t _lastRemoteTimeStamp;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000526 int8_t _lastPayloadType;
niklase@google.com470e71d2011-07-07 08:21:25 +0000527 bool _includeAudioLevelIndication;
528 // VoENetwork
529 bool _rtpPacketTimedOut;
530 bool _rtpPacketTimeOutIsEnabled;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000531 uint32_t _rtpTimeOutSeconds;
niklase@google.com470e71d2011-07-07 08:21:25 +0000532 bool _connectionObserver;
533 VoEConnectionObserver* _connectionObserverPtr;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000534 uint32_t _countAliveDetections;
535 uint32_t _countDeadDetections;
niklase@google.com470e71d2011-07-07 08:21:25 +0000536 AudioFrame::SpeechType _outputSpeechType;
537 // VoEVideoSync
pwestin@webrtc.org1de01352013-04-11 20:23:35 +0000538 uint32_t _average_jitter_buffer_delay_us;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000539 uint32_t _previousTimestamp;
540 uint16_t _recPacketDelayMs;
niklase@google.com470e71d2011-07-07 08:21:25 +0000541 // VoEAudioProcessing
542 bool _RxVadDetection;
543 bool _rxApmIsEnabled;
544 bool _rxAgcIsEnabled;
545 bool _rxNsIsEnabled;
546};
547
548} // namespace voe
549
550} // namespace webrtc
551
552#endif // WEBRTC_VOICE_ENGINE_CHANNEL_H