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