blob: f1c5809be36b23f3811574825a26a5726cc4cdef [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
pwestin@webrtc.org684f0572013-03-13 23:20:57 +000030#ifndef WEBRTC_EXTERNAL_TRANSPORT
31#include "webrtc/modules/udp_transport/interface/udp_transport.h"
32#endif
niklase@google.com470e71d2011-07-07 08:21:25 +000033#ifdef WEBRTC_SRTP
34#include "SrtpModule.h"
35#endif
niklase@google.com470e71d2011-07-07 08:21:25 +000036#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;
henrika@webrtc.org8a2fc882012-08-22 08:53:55 +000054struct ReportBlock;
55struct SenderInfo;
niklase@google.com470e71d2011-07-07 08:21:25 +000056
57namespace voe
58{
59class Statistics;
60class TransmitMixer;
61class OutputMixer;
62
63
64class Channel:
65 public RtpData,
66 public RtpFeedback,
67 public RtcpFeedback,
pwestin@webrtc.org684f0572013-03-13 23:20:57 +000068#ifndef WEBRTC_EXTERNAL_TRANSPORT
69 public UdpTransportData, // receiving packet from sockets
70#endif
niklase@google.com470e71d2011-07-07 08:21:25 +000071 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
niklase@google.com470e71d2011-07-07 08:21:25 +000076 public MixerParticipant // supplies output mixer with audio frames
77{
78public:
79 enum {KNumSocketThreads = 1};
80 enum {KNumberOfSocketBuffers = 8};
niklase@google.com470e71d2011-07-07 08:21:25 +000081public:
82 virtual ~Channel();
83 static WebRtc_Word32 CreateChannel(Channel*& channel,
84 const WebRtc_Word32 channelId,
85 const WebRtc_UWord32 instanceId);
86 Channel(const WebRtc_Word32 channelId, const WebRtc_UWord32 instanceId);
87 WebRtc_Word32 Init();
88 WebRtc_Word32 SetEngineInformation(
89 Statistics& engineStatistics,
90 OutputMixer& outputMixer,
91 TransmitMixer& transmitMixer,
92 ProcessThread& moduleProcessThread,
93 AudioDeviceModule& audioDeviceModule,
94 VoiceEngineObserver* voiceEngineObserver,
95 CriticalSectionWrapper* callbackCritSect);
96 WebRtc_Word32 UpdateLocalTimeStamp();
97
98public:
99 // API methods
100
101 // VoEBase
102 WebRtc_Word32 StartPlayout();
103 WebRtc_Word32 StopPlayout();
104 WebRtc_Word32 StartSend();
105 WebRtc_Word32 StopSend();
106 WebRtc_Word32 StartReceiving();
107 WebRtc_Word32 StopReceiving();
108
109#ifndef WEBRTC_EXTERNAL_TRANSPORT
110 WebRtc_Word32 SetLocalReceiver(const WebRtc_UWord16 rtpPort,
111 const WebRtc_UWord16 rtcpPort,
leozwang@webrtc.org813e4b02012-03-01 18:34:25 +0000112 const char ipAddr[64],
113 const char multicastIpAddr[64]);
niklase@google.com470e71d2011-07-07 08:21:25 +0000114 WebRtc_Word32 GetLocalReceiver(int& port, int& RTCPport, char ipAddr[]);
115 WebRtc_Word32 SetSendDestination(const WebRtc_UWord16 rtpPort,
leozwang@webrtc.org813e4b02012-03-01 18:34:25 +0000116 const char ipAddr[64],
niklase@google.com470e71d2011-07-07 08:21:25 +0000117 const int sourcePort,
118 const WebRtc_UWord16 rtcpPort);
119 WebRtc_Word32 GetSendDestination(int& port, char ipAddr[64],
120 int& sourcePort, int& RTCPport);
121#endif
122 WebRtc_Word32 SetNetEQPlayoutMode(NetEqModes mode);
123 WebRtc_Word32 GetNetEQPlayoutMode(NetEqModes& mode);
niklase@google.com470e71d2011-07-07 08:21:25 +0000124 WebRtc_Word32 SetOnHoldStatus(bool enable, OnHoldModes mode);
125 WebRtc_Word32 GetOnHoldStatus(bool& enabled, OnHoldModes& mode);
126 WebRtc_Word32 RegisterVoiceEngineObserver(VoiceEngineObserver& observer);
127 WebRtc_Word32 DeRegisterVoiceEngineObserver();
128
129 // VoECodec
130 WebRtc_Word32 GetSendCodec(CodecInst& codec);
131 WebRtc_Word32 GetRecCodec(CodecInst& codec);
132 WebRtc_Word32 SetSendCodec(const CodecInst& codec);
133 WebRtc_Word32 SetVADStatus(bool enableVAD, ACMVADMode mode,
134 bool disableDTX);
135 WebRtc_Word32 GetVADStatus(bool& enabledVAD, ACMVADMode& mode,
136 bool& disabledDTX);
137 WebRtc_Word32 SetRecPayloadType(const CodecInst& codec);
138 WebRtc_Word32 GetRecPayloadType(CodecInst& codec);
139 WebRtc_Word32 SetAMREncFormat(AmrMode mode);
140 WebRtc_Word32 SetAMRDecFormat(AmrMode mode);
141 WebRtc_Word32 SetAMRWbEncFormat(AmrMode mode);
142 WebRtc_Word32 SetAMRWbDecFormat(AmrMode mode);
143 WebRtc_Word32 SetSendCNPayloadType(int type, PayloadFrequencies frequency);
144 WebRtc_Word32 SetISACInitTargetRate(int rateBps, bool useFixedFrameSize);
145 WebRtc_Word32 SetISACMaxRate(int rateBps);
146 WebRtc_Word32 SetISACMaxPayloadSize(int sizeBytes);
147
turaj@webrtc.org42259e72012-12-11 02:15:12 +0000148 // VoE dual-streaming.
149 int SetSecondarySendCodec(const CodecInst& codec, int red_payload_type);
150 void RemoveSecondarySendCodec();
151 int GetSecondarySendCodec(CodecInst* codec);
152
niklase@google.com470e71d2011-07-07 08:21:25 +0000153 // VoENetwork
154 WebRtc_Word32 RegisterExternalTransport(Transport& transport);
155 WebRtc_Word32 DeRegisterExternalTransport();
156 WebRtc_Word32 ReceivedRTPPacket(const WebRtc_Word8* data,
157 WebRtc_Word32 length);
158 WebRtc_Word32 ReceivedRTCPPacket(const WebRtc_Word8* data,
159 WebRtc_Word32 length);
160#ifndef WEBRTC_EXTERNAL_TRANSPORT
161 WebRtc_Word32 GetSourceInfo(int& rtpPort, int& rtcpPort, char ipAddr[64]);
162 WebRtc_Word32 EnableIPv6();
163 bool IPv6IsEnabled() const;
164 WebRtc_Word32 SetSourceFilter(int rtpPort, int rtcpPort,
165 const char ipAddr[64]);
166 WebRtc_Word32 GetSourceFilter(int& rtpPort, int& rtcpPort, char ipAddr[64]);
167 WebRtc_Word32 SetSendTOS(int DSCP, int priority, bool useSetSockopt);
168 WebRtc_Word32 GetSendTOS(int &DSCP, int& priority, bool &useSetSockopt);
169#if defined(_WIN32)
170 WebRtc_Word32 SetSendGQoS(bool enable, int serviceType, int overrideDSCP);
171 WebRtc_Word32 GetSendGQoS(bool &enabled, int &serviceType,
172 int &overrideDSCP);
173#endif
174#endif
175 WebRtc_Word32 SetPacketTimeoutNotification(bool enable, int timeoutSeconds);
176 WebRtc_Word32 GetPacketTimeoutNotification(bool& enabled,
177 int& timeoutSeconds);
178 WebRtc_Word32 RegisterDeadOrAliveObserver(VoEConnectionObserver& observer);
179 WebRtc_Word32 DeRegisterDeadOrAliveObserver();
180 WebRtc_Word32 SetPeriodicDeadOrAliveStatus(bool enable,
181 int sampleTimeSeconds);
182 WebRtc_Word32 GetPeriodicDeadOrAliveStatus(bool& enabled,
183 int& sampleTimeSeconds);
pwestin@webrtc.org684f0572013-03-13 23:20:57 +0000184 WebRtc_Word32 SendUDPPacket(const void* data, unsigned int length,
185 int& transmittedBytes, bool useRtcpSocket);
186
niklase@google.com470e71d2011-07-07 08:21:25 +0000187 // VoEFile
188 int StartPlayingFileLocally(const char* fileName, const bool loop,
189 const FileFormats format,
190 const int startPosition,
191 const float volumeScaling,
192 const int stopPosition,
193 const CodecInst* codecInst);
194 int StartPlayingFileLocally(InStream* stream, const FileFormats format,
195 const int startPosition,
196 const float volumeScaling,
197 const int stopPosition,
198 const CodecInst* codecInst);
199 int StopPlayingFileLocally();
200 int IsPlayingFileLocally() const;
braveyao@webrtc.orgab129902012-06-04 03:26:39 +0000201 int RegisterFilePlayingToMixer();
niklase@google.com470e71d2011-07-07 08:21:25 +0000202 int ScaleLocalFilePlayout(const float scale);
203 int GetLocalPlayoutPosition(int& positionMs);
204 int StartPlayingFileAsMicrophone(const char* fileName, const bool loop,
205 const FileFormats format,
206 const int startPosition,
207 const float volumeScaling,
208 const int stopPosition,
209 const CodecInst* codecInst);
210 int StartPlayingFileAsMicrophone(InStream* stream,
211 const FileFormats format,
212 const int startPosition,
213 const float volumeScaling,
214 const int stopPosition,
215 const CodecInst* codecInst);
216 int StopPlayingFileAsMicrophone();
217 int IsPlayingFileAsMicrophone() const;
218 int ScaleFileAsMicrophonePlayout(const float scale);
219 int StartRecordingPlayout(const char* fileName, const CodecInst* codecInst);
220 int StartRecordingPlayout(OutStream* stream, const CodecInst* codecInst);
221 int StopRecordingPlayout();
222
223 void SetMixWithMicStatus(bool mix);
224
225 // VoEExternalMediaProcessing
226 int RegisterExternalMediaProcessing(ProcessingTypes type,
227 VoEMediaProcess& processObject);
228 int DeRegisterExternalMediaProcessing(ProcessingTypes type);
roosa@google.com1b60ceb2012-12-12 23:00:29 +0000229 int SetExternalMixing(bool enabled);
niklase@google.com470e71d2011-07-07 08:21:25 +0000230
231 // VoEVolumeControl
232 int GetSpeechOutputLevel(WebRtc_UWord32& level) const;
233 int GetSpeechOutputLevelFullRange(WebRtc_UWord32& level) const;
234 int SetMute(const bool enable);
235 bool Mute() const;
236 int SetOutputVolumePan(float left, float right);
237 int GetOutputVolumePan(float& left, float& right) const;
238 int SetChannelOutputVolumeScaling(float scaling);
239 int GetChannelOutputVolumeScaling(float& scaling) const;
240
241 // VoECallReport
242 void ResetDeadOrAliveCounters();
243 int ResetRTCPStatistics();
244 int GetRoundTripTimeSummary(StatVal& delaysMs) const;
245 int GetDeadOrAliveCounters(int& countDead, int& countAlive) const;
246
247 // VoENetEqStats
248 int GetNetworkStatistics(NetworkStatistics& stats);
niklase@google.com470e71d2011-07-07 08:21:25 +0000249
250 // VoEVideoSync
251 int GetDelayEstimate(int& delayMs) const;
turaj@webrtc.org6388c3e2013-02-12 21:42:18 +0000252 int SetInitialPlayoutDelay(int delay_ms);
niklase@google.com470e71d2011-07-07 08:21:25 +0000253 int SetMinimumPlayoutDelay(int delayMs);
254 int GetPlayoutTimestamp(unsigned int& timestamp);
255 int SetInitTimestamp(unsigned int timestamp);
256 int SetInitSequenceNumber(short sequenceNumber);
257
258 // VoEVideoSyncExtended
259 int GetRtpRtcp(RtpRtcp* &rtpRtcpModule) const;
260
261 // VoEEncryption
262#ifdef WEBRTC_SRTP
263 int EnableSRTPSend(
264 CipherTypes cipherType,
265 int cipherKeyLength,
266 AuthenticationTypes authType,
267 int authKeyLength,
268 int authTagLength,
269 SecurityLevels level,
270 const unsigned char key[kVoiceEngineMaxSrtpKeyLength],
271 bool useForRTCP);
272 int DisableSRTPSend();
273 int EnableSRTPReceive(
274 CipherTypes cipherType,
275 int cipherKeyLength,
276 AuthenticationTypes authType,
277 int authKeyLength,
278 int authTagLength,
279 SecurityLevels level,
280 const unsigned char key[kVoiceEngineMaxSrtpKeyLength],
281 bool useForRTCP);
282 int DisableSRTPReceive();
283#endif
284 int RegisterExternalEncryption(Encryption& encryption);
285 int DeRegisterExternalEncryption();
286
287 // VoEDtmf
288 int SendTelephoneEventOutband(unsigned char eventCode, int lengthMs,
289 int attenuationDb, bool playDtmfEvent);
290 int SendTelephoneEventInband(unsigned char eventCode, int lengthMs,
291 int attenuationDb, bool playDtmfEvent);
292 int SetDtmfPlayoutStatus(bool enable);
293 bool DtmfPlayoutStatus() const;
294 int SetSendTelephoneEventPayloadType(unsigned char type);
295 int GetSendTelephoneEventPayloadType(unsigned char& type);
niklase@google.com470e71d2011-07-07 08:21:25 +0000296
297 // VoEAudioProcessingImpl
298 int UpdateRxVadDetection(AudioFrame& audioFrame);
299 int RegisterRxVadObserver(VoERxVadCallback &observer);
300 int DeRegisterRxVadObserver();
301 int VoiceActivityIndicator(int &activity);
302#ifdef WEBRTC_VOICE_ENGINE_AGC
303 int SetRxAgcStatus(const bool enable, const AgcModes mode);
304 int GetRxAgcStatus(bool& enabled, AgcModes& mode);
305 int SetRxAgcConfig(const AgcConfig config);
306 int GetRxAgcConfig(AgcConfig& config);
307#endif
308#ifdef WEBRTC_VOICE_ENGINE_NR
309 int SetRxNsStatus(const bool enable, const NsModes mode);
310 int GetRxNsStatus(bool& enabled, NsModes& mode);
311#endif
312
313 // VoERTP_RTCP
314 int RegisterRTPObserver(VoERTPObserver& observer);
315 int DeRegisterRTPObserver();
316 int RegisterRTCPObserver(VoERTCPObserver& observer);
317 int DeRegisterRTCPObserver();
318 int SetLocalSSRC(unsigned int ssrc);
319 int GetLocalSSRC(unsigned int& ssrc);
320 int GetRemoteSSRC(unsigned int& ssrc);
321 int GetRemoteCSRCs(unsigned int arrCSRC[15]);
322 int SetRTPAudioLevelIndicationStatus(bool enable, unsigned char ID);
323 int GetRTPAudioLevelIndicationStatus(bool& enable, unsigned char& ID);
324 int SetRTCPStatus(bool enable);
325 int GetRTCPStatus(bool& enabled);
326 int SetRTCP_CNAME(const char cName[256]);
327 int GetRTCP_CNAME(char cName[256]);
328 int GetRemoteRTCP_CNAME(char cName[256]);
329 int GetRemoteRTCPData(unsigned int& NTPHigh, unsigned int& NTPLow,
330 unsigned int& timestamp,
331 unsigned int& playoutTimestamp, unsigned int* jitter,
332 unsigned short* fractionLost);
333 int SendApplicationDefinedRTCPPacket(const unsigned char subType,
334 unsigned int name, const char* data,
335 unsigned short dataLengthInBytes);
336 int GetRTPStatistics(unsigned int& averageJitterMs,
337 unsigned int& maxJitterMs,
338 unsigned int& discardedPackets);
henrika@webrtc.org8a2fc882012-08-22 08:53:55 +0000339 int GetRemoteRTCPSenderInfo(SenderInfo* sender_info);
340 int GetRemoteRTCPReportBlocks(std::vector<ReportBlock>* report_blocks);
niklase@google.com470e71d2011-07-07 08:21:25 +0000341 int GetRTPStatistics(CallStatistics& stats);
342 int SetFECStatus(bool enable, int redPayloadtype);
343 int GetFECStatus(bool& enabled, int& redPayloadtype);
niklase@google.com470e71d2011-07-07 08:21:25 +0000344 int StartRTPDump(const char fileNameUTF8[1024], RTPDirections direction);
345 int StopRTPDump(RTPDirections direction);
346 bool RTPDumpIsActive(RTPDirections direction);
347 int InsertExtraRTPPacket(unsigned char payloadType, bool markerBit,
348 const char* payloadData,
349 unsigned short payloadSize);
roosa@google.com0870f022012-12-12 21:31:41 +0000350 uint32_t LastRemoteTimeStamp() { return _lastRemoteTimeStamp; }
niklase@google.com470e71d2011-07-07 08:21:25 +0000351
352public:
353 // From AudioPacketizationCallback in the ACM
354 WebRtc_Word32 SendData(FrameType frameType,
355 WebRtc_UWord8 payloadType,
356 WebRtc_UWord32 timeStamp,
357 const WebRtc_UWord8* payloadData,
358 WebRtc_UWord16 payloadSize,
359 const RTPFragmentationHeader* fragmentation);
360 // From ACMVADCallback in the ACM
361 WebRtc_Word32 InFrameType(WebRtc_Word16 frameType);
362
niklase@google.com470e71d2011-07-07 08:21:25 +0000363public:
364 WebRtc_Word32 OnRxVadDetected(const int vadDecision);
365
366public:
367 // From RtpData in the RTP/RTCP module
368 WebRtc_Word32 OnReceivedPayloadData(const WebRtc_UWord8* payloadData,
369 const WebRtc_UWord16 payloadSize,
370 const WebRtcRTPHeader* rtpHeader);
371
372public:
373 // From RtpFeedback in the RTP/RTCP module
374 WebRtc_Word32 OnInitializeDecoder(
375 const WebRtc_Word32 id,
376 const WebRtc_Word8 payloadType,
leozwang@webrtc.org813e4b02012-03-01 18:34:25 +0000377 const char payloadName[RTP_PAYLOAD_NAME_SIZE],
xians@google.com0b0665a2011-08-08 08:18:44 +0000378 const int frequency,
niklase@google.com470e71d2011-07-07 08:21:25 +0000379 const WebRtc_UWord8 channels,
380 const WebRtc_UWord32 rate);
381
382 void OnPacketTimeout(const WebRtc_Word32 id);
383
384 void OnReceivedPacket(const WebRtc_Word32 id,
385 const RtpRtcpPacketType packetType);
386
387 void OnPeriodicDeadOrAlive(const WebRtc_Word32 id,
388 const RTPAliveType alive);
389
390 void OnIncomingSSRCChanged(const WebRtc_Word32 id,
391 const WebRtc_UWord32 SSRC);
392
393 void OnIncomingCSRCChanged(const WebRtc_Word32 id,
394 const WebRtc_UWord32 CSRC, const bool added);
395
396public:
397 // From RtcpFeedback in the RTP/RTCP module
niklase@google.com470e71d2011-07-07 08:21:25 +0000398 void OnApplicationDataReceived(const WebRtc_Word32 id,
399 const WebRtc_UWord8 subType,
400 const WebRtc_UWord32 name,
401 const WebRtc_UWord16 length,
402 const WebRtc_UWord8* data);
403
niklase@google.com470e71d2011-07-07 08:21:25 +0000404public:
405 // From RtpAudioFeedback in the RTP/RTCP module
406 void OnReceivedTelephoneEvent(const WebRtc_Word32 id,
407 const WebRtc_UWord8 event,
408 const bool endOfEvent);
409
410 void OnPlayTelephoneEvent(const WebRtc_Word32 id,
411 const WebRtc_UWord8 event,
412 const WebRtc_UWord16 lengthMs,
413 const WebRtc_UWord8 volume);
414
415public:
pwestin@webrtc.org684f0572013-03-13 23:20:57 +0000416 // From UdpTransportData in the Socket Transport module
417 void IncomingRTPPacket(const WebRtc_Word8* incomingRtpPacket,
418 const WebRtc_Word32 rtpPacketLength,
419 const char* fromIP,
420 const WebRtc_UWord16 fromPort);
421
422 void IncomingRTCPPacket(const WebRtc_Word8* incomingRtcpPacket,
423 const WebRtc_Word32 rtcpPacketLength,
424 const char* fromIP,
425 const WebRtc_UWord16 fromPort);
426
427public:
niklase@google.com470e71d2011-07-07 08:21:25 +0000428 // From Transport (called by the RTP/RTCP module)
429 int SendPacket(int /*channel*/, const void *data, int len);
430 int SendRTCPPacket(int /*channel*/, const void *data, int len);
431
432public:
433 // From MixerParticipant
434 WebRtc_Word32 GetAudioFrame(const WebRtc_Word32 id,
435 AudioFrame& audioFrame);
436 WebRtc_Word32 NeededFrequency(const WebRtc_Word32 id);
437
438public:
439 // From MonitorObserver
440 void OnPeriodicProcess();
441
442public:
443 // From FileCallback
444 void PlayNotification(const WebRtc_Word32 id,
445 const WebRtc_UWord32 durationMs);
446 void RecordNotification(const WebRtc_Word32 id,
447 const WebRtc_UWord32 durationMs);
448 void PlayFileEnded(const WebRtc_Word32 id);
449 void RecordFileEnded(const WebRtc_Word32 id);
450
451public:
452 WebRtc_UWord32 InstanceId() const
453 {
454 return _instanceId;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000455 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000456 WebRtc_Word32 ChannelId() const
457 {
458 return _channelId;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000459 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000460 bool Playing() const
461 {
462 return _playing;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000463 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000464 bool Sending() const
465 {
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000466 // A lock is needed because |_sending| is accessed by both
467 // TransmitMixer::PrepareDemux() and StartSend()/StopSend(), which
468 // are called by different threads.
mflodman@webrtc.org9a065d12012-03-07 08:12:21 +0000469 CriticalSectionScoped cs(&_callbackCritSect);
niklase@google.com470e71d2011-07-07 08:21:25 +0000470 return _sending;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000471 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000472 bool Receiving() const
473 {
474 return _receiving;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000475 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000476 bool ExternalTransport() const
477 {
478 return _externalTransport;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000479 }
roosa@google.com1b60ceb2012-12-12 23:00:29 +0000480 bool ExternalMixing() const
481 {
482 return _externalMixing;
483 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000484 bool OutputIsOnHold() const
485 {
486 return _outputIsOnHold;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000487 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000488 bool InputIsOnHold() const
489 {
490 return _inputIsOnHold;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000491 }
andrew@webrtc.orgf81f9f82011-08-19 22:56:22 +0000492 RtpRtcp* RtpRtcpModulePtr() const
niklase@google.com470e71d2011-07-07 08:21:25 +0000493 {
pwestin@webrtc.org2853dde2012-05-11 11:08:54 +0000494 return _rtpRtcpModule.get();
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000495 }
andrew@webrtc.orgf81f9f82011-08-19 22:56:22 +0000496 WebRtc_Word8 OutputEnergyLevel() const
niklase@google.com470e71d2011-07-07 08:21:25 +0000497 {
498 return _outputAudioLevel.Level();
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000499 }
pwestin@webrtc.org684f0572013-03-13 23:20:57 +0000500#ifndef WEBRTC_EXTERNAL_TRANSPORT
501 bool SendSocketsInitialized() const
502 {
503 return _socketTransportModule.SendSocketsInitialized();
504 }
505 bool ReceiveSocketsInitialized() const
506 {
507 return _socketTransportModule.ReceiveSocketsInitialized();
508 }
509#endif
andrew@webrtc.org755b04a2011-11-15 16:57:56 +0000510 WebRtc_UWord32 Demultiplex(const AudioFrame& audioFrame);
xians@google.com0b0665a2011-08-08 08:18:44 +0000511 WebRtc_UWord32 PrepareEncodeAndSend(int mixingFrequency);
niklase@google.com470e71d2011-07-07 08:21:25 +0000512 WebRtc_UWord32 EncodeAndSend();
513
514private:
515 int InsertInbandDtmfTone();
516 WebRtc_Word32
xians@google.com0b0665a2011-08-08 08:18:44 +0000517 MixOrReplaceAudioWithFile(const int mixingFrequency);
niklase@google.com470e71d2011-07-07 08:21:25 +0000518 WebRtc_Word32 MixAudioWithFile(AudioFrame& audioFrame,
xians@google.com0b0665a2011-08-08 08:18:44 +0000519 const int mixingFrequency);
niklase@google.com470e71d2011-07-07 08:21:25 +0000520 WebRtc_Word32 GetPlayoutTimeStamp(WebRtc_UWord32& playoutTimestamp);
521 void UpdateDeadOrAliveCounters(bool alive);
522 WebRtc_Word32 SendPacketRaw(const void *data, int len, bool RTCP);
523 WebRtc_Word32 UpdatePacketDelay(const WebRtc_UWord32 timestamp,
524 const WebRtc_UWord16 sequenceNumber);
525 void RegisterReceiveCodecsToRTPModule();
526 int ApmProcessRx(AudioFrame& audioFrame);
527
turaj@webrtc.org42259e72012-12-11 02:15:12 +0000528 int SetRedPayloadType(int red_payload_type);
niklase@google.com470e71d2011-07-07 08:21:25 +0000529private:
530 CriticalSectionWrapper& _fileCritSect;
531 CriticalSectionWrapper& _callbackCritSect;
niklase@google.com470e71d2011-07-07 08:21:25 +0000532 WebRtc_UWord32 _instanceId;
533 WebRtc_Word32 _channelId;
534
535private:
pwestin@webrtc.org2853dde2012-05-11 11:08:54 +0000536 scoped_ptr<RtpRtcp> _rtpRtcpModule;
niklase@google.com470e71d2011-07-07 08:21:25 +0000537 AudioCodingModule& _audioCodingModule;
pwestin@webrtc.org684f0572013-03-13 23:20:57 +0000538#ifndef WEBRTC_EXTERNAL_TRANSPORT
539 WebRtc_UWord8 _numSocketThreads;
540 UdpTransport& _socketTransportModule;
541#endif
niklase@google.com470e71d2011-07-07 08:21:25 +0000542#ifdef WEBRTC_SRTP
543 SrtpModule& _srtpModule;
544#endif
545 RtpDump& _rtpDumpIn;
546 RtpDump& _rtpDumpOut;
547private:
548 AudioLevel _outputAudioLevel;
549 bool _externalTransport;
550 AudioFrame _audioFrame;
551 WebRtc_UWord8 _audioLevel_dBov;
552 FilePlayer* _inputFilePlayerPtr;
553 FilePlayer* _outputFilePlayerPtr;
554 FileRecorder* _outputFileRecorderPtr;
xians@google.com0b0665a2011-08-08 08:18:44 +0000555 int _inputFilePlayerId;
556 int _outputFilePlayerId;
557 int _outputFileRecorderId;
niklase@google.com470e71d2011-07-07 08:21:25 +0000558 bool _inputFilePlaying;
559 bool _outputFilePlaying;
560 bool _outputFileRecording;
561 DtmfInbandQueue _inbandDtmfQueue;
562 DtmfInband _inbandDtmfGenerator;
niklase@google.com470e71d2011-07-07 08:21:25 +0000563 bool _inputExternalMedia;
xians@google.com22963ab2011-08-03 12:40:23 +0000564 bool _outputExternalMedia;
niklase@google.com470e71d2011-07-07 08:21:25 +0000565 VoEMediaProcess* _inputExternalMediaCallbackPtr;
566 VoEMediaProcess* _outputExternalMediaCallbackPtr;
567 WebRtc_UWord8* _encryptionRTPBufferPtr;
568 WebRtc_UWord8* _decryptionRTPBufferPtr;
569 WebRtc_UWord8* _encryptionRTCPBufferPtr;
570 WebRtc_UWord8* _decryptionRTCPBufferPtr;
571 WebRtc_UWord32 _timeStamp;
572 WebRtc_UWord8 _sendTelephoneEventPayloadType;
573 WebRtc_UWord32 _playoutTimeStampRTP;
574 WebRtc_UWord32 _playoutTimeStampRTCP;
575 WebRtc_UWord32 _numberOfDiscardedPackets;
576private:
577 // uses
578 Statistics* _engineStatisticsPtr;
579 OutputMixer* _outputMixerPtr;
580 TransmitMixer* _transmitMixerPtr;
581 ProcessThread* _moduleProcessThreadPtr;
582 AudioDeviceModule* _audioDeviceModulePtr;
583 VoiceEngineObserver* _voiceEngineObserverPtr; // owned by base
584 CriticalSectionWrapper* _callbackCritSectPtr; // owned by base
585 Transport* _transportPtr; // WebRtc socket or external transport
586 Encryption* _encryptionPtr; // WebRtc SRTP or external encryption
andrew@webrtc.org755b04a2011-11-15 16:57:56 +0000587 scoped_ptr<AudioProcessing> _rtpAudioProc;
niklase@google.com470e71d2011-07-07 08:21:25 +0000588 AudioProcessing* _rxAudioProcessingModulePtr; // far end AudioProcessing
niklase@google.com470e71d2011-07-07 08:21:25 +0000589 VoERxVadCallback* _rxVadObserverPtr;
590 WebRtc_Word32 _oldVadDecision;
591 WebRtc_Word32 _sendFrameType; // Send data is voice, 1-voice, 0-otherwise
592 VoERTPObserver* _rtpObserverPtr;
593 VoERTCPObserver* _rtcpObserverPtr;
594private:
595 // VoEBase
596 bool _outputIsOnHold;
597 bool _externalPlayout;
roosa@google.com1b60ceb2012-12-12 23:00:29 +0000598 bool _externalMixing;
niklase@google.com470e71d2011-07-07 08:21:25 +0000599 bool _inputIsOnHold;
600 bool _playing;
601 bool _sending;
602 bool _receiving;
603 bool _mixFileWithMicrophone;
604 bool _rtpObserver;
605 bool _rtcpObserver;
606 // VoEVolumeControl
607 bool _mute;
608 float _panLeft;
609 float _panRight;
610 float _outputGain;
611 // VoEEncryption
612 bool _encrypting;
613 bool _decrypting;
614 // VoEDtmf
615 bool _playOutbandDtmfEvent;
616 bool _playInbandDtmfEvent;
niklase@google.com470e71d2011-07-07 08:21:25 +0000617 // VoeRTP_RTCP
618 WebRtc_UWord8 _extraPayloadType;
619 bool _insertExtraRTPPacket;
620 bool _extraMarkerBit;
621 WebRtc_UWord32 _lastLocalTimeStamp;
roosa@google.com0870f022012-12-12 21:31:41 +0000622 uint32_t _lastRemoteTimeStamp;
niklase@google.com470e71d2011-07-07 08:21:25 +0000623 WebRtc_Word8 _lastPayloadType;
624 bool _includeAudioLevelIndication;
625 // VoENetwork
626 bool _rtpPacketTimedOut;
627 bool _rtpPacketTimeOutIsEnabled;
628 WebRtc_UWord32 _rtpTimeOutSeconds;
629 bool _connectionObserver;
630 VoEConnectionObserver* _connectionObserverPtr;
631 WebRtc_UWord32 _countAliveDetections;
632 WebRtc_UWord32 _countDeadDetections;
633 AudioFrame::SpeechType _outputSpeechType;
634 // VoEVideoSync
635 WebRtc_UWord32 _averageDelayMs;
636 WebRtc_UWord16 _previousSequenceNumber;
637 WebRtc_UWord32 _previousTimestamp;
638 WebRtc_UWord16 _recPacketDelayMs;
639 // VoEAudioProcessing
640 bool _RxVadDetection;
641 bool _rxApmIsEnabled;
642 bool _rxAgcIsEnabled;
643 bool _rxNsIsEnabled;
644};
645
646} // namespace voe
647
648} // namespace webrtc
649
650#endif // WEBRTC_VOICE_ENGINE_CHANNEL_H