niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
leozwang@webrtc.org | 813e4b0 | 2012-03-01 18:34:25 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 3 | * |
| 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.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 14 | #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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 29 | |
pwestin@webrtc.org | 684f057 | 2013-03-13 23:20:57 +0000 | [diff] [blame^] | 30 | #ifndef WEBRTC_EXTERNAL_TRANSPORT |
| 31 | #include "webrtc/modules/udp_transport/interface/udp_transport.h" |
| 32 | #endif |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 33 | #ifdef WEBRTC_SRTP |
| 34 | #include "SrtpModule.h" |
| 35 | #endif |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 36 | #ifdef WEBRTC_DTMF_DETECTION |
| 37 | #include "voe_dtmf.h" // TelephoneEventDetectionMethods, TelephoneEventObserver |
| 38 | #endif |
| 39 | |
| 40 | namespace webrtc |
| 41 | { |
| 42 | class CriticalSectionWrapper; |
| 43 | class ProcessThread; |
| 44 | class AudioDeviceModule; |
| 45 | class RtpRtcp; |
| 46 | class FileWrapper; |
| 47 | class RtpDump; |
| 48 | class VoiceEngineObserver; |
| 49 | class VoEMediaProcess; |
| 50 | class VoERTPObserver; |
| 51 | class VoERTCPObserver; |
| 52 | |
| 53 | struct CallStatistics; |
henrika@webrtc.org | 8a2fc88 | 2012-08-22 08:53:55 +0000 | [diff] [blame] | 54 | struct ReportBlock; |
| 55 | struct SenderInfo; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 56 | |
| 57 | namespace voe |
| 58 | { |
| 59 | class Statistics; |
| 60 | class TransmitMixer; |
| 61 | class OutputMixer; |
| 62 | |
| 63 | |
| 64 | class Channel: |
| 65 | public RtpData, |
| 66 | public RtpFeedback, |
| 67 | public RtcpFeedback, |
pwestin@webrtc.org | 684f057 | 2013-03-13 23:20:57 +0000 | [diff] [blame^] | 68 | #ifndef WEBRTC_EXTERNAL_TRANSPORT |
| 69 | public UdpTransportData, // receiving packet from sockets |
| 70 | #endif |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 71 | 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 76 | public MixerParticipant // supplies output mixer with audio frames |
| 77 | { |
| 78 | public: |
| 79 | enum {KNumSocketThreads = 1}; |
| 80 | enum {KNumberOfSocketBuffers = 8}; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 81 | public: |
| 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 | |
| 98 | public: |
| 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.org | 813e4b0 | 2012-03-01 18:34:25 +0000 | [diff] [blame] | 112 | const char ipAddr[64], |
| 113 | const char multicastIpAddr[64]); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 114 | WebRtc_Word32 GetLocalReceiver(int& port, int& RTCPport, char ipAddr[]); |
| 115 | WebRtc_Word32 SetSendDestination(const WebRtc_UWord16 rtpPort, |
leozwang@webrtc.org | 813e4b0 | 2012-03-01 18:34:25 +0000 | [diff] [blame] | 116 | const char ipAddr[64], |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 117 | 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 124 | 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.org | 42259e7 | 2012-12-11 02:15:12 +0000 | [diff] [blame] | 148 | // VoE dual-streaming. |
| 149 | int SetSecondarySendCodec(const CodecInst& codec, int red_payload_type); |
| 150 | void RemoveSecondarySendCodec(); |
| 151 | int GetSecondarySendCodec(CodecInst* codec); |
| 152 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 153 | // 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.org | 684f057 | 2013-03-13 23:20:57 +0000 | [diff] [blame^] | 184 | WebRtc_Word32 SendUDPPacket(const void* data, unsigned int length, |
| 185 | int& transmittedBytes, bool useRtcpSocket); |
| 186 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 187 | // 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.org | ab12990 | 2012-06-04 03:26:39 +0000 | [diff] [blame] | 201 | int RegisterFilePlayingToMixer(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 202 | 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.com | 1b60ceb | 2012-12-12 23:00:29 +0000 | [diff] [blame] | 229 | int SetExternalMixing(bool enabled); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 230 | |
| 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 249 | |
| 250 | // VoEVideoSync |
| 251 | int GetDelayEstimate(int& delayMs) const; |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 252 | int SetInitialPlayoutDelay(int delay_ms); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 253 | 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 296 | |
| 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.org | 8a2fc88 | 2012-08-22 08:53:55 +0000 | [diff] [blame] | 339 | int GetRemoteRTCPSenderInfo(SenderInfo* sender_info); |
| 340 | int GetRemoteRTCPReportBlocks(std::vector<ReportBlock>* report_blocks); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 341 | int GetRTPStatistics(CallStatistics& stats); |
| 342 | int SetFECStatus(bool enable, int redPayloadtype); |
| 343 | int GetFECStatus(bool& enabled, int& redPayloadtype); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 344 | 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.com | 0870f02 | 2012-12-12 21:31:41 +0000 | [diff] [blame] | 350 | uint32_t LastRemoteTimeStamp() { return _lastRemoteTimeStamp; } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 351 | |
| 352 | public: |
| 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 363 | public: |
| 364 | WebRtc_Word32 OnRxVadDetected(const int vadDecision); |
| 365 | |
| 366 | public: |
| 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 | |
| 372 | public: |
| 373 | // From RtpFeedback in the RTP/RTCP module |
| 374 | WebRtc_Word32 OnInitializeDecoder( |
| 375 | const WebRtc_Word32 id, |
| 376 | const WebRtc_Word8 payloadType, |
leozwang@webrtc.org | 813e4b0 | 2012-03-01 18:34:25 +0000 | [diff] [blame] | 377 | const char payloadName[RTP_PAYLOAD_NAME_SIZE], |
xians@google.com | 0b0665a | 2011-08-08 08:18:44 +0000 | [diff] [blame] | 378 | const int frequency, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 379 | 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 | |
| 396 | public: |
| 397 | // From RtcpFeedback in the RTP/RTCP module |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 398 | 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 404 | public: |
| 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 | |
| 415 | public: |
pwestin@webrtc.org | 684f057 | 2013-03-13 23:20:57 +0000 | [diff] [blame^] | 416 | // 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 | |
| 427 | public: |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 428 | // 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 | |
| 432 | public: |
| 433 | // From MixerParticipant |
| 434 | WebRtc_Word32 GetAudioFrame(const WebRtc_Word32 id, |
| 435 | AudioFrame& audioFrame); |
| 436 | WebRtc_Word32 NeededFrequency(const WebRtc_Word32 id); |
| 437 | |
| 438 | public: |
| 439 | // From MonitorObserver |
| 440 | void OnPeriodicProcess(); |
| 441 | |
| 442 | public: |
| 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 | |
| 451 | public: |
| 452 | WebRtc_UWord32 InstanceId() const |
| 453 | { |
| 454 | return _instanceId; |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 455 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 456 | WebRtc_Word32 ChannelId() const |
| 457 | { |
| 458 | return _channelId; |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 459 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 460 | bool Playing() const |
| 461 | { |
| 462 | return _playing; |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 463 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 464 | bool Sending() const |
| 465 | { |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 466 | // 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.org | 9a065d1 | 2012-03-07 08:12:21 +0000 | [diff] [blame] | 469 | CriticalSectionScoped cs(&_callbackCritSect); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 470 | return _sending; |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 471 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 472 | bool Receiving() const |
| 473 | { |
| 474 | return _receiving; |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 475 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 476 | bool ExternalTransport() const |
| 477 | { |
| 478 | return _externalTransport; |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 479 | } |
roosa@google.com | 1b60ceb | 2012-12-12 23:00:29 +0000 | [diff] [blame] | 480 | bool ExternalMixing() const |
| 481 | { |
| 482 | return _externalMixing; |
| 483 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 484 | bool OutputIsOnHold() const |
| 485 | { |
| 486 | return _outputIsOnHold; |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 487 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 488 | bool InputIsOnHold() const |
| 489 | { |
| 490 | return _inputIsOnHold; |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 491 | } |
andrew@webrtc.org | f81f9f8 | 2011-08-19 22:56:22 +0000 | [diff] [blame] | 492 | RtpRtcp* RtpRtcpModulePtr() const |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 493 | { |
pwestin@webrtc.org | 2853dde | 2012-05-11 11:08:54 +0000 | [diff] [blame] | 494 | return _rtpRtcpModule.get(); |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 495 | } |
andrew@webrtc.org | f81f9f8 | 2011-08-19 22:56:22 +0000 | [diff] [blame] | 496 | WebRtc_Word8 OutputEnergyLevel() const |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 497 | { |
| 498 | return _outputAudioLevel.Level(); |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 499 | } |
pwestin@webrtc.org | 684f057 | 2013-03-13 23:20:57 +0000 | [diff] [blame^] | 500 | #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.org | 755b04a | 2011-11-15 16:57:56 +0000 | [diff] [blame] | 510 | WebRtc_UWord32 Demultiplex(const AudioFrame& audioFrame); |
xians@google.com | 0b0665a | 2011-08-08 08:18:44 +0000 | [diff] [blame] | 511 | WebRtc_UWord32 PrepareEncodeAndSend(int mixingFrequency); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 512 | WebRtc_UWord32 EncodeAndSend(); |
| 513 | |
| 514 | private: |
| 515 | int InsertInbandDtmfTone(); |
| 516 | WebRtc_Word32 |
xians@google.com | 0b0665a | 2011-08-08 08:18:44 +0000 | [diff] [blame] | 517 | MixOrReplaceAudioWithFile(const int mixingFrequency); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 518 | WebRtc_Word32 MixAudioWithFile(AudioFrame& audioFrame, |
xians@google.com | 0b0665a | 2011-08-08 08:18:44 +0000 | [diff] [blame] | 519 | const int mixingFrequency); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 520 | 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.org | 42259e7 | 2012-12-11 02:15:12 +0000 | [diff] [blame] | 528 | int SetRedPayloadType(int red_payload_type); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 529 | private: |
| 530 | CriticalSectionWrapper& _fileCritSect; |
| 531 | CriticalSectionWrapper& _callbackCritSect; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 532 | WebRtc_UWord32 _instanceId; |
| 533 | WebRtc_Word32 _channelId; |
| 534 | |
| 535 | private: |
pwestin@webrtc.org | 2853dde | 2012-05-11 11:08:54 +0000 | [diff] [blame] | 536 | scoped_ptr<RtpRtcp> _rtpRtcpModule; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 537 | AudioCodingModule& _audioCodingModule; |
pwestin@webrtc.org | 684f057 | 2013-03-13 23:20:57 +0000 | [diff] [blame^] | 538 | #ifndef WEBRTC_EXTERNAL_TRANSPORT |
| 539 | WebRtc_UWord8 _numSocketThreads; |
| 540 | UdpTransport& _socketTransportModule; |
| 541 | #endif |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 542 | #ifdef WEBRTC_SRTP |
| 543 | SrtpModule& _srtpModule; |
| 544 | #endif |
| 545 | RtpDump& _rtpDumpIn; |
| 546 | RtpDump& _rtpDumpOut; |
| 547 | private: |
| 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.com | 0b0665a | 2011-08-08 08:18:44 +0000 | [diff] [blame] | 555 | int _inputFilePlayerId; |
| 556 | int _outputFilePlayerId; |
| 557 | int _outputFileRecorderId; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 558 | bool _inputFilePlaying; |
| 559 | bool _outputFilePlaying; |
| 560 | bool _outputFileRecording; |
| 561 | DtmfInbandQueue _inbandDtmfQueue; |
| 562 | DtmfInband _inbandDtmfGenerator; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 563 | bool _inputExternalMedia; |
xians@google.com | 22963ab | 2011-08-03 12:40:23 +0000 | [diff] [blame] | 564 | bool _outputExternalMedia; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 565 | 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; |
| 576 | private: |
| 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.org | 755b04a | 2011-11-15 16:57:56 +0000 | [diff] [blame] | 587 | scoped_ptr<AudioProcessing> _rtpAudioProc; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 588 | AudioProcessing* _rxAudioProcessingModulePtr; // far end AudioProcessing |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 589 | VoERxVadCallback* _rxVadObserverPtr; |
| 590 | WebRtc_Word32 _oldVadDecision; |
| 591 | WebRtc_Word32 _sendFrameType; // Send data is voice, 1-voice, 0-otherwise |
| 592 | VoERTPObserver* _rtpObserverPtr; |
| 593 | VoERTCPObserver* _rtcpObserverPtr; |
| 594 | private: |
| 595 | // VoEBase |
| 596 | bool _outputIsOnHold; |
| 597 | bool _externalPlayout; |
roosa@google.com | 1b60ceb | 2012-12-12 23:00:29 +0000 | [diff] [blame] | 598 | bool _externalMixing; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 599 | 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 617 | // VoeRTP_RTCP |
| 618 | WebRtc_UWord8 _extraPayloadType; |
| 619 | bool _insertExtraRTPPacket; |
| 620 | bool _extraMarkerBit; |
| 621 | WebRtc_UWord32 _lastLocalTimeStamp; |
roosa@google.com | 0870f02 | 2012-12-12 21:31:41 +0000 | [diff] [blame] | 622 | uint32_t _lastRemoteTimeStamp; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 623 | 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 |