blob: 972b5abc861b76315fa3dff2ae15cbf8152a4f55 [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
31#include "voe_dtmf.h" // TelephoneEventDetectionMethods, TelephoneEventObserver
32#endif
33
34namespace webrtc
35{
36class CriticalSectionWrapper;
37class ProcessThread;
38class AudioDeviceModule;
39class RtpRtcp;
40class FileWrapper;
41class RtpDump;
42class VoiceEngineObserver;
43class VoEMediaProcess;
44class VoERTPObserver;
45class VoERTCPObserver;
46
47struct CallStatistics;
henrika@webrtc.org8a2fc882012-08-22 08:53:55 +000048struct ReportBlock;
49struct SenderInfo;
niklase@google.com470e71d2011-07-07 08:21:25 +000050
51namespace voe
52{
53class Statistics;
54class TransmitMixer;
55class OutputMixer;
56
57
58class Channel:
59 public RtpData,
60 public RtpFeedback,
61 public RtcpFeedback,
niklase@google.com470e71d2011-07-07 08:21:25 +000062 public FileCallback, // receiving notification from file player & recorder
63 public Transport,
64 public RtpAudioFeedback,
65 public AudioPacketizationCallback, // receive encoded packets from the ACM
66 public ACMVADCallback, // receive voice activity from the ACM
niklase@google.com470e71d2011-07-07 08:21:25 +000067 public MixerParticipant // supplies output mixer with audio frames
68{
69public:
70 enum {KNumSocketThreads = 1};
71 enum {KNumberOfSocketBuffers = 8};
niklase@google.com470e71d2011-07-07 08:21:25 +000072public:
73 virtual ~Channel();
pbos@webrtc.org6141e132013-04-09 10:09:10 +000074 static int32_t CreateChannel(Channel*& channel,
75 const int32_t channelId,
76 const uint32_t instanceId);
77 Channel(const int32_t channelId, const uint32_t instanceId);
78 int32_t Init();
79 int32_t SetEngineInformation(
niklase@google.com470e71d2011-07-07 08:21:25 +000080 Statistics& engineStatistics,
81 OutputMixer& outputMixer,
82 TransmitMixer& transmitMixer,
83 ProcessThread& moduleProcessThread,
84 AudioDeviceModule& audioDeviceModule,
85 VoiceEngineObserver* voiceEngineObserver,
86 CriticalSectionWrapper* callbackCritSect);
pbos@webrtc.org6141e132013-04-09 10:09:10 +000087 int32_t UpdateLocalTimeStamp();
niklase@google.com470e71d2011-07-07 08:21:25 +000088
89public:
90 // API methods
91
92 // VoEBase
pbos@webrtc.org6141e132013-04-09 10:09:10 +000093 int32_t StartPlayout();
94 int32_t StopPlayout();
95 int32_t StartSend();
96 int32_t StopSend();
97 int32_t StartReceiving();
98 int32_t StopReceiving();
niklase@google.com470e71d2011-07-07 08:21:25 +000099
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000100 int32_t SetNetEQPlayoutMode(NetEqModes mode);
101 int32_t GetNetEQPlayoutMode(NetEqModes& mode);
102 int32_t SetOnHoldStatus(bool enable, OnHoldModes mode);
103 int32_t GetOnHoldStatus(bool& enabled, OnHoldModes& mode);
104 int32_t RegisterVoiceEngineObserver(VoiceEngineObserver& observer);
105 int32_t DeRegisterVoiceEngineObserver();
niklase@google.com470e71d2011-07-07 08:21:25 +0000106
107 // VoECodec
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000108 int32_t GetSendCodec(CodecInst& codec);
109 int32_t GetRecCodec(CodecInst& codec);
110 int32_t SetSendCodec(const CodecInst& codec);
111 int32_t SetVADStatus(bool enableVAD, ACMVADMode mode, bool disableDTX);
112 int32_t GetVADStatus(bool& enabledVAD, ACMVADMode& mode, bool& disabledDTX);
113 int32_t SetRecPayloadType(const CodecInst& codec);
114 int32_t GetRecPayloadType(CodecInst& codec);
115 int32_t SetAMREncFormat(AmrMode mode);
116 int32_t SetAMRDecFormat(AmrMode mode);
117 int32_t SetAMRWbEncFormat(AmrMode mode);
118 int32_t SetAMRWbDecFormat(AmrMode mode);
119 int32_t SetSendCNPayloadType(int type, PayloadFrequencies frequency);
120 int32_t SetISACInitTargetRate(int rateBps, bool useFixedFrameSize);
121 int32_t SetISACMaxRate(int rateBps);
122 int32_t SetISACMaxPayloadSize(int sizeBytes);
niklase@google.com470e71d2011-07-07 08:21:25 +0000123
turaj@webrtc.org42259e72012-12-11 02:15:12 +0000124 // VoE dual-streaming.
125 int SetSecondarySendCodec(const CodecInst& codec, int red_payload_type);
126 void RemoveSecondarySendCodec();
127 int GetSecondarySendCodec(CodecInst* codec);
128
niklase@google.com470e71d2011-07-07 08:21:25 +0000129 // VoENetwork
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000130 int32_t RegisterExternalTransport(Transport& transport);
131 int32_t DeRegisterExternalTransport();
132 int32_t ReceivedRTPPacket(const int8_t* data, int32_t length);
133 int32_t ReceivedRTCPPacket(const int8_t* data, int32_t length);
134 int32_t SetPacketTimeoutNotification(bool enable, int timeoutSeconds);
135 int32_t GetPacketTimeoutNotification(bool& enabled, int& timeoutSeconds);
136 int32_t RegisterDeadOrAliveObserver(VoEConnectionObserver& observer);
137 int32_t DeRegisterDeadOrAliveObserver();
138 int32_t SetPeriodicDeadOrAliveStatus(bool enable, int sampleTimeSeconds);
139 int32_t GetPeriodicDeadOrAliveStatus(bool& enabled, int& sampleTimeSeconds);
pwestin@webrtc.org684f0572013-03-13 23:20:57 +0000140
niklase@google.com470e71d2011-07-07 08:21:25 +0000141 // VoEFile
142 int StartPlayingFileLocally(const char* fileName, const bool loop,
143 const FileFormats format,
144 const int startPosition,
145 const float volumeScaling,
146 const int stopPosition,
147 const CodecInst* codecInst);
148 int StartPlayingFileLocally(InStream* stream, const FileFormats format,
149 const int startPosition,
150 const float volumeScaling,
151 const int stopPosition,
152 const CodecInst* codecInst);
153 int StopPlayingFileLocally();
154 int IsPlayingFileLocally() const;
braveyao@webrtc.orgab129902012-06-04 03:26:39 +0000155 int RegisterFilePlayingToMixer();
niklase@google.com470e71d2011-07-07 08:21:25 +0000156 int ScaleLocalFilePlayout(const float scale);
157 int GetLocalPlayoutPosition(int& positionMs);
158 int StartPlayingFileAsMicrophone(const char* fileName, const bool loop,
159 const FileFormats format,
160 const int startPosition,
161 const float volumeScaling,
162 const int stopPosition,
163 const CodecInst* codecInst);
164 int StartPlayingFileAsMicrophone(InStream* stream,
165 const FileFormats format,
166 const int startPosition,
167 const float volumeScaling,
168 const int stopPosition,
169 const CodecInst* codecInst);
170 int StopPlayingFileAsMicrophone();
171 int IsPlayingFileAsMicrophone() const;
172 int ScaleFileAsMicrophonePlayout(const float scale);
173 int StartRecordingPlayout(const char* fileName, const CodecInst* codecInst);
174 int StartRecordingPlayout(OutStream* stream, const CodecInst* codecInst);
175 int StopRecordingPlayout();
176
177 void SetMixWithMicStatus(bool mix);
178
179 // VoEExternalMediaProcessing
180 int RegisterExternalMediaProcessing(ProcessingTypes type,
181 VoEMediaProcess& processObject);
182 int DeRegisterExternalMediaProcessing(ProcessingTypes type);
roosa@google.com1b60ceb2012-12-12 23:00:29 +0000183 int SetExternalMixing(bool enabled);
niklase@google.com470e71d2011-07-07 08:21:25 +0000184
185 // VoEVolumeControl
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000186 int GetSpeechOutputLevel(uint32_t& level) const;
187 int GetSpeechOutputLevelFullRange(uint32_t& level) const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000188 int SetMute(const bool enable);
189 bool Mute() const;
190 int SetOutputVolumePan(float left, float right);
191 int GetOutputVolumePan(float& left, float& right) const;
192 int SetChannelOutputVolumeScaling(float scaling);
193 int GetChannelOutputVolumeScaling(float& scaling) const;
194
195 // VoECallReport
196 void ResetDeadOrAliveCounters();
197 int ResetRTCPStatistics();
198 int GetRoundTripTimeSummary(StatVal& delaysMs) const;
199 int GetDeadOrAliveCounters(int& countDead, int& countAlive) const;
200
201 // VoENetEqStats
202 int GetNetworkStatistics(NetworkStatistics& stats);
niklase@google.com470e71d2011-07-07 08:21:25 +0000203
204 // VoEVideoSync
205 int GetDelayEstimate(int& delayMs) const;
turaj@webrtc.org6388c3e2013-02-12 21:42:18 +0000206 int SetInitialPlayoutDelay(int delay_ms);
niklase@google.com470e71d2011-07-07 08:21:25 +0000207 int SetMinimumPlayoutDelay(int delayMs);
208 int GetPlayoutTimestamp(unsigned int& timestamp);
209 int SetInitTimestamp(unsigned int timestamp);
210 int SetInitSequenceNumber(short sequenceNumber);
211
212 // VoEVideoSyncExtended
213 int GetRtpRtcp(RtpRtcp* &rtpRtcpModule) const;
214
215 // VoEEncryption
niklase@google.com470e71d2011-07-07 08:21:25 +0000216 int RegisterExternalEncryption(Encryption& encryption);
217 int DeRegisterExternalEncryption();
218
219 // VoEDtmf
220 int SendTelephoneEventOutband(unsigned char eventCode, int lengthMs,
221 int attenuationDb, bool playDtmfEvent);
222 int SendTelephoneEventInband(unsigned char eventCode, int lengthMs,
223 int attenuationDb, bool playDtmfEvent);
224 int SetDtmfPlayoutStatus(bool enable);
225 bool DtmfPlayoutStatus() const;
226 int SetSendTelephoneEventPayloadType(unsigned char type);
227 int GetSendTelephoneEventPayloadType(unsigned char& type);
niklase@google.com470e71d2011-07-07 08:21:25 +0000228
229 // VoEAudioProcessingImpl
230 int UpdateRxVadDetection(AudioFrame& audioFrame);
231 int RegisterRxVadObserver(VoERxVadCallback &observer);
232 int DeRegisterRxVadObserver();
233 int VoiceActivityIndicator(int &activity);
234#ifdef WEBRTC_VOICE_ENGINE_AGC
235 int SetRxAgcStatus(const bool enable, const AgcModes mode);
236 int GetRxAgcStatus(bool& enabled, AgcModes& mode);
237 int SetRxAgcConfig(const AgcConfig config);
238 int GetRxAgcConfig(AgcConfig& config);
239#endif
240#ifdef WEBRTC_VOICE_ENGINE_NR
241 int SetRxNsStatus(const bool enable, const NsModes mode);
242 int GetRxNsStatus(bool& enabled, NsModes& mode);
243#endif
244
245 // VoERTP_RTCP
246 int RegisterRTPObserver(VoERTPObserver& observer);
247 int DeRegisterRTPObserver();
248 int RegisterRTCPObserver(VoERTCPObserver& observer);
249 int DeRegisterRTCPObserver();
250 int SetLocalSSRC(unsigned int ssrc);
251 int GetLocalSSRC(unsigned int& ssrc);
252 int GetRemoteSSRC(unsigned int& ssrc);
253 int GetRemoteCSRCs(unsigned int arrCSRC[15]);
254 int SetRTPAudioLevelIndicationStatus(bool enable, unsigned char ID);
255 int GetRTPAudioLevelIndicationStatus(bool& enable, unsigned char& ID);
256 int SetRTCPStatus(bool enable);
257 int GetRTCPStatus(bool& enabled);
258 int SetRTCP_CNAME(const char cName[256]);
259 int GetRTCP_CNAME(char cName[256]);
260 int GetRemoteRTCP_CNAME(char cName[256]);
261 int GetRemoteRTCPData(unsigned int& NTPHigh, unsigned int& NTPLow,
262 unsigned int& timestamp,
263 unsigned int& playoutTimestamp, unsigned int* jitter,
264 unsigned short* fractionLost);
265 int SendApplicationDefinedRTCPPacket(const unsigned char subType,
266 unsigned int name, const char* data,
267 unsigned short dataLengthInBytes);
268 int GetRTPStatistics(unsigned int& averageJitterMs,
269 unsigned int& maxJitterMs,
270 unsigned int& discardedPackets);
henrika@webrtc.org8a2fc882012-08-22 08:53:55 +0000271 int GetRemoteRTCPSenderInfo(SenderInfo* sender_info);
272 int GetRemoteRTCPReportBlocks(std::vector<ReportBlock>* report_blocks);
niklase@google.com470e71d2011-07-07 08:21:25 +0000273 int GetRTPStatistics(CallStatistics& stats);
274 int SetFECStatus(bool enable, int redPayloadtype);
275 int GetFECStatus(bool& enabled, int& redPayloadtype);
niklase@google.com470e71d2011-07-07 08:21:25 +0000276 int StartRTPDump(const char fileNameUTF8[1024], RTPDirections direction);
277 int StopRTPDump(RTPDirections direction);
278 bool RTPDumpIsActive(RTPDirections direction);
279 int InsertExtraRTPPacket(unsigned char payloadType, bool markerBit,
280 const char* payloadData,
281 unsigned short payloadSize);
roosa@google.com0870f022012-12-12 21:31:41 +0000282 uint32_t LastRemoteTimeStamp() { return _lastRemoteTimeStamp; }
niklase@google.com470e71d2011-07-07 08:21:25 +0000283
284public:
285 // From AudioPacketizationCallback in the ACM
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000286 int32_t SendData(FrameType frameType,
287 uint8_t payloadType,
288 uint32_t timeStamp,
289 const uint8_t* payloadData,
290 uint16_t payloadSize,
291 const RTPFragmentationHeader* fragmentation);
niklase@google.com470e71d2011-07-07 08:21:25 +0000292 // From ACMVADCallback in the ACM
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000293 int32_t InFrameType(int16_t frameType);
niklase@google.com470e71d2011-07-07 08:21:25 +0000294
niklase@google.com470e71d2011-07-07 08:21:25 +0000295public:
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000296 int32_t OnRxVadDetected(const int vadDecision);
niklase@google.com470e71d2011-07-07 08:21:25 +0000297
298public:
299 // From RtpData in the RTP/RTCP module
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000300 int32_t OnReceivedPayloadData(const uint8_t* payloadData,
301 const uint16_t payloadSize,
302 const WebRtcRTPHeader* rtpHeader);
niklase@google.com470e71d2011-07-07 08:21:25 +0000303
304public:
305 // From RtpFeedback in the RTP/RTCP module
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000306 int32_t OnInitializeDecoder(
307 const int32_t id,
308 const int8_t payloadType,
leozwang@webrtc.org813e4b02012-03-01 18:34:25 +0000309 const char payloadName[RTP_PAYLOAD_NAME_SIZE],
xians@google.com0b0665a2011-08-08 08:18:44 +0000310 const int frequency,
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000311 const uint8_t channels,
312 const uint32_t rate);
niklase@google.com470e71d2011-07-07 08:21:25 +0000313
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000314 void OnPacketTimeout(const int32_t id);
niklase@google.com470e71d2011-07-07 08:21:25 +0000315
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000316 void OnReceivedPacket(const int32_t id, const RtpRtcpPacketType packetType);
niklase@google.com470e71d2011-07-07 08:21:25 +0000317
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000318 void OnPeriodicDeadOrAlive(const int32_t id,
niklase@google.com470e71d2011-07-07 08:21:25 +0000319 const RTPAliveType alive);
320
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000321 void OnIncomingSSRCChanged(const int32_t id,
322 const uint32_t SSRC);
niklase@google.com470e71d2011-07-07 08:21:25 +0000323
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000324 void OnIncomingCSRCChanged(const int32_t id,
325 const uint32_t CSRC, const bool added);
niklase@google.com470e71d2011-07-07 08:21:25 +0000326
327public:
328 // From RtcpFeedback in the RTP/RTCP module
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000329 void OnApplicationDataReceived(const int32_t id,
330 const uint8_t subType,
331 const uint32_t name,
332 const uint16_t length,
333 const uint8_t* data);
niklase@google.com470e71d2011-07-07 08:21:25 +0000334
niklase@google.com470e71d2011-07-07 08:21:25 +0000335public:
336 // From RtpAudioFeedback in the RTP/RTCP module
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000337 void OnReceivedTelephoneEvent(const int32_t id,
338 const uint8_t event,
niklase@google.com470e71d2011-07-07 08:21:25 +0000339 const bool endOfEvent);
340
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000341 void OnPlayTelephoneEvent(const int32_t id,
342 const uint8_t event,
343 const uint16_t lengthMs,
344 const uint8_t volume);
niklase@google.com470e71d2011-07-07 08:21:25 +0000345
346public:
niklase@google.com470e71d2011-07-07 08:21:25 +0000347 // From Transport (called by the RTP/RTCP module)
348 int SendPacket(int /*channel*/, const void *data, int len);
349 int SendRTCPPacket(int /*channel*/, const void *data, int len);
350
351public:
352 // From MixerParticipant
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000353 int32_t GetAudioFrame(const int32_t id, AudioFrame& audioFrame);
354 int32_t NeededFrequency(const int32_t id);
niklase@google.com470e71d2011-07-07 08:21:25 +0000355
356public:
357 // From MonitorObserver
358 void OnPeriodicProcess();
359
360public:
361 // From FileCallback
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000362 void PlayNotification(const int32_t id,
363 const uint32_t durationMs);
364 void RecordNotification(const int32_t id,
365 const uint32_t durationMs);
366 void PlayFileEnded(const int32_t id);
367 void RecordFileEnded(const int32_t id);
niklase@google.com470e71d2011-07-07 08:21:25 +0000368
369public:
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000370 uint32_t InstanceId() const
niklase@google.com470e71d2011-07-07 08:21:25 +0000371 {
372 return _instanceId;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000373 }
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000374 int32_t ChannelId() const
niklase@google.com470e71d2011-07-07 08:21:25 +0000375 {
376 return _channelId;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000377 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000378 bool Playing() const
379 {
380 return _playing;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000381 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000382 bool Sending() const
383 {
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000384 // A lock is needed because |_sending| is accessed by both
385 // TransmitMixer::PrepareDemux() and StartSend()/StopSend(), which
386 // are called by different threads.
mflodman@webrtc.org9a065d12012-03-07 08:12:21 +0000387 CriticalSectionScoped cs(&_callbackCritSect);
niklase@google.com470e71d2011-07-07 08:21:25 +0000388 return _sending;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000389 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000390 bool Receiving() const
391 {
392 return _receiving;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000393 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000394 bool ExternalTransport() const
395 {
396 return _externalTransport;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000397 }
roosa@google.com1b60ceb2012-12-12 23:00:29 +0000398 bool ExternalMixing() const
399 {
400 return _externalMixing;
401 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000402 bool OutputIsOnHold() const
403 {
404 return _outputIsOnHold;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000405 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000406 bool InputIsOnHold() const
407 {
408 return _inputIsOnHold;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000409 }
andrew@webrtc.orgf81f9f82011-08-19 22:56:22 +0000410 RtpRtcp* RtpRtcpModulePtr() const
niklase@google.com470e71d2011-07-07 08:21:25 +0000411 {
pwestin@webrtc.org2853dde2012-05-11 11:08:54 +0000412 return _rtpRtcpModule.get();
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000413 }
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000414 int8_t OutputEnergyLevel() const
niklase@google.com470e71d2011-07-07 08:21:25 +0000415 {
416 return _outputAudioLevel.Level();
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000417 }
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000418 uint32_t Demultiplex(const AudioFrame& audioFrame);
419 uint32_t PrepareEncodeAndSend(int mixingFrequency);
420 uint32_t EncodeAndSend();
niklase@google.com470e71d2011-07-07 08:21:25 +0000421
422private:
423 int InsertInbandDtmfTone();
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000424 int32_t
xians@google.com0b0665a2011-08-08 08:18:44 +0000425 MixOrReplaceAudioWithFile(const int mixingFrequency);
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000426 int32_t MixAudioWithFile(AudioFrame& audioFrame, const int mixingFrequency);
427 int32_t GetPlayoutTimeStamp(uint32_t& playoutTimestamp);
niklase@google.com470e71d2011-07-07 08:21:25 +0000428 void UpdateDeadOrAliveCounters(bool alive);
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000429 int32_t SendPacketRaw(const void *data, int len, bool RTCP);
430 int32_t UpdatePacketDelay(const uint32_t timestamp,
431 const uint16_t sequenceNumber);
niklase@google.com470e71d2011-07-07 08:21:25 +0000432 void RegisterReceiveCodecsToRTPModule();
433 int ApmProcessRx(AudioFrame& audioFrame);
434
turaj@webrtc.org42259e72012-12-11 02:15:12 +0000435 int SetRedPayloadType(int red_payload_type);
niklase@google.com470e71d2011-07-07 08:21:25 +0000436private:
437 CriticalSectionWrapper& _fileCritSect;
438 CriticalSectionWrapper& _callbackCritSect;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000439 uint32_t _instanceId;
440 int32_t _channelId;
niklase@google.com470e71d2011-07-07 08:21:25 +0000441
442private:
pwestin@webrtc.org2853dde2012-05-11 11:08:54 +0000443 scoped_ptr<RtpRtcp> _rtpRtcpModule;
niklase@google.com470e71d2011-07-07 08:21:25 +0000444 AudioCodingModule& _audioCodingModule;
niklase@google.com470e71d2011-07-07 08:21:25 +0000445 RtpDump& _rtpDumpIn;
446 RtpDump& _rtpDumpOut;
447private:
448 AudioLevel _outputAudioLevel;
449 bool _externalTransport;
450 AudioFrame _audioFrame;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000451 uint8_t _audioLevel_dBov;
niklase@google.com470e71d2011-07-07 08:21:25 +0000452 FilePlayer* _inputFilePlayerPtr;
453 FilePlayer* _outputFilePlayerPtr;
454 FileRecorder* _outputFileRecorderPtr;
xians@google.com0b0665a2011-08-08 08:18:44 +0000455 int _inputFilePlayerId;
456 int _outputFilePlayerId;
457 int _outputFileRecorderId;
niklase@google.com470e71d2011-07-07 08:21:25 +0000458 bool _inputFilePlaying;
459 bool _outputFilePlaying;
460 bool _outputFileRecording;
461 DtmfInbandQueue _inbandDtmfQueue;
462 DtmfInband _inbandDtmfGenerator;
niklase@google.com470e71d2011-07-07 08:21:25 +0000463 bool _inputExternalMedia;
xians@google.com22963ab2011-08-03 12:40:23 +0000464 bool _outputExternalMedia;
niklase@google.com470e71d2011-07-07 08:21:25 +0000465 VoEMediaProcess* _inputExternalMediaCallbackPtr;
466 VoEMediaProcess* _outputExternalMediaCallbackPtr;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000467 uint8_t* _encryptionRTPBufferPtr;
468 uint8_t* _decryptionRTPBufferPtr;
469 uint8_t* _encryptionRTCPBufferPtr;
470 uint8_t* _decryptionRTCPBufferPtr;
471 uint32_t _timeStamp;
472 uint8_t _sendTelephoneEventPayloadType;
473 uint32_t _playoutTimeStampRTP;
474 uint32_t _playoutTimeStampRTCP;
475 uint32_t _numberOfDiscardedPackets;
niklase@google.com470e71d2011-07-07 08:21:25 +0000476private:
477 // uses
478 Statistics* _engineStatisticsPtr;
479 OutputMixer* _outputMixerPtr;
480 TransmitMixer* _transmitMixerPtr;
481 ProcessThread* _moduleProcessThreadPtr;
482 AudioDeviceModule* _audioDeviceModulePtr;
483 VoiceEngineObserver* _voiceEngineObserverPtr; // owned by base
484 CriticalSectionWrapper* _callbackCritSectPtr; // owned by base
485 Transport* _transportPtr; // WebRtc socket or external transport
486 Encryption* _encryptionPtr; // WebRtc SRTP or external encryption
andrew@webrtc.org755b04a2011-11-15 16:57:56 +0000487 scoped_ptr<AudioProcessing> _rtpAudioProc;
niklase@google.com470e71d2011-07-07 08:21:25 +0000488 AudioProcessing* _rxAudioProcessingModulePtr; // far end AudioProcessing
niklase@google.com470e71d2011-07-07 08:21:25 +0000489 VoERxVadCallback* _rxVadObserverPtr;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000490 int32_t _oldVadDecision;
491 int32_t _sendFrameType; // Send data is voice, 1-voice, 0-otherwise
niklase@google.com470e71d2011-07-07 08:21:25 +0000492 VoERTPObserver* _rtpObserverPtr;
493 VoERTCPObserver* _rtcpObserverPtr;
494private:
495 // VoEBase
496 bool _outputIsOnHold;
497 bool _externalPlayout;
roosa@google.com1b60ceb2012-12-12 23:00:29 +0000498 bool _externalMixing;
niklase@google.com470e71d2011-07-07 08:21:25 +0000499 bool _inputIsOnHold;
500 bool _playing;
501 bool _sending;
502 bool _receiving;
503 bool _mixFileWithMicrophone;
504 bool _rtpObserver;
505 bool _rtcpObserver;
506 // VoEVolumeControl
507 bool _mute;
508 float _panLeft;
509 float _panRight;
510 float _outputGain;
511 // VoEEncryption
512 bool _encrypting;
513 bool _decrypting;
514 // VoEDtmf
515 bool _playOutbandDtmfEvent;
516 bool _playInbandDtmfEvent;
niklase@google.com470e71d2011-07-07 08:21:25 +0000517 // VoeRTP_RTCP
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000518 uint8_t _extraPayloadType;
niklase@google.com470e71d2011-07-07 08:21:25 +0000519 bool _insertExtraRTPPacket;
520 bool _extraMarkerBit;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000521 uint32_t _lastLocalTimeStamp;
roosa@google.com0870f022012-12-12 21:31:41 +0000522 uint32_t _lastRemoteTimeStamp;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000523 int8_t _lastPayloadType;
niklase@google.com470e71d2011-07-07 08:21:25 +0000524 bool _includeAudioLevelIndication;
525 // VoENetwork
526 bool _rtpPacketTimedOut;
527 bool _rtpPacketTimeOutIsEnabled;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000528 uint32_t _rtpTimeOutSeconds;
niklase@google.com470e71d2011-07-07 08:21:25 +0000529 bool _connectionObserver;
530 VoEConnectionObserver* _connectionObserverPtr;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000531 uint32_t _countAliveDetections;
532 uint32_t _countDeadDetections;
niklase@google.com470e71d2011-07-07 08:21:25 +0000533 AudioFrame::SpeechType _outputSpeechType;
534 // VoEVideoSync
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000535 uint32_t _averageDelayMs;
536 uint16_t _previousSequenceNumber;
537 uint32_t _previousTimestamp;
538 uint16_t _recPacketDelayMs;
niklase@google.com470e71d2011-07-07 08:21:25 +0000539 // VoEAudioProcessing
540 bool _RxVadDetection;
541 bool _rxApmIsEnabled;
542 bool _rxAgcIsEnabled;
543 bool _rxNsIsEnabled;
544};
545
546} // namespace voe
547
548} // namespace webrtc
549
550#endif // WEBRTC_VOICE_ENGINE_CHANNEL_H