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 |
| 205 | int GetDelayEstimate(int& delayMs) const; |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 206 | int SetInitialPlayoutDelay(int delay_ms); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 207 | int SetMinimumPlayoutDelay(int delayMs); |
| 208 | int GetPlayoutTimestamp(unsigned int& timestamp); |
| 209 | int SetInitTimestamp(unsigned int timestamp); |
| 210 | int SetInitSequenceNumber(short sequenceNumber); |
| 211 | |
| 212 | // VoEVideoSyncExtended |
| 213 | int GetRtpRtcp(RtpRtcp* &rtpRtcpModule) const; |
| 214 | |
| 215 | // VoEEncryption |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 216 | int RegisterExternalEncryption(Encryption& encryption); |
| 217 | int DeRegisterExternalEncryption(); |
| 218 | |
| 219 | // VoEDtmf |
| 220 | int SendTelephoneEventOutband(unsigned char eventCode, int lengthMs, |
| 221 | int attenuationDb, bool playDtmfEvent); |
| 222 | int SendTelephoneEventInband(unsigned char eventCode, int lengthMs, |
| 223 | int attenuationDb, bool playDtmfEvent); |
| 224 | int SetDtmfPlayoutStatus(bool enable); |
| 225 | bool DtmfPlayoutStatus() const; |
| 226 | int SetSendTelephoneEventPayloadType(unsigned char type); |
| 227 | int GetSendTelephoneEventPayloadType(unsigned char& type); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 228 | |
| 229 | // VoEAudioProcessingImpl |
| 230 | int UpdateRxVadDetection(AudioFrame& audioFrame); |
| 231 | int RegisterRxVadObserver(VoERxVadCallback &observer); |
| 232 | int DeRegisterRxVadObserver(); |
| 233 | int VoiceActivityIndicator(int &activity); |
| 234 | #ifdef WEBRTC_VOICE_ENGINE_AGC |
| 235 | int SetRxAgcStatus(const bool enable, const AgcModes mode); |
| 236 | int GetRxAgcStatus(bool& enabled, AgcModes& mode); |
| 237 | int SetRxAgcConfig(const AgcConfig config); |
| 238 | int GetRxAgcConfig(AgcConfig& config); |
| 239 | #endif |
| 240 | #ifdef WEBRTC_VOICE_ENGINE_NR |
| 241 | int SetRxNsStatus(const bool enable, const NsModes mode); |
| 242 | int GetRxNsStatus(bool& enabled, NsModes& mode); |
| 243 | #endif |
| 244 | |
| 245 | // VoERTP_RTCP |
| 246 | int RegisterRTPObserver(VoERTPObserver& observer); |
| 247 | int DeRegisterRTPObserver(); |
| 248 | int RegisterRTCPObserver(VoERTCPObserver& observer); |
| 249 | int DeRegisterRTCPObserver(); |
| 250 | int SetLocalSSRC(unsigned int ssrc); |
| 251 | int GetLocalSSRC(unsigned int& ssrc); |
| 252 | int GetRemoteSSRC(unsigned int& ssrc); |
| 253 | int GetRemoteCSRCs(unsigned int arrCSRC[15]); |
| 254 | int SetRTPAudioLevelIndicationStatus(bool enable, unsigned char ID); |
| 255 | int GetRTPAudioLevelIndicationStatus(bool& enable, unsigned char& ID); |
| 256 | int SetRTCPStatus(bool enable); |
| 257 | int GetRTCPStatus(bool& enabled); |
| 258 | int SetRTCP_CNAME(const char cName[256]); |
| 259 | int GetRTCP_CNAME(char cName[256]); |
| 260 | int GetRemoteRTCP_CNAME(char cName[256]); |
| 261 | int GetRemoteRTCPData(unsigned int& NTPHigh, unsigned int& NTPLow, |
| 262 | unsigned int& timestamp, |
| 263 | unsigned int& playoutTimestamp, unsigned int* jitter, |
| 264 | unsigned short* fractionLost); |
| 265 | int SendApplicationDefinedRTCPPacket(const unsigned char subType, |
| 266 | unsigned int name, const char* data, |
| 267 | unsigned short dataLengthInBytes); |
| 268 | int GetRTPStatistics(unsigned int& averageJitterMs, |
| 269 | unsigned int& maxJitterMs, |
| 270 | unsigned int& discardedPackets); |
henrika@webrtc.org | 8a2fc88 | 2012-08-22 08:53:55 +0000 | [diff] [blame] | 271 | int GetRemoteRTCPSenderInfo(SenderInfo* sender_info); |
| 272 | int GetRemoteRTCPReportBlocks(std::vector<ReportBlock>* report_blocks); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 273 | int GetRTPStatistics(CallStatistics& stats); |
| 274 | int SetFECStatus(bool enable, int redPayloadtype); |
| 275 | int GetFECStatus(bool& enabled, int& redPayloadtype); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 276 | int StartRTPDump(const char fileNameUTF8[1024], RTPDirections direction); |
| 277 | int StopRTPDump(RTPDirections direction); |
| 278 | bool RTPDumpIsActive(RTPDirections direction); |
| 279 | int InsertExtraRTPPacket(unsigned char payloadType, bool markerBit, |
| 280 | const char* payloadData, |
| 281 | unsigned short payloadSize); |
roosa@google.com | 0870f02 | 2012-12-12 21:31:41 +0000 | [diff] [blame] | 282 | uint32_t LastRemoteTimeStamp() { return _lastRemoteTimeStamp; } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 283 | |
| 284 | public: |
| 285 | // From AudioPacketizationCallback in the ACM |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 286 | int32_t SendData(FrameType frameType, |
| 287 | uint8_t payloadType, |
| 288 | uint32_t timeStamp, |
| 289 | const uint8_t* payloadData, |
| 290 | uint16_t payloadSize, |
| 291 | const RTPFragmentationHeader* fragmentation); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 292 | // From ACMVADCallback in the ACM |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 293 | int32_t InFrameType(int16_t frameType); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 294 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 295 | public: |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 296 | int32_t OnRxVadDetected(const int vadDecision); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 297 | |
| 298 | public: |
| 299 | // From RtpData in the RTP/RTCP module |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 300 | int32_t OnReceivedPayloadData(const uint8_t* payloadData, |
| 301 | const uint16_t payloadSize, |
| 302 | const WebRtcRTPHeader* rtpHeader); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 303 | |
| 304 | public: |
| 305 | // From RtpFeedback in the RTP/RTCP module |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 306 | int32_t OnInitializeDecoder( |
| 307 | const int32_t id, |
| 308 | const int8_t payloadType, |
leozwang@webrtc.org | 813e4b0 | 2012-03-01 18:34:25 +0000 | [diff] [blame] | 309 | const char payloadName[RTP_PAYLOAD_NAME_SIZE], |
xians@google.com | 0b0665a | 2011-08-08 08:18:44 +0000 | [diff] [blame] | 310 | const int frequency, |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 311 | const uint8_t channels, |
| 312 | const uint32_t rate); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 313 | |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 314 | void OnPacketTimeout(const int32_t id); |
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 OnReceivedPacket(const int32_t id, const RtpRtcpPacketType packetType); |
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 OnPeriodicDeadOrAlive(const int32_t id, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 319 | const RTPAliveType alive); |
| 320 | |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 321 | void OnIncomingSSRCChanged(const int32_t id, |
| 322 | const uint32_t SSRC); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 323 | |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 324 | void OnIncomingCSRCChanged(const int32_t id, |
| 325 | const uint32_t CSRC, const bool added); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 326 | |
| 327 | public: |
| 328 | // From RtcpFeedback in the RTP/RTCP module |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 329 | void OnApplicationDataReceived(const int32_t id, |
| 330 | const uint8_t subType, |
| 331 | const uint32_t name, |
| 332 | const uint16_t length, |
| 333 | const uint8_t* data); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 334 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 335 | public: |
| 336 | // From RtpAudioFeedback in the RTP/RTCP module |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 337 | void OnReceivedTelephoneEvent(const int32_t id, |
| 338 | const uint8_t event, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 339 | const bool endOfEvent); |
| 340 | |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 341 | void OnPlayTelephoneEvent(const int32_t id, |
| 342 | const uint8_t event, |
| 343 | const uint16_t lengthMs, |
| 344 | const uint8_t volume); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 345 | |
| 346 | public: |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 347 | // From Transport (called by the RTP/RTCP module) |
| 348 | int SendPacket(int /*channel*/, const void *data, int len); |
| 349 | int SendRTCPPacket(int /*channel*/, const void *data, int len); |
| 350 | |
| 351 | public: |
| 352 | // From MixerParticipant |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 353 | int32_t GetAudioFrame(const int32_t id, AudioFrame& audioFrame); |
| 354 | int32_t NeededFrequency(const int32_t id); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 355 | |
| 356 | public: |
| 357 | // From MonitorObserver |
| 358 | void OnPeriodicProcess(); |
| 359 | |
| 360 | public: |
| 361 | // From FileCallback |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 362 | void PlayNotification(const int32_t id, |
| 363 | const uint32_t durationMs); |
| 364 | void RecordNotification(const int32_t id, |
| 365 | const uint32_t durationMs); |
| 366 | void PlayFileEnded(const int32_t id); |
| 367 | void RecordFileEnded(const int32_t id); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 368 | |
| 369 | public: |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 370 | uint32_t InstanceId() const |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 371 | { |
| 372 | return _instanceId; |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 373 | } |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 374 | int32_t ChannelId() const |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 375 | { |
| 376 | return _channelId; |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 377 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 378 | bool Playing() const |
| 379 | { |
| 380 | return _playing; |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 381 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 382 | bool Sending() const |
| 383 | { |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 384 | // A lock is needed because |_sending| is accessed by both |
| 385 | // TransmitMixer::PrepareDemux() and StartSend()/StopSend(), which |
| 386 | // are called by different threads. |
mflodman@webrtc.org | 9a065d1 | 2012-03-07 08:12:21 +0000 | [diff] [blame] | 387 | CriticalSectionScoped cs(&_callbackCritSect); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 388 | return _sending; |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 389 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 390 | bool Receiving() const |
| 391 | { |
| 392 | return _receiving; |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 393 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 394 | bool ExternalTransport() const |
| 395 | { |
| 396 | return _externalTransport; |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 397 | } |
roosa@google.com | 1b60ceb | 2012-12-12 23:00:29 +0000 | [diff] [blame] | 398 | bool ExternalMixing() const |
| 399 | { |
| 400 | return _externalMixing; |
| 401 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 402 | bool OutputIsOnHold() const |
| 403 | { |
| 404 | return _outputIsOnHold; |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 405 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 406 | bool InputIsOnHold() const |
| 407 | { |
| 408 | return _inputIsOnHold; |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 409 | } |
andrew@webrtc.org | f81f9f8 | 2011-08-19 22:56:22 +0000 | [diff] [blame] | 410 | RtpRtcp* RtpRtcpModulePtr() const |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 411 | { |
pwestin@webrtc.org | 2853dde | 2012-05-11 11:08:54 +0000 | [diff] [blame] | 412 | return _rtpRtcpModule.get(); |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 413 | } |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 414 | int8_t OutputEnergyLevel() const |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 415 | { |
| 416 | return _outputAudioLevel.Level(); |
xians@webrtc.org | e07247a | 2011-11-28 16:31:28 +0000 | [diff] [blame] | 417 | } |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 418 | uint32_t Demultiplex(const AudioFrame& audioFrame); |
| 419 | uint32_t PrepareEncodeAndSend(int mixingFrequency); |
| 420 | uint32_t EncodeAndSend(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 421 | |
| 422 | private: |
| 423 | int InsertInbandDtmfTone(); |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 424 | int32_t |
xians@google.com | 0b0665a | 2011-08-08 08:18:44 +0000 | [diff] [blame] | 425 | MixOrReplaceAudioWithFile(const int mixingFrequency); |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 426 | int32_t MixAudioWithFile(AudioFrame& audioFrame, const int mixingFrequency); |
| 427 | int32_t GetPlayoutTimeStamp(uint32_t& playoutTimestamp); |
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); |
| 430 | int32_t UpdatePacketDelay(const uint32_t timestamp, |
| 431 | const 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; |
| 473 | uint32_t _playoutTimeStampRTP; |
| 474 | uint32_t _playoutTimeStampRTCP; |
| 475 | uint32_t _numberOfDiscardedPackets; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 476 | private: |
| 477 | // uses |
| 478 | Statistics* _engineStatisticsPtr; |
| 479 | OutputMixer* _outputMixerPtr; |
| 480 | TransmitMixer* _transmitMixerPtr; |
| 481 | ProcessThread* _moduleProcessThreadPtr; |
| 482 | AudioDeviceModule* _audioDeviceModulePtr; |
| 483 | VoiceEngineObserver* _voiceEngineObserverPtr; // owned by base |
| 484 | CriticalSectionWrapper* _callbackCritSectPtr; // owned by base |
| 485 | Transport* _transportPtr; // WebRtc socket or external transport |
| 486 | Encryption* _encryptionPtr; // WebRtc SRTP or external encryption |
andrew@webrtc.org | 755b04a | 2011-11-15 16:57:56 +0000 | [diff] [blame] | 487 | scoped_ptr<AudioProcessing> _rtpAudioProc; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 488 | AudioProcessing* _rxAudioProcessingModulePtr; // far end AudioProcessing |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 489 | VoERxVadCallback* _rxVadObserverPtr; |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 490 | int32_t _oldVadDecision; |
| 491 | int32_t _sendFrameType; // Send data is voice, 1-voice, 0-otherwise |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 492 | VoERTPObserver* _rtpObserverPtr; |
| 493 | VoERTCPObserver* _rtcpObserverPtr; |
| 494 | private: |
| 495 | // VoEBase |
| 496 | bool _outputIsOnHold; |
| 497 | bool _externalPlayout; |
roosa@google.com | 1b60ceb | 2012-12-12 23:00:29 +0000 | [diff] [blame] | 498 | bool _externalMixing; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 499 | bool _inputIsOnHold; |
| 500 | bool _playing; |
| 501 | bool _sending; |
| 502 | bool _receiving; |
| 503 | bool _mixFileWithMicrophone; |
| 504 | bool _rtpObserver; |
| 505 | bool _rtcpObserver; |
| 506 | // VoEVolumeControl |
| 507 | bool _mute; |
| 508 | float _panLeft; |
| 509 | float _panRight; |
| 510 | float _outputGain; |
| 511 | // VoEEncryption |
| 512 | bool _encrypting; |
| 513 | bool _decrypting; |
| 514 | // VoEDtmf |
| 515 | bool _playOutbandDtmfEvent; |
| 516 | bool _playInbandDtmfEvent; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 517 | // VoeRTP_RTCP |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 518 | uint8_t _extraPayloadType; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 519 | bool _insertExtraRTPPacket; |
| 520 | bool _extraMarkerBit; |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 521 | uint32_t _lastLocalTimeStamp; |
roosa@google.com | 0870f02 | 2012-12-12 21:31:41 +0000 | [diff] [blame] | 522 | uint32_t _lastRemoteTimeStamp; |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 523 | int8_t _lastPayloadType; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 524 | bool _includeAudioLevelIndication; |
| 525 | // VoENetwork |
| 526 | bool _rtpPacketTimedOut; |
| 527 | bool _rtpPacketTimeOutIsEnabled; |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 528 | uint32_t _rtpTimeOutSeconds; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 529 | bool _connectionObserver; |
| 530 | VoEConnectionObserver* _connectionObserverPtr; |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 531 | uint32_t _countAliveDetections; |
| 532 | uint32_t _countDeadDetections; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 533 | AudioFrame::SpeechType _outputSpeechType; |
| 534 | // VoEVideoSync |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 535 | uint32_t _averageDelayMs; |
| 536 | uint16_t _previousSequenceNumber; |
| 537 | uint32_t _previousTimestamp; |
| 538 | uint16_t _recPacketDelayMs; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 539 | // VoEAudioProcessing |
| 540 | bool _RxVadDetection; |
| 541 | bool _rxApmIsEnabled; |
| 542 | bool _rxAgcIsEnabled; |
| 543 | bool _rxNsIsEnabled; |
| 544 | }; |
| 545 | |
| 546 | } // namespace voe |
| 547 | |
| 548 | } // namespace webrtc |
| 549 | |
| 550 | #endif // WEBRTC_VOICE_ENGINE_CHANNEL_H |