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