blob: 582a6fbf40b51afb1e00d25f0d4f57cee696e977 [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
pwestin@webrtc.org1de01352013-04-11 20:23:35 +0000205 bool GetDelayEstimate(int* jitter_buffer_delay_ms,
206 int* playout_buffer_delay_ms) const;
turaj@webrtc.org6388c3e2013-02-12 21:42:18 +0000207 int SetInitialPlayoutDelay(int delay_ms);
niklase@google.com470e71d2011-07-07 08:21:25 +0000208 int SetMinimumPlayoutDelay(int delayMs);
209 int GetPlayoutTimestamp(unsigned int& timestamp);
pwestin@webrtc.org1de01352013-04-11 20:23:35 +0000210 void UpdatePlayoutTimestamp(bool rtcp);
niklase@google.com470e71d2011-07-07 08:21:25 +0000211 int SetInitTimestamp(unsigned int timestamp);
212 int SetInitSequenceNumber(short sequenceNumber);
213
214 // VoEVideoSyncExtended
215 int GetRtpRtcp(RtpRtcp* &rtpRtcpModule) const;
216
217 // VoEEncryption
niklase@google.com470e71d2011-07-07 08:21:25 +0000218 int RegisterExternalEncryption(Encryption& encryption);
219 int DeRegisterExternalEncryption();
220
221 // VoEDtmf
222 int SendTelephoneEventOutband(unsigned char eventCode, int lengthMs,
223 int attenuationDb, bool playDtmfEvent);
224 int SendTelephoneEventInband(unsigned char eventCode, int lengthMs,
225 int attenuationDb, bool playDtmfEvent);
226 int SetDtmfPlayoutStatus(bool enable);
227 bool DtmfPlayoutStatus() const;
228 int SetSendTelephoneEventPayloadType(unsigned char type);
229 int GetSendTelephoneEventPayloadType(unsigned char& type);
niklase@google.com470e71d2011-07-07 08:21:25 +0000230
231 // VoEAudioProcessingImpl
232 int UpdateRxVadDetection(AudioFrame& audioFrame);
233 int RegisterRxVadObserver(VoERxVadCallback &observer);
234 int DeRegisterRxVadObserver();
235 int VoiceActivityIndicator(int &activity);
236#ifdef WEBRTC_VOICE_ENGINE_AGC
237 int SetRxAgcStatus(const bool enable, const AgcModes mode);
238 int GetRxAgcStatus(bool& enabled, AgcModes& mode);
239 int SetRxAgcConfig(const AgcConfig config);
240 int GetRxAgcConfig(AgcConfig& config);
241#endif
242#ifdef WEBRTC_VOICE_ENGINE_NR
243 int SetRxNsStatus(const bool enable, const NsModes mode);
244 int GetRxNsStatus(bool& enabled, NsModes& mode);
245#endif
246
247 // VoERTP_RTCP
248 int RegisterRTPObserver(VoERTPObserver& observer);
249 int DeRegisterRTPObserver();
250 int RegisterRTCPObserver(VoERTCPObserver& observer);
251 int DeRegisterRTCPObserver();
252 int SetLocalSSRC(unsigned int ssrc);
253 int GetLocalSSRC(unsigned int& ssrc);
254 int GetRemoteSSRC(unsigned int& ssrc);
255 int GetRemoteCSRCs(unsigned int arrCSRC[15]);
256 int SetRTPAudioLevelIndicationStatus(bool enable, unsigned char ID);
257 int GetRTPAudioLevelIndicationStatus(bool& enable, unsigned char& ID);
258 int SetRTCPStatus(bool enable);
259 int GetRTCPStatus(bool& enabled);
260 int SetRTCP_CNAME(const char cName[256]);
261 int GetRTCP_CNAME(char cName[256]);
262 int GetRemoteRTCP_CNAME(char cName[256]);
263 int GetRemoteRTCPData(unsigned int& NTPHigh, unsigned int& NTPLow,
264 unsigned int& timestamp,
265 unsigned int& playoutTimestamp, unsigned int* jitter,
266 unsigned short* fractionLost);
267 int SendApplicationDefinedRTCPPacket(const unsigned char subType,
268 unsigned int name, const char* data,
269 unsigned short dataLengthInBytes);
270 int GetRTPStatistics(unsigned int& averageJitterMs,
271 unsigned int& maxJitterMs,
272 unsigned int& discardedPackets);
henrika@webrtc.org8a2fc882012-08-22 08:53:55 +0000273 int GetRemoteRTCPSenderInfo(SenderInfo* sender_info);
274 int GetRemoteRTCPReportBlocks(std::vector<ReportBlock>* report_blocks);
niklase@google.com470e71d2011-07-07 08:21:25 +0000275 int GetRTPStatistics(CallStatistics& stats);
276 int SetFECStatus(bool enable, int redPayloadtype);
277 int GetFECStatus(bool& enabled, int& redPayloadtype);
niklase@google.com470e71d2011-07-07 08:21:25 +0000278 int StartRTPDump(const char fileNameUTF8[1024], RTPDirections direction);
279 int StopRTPDump(RTPDirections direction);
280 bool RTPDumpIsActive(RTPDirections direction);
281 int InsertExtraRTPPacket(unsigned char payloadType, bool markerBit,
282 const char* payloadData,
283 unsigned short payloadSize);
roosa@google.com0870f022012-12-12 21:31:41 +0000284 uint32_t LastRemoteTimeStamp() { return _lastRemoteTimeStamp; }
niklase@google.com470e71d2011-07-07 08:21:25 +0000285
286public:
287 // From AudioPacketizationCallback in the ACM
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000288 int32_t SendData(FrameType frameType,
289 uint8_t payloadType,
290 uint32_t timeStamp,
291 const uint8_t* payloadData,
292 uint16_t payloadSize,
293 const RTPFragmentationHeader* fragmentation);
niklase@google.com470e71d2011-07-07 08:21:25 +0000294 // From ACMVADCallback in the ACM
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000295 int32_t InFrameType(int16_t frameType);
niklase@google.com470e71d2011-07-07 08:21:25 +0000296
niklase@google.com470e71d2011-07-07 08:21:25 +0000297public:
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000298 int32_t OnRxVadDetected(const int vadDecision);
niklase@google.com470e71d2011-07-07 08:21:25 +0000299
300public:
301 // From RtpData in the RTP/RTCP module
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000302 int32_t OnReceivedPayloadData(const uint8_t* payloadData,
303 const uint16_t payloadSize,
304 const WebRtcRTPHeader* rtpHeader);
niklase@google.com470e71d2011-07-07 08:21:25 +0000305
306public:
307 // From RtpFeedback in the RTP/RTCP module
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000308 int32_t OnInitializeDecoder(
309 const int32_t id,
310 const int8_t payloadType,
leozwang@webrtc.org813e4b02012-03-01 18:34:25 +0000311 const char payloadName[RTP_PAYLOAD_NAME_SIZE],
xians@google.com0b0665a2011-08-08 08:18:44 +0000312 const int frequency,
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000313 const uint8_t channels,
314 const uint32_t rate);
niklase@google.com470e71d2011-07-07 08:21:25 +0000315
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000316 void OnPacketTimeout(const int32_t id);
niklase@google.com470e71d2011-07-07 08:21:25 +0000317
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000318 void OnReceivedPacket(const int32_t id, const RtpRtcpPacketType packetType);
niklase@google.com470e71d2011-07-07 08:21:25 +0000319
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000320 void OnPeriodicDeadOrAlive(const int32_t id,
niklase@google.com470e71d2011-07-07 08:21:25 +0000321 const RTPAliveType alive);
322
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000323 void OnIncomingSSRCChanged(const int32_t id,
324 const uint32_t SSRC);
niklase@google.com470e71d2011-07-07 08:21:25 +0000325
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000326 void OnIncomingCSRCChanged(const int32_t id,
327 const uint32_t CSRC, const bool added);
niklase@google.com470e71d2011-07-07 08:21:25 +0000328
329public:
330 // From RtcpFeedback in the RTP/RTCP module
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000331 void OnApplicationDataReceived(const int32_t id,
332 const uint8_t subType,
333 const uint32_t name,
334 const uint16_t length,
335 const uint8_t* data);
niklase@google.com470e71d2011-07-07 08:21:25 +0000336
niklase@google.com470e71d2011-07-07 08:21:25 +0000337public:
338 // From RtpAudioFeedback in the RTP/RTCP module
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000339 void OnReceivedTelephoneEvent(const int32_t id,
340 const uint8_t event,
niklase@google.com470e71d2011-07-07 08:21:25 +0000341 const bool endOfEvent);
342
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000343 void OnPlayTelephoneEvent(const int32_t id,
344 const uint8_t event,
345 const uint16_t lengthMs,
346 const uint8_t volume);
niklase@google.com470e71d2011-07-07 08:21:25 +0000347
348public:
niklase@google.com470e71d2011-07-07 08:21:25 +0000349 // From Transport (called by the RTP/RTCP module)
350 int SendPacket(int /*channel*/, const void *data, int len);
351 int SendRTCPPacket(int /*channel*/, const void *data, int len);
352
353public:
354 // From MixerParticipant
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000355 int32_t GetAudioFrame(const int32_t id, AudioFrame& audioFrame);
356 int32_t NeededFrequency(const int32_t id);
niklase@google.com470e71d2011-07-07 08:21:25 +0000357
358public:
359 // From MonitorObserver
360 void OnPeriodicProcess();
361
362public:
363 // From FileCallback
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000364 void PlayNotification(const int32_t id,
365 const uint32_t durationMs);
366 void RecordNotification(const int32_t id,
367 const uint32_t durationMs);
368 void PlayFileEnded(const int32_t id);
369 void RecordFileEnded(const int32_t id);
niklase@google.com470e71d2011-07-07 08:21:25 +0000370
371public:
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000372 uint32_t InstanceId() const
niklase@google.com470e71d2011-07-07 08:21:25 +0000373 {
374 return _instanceId;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000375 }
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000376 int32_t ChannelId() const
niklase@google.com470e71d2011-07-07 08:21:25 +0000377 {
378 return _channelId;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000379 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000380 bool Playing() const
381 {
382 return _playing;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000383 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000384 bool Sending() const
385 {
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000386 // A lock is needed because |_sending| is accessed by both
387 // TransmitMixer::PrepareDemux() and StartSend()/StopSend(), which
388 // are called by different threads.
mflodman@webrtc.org9a065d12012-03-07 08:12:21 +0000389 CriticalSectionScoped cs(&_callbackCritSect);
niklase@google.com470e71d2011-07-07 08:21:25 +0000390 return _sending;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000391 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000392 bool Receiving() const
393 {
394 return _receiving;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000395 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000396 bool ExternalTransport() const
397 {
398 return _externalTransport;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000399 }
roosa@google.com1b60ceb2012-12-12 23:00:29 +0000400 bool ExternalMixing() const
401 {
402 return _externalMixing;
403 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000404 bool OutputIsOnHold() const
405 {
406 return _outputIsOnHold;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000407 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000408 bool InputIsOnHold() const
409 {
410 return _inputIsOnHold;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000411 }
andrew@webrtc.orgf81f9f82011-08-19 22:56:22 +0000412 RtpRtcp* RtpRtcpModulePtr() const
niklase@google.com470e71d2011-07-07 08:21:25 +0000413 {
pwestin@webrtc.org2853dde2012-05-11 11:08:54 +0000414 return _rtpRtcpModule.get();
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000415 }
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000416 int8_t OutputEnergyLevel() const
niklase@google.com470e71d2011-07-07 08:21:25 +0000417 {
418 return _outputAudioLevel.Level();
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000419 }
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000420 uint32_t Demultiplex(const AudioFrame& audioFrame);
421 uint32_t PrepareEncodeAndSend(int mixingFrequency);
422 uint32_t EncodeAndSend();
niklase@google.com470e71d2011-07-07 08:21:25 +0000423
424private:
425 int InsertInbandDtmfTone();
pwestin@webrtc.org1de01352013-04-11 20:23:35 +0000426 int32_t MixOrReplaceAudioWithFile(const int mixingFrequency);
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000427 int32_t MixAudioWithFile(AudioFrame& audioFrame, const int mixingFrequency);
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);
pwestin@webrtc.org1de01352013-04-11 20:23:35 +0000430 void UpdatePacketDelay(uint32_t timestamp,
431 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;
pwestin@webrtc.org1de01352013-04-11 20:23:35 +0000473 uint32_t playout_timestamp_rtp_;
474 uint32_t playout_timestamp_rtcp_;
475 uint32_t playout_delay_ms_;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000476 uint32_t _numberOfDiscardedPackets;
pwestin@webrtc.org1de01352013-04-11 20:23:35 +0000477
478 private:
niklase@google.com470e71d2011-07-07 08:21:25 +0000479 // uses
480 Statistics* _engineStatisticsPtr;
481 OutputMixer* _outputMixerPtr;
482 TransmitMixer* _transmitMixerPtr;
483 ProcessThread* _moduleProcessThreadPtr;
484 AudioDeviceModule* _audioDeviceModulePtr;
485 VoiceEngineObserver* _voiceEngineObserverPtr; // owned by base
486 CriticalSectionWrapper* _callbackCritSectPtr; // owned by base
487 Transport* _transportPtr; // WebRtc socket or external transport
488 Encryption* _encryptionPtr; // WebRtc SRTP or external encryption
andrew@webrtc.org755b04a2011-11-15 16:57:56 +0000489 scoped_ptr<AudioProcessing> _rtpAudioProc;
niklase@google.com470e71d2011-07-07 08:21:25 +0000490 AudioProcessing* _rxAudioProcessingModulePtr; // far end AudioProcessing
niklase@google.com470e71d2011-07-07 08:21:25 +0000491 VoERxVadCallback* _rxVadObserverPtr;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000492 int32_t _oldVadDecision;
493 int32_t _sendFrameType; // Send data is voice, 1-voice, 0-otherwise
niklase@google.com470e71d2011-07-07 08:21:25 +0000494 VoERTPObserver* _rtpObserverPtr;
495 VoERTCPObserver* _rtcpObserverPtr;
496private:
497 // VoEBase
498 bool _outputIsOnHold;
499 bool _externalPlayout;
roosa@google.com1b60ceb2012-12-12 23:00:29 +0000500 bool _externalMixing;
niklase@google.com470e71d2011-07-07 08:21:25 +0000501 bool _inputIsOnHold;
502 bool _playing;
503 bool _sending;
504 bool _receiving;
505 bool _mixFileWithMicrophone;
506 bool _rtpObserver;
507 bool _rtcpObserver;
508 // VoEVolumeControl
509 bool _mute;
510 float _panLeft;
511 float _panRight;
512 float _outputGain;
513 // VoEEncryption
514 bool _encrypting;
515 bool _decrypting;
516 // VoEDtmf
517 bool _playOutbandDtmfEvent;
518 bool _playInbandDtmfEvent;
niklase@google.com470e71d2011-07-07 08:21:25 +0000519 // VoeRTP_RTCP
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000520 uint8_t _extraPayloadType;
niklase@google.com470e71d2011-07-07 08:21:25 +0000521 bool _insertExtraRTPPacket;
522 bool _extraMarkerBit;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000523 uint32_t _lastLocalTimeStamp;
roosa@google.com0870f022012-12-12 21:31:41 +0000524 uint32_t _lastRemoteTimeStamp;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000525 int8_t _lastPayloadType;
niklase@google.com470e71d2011-07-07 08:21:25 +0000526 bool _includeAudioLevelIndication;
527 // VoENetwork
528 bool _rtpPacketTimedOut;
529 bool _rtpPacketTimeOutIsEnabled;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000530 uint32_t _rtpTimeOutSeconds;
niklase@google.com470e71d2011-07-07 08:21:25 +0000531 bool _connectionObserver;
532 VoEConnectionObserver* _connectionObserverPtr;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000533 uint32_t _countAliveDetections;
534 uint32_t _countDeadDetections;
niklase@google.com470e71d2011-07-07 08:21:25 +0000535 AudioFrame::SpeechType _outputSpeechType;
536 // VoEVideoSync
pwestin@webrtc.org1de01352013-04-11 20:23:35 +0000537 uint32_t _average_jitter_buffer_delay_us;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000538 uint32_t _previousTimestamp;
539 uint16_t _recPacketDelayMs;
niklase@google.com470e71d2011-07-07 08:21:25 +0000540 // VoEAudioProcessing
541 bool _RxVadDetection;
542 bool _rxApmIsEnabled;
543 bool _rxAgcIsEnabled;
544 bool _rxNsIsEnabled;
545};
546
547} // namespace voe
548
549} // namespace webrtc
550
551#endif // WEBRTC_VOICE_ENGINE_CHANNEL_H