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