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