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 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 14 | #include "audio_coding_module.h" |
andrew@webrtc.org | 755b04a | 2011-11-15 16:57:56 +0000 | [diff] [blame] | 15 | #include "audio_conference_mixer_defines.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 16 | #include "common_types.h" |
andrew@webrtc.org | 755b04a | 2011-11-15 16:57:56 +0000 | [diff] [blame] | 17 | #include "dtmf_inband.h" |
| 18 | #include "dtmf_inband_queue.h" |
| 19 | #include "file_player.h" |
| 20 | #include "file_recorder.h" |
| 21 | #include "level_indicator.h" |
| 22 | #include "resampler.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 23 | #include "rtp_rtcp.h" |
andrew@webrtc.org | 755b04a | 2011-11-15 16:57:56 +0000 | [diff] [blame] | 24 | #include "scoped_ptr.h" |
| 25 | #include "shared_data.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 26 | #include "voe_audio_processing.h" |
andrew@webrtc.org | 755b04a | 2011-11-15 16:57:56 +0000 | [diff] [blame] | 27 | #include "voe_network.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 28 | #include "voice_engine_defines.h" |
| 29 | |
| 30 | #ifndef WEBRTC_EXTERNAL_TRANSPORT |
| 31 | #include "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; |
| 54 | |
| 55 | namespace voe |
| 56 | { |
| 57 | class Statistics; |
| 58 | class TransmitMixer; |
| 59 | class OutputMixer; |
| 60 | |
| 61 | |
| 62 | class Channel: |
| 63 | public RtpData, |
| 64 | public RtpFeedback, |
| 65 | public RtcpFeedback, |
| 66 | #ifndef WEBRTC_EXTERNAL_TRANSPORT |
| 67 | public UdpTransportData, // receiving packet from sockets |
| 68 | #endif |
| 69 | public FileCallback, // receiving notification from file player & recorder |
| 70 | public Transport, |
| 71 | public RtpAudioFeedback, |
| 72 | public AudioPacketizationCallback, // receive encoded packets from the ACM |
| 73 | public ACMVADCallback, // receive voice activity from the ACM |
| 74 | #ifdef WEBRTC_DTMF_DETECTION |
| 75 | public AudioCodingFeedback, // inband Dtmf detection in the ACM |
| 76 | #endif |
| 77 | public MixerParticipant // supplies output mixer with audio frames |
| 78 | { |
| 79 | public: |
| 80 | enum {KNumSocketThreads = 1}; |
| 81 | enum {KNumberOfSocketBuffers = 8}; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 82 | public: |
| 83 | virtual ~Channel(); |
| 84 | static WebRtc_Word32 CreateChannel(Channel*& channel, |
| 85 | const WebRtc_Word32 channelId, |
| 86 | const WebRtc_UWord32 instanceId); |
| 87 | Channel(const WebRtc_Word32 channelId, const WebRtc_UWord32 instanceId); |
| 88 | WebRtc_Word32 Init(); |
| 89 | WebRtc_Word32 SetEngineInformation( |
| 90 | Statistics& engineStatistics, |
| 91 | OutputMixer& outputMixer, |
| 92 | TransmitMixer& transmitMixer, |
| 93 | ProcessThread& moduleProcessThread, |
| 94 | AudioDeviceModule& audioDeviceModule, |
| 95 | VoiceEngineObserver* voiceEngineObserver, |
| 96 | CriticalSectionWrapper* callbackCritSect); |
| 97 | WebRtc_Word32 UpdateLocalTimeStamp(); |
| 98 | |
| 99 | public: |
| 100 | // API methods |
| 101 | |
| 102 | // VoEBase |
| 103 | WebRtc_Word32 StartPlayout(); |
| 104 | WebRtc_Word32 StopPlayout(); |
| 105 | WebRtc_Word32 StartSend(); |
| 106 | WebRtc_Word32 StopSend(); |
| 107 | WebRtc_Word32 StartReceiving(); |
| 108 | WebRtc_Word32 StopReceiving(); |
| 109 | |
| 110 | #ifndef WEBRTC_EXTERNAL_TRANSPORT |
| 111 | WebRtc_Word32 SetLocalReceiver(const WebRtc_UWord16 rtpPort, |
| 112 | const WebRtc_UWord16 rtcpPort, |
leozwang@webrtc.org | 813e4b0 | 2012-03-01 18:34:25 +0000 | [diff] [blame^] | 113 | const char ipAddr[64], |
| 114 | const char multicastIpAddr[64]); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 115 | WebRtc_Word32 GetLocalReceiver(int& port, int& RTCPport, char ipAddr[]); |
| 116 | WebRtc_Word32 SetSendDestination(const WebRtc_UWord16 rtpPort, |
leozwang@webrtc.org | 813e4b0 | 2012-03-01 18:34:25 +0000 | [diff] [blame^] | 117 | const char ipAddr[64], |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 118 | const int sourcePort, |
| 119 | const WebRtc_UWord16 rtcpPort); |
| 120 | WebRtc_Word32 GetSendDestination(int& port, char ipAddr[64], |
| 121 | int& sourcePort, int& RTCPport); |
| 122 | #endif |
| 123 | WebRtc_Word32 SetNetEQPlayoutMode(NetEqModes mode); |
| 124 | WebRtc_Word32 GetNetEQPlayoutMode(NetEqModes& mode); |
| 125 | WebRtc_Word32 SetNetEQBGNMode(NetEqBgnModes mode); |
| 126 | WebRtc_Word32 GetNetEQBGNMode(NetEqBgnModes& mode); |
| 127 | WebRtc_Word32 SetOnHoldStatus(bool enable, OnHoldModes mode); |
| 128 | WebRtc_Word32 GetOnHoldStatus(bool& enabled, OnHoldModes& mode); |
| 129 | WebRtc_Word32 RegisterVoiceEngineObserver(VoiceEngineObserver& observer); |
| 130 | WebRtc_Word32 DeRegisterVoiceEngineObserver(); |
| 131 | |
| 132 | // VoECodec |
| 133 | WebRtc_Word32 GetSendCodec(CodecInst& codec); |
| 134 | WebRtc_Word32 GetRecCodec(CodecInst& codec); |
| 135 | WebRtc_Word32 SetSendCodec(const CodecInst& codec); |
| 136 | WebRtc_Word32 SetVADStatus(bool enableVAD, ACMVADMode mode, |
| 137 | bool disableDTX); |
| 138 | WebRtc_Word32 GetVADStatus(bool& enabledVAD, ACMVADMode& mode, |
| 139 | bool& disabledDTX); |
| 140 | WebRtc_Word32 SetRecPayloadType(const CodecInst& codec); |
| 141 | WebRtc_Word32 GetRecPayloadType(CodecInst& codec); |
| 142 | WebRtc_Word32 SetAMREncFormat(AmrMode mode); |
| 143 | WebRtc_Word32 SetAMRDecFormat(AmrMode mode); |
| 144 | WebRtc_Word32 SetAMRWbEncFormat(AmrMode mode); |
| 145 | WebRtc_Word32 SetAMRWbDecFormat(AmrMode mode); |
| 146 | WebRtc_Word32 SetSendCNPayloadType(int type, PayloadFrequencies frequency); |
| 147 | WebRtc_Word32 SetISACInitTargetRate(int rateBps, bool useFixedFrameSize); |
| 148 | WebRtc_Word32 SetISACMaxRate(int rateBps); |
| 149 | WebRtc_Word32 SetISACMaxPayloadSize(int sizeBytes); |
| 150 | |
| 151 | // VoENetwork |
| 152 | WebRtc_Word32 RegisterExternalTransport(Transport& transport); |
| 153 | WebRtc_Word32 DeRegisterExternalTransport(); |
| 154 | WebRtc_Word32 ReceivedRTPPacket(const WebRtc_Word8* data, |
| 155 | WebRtc_Word32 length); |
| 156 | WebRtc_Word32 ReceivedRTCPPacket(const WebRtc_Word8* data, |
| 157 | WebRtc_Word32 length); |
| 158 | #ifndef WEBRTC_EXTERNAL_TRANSPORT |
| 159 | WebRtc_Word32 GetSourceInfo(int& rtpPort, int& rtcpPort, char ipAddr[64]); |
| 160 | WebRtc_Word32 EnableIPv6(); |
| 161 | bool IPv6IsEnabled() const; |
| 162 | WebRtc_Word32 SetSourceFilter(int rtpPort, int rtcpPort, |
| 163 | const char ipAddr[64]); |
| 164 | WebRtc_Word32 GetSourceFilter(int& rtpPort, int& rtcpPort, char ipAddr[64]); |
| 165 | WebRtc_Word32 SetSendTOS(int DSCP, int priority, bool useSetSockopt); |
| 166 | WebRtc_Word32 GetSendTOS(int &DSCP, int& priority, bool &useSetSockopt); |
| 167 | #if defined(_WIN32) |
| 168 | WebRtc_Word32 SetSendGQoS(bool enable, int serviceType, int overrideDSCP); |
| 169 | WebRtc_Word32 GetSendGQoS(bool &enabled, int &serviceType, |
| 170 | int &overrideDSCP); |
| 171 | #endif |
| 172 | #endif |
| 173 | WebRtc_Word32 SetPacketTimeoutNotification(bool enable, int timeoutSeconds); |
| 174 | WebRtc_Word32 GetPacketTimeoutNotification(bool& enabled, |
| 175 | int& timeoutSeconds); |
| 176 | WebRtc_Word32 RegisterDeadOrAliveObserver(VoEConnectionObserver& observer); |
| 177 | WebRtc_Word32 DeRegisterDeadOrAliveObserver(); |
| 178 | WebRtc_Word32 SetPeriodicDeadOrAliveStatus(bool enable, |
| 179 | int sampleTimeSeconds); |
| 180 | WebRtc_Word32 GetPeriodicDeadOrAliveStatus(bool& enabled, |
| 181 | int& sampleTimeSeconds); |
| 182 | WebRtc_Word32 SendUDPPacket(const void* data, unsigned int length, |
| 183 | int& transmittedBytes, bool useRtcpSocket); |
| 184 | |
| 185 | // VoEFile |
| 186 | int StartPlayingFileLocally(const char* fileName, const bool loop, |
| 187 | const FileFormats format, |
| 188 | const int startPosition, |
| 189 | const float volumeScaling, |
| 190 | const int stopPosition, |
| 191 | const CodecInst* codecInst); |
| 192 | int StartPlayingFileLocally(InStream* stream, const FileFormats format, |
| 193 | const int startPosition, |
| 194 | const float volumeScaling, |
| 195 | const int stopPosition, |
| 196 | const CodecInst* codecInst); |
| 197 | int StopPlayingFileLocally(); |
| 198 | int IsPlayingFileLocally() const; |
| 199 | int ScaleLocalFilePlayout(const float scale); |
| 200 | int GetLocalPlayoutPosition(int& positionMs); |
| 201 | int StartPlayingFileAsMicrophone(const char* fileName, const bool loop, |
| 202 | const FileFormats format, |
| 203 | const int startPosition, |
| 204 | const float volumeScaling, |
| 205 | const int stopPosition, |
| 206 | const CodecInst* codecInst); |
| 207 | int StartPlayingFileAsMicrophone(InStream* stream, |
| 208 | const FileFormats format, |
| 209 | const int startPosition, |
| 210 | const float volumeScaling, |
| 211 | const int stopPosition, |
| 212 | const CodecInst* codecInst); |
| 213 | int StopPlayingFileAsMicrophone(); |
| 214 | int IsPlayingFileAsMicrophone() const; |
| 215 | int ScaleFileAsMicrophonePlayout(const float scale); |
| 216 | int StartRecordingPlayout(const char* fileName, const CodecInst* codecInst); |
| 217 | int StartRecordingPlayout(OutStream* stream, const CodecInst* codecInst); |
| 218 | int StopRecordingPlayout(); |
| 219 | |
| 220 | void SetMixWithMicStatus(bool mix); |
| 221 | |
| 222 | // VoEExternalMediaProcessing |
| 223 | int RegisterExternalMediaProcessing(ProcessingTypes type, |
| 224 | VoEMediaProcess& processObject); |
| 225 | int DeRegisterExternalMediaProcessing(ProcessingTypes type); |
| 226 | |
| 227 | // VoEVolumeControl |
| 228 | int GetSpeechOutputLevel(WebRtc_UWord32& level) const; |
| 229 | int GetSpeechOutputLevelFullRange(WebRtc_UWord32& level) const; |
| 230 | int SetMute(const bool enable); |
| 231 | bool Mute() const; |
| 232 | int SetOutputVolumePan(float left, float right); |
| 233 | int GetOutputVolumePan(float& left, float& right) const; |
| 234 | int SetChannelOutputVolumeScaling(float scaling); |
| 235 | int GetChannelOutputVolumeScaling(float& scaling) const; |
| 236 | |
| 237 | // VoECallReport |
| 238 | void ResetDeadOrAliveCounters(); |
| 239 | int ResetRTCPStatistics(); |
| 240 | int GetRoundTripTimeSummary(StatVal& delaysMs) const; |
| 241 | int GetDeadOrAliveCounters(int& countDead, int& countAlive) const; |
| 242 | |
| 243 | // VoENetEqStats |
| 244 | int GetNetworkStatistics(NetworkStatistics& stats); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 245 | |
| 246 | // VoEVideoSync |
| 247 | int GetDelayEstimate(int& delayMs) const; |
| 248 | int SetMinimumPlayoutDelay(int delayMs); |
| 249 | int GetPlayoutTimestamp(unsigned int& timestamp); |
| 250 | int SetInitTimestamp(unsigned int timestamp); |
| 251 | int SetInitSequenceNumber(short sequenceNumber); |
| 252 | |
| 253 | // VoEVideoSyncExtended |
| 254 | int GetRtpRtcp(RtpRtcp* &rtpRtcpModule) const; |
| 255 | |
| 256 | // VoEEncryption |
| 257 | #ifdef WEBRTC_SRTP |
| 258 | int EnableSRTPSend( |
| 259 | CipherTypes cipherType, |
| 260 | int cipherKeyLength, |
| 261 | AuthenticationTypes authType, |
| 262 | int authKeyLength, |
| 263 | int authTagLength, |
| 264 | SecurityLevels level, |
| 265 | const unsigned char key[kVoiceEngineMaxSrtpKeyLength], |
| 266 | bool useForRTCP); |
| 267 | int DisableSRTPSend(); |
| 268 | int EnableSRTPReceive( |
| 269 | CipherTypes cipherType, |
| 270 | int cipherKeyLength, |
| 271 | AuthenticationTypes authType, |
| 272 | int authKeyLength, |
| 273 | int authTagLength, |
| 274 | SecurityLevels level, |
| 275 | const unsigned char key[kVoiceEngineMaxSrtpKeyLength], |
| 276 | bool useForRTCP); |
| 277 | int DisableSRTPReceive(); |
| 278 | #endif |
| 279 | int RegisterExternalEncryption(Encryption& encryption); |
| 280 | int DeRegisterExternalEncryption(); |
| 281 | |
| 282 | // VoEDtmf |
| 283 | int SendTelephoneEventOutband(unsigned char eventCode, int lengthMs, |
| 284 | int attenuationDb, bool playDtmfEvent); |
| 285 | int SendTelephoneEventInband(unsigned char eventCode, int lengthMs, |
| 286 | int attenuationDb, bool playDtmfEvent); |
| 287 | int SetDtmfPlayoutStatus(bool enable); |
| 288 | bool DtmfPlayoutStatus() const; |
| 289 | int SetSendTelephoneEventPayloadType(unsigned char type); |
| 290 | int GetSendTelephoneEventPayloadType(unsigned char& type); |
| 291 | #ifdef WEBRTC_DTMF_DETECTION |
| 292 | int RegisterTelephoneEventDetection( |
| 293 | TelephoneEventDetectionMethods detectionMethod, |
| 294 | VoETelephoneEventObserver& observer); |
| 295 | int DeRegisterTelephoneEventDetection(); |
| 296 | int GetTelephoneEventDetectionStatus( |
| 297 | bool& enabled, |
| 298 | TelephoneEventDetectionMethods& detectionMethod); |
| 299 | #endif |
| 300 | |
| 301 | // VoEAudioProcessingImpl |
| 302 | int UpdateRxVadDetection(AudioFrame& audioFrame); |
| 303 | int RegisterRxVadObserver(VoERxVadCallback &observer); |
| 304 | int DeRegisterRxVadObserver(); |
| 305 | int VoiceActivityIndicator(int &activity); |
| 306 | #ifdef WEBRTC_VOICE_ENGINE_AGC |
| 307 | int SetRxAgcStatus(const bool enable, const AgcModes mode); |
| 308 | int GetRxAgcStatus(bool& enabled, AgcModes& mode); |
| 309 | int SetRxAgcConfig(const AgcConfig config); |
| 310 | int GetRxAgcConfig(AgcConfig& config); |
| 311 | #endif |
| 312 | #ifdef WEBRTC_VOICE_ENGINE_NR |
| 313 | int SetRxNsStatus(const bool enable, const NsModes mode); |
| 314 | int GetRxNsStatus(bool& enabled, NsModes& mode); |
| 315 | #endif |
| 316 | |
| 317 | // VoERTP_RTCP |
| 318 | int RegisterRTPObserver(VoERTPObserver& observer); |
| 319 | int DeRegisterRTPObserver(); |
| 320 | int RegisterRTCPObserver(VoERTCPObserver& observer); |
| 321 | int DeRegisterRTCPObserver(); |
| 322 | int SetLocalSSRC(unsigned int ssrc); |
| 323 | int GetLocalSSRC(unsigned int& ssrc); |
| 324 | int GetRemoteSSRC(unsigned int& ssrc); |
| 325 | int GetRemoteCSRCs(unsigned int arrCSRC[15]); |
| 326 | int SetRTPAudioLevelIndicationStatus(bool enable, unsigned char ID); |
| 327 | int GetRTPAudioLevelIndicationStatus(bool& enable, unsigned char& ID); |
| 328 | int SetRTCPStatus(bool enable); |
| 329 | int GetRTCPStatus(bool& enabled); |
| 330 | int SetRTCP_CNAME(const char cName[256]); |
| 331 | int GetRTCP_CNAME(char cName[256]); |
| 332 | int GetRemoteRTCP_CNAME(char cName[256]); |
| 333 | int GetRemoteRTCPData(unsigned int& NTPHigh, unsigned int& NTPLow, |
| 334 | unsigned int& timestamp, |
| 335 | unsigned int& playoutTimestamp, unsigned int* jitter, |
| 336 | unsigned short* fractionLost); |
| 337 | int SendApplicationDefinedRTCPPacket(const unsigned char subType, |
| 338 | unsigned int name, const char* data, |
| 339 | unsigned short dataLengthInBytes); |
| 340 | int GetRTPStatistics(unsigned int& averageJitterMs, |
| 341 | unsigned int& maxJitterMs, |
| 342 | unsigned int& discardedPackets); |
| 343 | int GetRTPStatistics(CallStatistics& stats); |
| 344 | int SetFECStatus(bool enable, int redPayloadtype); |
| 345 | int GetFECStatus(bool& enabled, int& redPayloadtype); |
| 346 | int SetRTPKeepaliveStatus(bool enable, unsigned char unknownPayloadType, |
| 347 | int deltaTransmitTimeSeconds); |
| 348 | int GetRTPKeepaliveStatus(bool& enabled, unsigned char& unknownPayloadType, |
| 349 | int& deltaTransmitTimeSeconds); |
| 350 | int StartRTPDump(const char fileNameUTF8[1024], RTPDirections direction); |
| 351 | int StopRTPDump(RTPDirections direction); |
| 352 | bool RTPDumpIsActive(RTPDirections direction); |
| 353 | int InsertExtraRTPPacket(unsigned char payloadType, bool markerBit, |
| 354 | const char* payloadData, |
| 355 | unsigned short payloadSize); |
| 356 | |
| 357 | public: |
| 358 | // From AudioPacketizationCallback in the ACM |
| 359 | WebRtc_Word32 SendData(FrameType frameType, |
| 360 | WebRtc_UWord8 payloadType, |
| 361 | WebRtc_UWord32 timeStamp, |
| 362 | const WebRtc_UWord8* payloadData, |
| 363 | WebRtc_UWord16 payloadSize, |
| 364 | const RTPFragmentationHeader* fragmentation); |
| 365 | // From ACMVADCallback in the ACM |
| 366 | WebRtc_Word32 InFrameType(WebRtc_Word16 frameType); |
| 367 | |
| 368 | #ifdef WEBRTC_DTMF_DETECTION |
| 369 | public: // From AudioCodingFeedback in the ACM |
| 370 | int IncomingDtmf(const WebRtc_UWord8 digitDtmf, const bool end); |
| 371 | #endif |
| 372 | |
| 373 | public: |
| 374 | WebRtc_Word32 OnRxVadDetected(const int vadDecision); |
| 375 | |
| 376 | public: |
| 377 | // From RtpData in the RTP/RTCP module |
| 378 | WebRtc_Word32 OnReceivedPayloadData(const WebRtc_UWord8* payloadData, |
| 379 | const WebRtc_UWord16 payloadSize, |
| 380 | const WebRtcRTPHeader* rtpHeader); |
| 381 | |
| 382 | public: |
| 383 | // From RtpFeedback in the RTP/RTCP module |
| 384 | WebRtc_Word32 OnInitializeDecoder( |
| 385 | const WebRtc_Word32 id, |
| 386 | const WebRtc_Word8 payloadType, |
leozwang@webrtc.org | 813e4b0 | 2012-03-01 18:34:25 +0000 | [diff] [blame^] | 387 | const char payloadName[RTP_PAYLOAD_NAME_SIZE], |
xians@google.com | 0b0665a | 2011-08-08 08:18:44 +0000 | [diff] [blame] | 388 | const int frequency, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 389 | const WebRtc_UWord8 channels, |
| 390 | const WebRtc_UWord32 rate); |
| 391 | |
| 392 | void OnPacketTimeout(const WebRtc_Word32 id); |
| 393 | |
| 394 | void OnReceivedPacket(const WebRtc_Word32 id, |
| 395 | const RtpRtcpPacketType packetType); |
| 396 | |
| 397 | void OnPeriodicDeadOrAlive(const WebRtc_Word32 id, |
| 398 | const RTPAliveType alive); |
| 399 | |
| 400 | void OnIncomingSSRCChanged(const WebRtc_Word32 id, |
| 401 | const WebRtc_UWord32 SSRC); |
| 402 | |
| 403 | void OnIncomingCSRCChanged(const WebRtc_Word32 id, |
| 404 | const WebRtc_UWord32 CSRC, const bool added); |
| 405 | |
| 406 | public: |
| 407 | // From RtcpFeedback in the RTP/RTCP module |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 408 | void OnApplicationDataReceived(const WebRtc_Word32 id, |
| 409 | const WebRtc_UWord8 subType, |
| 410 | const WebRtc_UWord32 name, |
| 411 | const WebRtc_UWord16 length, |
| 412 | const WebRtc_UWord8* data); |
| 413 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 414 | public: |
| 415 | // From RtpAudioFeedback in the RTP/RTCP module |
| 416 | void OnReceivedTelephoneEvent(const WebRtc_Word32 id, |
| 417 | const WebRtc_UWord8 event, |
| 418 | const bool endOfEvent); |
| 419 | |
| 420 | void OnPlayTelephoneEvent(const WebRtc_Word32 id, |
| 421 | const WebRtc_UWord8 event, |
| 422 | const WebRtc_UWord16 lengthMs, |
| 423 | const WebRtc_UWord8 volume); |
| 424 | |
| 425 | public: |
| 426 | // From UdpTransportData in the Socket Transport module |
| 427 | void IncomingRTPPacket(const WebRtc_Word8* incomingRtpPacket, |
| 428 | const WebRtc_Word32 rtpPacketLength, |
leozwang@webrtc.org | 813e4b0 | 2012-03-01 18:34:25 +0000 | [diff] [blame^] | 429 | const char* fromIP, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 430 | const WebRtc_UWord16 fromPort); |
| 431 | |
| 432 | void IncomingRTCPPacket(const WebRtc_Word8* incomingRtcpPacket, |
| 433 | const WebRtc_Word32 rtcpPacketLength, |
leozwang@webrtc.org | 813e4b0 | 2012-03-01 18:34:25 +0000 | [diff] [blame^] | 434 | const char* fromIP, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 435 | const WebRtc_UWord16 fromPort); |
| 436 | |
| 437 | public: |
| 438 | // From Transport (called by the RTP/RTCP module) |
| 439 | int SendPacket(int /*channel*/, const void *data, int len); |
| 440 | int SendRTCPPacket(int /*channel*/, const void *data, int len); |
| 441 | |
| 442 | public: |
| 443 | // From MixerParticipant |
| 444 | WebRtc_Word32 GetAudioFrame(const WebRtc_Word32 id, |
| 445 | AudioFrame& audioFrame); |
| 446 | WebRtc_Word32 NeededFrequency(const WebRtc_Word32 id); |
| 447 | |
| 448 | public: |
| 449 | // From MonitorObserver |
| 450 | void OnPeriodicProcess(); |
| 451 | |
| 452 | public: |
| 453 | // From FileCallback |
| 454 | void PlayNotification(const WebRtc_Word32 id, |
| 455 | const WebRtc_UWord32 durationMs); |
| 456 | void RecordNotification(const WebRtc_Word32 id, |
| 457 | const WebRtc_UWord32 durationMs); |
| 458 | void PlayFileEnded(const WebRtc_Word32 id); |
| 459 | void RecordFileEnded(const WebRtc_Word32 id); |
| 460 | |
| 461 | public: |
| 462 | WebRtc_UWord32 InstanceId() const |
| 463 | { |
| 464 | return _instanceId; |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 465 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 466 | WebRtc_Word32 ChannelId() const |
| 467 | { |
| 468 | return _channelId; |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 469 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 470 | bool Playing() const |
| 471 | { |
| 472 | return _playing; |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 473 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 474 | bool Sending() const |
| 475 | { |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 476 | // A lock is needed because |_sending| is accessed by both |
| 477 | // TransmitMixer::PrepareDemux() and StartSend()/StopSend(), which |
| 478 | // are called by different threads. |
| 479 | CriticalSectionScoped cs(_callbackCritSect); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 480 | return _sending; |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 481 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 482 | bool Receiving() const |
| 483 | { |
| 484 | return _receiving; |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 485 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 486 | bool ExternalTransport() const |
| 487 | { |
| 488 | return _externalTransport; |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 489 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 490 | bool OutputIsOnHold() const |
| 491 | { |
| 492 | return _outputIsOnHold; |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 493 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 494 | bool InputIsOnHold() const |
| 495 | { |
| 496 | return _inputIsOnHold; |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 497 | } |
andrew@webrtc.org | f81f9f8 | 2011-08-19 22:56:22 +0000 | [diff] [blame] | 498 | RtpRtcp* RtpRtcpModulePtr() const |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 499 | { |
| 500 | return &_rtpRtcpModule; |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 501 | } |
andrew@webrtc.org | f81f9f8 | 2011-08-19 22:56:22 +0000 | [diff] [blame] | 502 | WebRtc_Word8 OutputEnergyLevel() const |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 503 | { |
| 504 | return _outputAudioLevel.Level(); |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 505 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 506 | #ifndef WEBRTC_EXTERNAL_TRANSPORT |
| 507 | bool SendSocketsInitialized() const |
| 508 | { |
| 509 | return _socketTransportModule.SendSocketsInitialized(); |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 510 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 511 | bool ReceiveSocketsInitialized() const |
| 512 | { |
| 513 | return _socketTransportModule.ReceiveSocketsInitialized(); |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 514 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 515 | #endif |
andrew@webrtc.org | 755b04a | 2011-11-15 16:57:56 +0000 | [diff] [blame] | 516 | WebRtc_UWord32 Demultiplex(const AudioFrame& audioFrame); |
xians@google.com | 0b0665a | 2011-08-08 08:18:44 +0000 | [diff] [blame] | 517 | WebRtc_UWord32 PrepareEncodeAndSend(int mixingFrequency); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 518 | WebRtc_UWord32 EncodeAndSend(); |
| 519 | |
| 520 | private: |
| 521 | int InsertInbandDtmfTone(); |
| 522 | WebRtc_Word32 |
xians@google.com | 0b0665a | 2011-08-08 08:18:44 +0000 | [diff] [blame] | 523 | MixOrReplaceAudioWithFile(const int mixingFrequency); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 524 | WebRtc_Word32 MixAudioWithFile(AudioFrame& audioFrame, |
xians@google.com | 0b0665a | 2011-08-08 08:18:44 +0000 | [diff] [blame] | 525 | const int mixingFrequency); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 526 | WebRtc_Word32 GetPlayoutTimeStamp(WebRtc_UWord32& playoutTimestamp); |
| 527 | void UpdateDeadOrAliveCounters(bool alive); |
| 528 | WebRtc_Word32 SendPacketRaw(const void *data, int len, bool RTCP); |
| 529 | WebRtc_Word32 UpdatePacketDelay(const WebRtc_UWord32 timestamp, |
| 530 | const WebRtc_UWord16 sequenceNumber); |
| 531 | void RegisterReceiveCodecsToRTPModule(); |
| 532 | int ApmProcessRx(AudioFrame& audioFrame); |
| 533 | |
| 534 | private: |
| 535 | CriticalSectionWrapper& _fileCritSect; |
| 536 | CriticalSectionWrapper& _callbackCritSect; |
| 537 | CriticalSectionWrapper& _transmitCritSect; |
| 538 | WebRtc_UWord32 _instanceId; |
| 539 | WebRtc_Word32 _channelId; |
| 540 | |
| 541 | private: |
| 542 | RtpRtcp& _rtpRtcpModule; |
| 543 | AudioCodingModule& _audioCodingModule; |
| 544 | #ifndef WEBRTC_EXTERNAL_TRANSPORT |
perkj@webrtc.org | 68f2168 | 2011-11-30 18:11:23 +0000 | [diff] [blame] | 545 | WebRtc_UWord8 _numSocketThreads; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 546 | UdpTransport& _socketTransportModule; |
| 547 | #endif |
| 548 | #ifdef WEBRTC_SRTP |
| 549 | SrtpModule& _srtpModule; |
| 550 | #endif |
| 551 | RtpDump& _rtpDumpIn; |
| 552 | RtpDump& _rtpDumpOut; |
| 553 | private: |
| 554 | AudioLevel _outputAudioLevel; |
| 555 | bool _externalTransport; |
| 556 | AudioFrame _audioFrame; |
| 557 | WebRtc_UWord8 _audioLevel_dBov; |
| 558 | FilePlayer* _inputFilePlayerPtr; |
| 559 | FilePlayer* _outputFilePlayerPtr; |
| 560 | FileRecorder* _outputFileRecorderPtr; |
xians@google.com | 0b0665a | 2011-08-08 08:18:44 +0000 | [diff] [blame] | 561 | int _inputFilePlayerId; |
| 562 | int _outputFilePlayerId; |
| 563 | int _outputFileRecorderId; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 564 | bool _inputFilePlaying; |
| 565 | bool _outputFilePlaying; |
| 566 | bool _outputFileRecording; |
| 567 | DtmfInbandQueue _inbandDtmfQueue; |
| 568 | DtmfInband _inbandDtmfGenerator; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 569 | bool _inputExternalMedia; |
xians@google.com | 22963ab | 2011-08-03 12:40:23 +0000 | [diff] [blame] | 570 | bool _outputExternalMedia; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 571 | VoEMediaProcess* _inputExternalMediaCallbackPtr; |
| 572 | VoEMediaProcess* _outputExternalMediaCallbackPtr; |
| 573 | WebRtc_UWord8* _encryptionRTPBufferPtr; |
| 574 | WebRtc_UWord8* _decryptionRTPBufferPtr; |
| 575 | WebRtc_UWord8* _encryptionRTCPBufferPtr; |
| 576 | WebRtc_UWord8* _decryptionRTCPBufferPtr; |
| 577 | WebRtc_UWord32 _timeStamp; |
| 578 | WebRtc_UWord8 _sendTelephoneEventPayloadType; |
| 579 | WebRtc_UWord32 _playoutTimeStampRTP; |
| 580 | WebRtc_UWord32 _playoutTimeStampRTCP; |
| 581 | WebRtc_UWord32 _numberOfDiscardedPackets; |
| 582 | private: |
| 583 | // uses |
| 584 | Statistics* _engineStatisticsPtr; |
| 585 | OutputMixer* _outputMixerPtr; |
| 586 | TransmitMixer* _transmitMixerPtr; |
| 587 | ProcessThread* _moduleProcessThreadPtr; |
| 588 | AudioDeviceModule* _audioDeviceModulePtr; |
| 589 | VoiceEngineObserver* _voiceEngineObserverPtr; // owned by base |
| 590 | CriticalSectionWrapper* _callbackCritSectPtr; // owned by base |
| 591 | Transport* _transportPtr; // WebRtc socket or external transport |
| 592 | Encryption* _encryptionPtr; // WebRtc SRTP or external encryption |
andrew@webrtc.org | 755b04a | 2011-11-15 16:57:56 +0000 | [diff] [blame] | 593 | scoped_ptr<AudioProcessing> _rtpAudioProc; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 594 | AudioProcessing* _rxAudioProcessingModulePtr; // far end AudioProcessing |
| 595 | #ifdef WEBRTC_DTMF_DETECTION |
| 596 | VoETelephoneEventObserver* _telephoneEventDetectionPtr; |
| 597 | #endif |
| 598 | VoERxVadCallback* _rxVadObserverPtr; |
| 599 | WebRtc_Word32 _oldVadDecision; |
| 600 | WebRtc_Word32 _sendFrameType; // Send data is voice, 1-voice, 0-otherwise |
| 601 | VoERTPObserver* _rtpObserverPtr; |
| 602 | VoERTCPObserver* _rtcpObserverPtr; |
| 603 | private: |
| 604 | // VoEBase |
| 605 | bool _outputIsOnHold; |
| 606 | bool _externalPlayout; |
| 607 | bool _inputIsOnHold; |
| 608 | bool _playing; |
| 609 | bool _sending; |
| 610 | bool _receiving; |
| 611 | bool _mixFileWithMicrophone; |
| 612 | bool _rtpObserver; |
| 613 | bool _rtcpObserver; |
| 614 | // VoEVolumeControl |
| 615 | bool _mute; |
| 616 | float _panLeft; |
| 617 | float _panRight; |
| 618 | float _outputGain; |
| 619 | // VoEEncryption |
| 620 | bool _encrypting; |
| 621 | bool _decrypting; |
| 622 | // VoEDtmf |
| 623 | bool _playOutbandDtmfEvent; |
| 624 | bool _playInbandDtmfEvent; |
| 625 | bool _inbandTelephoneEventDetection; |
| 626 | bool _outOfBandTelephoneEventDetecion; |
| 627 | // VoeRTP_RTCP |
| 628 | WebRtc_UWord8 _extraPayloadType; |
| 629 | bool _insertExtraRTPPacket; |
| 630 | bool _extraMarkerBit; |
| 631 | WebRtc_UWord32 _lastLocalTimeStamp; |
| 632 | WebRtc_Word8 _lastPayloadType; |
| 633 | bool _includeAudioLevelIndication; |
| 634 | // VoENetwork |
| 635 | bool _rtpPacketTimedOut; |
| 636 | bool _rtpPacketTimeOutIsEnabled; |
| 637 | WebRtc_UWord32 _rtpTimeOutSeconds; |
| 638 | bool _connectionObserver; |
| 639 | VoEConnectionObserver* _connectionObserverPtr; |
| 640 | WebRtc_UWord32 _countAliveDetections; |
| 641 | WebRtc_UWord32 _countDeadDetections; |
| 642 | AudioFrame::SpeechType _outputSpeechType; |
| 643 | // VoEVideoSync |
| 644 | WebRtc_UWord32 _averageDelayMs; |
| 645 | WebRtc_UWord16 _previousSequenceNumber; |
| 646 | WebRtc_UWord32 _previousTimestamp; |
| 647 | WebRtc_UWord16 _recPacketDelayMs; |
| 648 | // VoEAudioProcessing |
| 649 | bool _RxVadDetection; |
| 650 | bool _rxApmIsEnabled; |
| 651 | bool _rxAgcIsEnabled; |
| 652 | bool _rxNsIsEnabled; |
| 653 | }; |
| 654 | |
| 655 | } // namespace voe |
| 656 | |
| 657 | } // namespace webrtc |
| 658 | |
| 659 | #endif // WEBRTC_VOICE_ENGINE_CHANNEL_H |