blob: f4307644fef199411eb14dd3176d26ba80ac138b [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"
stefan@webrtc.orga5cb98c2013-05-29 12:12:51 +000018#include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h"
turaj@webrtc.org6388c3e2013-02-12 21:42:18 +000019#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h"
20#include "webrtc/modules/utility/interface/file_player.h"
21#include "webrtc/modules/utility/interface/file_recorder.h"
22#include "webrtc/system_wrappers/interface/scoped_ptr.h"
23#include "webrtc/voice_engine/dtmf_inband.h"
24#include "webrtc/voice_engine/dtmf_inband_queue.h"
25#include "webrtc/voice_engine/include/voe_audio_processing.h"
26#include "webrtc/voice_engine/include/voe_network.h"
27#include "webrtc/voice_engine/level_indicator.h"
28#include "webrtc/voice_engine/shared_data.h"
29#include "webrtc/voice_engine/voice_engine_defines.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000030
niklase@google.com470e71d2011-07-07 08:21:25 +000031#ifdef WEBRTC_DTMF_DETECTION
pbos@webrtc.org956aa7e2013-05-21 13:52:32 +000032// TelephoneEventDetectionMethods, TelephoneEventObserver
33#include "webrtc/voice_engine/include/voe_dtmf.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000034#endif
35
36namespace webrtc
37{
38class CriticalSectionWrapper;
39class ProcessThread;
40class AudioDeviceModule;
41class RtpRtcp;
42class FileWrapper;
43class RtpDump;
44class VoiceEngineObserver;
45class VoEMediaProcess;
46class VoERTPObserver;
47class VoERTCPObserver;
48
49struct CallStatistics;
henrika@webrtc.org8a2fc882012-08-22 08:53:55 +000050struct ReportBlock;
51struct SenderInfo;
niklase@google.com470e71d2011-07-07 08:21:25 +000052
53namespace voe
54{
55class Statistics;
56class TransmitMixer;
57class OutputMixer;
58
59
60class Channel:
61 public RtpData,
62 public RtpFeedback,
63 public RtcpFeedback,
niklase@google.com470e71d2011-07-07 08:21:25 +000064 public FileCallback, // receiving notification from file player & recorder
65 public Transport,
66 public RtpAudioFeedback,
67 public AudioPacketizationCallback, // receive encoded packets from the ACM
68 public ACMVADCallback, // receive voice activity from the ACM
niklase@google.com470e71d2011-07-07 08:21:25 +000069 public MixerParticipant // supplies output mixer with audio frames
70{
71public:
72 enum {KNumSocketThreads = 1};
73 enum {KNumberOfSocketBuffers = 8};
niklase@google.com470e71d2011-07-07 08:21:25 +000074public:
75 virtual ~Channel();
pbos@webrtc.org6141e132013-04-09 10:09:10 +000076 static int32_t CreateChannel(Channel*& channel,
pbos@webrtc.org92135212013-05-14 08:31:39 +000077 int32_t channelId,
78 uint32_t instanceId);
79 Channel(int32_t channelId, uint32_t instanceId);
pbos@webrtc.org6141e132013-04-09 10:09:10 +000080 int32_t Init();
81 int32_t SetEngineInformation(
niklase@google.com470e71d2011-07-07 08:21:25 +000082 Statistics& engineStatistics,
83 OutputMixer& outputMixer,
84 TransmitMixer& transmitMixer,
85 ProcessThread& moduleProcessThread,
86 AudioDeviceModule& audioDeviceModule,
87 VoiceEngineObserver* voiceEngineObserver,
88 CriticalSectionWrapper* callbackCritSect);
pbos@webrtc.org6141e132013-04-09 10:09:10 +000089 int32_t UpdateLocalTimeStamp();
niklase@google.com470e71d2011-07-07 08:21:25 +000090
91public:
92 // API methods
93
94 // VoEBase
pbos@webrtc.org6141e132013-04-09 10:09:10 +000095 int32_t StartPlayout();
96 int32_t StopPlayout();
97 int32_t StartSend();
98 int32_t StopSend();
99 int32_t StartReceiving();
100 int32_t StopReceiving();
niklase@google.com470e71d2011-07-07 08:21:25 +0000101
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000102 int32_t SetNetEQPlayoutMode(NetEqModes mode);
103 int32_t GetNetEQPlayoutMode(NetEqModes& mode);
104 int32_t SetOnHoldStatus(bool enable, OnHoldModes mode);
105 int32_t GetOnHoldStatus(bool& enabled, OnHoldModes& mode);
106 int32_t RegisterVoiceEngineObserver(VoiceEngineObserver& observer);
107 int32_t DeRegisterVoiceEngineObserver();
niklase@google.com470e71d2011-07-07 08:21:25 +0000108
109 // VoECodec
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000110 int32_t GetSendCodec(CodecInst& codec);
111 int32_t GetRecCodec(CodecInst& codec);
112 int32_t SetSendCodec(const CodecInst& codec);
113 int32_t SetVADStatus(bool enableVAD, ACMVADMode mode, bool disableDTX);
114 int32_t GetVADStatus(bool& enabledVAD, ACMVADMode& mode, bool& disabledDTX);
115 int32_t SetRecPayloadType(const CodecInst& codec);
116 int32_t GetRecPayloadType(CodecInst& codec);
117 int32_t SetAMREncFormat(AmrMode mode);
118 int32_t SetAMRDecFormat(AmrMode mode);
119 int32_t SetAMRWbEncFormat(AmrMode mode);
120 int32_t SetAMRWbDecFormat(AmrMode mode);
121 int32_t SetSendCNPayloadType(int type, PayloadFrequencies frequency);
122 int32_t SetISACInitTargetRate(int rateBps, bool useFixedFrameSize);
123 int32_t SetISACMaxRate(int rateBps);
124 int32_t SetISACMaxPayloadSize(int sizeBytes);
niklase@google.com470e71d2011-07-07 08:21:25 +0000125
turaj@webrtc.org42259e72012-12-11 02:15:12 +0000126 // VoE dual-streaming.
127 int SetSecondarySendCodec(const CodecInst& codec, int red_payload_type);
128 void RemoveSecondarySendCodec();
129 int GetSecondarySendCodec(CodecInst* codec);
130
niklase@google.com470e71d2011-07-07 08:21:25 +0000131 // VoENetwork
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000132 int32_t RegisterExternalTransport(Transport& transport);
133 int32_t DeRegisterExternalTransport();
134 int32_t ReceivedRTPPacket(const int8_t* data, int32_t length);
135 int32_t ReceivedRTCPPacket(const int8_t* data, int32_t length);
136 int32_t SetPacketTimeoutNotification(bool enable, int timeoutSeconds);
137 int32_t GetPacketTimeoutNotification(bool& enabled, int& timeoutSeconds);
138 int32_t RegisterDeadOrAliveObserver(VoEConnectionObserver& observer);
139 int32_t DeRegisterDeadOrAliveObserver();
140 int32_t SetPeriodicDeadOrAliveStatus(bool enable, int sampleTimeSeconds);
141 int32_t GetPeriodicDeadOrAliveStatus(bool& enabled, int& sampleTimeSeconds);
pwestin@webrtc.org684f0572013-03-13 23:20:57 +0000142
niklase@google.com470e71d2011-07-07 08:21:25 +0000143 // VoEFile
pbos@webrtc.org92135212013-05-14 08:31:39 +0000144 int StartPlayingFileLocally(const char* fileName, bool loop,
145 FileFormats format,
146 int startPosition,
147 float volumeScaling,
148 int stopPosition,
niklase@google.com470e71d2011-07-07 08:21:25 +0000149 const CodecInst* codecInst);
pbos@webrtc.org92135212013-05-14 08:31:39 +0000150 int StartPlayingFileLocally(InStream* stream, FileFormats format,
151 int startPosition,
152 float volumeScaling,
153 int stopPosition,
niklase@google.com470e71d2011-07-07 08:21:25 +0000154 const CodecInst* codecInst);
155 int StopPlayingFileLocally();
156 int IsPlayingFileLocally() const;
braveyao@webrtc.orgab129902012-06-04 03:26:39 +0000157 int RegisterFilePlayingToMixer();
pbos@webrtc.org92135212013-05-14 08:31:39 +0000158 int ScaleLocalFilePlayout(float scale);
niklase@google.com470e71d2011-07-07 08:21:25 +0000159 int GetLocalPlayoutPosition(int& positionMs);
pbos@webrtc.org92135212013-05-14 08:31:39 +0000160 int StartPlayingFileAsMicrophone(const char* fileName, bool loop,
161 FileFormats format,
162 int startPosition,
163 float volumeScaling,
164 int stopPosition,
niklase@google.com470e71d2011-07-07 08:21:25 +0000165 const CodecInst* codecInst);
166 int StartPlayingFileAsMicrophone(InStream* stream,
pbos@webrtc.org92135212013-05-14 08:31:39 +0000167 FileFormats format,
168 int startPosition,
169 float volumeScaling,
170 int stopPosition,
niklase@google.com470e71d2011-07-07 08:21:25 +0000171 const CodecInst* codecInst);
172 int StopPlayingFileAsMicrophone();
173 int IsPlayingFileAsMicrophone() const;
pbos@webrtc.org92135212013-05-14 08:31:39 +0000174 int ScaleFileAsMicrophonePlayout(float scale);
niklase@google.com470e71d2011-07-07 08:21:25 +0000175 int StartRecordingPlayout(const char* fileName, const CodecInst* codecInst);
176 int StartRecordingPlayout(OutStream* stream, const CodecInst* codecInst);
177 int StopRecordingPlayout();
178
179 void SetMixWithMicStatus(bool mix);
180
181 // VoEExternalMediaProcessing
182 int RegisterExternalMediaProcessing(ProcessingTypes type,
183 VoEMediaProcess& processObject);
184 int DeRegisterExternalMediaProcessing(ProcessingTypes type);
roosa@google.com1b60ceb2012-12-12 23:00:29 +0000185 int SetExternalMixing(bool enabled);
niklase@google.com470e71d2011-07-07 08:21:25 +0000186
187 // VoEVolumeControl
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000188 int GetSpeechOutputLevel(uint32_t& level) const;
189 int GetSpeechOutputLevelFullRange(uint32_t& level) const;
pbos@webrtc.org92135212013-05-14 08:31:39 +0000190 int SetMute(bool enable);
niklase@google.com470e71d2011-07-07 08:21:25 +0000191 bool Mute() const;
192 int SetOutputVolumePan(float left, float right);
193 int GetOutputVolumePan(float& left, float& right) const;
194 int SetChannelOutputVolumeScaling(float scaling);
195 int GetChannelOutputVolumeScaling(float& scaling) const;
196
197 // VoECallReport
198 void ResetDeadOrAliveCounters();
199 int ResetRTCPStatistics();
200 int GetRoundTripTimeSummary(StatVal& delaysMs) const;
201 int GetDeadOrAliveCounters(int& countDead, int& countAlive) const;
202
203 // VoENetEqStats
204 int GetNetworkStatistics(NetworkStatistics& stats);
niklase@google.com470e71d2011-07-07 08:21:25 +0000205
206 // VoEVideoSync
pwestin@webrtc.org1de01352013-04-11 20:23:35 +0000207 bool GetDelayEstimate(int* jitter_buffer_delay_ms,
208 int* playout_buffer_delay_ms) const;
turaj@webrtc.orge46c8d32013-05-22 20:39:43 +0000209 int least_required_delay_ms() const { return least_required_delay_ms_; }
turaj@webrtc.org6388c3e2013-02-12 21:42:18 +0000210 int SetInitialPlayoutDelay(int delay_ms);
niklase@google.com470e71d2011-07-07 08:21:25 +0000211 int SetMinimumPlayoutDelay(int delayMs);
212 int GetPlayoutTimestamp(unsigned int& timestamp);
pwestin@webrtc.org1de01352013-04-11 20:23:35 +0000213 void UpdatePlayoutTimestamp(bool rtcp);
niklase@google.com470e71d2011-07-07 08:21:25 +0000214 int SetInitTimestamp(unsigned int timestamp);
215 int SetInitSequenceNumber(short sequenceNumber);
216
217 // VoEVideoSyncExtended
218 int GetRtpRtcp(RtpRtcp* &rtpRtcpModule) const;
219
220 // VoEEncryption
niklase@google.com470e71d2011-07-07 08:21:25 +0000221 int RegisterExternalEncryption(Encryption& encryption);
222 int DeRegisterExternalEncryption();
223
224 // VoEDtmf
225 int SendTelephoneEventOutband(unsigned char eventCode, int lengthMs,
226 int attenuationDb, bool playDtmfEvent);
227 int SendTelephoneEventInband(unsigned char eventCode, int lengthMs,
228 int attenuationDb, bool playDtmfEvent);
229 int SetDtmfPlayoutStatus(bool enable);
230 bool DtmfPlayoutStatus() const;
231 int SetSendTelephoneEventPayloadType(unsigned char type);
232 int GetSendTelephoneEventPayloadType(unsigned char& type);
niklase@google.com470e71d2011-07-07 08:21:25 +0000233
234 // VoEAudioProcessingImpl
235 int UpdateRxVadDetection(AudioFrame& audioFrame);
236 int RegisterRxVadObserver(VoERxVadCallback &observer);
237 int DeRegisterRxVadObserver();
238 int VoiceActivityIndicator(int &activity);
239#ifdef WEBRTC_VOICE_ENGINE_AGC
pbos@webrtc.org92135212013-05-14 08:31:39 +0000240 int SetRxAgcStatus(bool enable, AgcModes mode);
niklase@google.com470e71d2011-07-07 08:21:25 +0000241 int GetRxAgcStatus(bool& enabled, AgcModes& mode);
pbos@webrtc.org92135212013-05-14 08:31:39 +0000242 int SetRxAgcConfig(AgcConfig config);
niklase@google.com470e71d2011-07-07 08:21:25 +0000243 int GetRxAgcConfig(AgcConfig& config);
244#endif
245#ifdef WEBRTC_VOICE_ENGINE_NR
pbos@webrtc.org92135212013-05-14 08:31:39 +0000246 int SetRxNsStatus(bool enable, NsModes mode);
niklase@google.com470e71d2011-07-07 08:21:25 +0000247 int GetRxNsStatus(bool& enabled, NsModes& mode);
248#endif
249
250 // VoERTP_RTCP
251 int RegisterRTPObserver(VoERTPObserver& observer);
252 int DeRegisterRTPObserver();
253 int RegisterRTCPObserver(VoERTCPObserver& observer);
254 int DeRegisterRTCPObserver();
255 int SetLocalSSRC(unsigned int ssrc);
256 int GetLocalSSRC(unsigned int& ssrc);
257 int GetRemoteSSRC(unsigned int& ssrc);
258 int GetRemoteCSRCs(unsigned int arrCSRC[15]);
259 int SetRTPAudioLevelIndicationStatus(bool enable, unsigned char ID);
260 int GetRTPAudioLevelIndicationStatus(bool& enable, unsigned char& ID);
261 int SetRTCPStatus(bool enable);
262 int GetRTCPStatus(bool& enabled);
263 int SetRTCP_CNAME(const char cName[256]);
264 int GetRTCP_CNAME(char cName[256]);
265 int GetRemoteRTCP_CNAME(char cName[256]);
266 int GetRemoteRTCPData(unsigned int& NTPHigh, unsigned int& NTPLow,
267 unsigned int& timestamp,
268 unsigned int& playoutTimestamp, unsigned int* jitter,
269 unsigned short* fractionLost);
pbos@webrtc.org92135212013-05-14 08:31:39 +0000270 int SendApplicationDefinedRTCPPacket(unsigned char subType,
niklase@google.com470e71d2011-07-07 08:21:25 +0000271 unsigned int name, const char* data,
272 unsigned short dataLengthInBytes);
273 int GetRTPStatistics(unsigned int& averageJitterMs,
274 unsigned int& maxJitterMs,
275 unsigned int& discardedPackets);
henrika@webrtc.org8a2fc882012-08-22 08:53:55 +0000276 int GetRemoteRTCPSenderInfo(SenderInfo* sender_info);
277 int GetRemoteRTCPReportBlocks(std::vector<ReportBlock>* report_blocks);
niklase@google.com470e71d2011-07-07 08:21:25 +0000278 int GetRTPStatistics(CallStatistics& stats);
279 int SetFECStatus(bool enable, int redPayloadtype);
280 int GetFECStatus(bool& enabled, int& redPayloadtype);
niklase@google.com470e71d2011-07-07 08:21:25 +0000281 int StartRTPDump(const char fileNameUTF8[1024], RTPDirections direction);
282 int StopRTPDump(RTPDirections direction);
283 bool RTPDumpIsActive(RTPDirections direction);
284 int InsertExtraRTPPacket(unsigned char payloadType, bool markerBit,
285 const char* payloadData,
286 unsigned short payloadSize);
roosa@google.com0870f022012-12-12 21:31:41 +0000287 uint32_t LastRemoteTimeStamp() { return _lastRemoteTimeStamp; }
niklase@google.com470e71d2011-07-07 08:21:25 +0000288
289public:
290 // From AudioPacketizationCallback in the ACM
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000291 int32_t SendData(FrameType frameType,
292 uint8_t payloadType,
293 uint32_t timeStamp,
294 const uint8_t* payloadData,
295 uint16_t payloadSize,
296 const RTPFragmentationHeader* fragmentation);
niklase@google.com470e71d2011-07-07 08:21:25 +0000297 // From ACMVADCallback in the ACM
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000298 int32_t InFrameType(int16_t frameType);
niklase@google.com470e71d2011-07-07 08:21:25 +0000299
niklase@google.com470e71d2011-07-07 08:21:25 +0000300public:
pbos@webrtc.org92135212013-05-14 08:31:39 +0000301 int32_t OnRxVadDetected(int vadDecision);
niklase@google.com470e71d2011-07-07 08:21:25 +0000302
303public:
304 // From RtpData in the RTP/RTCP module
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000305 int32_t OnReceivedPayloadData(const uint8_t* payloadData,
pbos@webrtc.org92135212013-05-14 08:31:39 +0000306 uint16_t payloadSize,
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000307 const WebRtcRTPHeader* rtpHeader);
niklase@google.com470e71d2011-07-07 08:21:25 +0000308
309public:
310 // From RtpFeedback in the RTP/RTCP module
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000311 int32_t OnInitializeDecoder(
pbos@webrtc.org92135212013-05-14 08:31:39 +0000312 int32_t id,
313 int8_t payloadType,
leozwang@webrtc.org813e4b02012-03-01 18:34:25 +0000314 const char payloadName[RTP_PAYLOAD_NAME_SIZE],
pbos@webrtc.org92135212013-05-14 08:31:39 +0000315 int frequency,
316 uint8_t channels,
317 uint32_t rate);
niklase@google.com470e71d2011-07-07 08:21:25 +0000318
pbos@webrtc.org92135212013-05-14 08:31:39 +0000319 void OnPacketTimeout(int32_t id);
niklase@google.com470e71d2011-07-07 08:21:25 +0000320
pbos@webrtc.org92135212013-05-14 08:31:39 +0000321 void OnReceivedPacket(int32_t id, RtpRtcpPacketType packetType);
niklase@google.com470e71d2011-07-07 08:21:25 +0000322
pbos@webrtc.org92135212013-05-14 08:31:39 +0000323 void OnPeriodicDeadOrAlive(int32_t id,
324 RTPAliveType alive);
niklase@google.com470e71d2011-07-07 08:21:25 +0000325
pbos@webrtc.org92135212013-05-14 08:31:39 +0000326 void OnIncomingSSRCChanged(int32_t id,
327 uint32_t SSRC);
niklase@google.com470e71d2011-07-07 08:21:25 +0000328
pbos@webrtc.org92135212013-05-14 08:31:39 +0000329 void OnIncomingCSRCChanged(int32_t id,
330 uint32_t CSRC, bool added);
niklase@google.com470e71d2011-07-07 08:21:25 +0000331
332public:
333 // From RtcpFeedback in the RTP/RTCP module
pbos@webrtc.org92135212013-05-14 08:31:39 +0000334 void OnApplicationDataReceived(int32_t id,
335 uint8_t subType,
336 uint32_t name,
337 uint16_t length,
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000338 const uint8_t* data);
niklase@google.com470e71d2011-07-07 08:21:25 +0000339
niklase@google.com470e71d2011-07-07 08:21:25 +0000340public:
341 // From RtpAudioFeedback in the RTP/RTCP module
pbos@webrtc.org92135212013-05-14 08:31:39 +0000342 void OnReceivedTelephoneEvent(int32_t id,
343 uint8_t event,
344 bool endOfEvent);
niklase@google.com470e71d2011-07-07 08:21:25 +0000345
pbos@webrtc.org92135212013-05-14 08:31:39 +0000346 void OnPlayTelephoneEvent(int32_t id,
347 uint8_t event,
348 uint16_t lengthMs,
349 uint8_t volume);
niklase@google.com470e71d2011-07-07 08:21:25 +0000350
351public:
niklase@google.com470e71d2011-07-07 08:21:25 +0000352 // From Transport (called by the RTP/RTCP module)
353 int SendPacket(int /*channel*/, const void *data, int len);
354 int SendRTCPPacket(int /*channel*/, const void *data, int len);
355
356public:
357 // From MixerParticipant
pbos@webrtc.org92135212013-05-14 08:31:39 +0000358 int32_t GetAudioFrame(int32_t id, AudioFrame& audioFrame);
359 int32_t NeededFrequency(int32_t id);
niklase@google.com470e71d2011-07-07 08:21:25 +0000360
361public:
362 // From MonitorObserver
363 void OnPeriodicProcess();
364
365public:
366 // From FileCallback
pbos@webrtc.org92135212013-05-14 08:31:39 +0000367 void PlayNotification(int32_t id,
368 uint32_t durationMs);
369 void RecordNotification(int32_t id,
370 uint32_t durationMs);
371 void PlayFileEnded(int32_t id);
372 void RecordFileEnded(int32_t id);
niklase@google.com470e71d2011-07-07 08:21:25 +0000373
374public:
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000375 uint32_t InstanceId() const
niklase@google.com470e71d2011-07-07 08:21:25 +0000376 {
377 return _instanceId;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000378 }
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000379 int32_t ChannelId() const
niklase@google.com470e71d2011-07-07 08:21:25 +0000380 {
381 return _channelId;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000382 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000383 bool Playing() const
384 {
385 return _playing;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000386 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000387 bool Sending() const
388 {
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000389 // A lock is needed because |_sending| is accessed by both
390 // TransmitMixer::PrepareDemux() and StartSend()/StopSend(), which
391 // are called by different threads.
mflodman@webrtc.org9a065d12012-03-07 08:12:21 +0000392 CriticalSectionScoped cs(&_callbackCritSect);
niklase@google.com470e71d2011-07-07 08:21:25 +0000393 return _sending;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000394 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000395 bool Receiving() const
396 {
397 return _receiving;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000398 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000399 bool ExternalTransport() const
400 {
401 return _externalTransport;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000402 }
roosa@google.com1b60ceb2012-12-12 23:00:29 +0000403 bool ExternalMixing() const
404 {
405 return _externalMixing;
406 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000407 bool OutputIsOnHold() const
408 {
409 return _outputIsOnHold;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000410 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000411 bool InputIsOnHold() const
412 {
413 return _inputIsOnHold;
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000414 }
andrew@webrtc.orgf81f9f82011-08-19 22:56:22 +0000415 RtpRtcp* RtpRtcpModulePtr() const
niklase@google.com470e71d2011-07-07 08:21:25 +0000416 {
pwestin@webrtc.org2853dde2012-05-11 11:08:54 +0000417 return _rtpRtcpModule.get();
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000418 }
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000419 int8_t OutputEnergyLevel() const
niklase@google.com470e71d2011-07-07 08:21:25 +0000420 {
421 return _outputAudioLevel.Level();
xians@webrtc.orge07247a2011-11-28 16:31:28 +0000422 }
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000423 uint32_t Demultiplex(const AudioFrame& audioFrame);
424 uint32_t PrepareEncodeAndSend(int mixingFrequency);
425 uint32_t EncodeAndSend();
niklase@google.com470e71d2011-07-07 08:21:25 +0000426
427private:
428 int InsertInbandDtmfTone();
pbos@webrtc.org92135212013-05-14 08:31:39 +0000429 int32_t MixOrReplaceAudioWithFile(int mixingFrequency);
430 int32_t MixAudioWithFile(AudioFrame& audioFrame, int mixingFrequency);
niklase@google.com470e71d2011-07-07 08:21:25 +0000431 void UpdateDeadOrAliveCounters(bool alive);
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000432 int32_t SendPacketRaw(const void *data, int len, bool RTCP);
pwestin@webrtc.org1de01352013-04-11 20:23:35 +0000433 void UpdatePacketDelay(uint32_t timestamp,
434 uint16_t sequenceNumber);
niklase@google.com470e71d2011-07-07 08:21:25 +0000435 void RegisterReceiveCodecsToRTPModule();
436 int ApmProcessRx(AudioFrame& audioFrame);
437
turaj@webrtc.org42259e72012-12-11 02:15:12 +0000438 int SetRedPayloadType(int red_payload_type);
niklase@google.com470e71d2011-07-07 08:21:25 +0000439private:
440 CriticalSectionWrapper& _fileCritSect;
441 CriticalSectionWrapper& _callbackCritSect;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000442 uint32_t _instanceId;
443 int32_t _channelId;
niklase@google.com470e71d2011-07-07 08:21:25 +0000444
445private:
stefan@webrtc.orga5cb98c2013-05-29 12:12:51 +0000446 scoped_ptr<RtpHeaderParser> rtp_header_parser_;
pwestin@webrtc.org2853dde2012-05-11 11:08:54 +0000447 scoped_ptr<RtpRtcp> _rtpRtcpModule;
niklase@google.com470e71d2011-07-07 08:21:25 +0000448 AudioCodingModule& _audioCodingModule;
niklase@google.com470e71d2011-07-07 08:21:25 +0000449 RtpDump& _rtpDumpIn;
450 RtpDump& _rtpDumpOut;
451private:
452 AudioLevel _outputAudioLevel;
453 bool _externalTransport;
454 AudioFrame _audioFrame;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000455 uint8_t _audioLevel_dBov;
niklase@google.com470e71d2011-07-07 08:21:25 +0000456 FilePlayer* _inputFilePlayerPtr;
457 FilePlayer* _outputFilePlayerPtr;
458 FileRecorder* _outputFileRecorderPtr;
xians@google.com0b0665a2011-08-08 08:18:44 +0000459 int _inputFilePlayerId;
460 int _outputFilePlayerId;
461 int _outputFileRecorderId;
niklase@google.com470e71d2011-07-07 08:21:25 +0000462 bool _inputFilePlaying;
463 bool _outputFilePlaying;
464 bool _outputFileRecording;
465 DtmfInbandQueue _inbandDtmfQueue;
466 DtmfInband _inbandDtmfGenerator;
niklase@google.com470e71d2011-07-07 08:21:25 +0000467 bool _inputExternalMedia;
xians@google.com22963ab2011-08-03 12:40:23 +0000468 bool _outputExternalMedia;
niklase@google.com470e71d2011-07-07 08:21:25 +0000469 VoEMediaProcess* _inputExternalMediaCallbackPtr;
470 VoEMediaProcess* _outputExternalMediaCallbackPtr;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000471 uint8_t* _encryptionRTPBufferPtr;
472 uint8_t* _decryptionRTPBufferPtr;
473 uint8_t* _encryptionRTCPBufferPtr;
474 uint8_t* _decryptionRTCPBufferPtr;
475 uint32_t _timeStamp;
476 uint8_t _sendTelephoneEventPayloadType;
pwestin@webrtc.org1de01352013-04-11 20:23:35 +0000477 uint32_t playout_timestamp_rtp_;
478 uint32_t playout_timestamp_rtcp_;
479 uint32_t playout_delay_ms_;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000480 uint32_t _numberOfDiscardedPackets;
pwestin@webrtc.org1de01352013-04-11 20:23:35 +0000481
482 private:
niklase@google.com470e71d2011-07-07 08:21:25 +0000483 // uses
484 Statistics* _engineStatisticsPtr;
485 OutputMixer* _outputMixerPtr;
486 TransmitMixer* _transmitMixerPtr;
487 ProcessThread* _moduleProcessThreadPtr;
488 AudioDeviceModule* _audioDeviceModulePtr;
489 VoiceEngineObserver* _voiceEngineObserverPtr; // owned by base
490 CriticalSectionWrapper* _callbackCritSectPtr; // owned by base
491 Transport* _transportPtr; // WebRtc socket or external transport
492 Encryption* _encryptionPtr; // WebRtc SRTP or external encryption
andrew@webrtc.org755b04a2011-11-15 16:57:56 +0000493 scoped_ptr<AudioProcessing> _rtpAudioProc;
niklase@google.com470e71d2011-07-07 08:21:25 +0000494 AudioProcessing* _rxAudioProcessingModulePtr; // far end AudioProcessing
niklase@google.com470e71d2011-07-07 08:21:25 +0000495 VoERxVadCallback* _rxVadObserverPtr;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000496 int32_t _oldVadDecision;
497 int32_t _sendFrameType; // Send data is voice, 1-voice, 0-otherwise
niklase@google.com470e71d2011-07-07 08:21:25 +0000498 VoERTPObserver* _rtpObserverPtr;
499 VoERTCPObserver* _rtcpObserverPtr;
500private:
501 // VoEBase
502 bool _outputIsOnHold;
503 bool _externalPlayout;
roosa@google.com1b60ceb2012-12-12 23:00:29 +0000504 bool _externalMixing;
niklase@google.com470e71d2011-07-07 08:21:25 +0000505 bool _inputIsOnHold;
506 bool _playing;
507 bool _sending;
508 bool _receiving;
509 bool _mixFileWithMicrophone;
510 bool _rtpObserver;
511 bool _rtcpObserver;
512 // VoEVolumeControl
513 bool _mute;
514 float _panLeft;
515 float _panRight;
516 float _outputGain;
517 // VoEEncryption
518 bool _encrypting;
519 bool _decrypting;
520 // VoEDtmf
521 bool _playOutbandDtmfEvent;
522 bool _playInbandDtmfEvent;
niklase@google.com470e71d2011-07-07 08:21:25 +0000523 // VoeRTP_RTCP
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000524 uint8_t _extraPayloadType;
niklase@google.com470e71d2011-07-07 08:21:25 +0000525 bool _insertExtraRTPPacket;
526 bool _extraMarkerBit;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000527 uint32_t _lastLocalTimeStamp;
roosa@google.com0870f022012-12-12 21:31:41 +0000528 uint32_t _lastRemoteTimeStamp;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000529 int8_t _lastPayloadType;
niklase@google.com470e71d2011-07-07 08:21:25 +0000530 bool _includeAudioLevelIndication;
531 // VoENetwork
532 bool _rtpPacketTimedOut;
533 bool _rtpPacketTimeOutIsEnabled;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000534 uint32_t _rtpTimeOutSeconds;
niklase@google.com470e71d2011-07-07 08:21:25 +0000535 bool _connectionObserver;
536 VoEConnectionObserver* _connectionObserverPtr;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000537 uint32_t _countAliveDetections;
538 uint32_t _countDeadDetections;
niklase@google.com470e71d2011-07-07 08:21:25 +0000539 AudioFrame::SpeechType _outputSpeechType;
540 // VoEVideoSync
pwestin@webrtc.org1de01352013-04-11 20:23:35 +0000541 uint32_t _average_jitter_buffer_delay_us;
turaj@webrtc.orge46c8d32013-05-22 20:39:43 +0000542 int least_required_delay_ms_;
pbos@webrtc.org6141e132013-04-09 10:09:10 +0000543 uint32_t _previousTimestamp;
544 uint16_t _recPacketDelayMs;
niklase@google.com470e71d2011-07-07 08:21:25 +0000545 // VoEAudioProcessing
546 bool _RxVadDetection;
547 bool _rxApmIsEnabled;
548 bool _rxAgcIsEnabled;
549 bool _rxNsIsEnabled;
550};
551
552} // namespace voe
553
554} // namespace webrtc
555
556#endif // WEBRTC_VOICE_ENGINE_CHANNEL_H