Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: webrtc/voice_engine/channel.h

Issue 1644633005: clang-format -i -style=file webrtc/voice_engine/channel.* (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/voice_engine/channel.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 class TransportSequenceNumberProxy; 77 class TransportSequenceNumberProxy;
78 class VoERtcpObserver; 78 class VoERtcpObserver;
79 79
80 // Helper class to simplify locking scheme for members that are accessed from 80 // Helper class to simplify locking scheme for members that are accessed from
81 // multiple threads. 81 // multiple threads.
82 // Example: a member can be set on thread T1 and read by an internal audio 82 // Example: a member can be set on thread T1 and read by an internal audio
83 // thread T2. Accessing the member via this class ensures that we are 83 // thread T2. Accessing the member via this class ensures that we are
84 // safe and also avoid TSan v2 warnings. 84 // safe and also avoid TSan v2 warnings.
85 class ChannelState { 85 class ChannelState {
86 public: 86 public:
87 struct State { 87 struct State {
88 State() : rx_apm_is_enabled(false), 88 State()
89 input_external_media(false), 89 : rx_apm_is_enabled(false),
90 output_file_playing(false), 90 input_external_media(false),
91 input_file_playing(false), 91 output_file_playing(false),
92 playing(false), 92 input_file_playing(false),
93 sending(false), 93 playing(false),
94 receiving(false) {} 94 sending(false),
95 95 receiving(false) {}
96 bool rx_apm_is_enabled; 96
97 bool input_external_media; 97 bool rx_apm_is_enabled;
98 bool output_file_playing; 98 bool input_external_media;
99 bool input_file_playing; 99 bool output_file_playing;
100 bool playing; 100 bool input_file_playing;
101 bool sending; 101 bool playing;
102 bool receiving; 102 bool sending;
103 }; 103 bool receiving;
104 104 };
105 ChannelState() {} 105
106 virtual ~ChannelState() {} 106 ChannelState() {}
107 107 virtual ~ChannelState() {}
108 void Reset() { 108
109 rtc::CritScope lock(&lock_); 109 void Reset() {
110 state_ = State(); 110 rtc::CritScope lock(&lock_);
111 } 111 state_ = State();
112 112 }
113 State Get() const { 113
114 rtc::CritScope lock(&lock_); 114 State Get() const {
115 return state_; 115 rtc::CritScope lock(&lock_);
116 } 116 return state_;
117 117 }
118 void SetRxApmIsEnabled(bool enable) { 118
119 rtc::CritScope lock(&lock_); 119 void SetRxApmIsEnabled(bool enable) {
120 state_.rx_apm_is_enabled = enable; 120 rtc::CritScope lock(&lock_);
121 } 121 state_.rx_apm_is_enabled = enable;
122 122 }
123 void SetInputExternalMedia(bool enable) { 123
124 rtc::CritScope lock(&lock_); 124 void SetInputExternalMedia(bool enable) {
125 state_.input_external_media = enable; 125 rtc::CritScope lock(&lock_);
126 } 126 state_.input_external_media = enable;
127 127 }
128 void SetOutputFilePlaying(bool enable) { 128
129 rtc::CritScope lock(&lock_); 129 void SetOutputFilePlaying(bool enable) {
130 state_.output_file_playing = enable; 130 rtc::CritScope lock(&lock_);
131 } 131 state_.output_file_playing = enable;
132 132 }
133 void SetInputFilePlaying(bool enable) { 133
134 rtc::CritScope lock(&lock_); 134 void SetInputFilePlaying(bool enable) {
135 state_.input_file_playing = enable; 135 rtc::CritScope lock(&lock_);
136 } 136 state_.input_file_playing = enable;
137 137 }
138 void SetPlaying(bool enable) { 138
139 rtc::CritScope lock(&lock_); 139 void SetPlaying(bool enable) {
140 state_.playing = enable; 140 rtc::CritScope lock(&lock_);
141 } 141 state_.playing = enable;
142 142 }
143 void SetSending(bool enable) { 143
144 rtc::CritScope lock(&lock_); 144 void SetSending(bool enable) {
145 state_.sending = enable; 145 rtc::CritScope lock(&lock_);
146 } 146 state_.sending = enable;
147 147 }
148 void SetReceiving(bool enable) { 148
149 rtc::CritScope lock(&lock_); 149 void SetReceiving(bool enable) {
150 state_.receiving = enable; 150 rtc::CritScope lock(&lock_);
151 } 151 state_.receiving = enable;
152 152 }
153 private: 153
154 mutable rtc::CriticalSection lock_; 154 private:
155 State state_; 155 mutable rtc::CriticalSection lock_;
156 State state_;
156 }; 157 };
157 158
158 class Channel: 159 class Channel
159 public RtpData, 160 : public RtpData,
160 public RtpFeedback, 161 public RtpFeedback,
161 public FileCallback, // receiving notification from file player & recorder 162 public FileCallback, // receiving notification from file player &
162 public Transport, 163 // recorder
163 public RtpAudioFeedback, 164 public Transport,
164 public AudioPacketizationCallback, // receive encoded packets from the ACM 165 public RtpAudioFeedback,
165 public ACMVADCallback, // receive voice activity from the ACM 166 public AudioPacketizationCallback, // receive encoded packets from the
166 public MixerParticipant // supplies output mixer with audio frames 167 // ACM
168 public ACMVADCallback, // receive voice activity from the ACM
169 public MixerParticipant // supplies output mixer with audio frames
167 { 170 {
168 public: 171 public:
169 friend class VoERtcpObserver; 172 friend class VoERtcpObserver;
170 173
171 enum {KNumSocketThreads = 1}; 174 enum { KNumSocketThreads = 1 };
172 enum {KNumberOfSocketBuffers = 8}; 175 enum { KNumberOfSocketBuffers = 8 };
173 virtual ~Channel(); 176 virtual ~Channel();
174 static int32_t CreateChannel(Channel*& channel, 177 static int32_t CreateChannel(Channel*& channel,
175 int32_t channelId, 178 int32_t channelId,
176 uint32_t instanceId, 179 uint32_t instanceId,
177 RtcEventLog* const event_log, 180 RtcEventLog* const event_log,
178 const Config& config); 181 const Config& config);
179 Channel(int32_t channelId, 182 Channel(int32_t channelId,
180 uint32_t instanceId, 183 uint32_t instanceId,
181 RtcEventLog* const event_log, 184 RtcEventLog* const event_log,
182 const Config& config); 185 const Config& config);
183 int32_t Init(); 186 int32_t Init();
184 int32_t SetEngineInformation( 187 int32_t SetEngineInformation(Statistics& engineStatistics,
185 Statistics& engineStatistics, 188 OutputMixer& outputMixer,
186 OutputMixer& outputMixer, 189 TransmitMixer& transmitMixer,
187 TransmitMixer& transmitMixer, 190 ProcessThread& moduleProcessThread,
188 ProcessThread& moduleProcessThread, 191 AudioDeviceModule& audioDeviceModule,
189 AudioDeviceModule& audioDeviceModule, 192 VoiceEngineObserver* voiceEngineObserver,
190 VoiceEngineObserver* voiceEngineObserver, 193 rtc::CriticalSection* callbackCritSect);
191 rtc::CriticalSection* callbackCritSect); 194 int32_t UpdateLocalTimeStamp();
192 int32_t UpdateLocalTimeStamp(); 195
193 196 void SetSink(rtc::scoped_ptr<AudioSinkInterface> sink);
194 void SetSink(rtc::scoped_ptr<AudioSinkInterface> sink); 197
195 198 // API methods
196 // API methods 199
197 200 // VoEBase
198 // VoEBase 201 int32_t StartPlayout();
199 int32_t StartPlayout(); 202 int32_t StopPlayout();
200 int32_t StopPlayout(); 203 int32_t StartSend();
201 int32_t StartSend(); 204 int32_t StopSend();
202 int32_t StopSend(); 205 int32_t StartReceiving();
203 int32_t StartReceiving(); 206 int32_t StopReceiving();
204 int32_t StopReceiving(); 207
205 208 int32_t RegisterVoiceEngineObserver(VoiceEngineObserver& observer);
206 int32_t RegisterVoiceEngineObserver(VoiceEngineObserver& observer); 209 int32_t DeRegisterVoiceEngineObserver();
207 int32_t DeRegisterVoiceEngineObserver(); 210
208 211 // VoECodec
209 // VoECodec 212 int32_t GetSendCodec(CodecInst& codec);
210 int32_t GetSendCodec(CodecInst& codec); 213 int32_t GetRecCodec(CodecInst& codec);
211 int32_t GetRecCodec(CodecInst& codec); 214 int32_t SetSendCodec(const CodecInst& codec);
212 int32_t SetSendCodec(const CodecInst& codec); 215 void SetBitRate(int bitrate_bps);
213 void SetBitRate(int bitrate_bps); 216 int32_t SetVADStatus(bool enableVAD, ACMVADMode mode, bool disableDTX);
214 int32_t SetVADStatus(bool enableVAD, ACMVADMode mode, bool disableDTX); 217 int32_t GetVADStatus(bool& enabledVAD, ACMVADMode& mode, bool& disabledDTX);
215 int32_t GetVADStatus(bool& enabledVAD, ACMVADMode& mode, bool& disabledDTX); 218 int32_t SetRecPayloadType(const CodecInst& codec);
216 int32_t SetRecPayloadType(const CodecInst& codec); 219 int32_t GetRecPayloadType(CodecInst& codec);
217 int32_t GetRecPayloadType(CodecInst& codec); 220 int32_t SetSendCNPayloadType(int type, PayloadFrequencies frequency);
218 int32_t SetSendCNPayloadType(int type, PayloadFrequencies frequency); 221 int SetOpusMaxPlaybackRate(int frequency_hz);
219 int SetOpusMaxPlaybackRate(int frequency_hz); 222 int SetOpusDtx(bool enable_dtx);
220 int SetOpusDtx(bool enable_dtx); 223
221 224 // VoENetwork
222 // VoENetwork 225 int32_t RegisterExternalTransport(Transport& transport);
223 int32_t RegisterExternalTransport(Transport& transport); 226 int32_t DeRegisterExternalTransport();
224 int32_t DeRegisterExternalTransport(); 227 int32_t ReceivedRTPPacket(const int8_t* data,
225 int32_t ReceivedRTPPacket(const int8_t* data, size_t length, 228 size_t length,
226 const PacketTime& packet_time); 229 const PacketTime& packet_time);
227 int32_t ReceivedRTCPPacket(const int8_t* data, size_t length); 230 int32_t ReceivedRTCPPacket(const int8_t* data, size_t length);
228 231
229 // VoEFile 232 // VoEFile
230 int StartPlayingFileLocally(const char* fileName, bool loop, 233 int StartPlayingFileLocally(const char* fileName,
231 FileFormats format, 234 bool loop,
232 int startPosition, 235 FileFormats format,
233 float volumeScaling, 236 int startPosition,
234 int stopPosition, 237 float volumeScaling,
235 const CodecInst* codecInst); 238 int stopPosition,
236 int StartPlayingFileLocally(InStream* stream, FileFormats format, 239 const CodecInst* codecInst);
237 int startPosition, 240 int StartPlayingFileLocally(InStream* stream,
238 float volumeScaling, 241 FileFormats format,
239 int stopPosition, 242 int startPosition,
240 const CodecInst* codecInst); 243 float volumeScaling,
241 int StopPlayingFileLocally(); 244 int stopPosition,
242 int IsPlayingFileLocally() const; 245 const CodecInst* codecInst);
243 int RegisterFilePlayingToMixer(); 246 int StopPlayingFileLocally();
244 int StartPlayingFileAsMicrophone(const char* fileName, bool loop, 247 int IsPlayingFileLocally() const;
245 FileFormats format, 248 int RegisterFilePlayingToMixer();
246 int startPosition, 249 int StartPlayingFileAsMicrophone(const char* fileName,
247 float volumeScaling, 250 bool loop,
248 int stopPosition, 251 FileFormats format,
249 const CodecInst* codecInst); 252 int startPosition,
250 int StartPlayingFileAsMicrophone(InStream* stream, 253 float volumeScaling,
251 FileFormats format, 254 int stopPosition,
252 int startPosition, 255 const CodecInst* codecInst);
253 float volumeScaling, 256 int StartPlayingFileAsMicrophone(InStream* stream,
254 int stopPosition, 257 FileFormats format,
255 const CodecInst* codecInst); 258 int startPosition,
256 int StopPlayingFileAsMicrophone(); 259 float volumeScaling,
257 int IsPlayingFileAsMicrophone() const; 260 int stopPosition,
258 int StartRecordingPlayout(const char* fileName, const CodecInst* codecInst); 261 const CodecInst* codecInst);
259 int StartRecordingPlayout(OutStream* stream, const CodecInst* codecInst); 262 int StopPlayingFileAsMicrophone();
260 int StopRecordingPlayout(); 263 int IsPlayingFileAsMicrophone() const;
261 264 int StartRecordingPlayout(const char* fileName, const CodecInst* codecInst);
262 void SetMixWithMicStatus(bool mix); 265 int StartRecordingPlayout(OutStream* stream, const CodecInst* codecInst);
263 266 int StopRecordingPlayout();
264 // VoEExternalMediaProcessing 267
265 int RegisterExternalMediaProcessing(ProcessingTypes type, 268 void SetMixWithMicStatus(bool mix);
266 VoEMediaProcess& processObject); 269
267 int DeRegisterExternalMediaProcessing(ProcessingTypes type); 270 // VoEExternalMediaProcessing
268 int SetExternalMixing(bool enabled); 271 int RegisterExternalMediaProcessing(ProcessingTypes type,
269 272 VoEMediaProcess& processObject);
270 // VoEVolumeControl 273 int DeRegisterExternalMediaProcessing(ProcessingTypes type);
271 int GetSpeechOutputLevel(uint32_t& level) const; 274 int SetExternalMixing(bool enabled);
272 int GetSpeechOutputLevelFullRange(uint32_t& level) const; 275
273 int SetMute(bool enable); 276 // VoEVolumeControl
274 bool Mute() const; 277 int GetSpeechOutputLevel(uint32_t& level) const;
275 int SetOutputVolumePan(float left, float right); 278 int GetSpeechOutputLevelFullRange(uint32_t& level) const;
276 int GetOutputVolumePan(float& left, float& right) const; 279 int SetMute(bool enable);
277 int SetChannelOutputVolumeScaling(float scaling); 280 bool Mute() const;
278 int GetChannelOutputVolumeScaling(float& scaling) const; 281 int SetOutputVolumePan(float left, float right);
279 282 int GetOutputVolumePan(float& left, float& right) const;
280 // VoENetEqStats 283 int SetChannelOutputVolumeScaling(float scaling);
281 int GetNetworkStatistics(NetworkStatistics& stats); 284 int GetChannelOutputVolumeScaling(float& scaling) const;
282 void GetDecodingCallStatistics(AudioDecodingCallStats* stats) const; 285
283 286 // VoENetEqStats
284 // VoEVideoSync 287 int GetNetworkStatistics(NetworkStatistics& stats);
285 bool GetDelayEstimate(int* jitter_buffer_delay_ms, 288 void GetDecodingCallStatistics(AudioDecodingCallStats* stats) const;
286 int* playout_buffer_delay_ms) const; 289
287 uint32_t GetDelayEstimate() const; 290 // VoEVideoSync
288 int LeastRequiredDelayMs() const; 291 bool GetDelayEstimate(int* jitter_buffer_delay_ms,
289 int SetMinimumPlayoutDelay(int delayMs); 292 int* playout_buffer_delay_ms) const;
290 int GetPlayoutTimestamp(unsigned int& timestamp); 293 uint32_t GetDelayEstimate() const;
291 int SetInitTimestamp(unsigned int timestamp); 294 int LeastRequiredDelayMs() const;
292 int SetInitSequenceNumber(short sequenceNumber); 295 int SetMinimumPlayoutDelay(int delayMs);
293 296 int GetPlayoutTimestamp(unsigned int& timestamp);
294 // VoEVideoSyncExtended 297 int SetInitTimestamp(unsigned int timestamp);
295 int GetRtpRtcp(RtpRtcp** rtpRtcpModule, RtpReceiver** rtp_receiver) const; 298 int SetInitSequenceNumber(short sequenceNumber);
296 299
297 // VoEDtmf 300 // VoEVideoSyncExtended
298 int SendTelephoneEventOutband(unsigned char eventCode, int lengthMs, 301 int GetRtpRtcp(RtpRtcp** rtpRtcpModule, RtpReceiver** rtp_receiver) const;
299 int attenuationDb, bool playDtmfEvent); 302
300 int SendTelephoneEventInband(unsigned char eventCode, int lengthMs, 303 // VoEDtmf
301 int attenuationDb, bool playDtmfEvent); 304 int SendTelephoneEventOutband(unsigned char eventCode,
302 int SetSendTelephoneEventPayloadType(unsigned char type); 305 int lengthMs,
303 int GetSendTelephoneEventPayloadType(unsigned char& type); 306 int attenuationDb,
304 307 bool playDtmfEvent);
305 // VoEAudioProcessingImpl 308 int SendTelephoneEventInband(unsigned char eventCode,
306 int UpdateRxVadDetection(AudioFrame& audioFrame); 309 int lengthMs,
307 int RegisterRxVadObserver(VoERxVadCallback &observer); 310 int attenuationDb,
308 int DeRegisterRxVadObserver(); 311 bool playDtmfEvent);
309 int VoiceActivityIndicator(int &activity); 312 int SetSendTelephoneEventPayloadType(unsigned char type);
313 int GetSendTelephoneEventPayloadType(unsigned char& type);
314
315 // VoEAudioProcessingImpl
316 int UpdateRxVadDetection(AudioFrame& audioFrame);
317 int RegisterRxVadObserver(VoERxVadCallback& observer);
318 int DeRegisterRxVadObserver();
319 int VoiceActivityIndicator(int& activity);
310 #ifdef WEBRTC_VOICE_ENGINE_AGC 320 #ifdef WEBRTC_VOICE_ENGINE_AGC
311 int SetRxAgcStatus(bool enable, AgcModes mode); 321 int SetRxAgcStatus(bool enable, AgcModes mode);
312 int GetRxAgcStatus(bool& enabled, AgcModes& mode); 322 int GetRxAgcStatus(bool& enabled, AgcModes& mode);
313 int SetRxAgcConfig(AgcConfig config); 323 int SetRxAgcConfig(AgcConfig config);
314 int GetRxAgcConfig(AgcConfig& config); 324 int GetRxAgcConfig(AgcConfig& config);
315 #endif 325 #endif
316 #ifdef WEBRTC_VOICE_ENGINE_NR 326 #ifdef WEBRTC_VOICE_ENGINE_NR
317 int SetRxNsStatus(bool enable, NsModes mode); 327 int SetRxNsStatus(bool enable, NsModes mode);
318 int GetRxNsStatus(bool& enabled, NsModes& mode); 328 int GetRxNsStatus(bool& enabled, NsModes& mode);
319 #endif 329 #endif
320 330
321 // VoERTP_RTCP 331 // VoERTP_RTCP
322 int SetLocalSSRC(unsigned int ssrc); 332 int SetLocalSSRC(unsigned int ssrc);
323 int GetLocalSSRC(unsigned int& ssrc); 333 int GetLocalSSRC(unsigned int& ssrc);
324 int GetRemoteSSRC(unsigned int& ssrc); 334 int GetRemoteSSRC(unsigned int& ssrc);
325 int SetSendAudioLevelIndicationStatus(bool enable, unsigned char id); 335 int SetSendAudioLevelIndicationStatus(bool enable, unsigned char id);
326 int SetReceiveAudioLevelIndicationStatus(bool enable, unsigned char id); 336 int SetReceiveAudioLevelIndicationStatus(bool enable, unsigned char id);
327 int SetSendAbsoluteSenderTimeStatus(bool enable, unsigned char id); 337 int SetSendAbsoluteSenderTimeStatus(bool enable, unsigned char id);
328 int SetReceiveAbsoluteSenderTimeStatus(bool enable, unsigned char id); 338 int SetReceiveAbsoluteSenderTimeStatus(bool enable, unsigned char id);
329 void EnableSendTransportSequenceNumber(int id); 339 void EnableSendTransportSequenceNumber(int id);
330 void EnableReceiveTransportSequenceNumber(int id); 340 void EnableReceiveTransportSequenceNumber(int id);
331 341
332 void SetCongestionControlObjects( 342 void SetCongestionControlObjects(
333 RtpPacketSender* rtp_packet_sender, 343 RtpPacketSender* rtp_packet_sender,
334 TransportFeedbackObserver* transport_feedback_observer, 344 TransportFeedbackObserver* transport_feedback_observer,
335 PacketRouter* packet_router); 345 PacketRouter* packet_router);
336 346
337 void SetRTCPStatus(bool enable); 347 void SetRTCPStatus(bool enable);
338 int GetRTCPStatus(bool& enabled); 348 int GetRTCPStatus(bool& enabled);
339 int SetRTCP_CNAME(const char cName[256]); 349 int SetRTCP_CNAME(const char cName[256]);
340 int GetRemoteRTCP_CNAME(char cName[256]); 350 int GetRemoteRTCP_CNAME(char cName[256]);
341 int GetRemoteRTCPData(unsigned int& NTPHigh, unsigned int& NTPLow, 351 int GetRemoteRTCPData(unsigned int& NTPHigh,
342 unsigned int& timestamp, 352 unsigned int& NTPLow,
343 unsigned int& playoutTimestamp, unsigned int* jitter, 353 unsigned int& timestamp,
344 unsigned short* fractionLost); 354 unsigned int& playoutTimestamp,
345 int SendApplicationDefinedRTCPPacket(unsigned char subType, 355 unsigned int* jitter,
346 unsigned int name, const char* data, 356 unsigned short* fractionLost);
347 unsigned short dataLengthInBytes); 357 int SendApplicationDefinedRTCPPacket(unsigned char subType,
348 int GetRTPStatistics(unsigned int& averageJitterMs, 358 unsigned int name,
349 unsigned int& maxJitterMs, 359 const char* data,
350 unsigned int& discardedPackets); 360 unsigned short dataLengthInBytes);
351 int GetRemoteRTCPReportBlocks(std::vector<ReportBlock>* report_blocks); 361 int GetRTPStatistics(unsigned int& averageJitterMs,
352 int GetRTPStatistics(CallStatistics& stats); 362 unsigned int& maxJitterMs,
353 int SetREDStatus(bool enable, int redPayloadtype); 363 unsigned int& discardedPackets);
354 int GetREDStatus(bool& enabled, int& redPayloadtype); 364 int GetRemoteRTCPReportBlocks(std::vector<ReportBlock>* report_blocks);
355 int SetCodecFECStatus(bool enable); 365 int GetRTPStatistics(CallStatistics& stats);
356 bool GetCodecFECStatus(); 366 int SetREDStatus(bool enable, int redPayloadtype);
357 void SetNACKStatus(bool enable, int maxNumberOfPackets); 367 int GetREDStatus(bool& enabled, int& redPayloadtype);
358 368 int SetCodecFECStatus(bool enable);
359 // From AudioPacketizationCallback in the ACM 369 bool GetCodecFECStatus();
360 int32_t SendData(FrameType frameType, 370 void SetNACKStatus(bool enable, int maxNumberOfPackets);
361 uint8_t payloadType, 371
362 uint32_t timeStamp, 372 // From AudioPacketizationCallback in the ACM
363 const uint8_t* payloadData, 373 int32_t SendData(FrameType frameType,
364 size_t payloadSize, 374 uint8_t payloadType,
365 const RTPFragmentationHeader* fragmentation) override; 375 uint32_t timeStamp,
366 376 const uint8_t* payloadData,
367 // From ACMVADCallback in the ACM 377 size_t payloadSize,
368 int32_t InFrameType(FrameType frame_type) override; 378 const RTPFragmentationHeader* fragmentation) override;
369 379
370 int32_t OnRxVadDetected(int vadDecision); 380 // From ACMVADCallback in the ACM
371 381 int32_t InFrameType(FrameType frame_type) override;
372 // From RtpData in the RTP/RTCP module 382
373 int32_t OnReceivedPayloadData(const uint8_t* payloadData, 383 int32_t OnRxVadDetected(int vadDecision);
374 size_t payloadSize, 384
375 const WebRtcRTPHeader* rtpHeader) override; 385 // From RtpData in the RTP/RTCP module
376 bool OnRecoveredPacket(const uint8_t* packet, 386 int32_t OnReceivedPayloadData(const uint8_t* payloadData,
377 size_t packet_length) override; 387 size_t payloadSize,
378 388 const WebRtcRTPHeader* rtpHeader) override;
379 // From RtpFeedback in the RTP/RTCP module 389 bool OnRecoveredPacket(const uint8_t* packet, size_t packet_length) override;
380 int32_t OnInitializeDecoder(int8_t payloadType, 390
381 const char payloadName[RTP_PAYLOAD_NAME_SIZE], 391 // From RtpFeedback in the RTP/RTCP module
382 int frequency, 392 int32_t OnInitializeDecoder(int8_t payloadType,
383 size_t channels, 393 const char payloadName[RTP_PAYLOAD_NAME_SIZE],
384 uint32_t rate) override; 394 int frequency,
385 void OnIncomingSSRCChanged(uint32_t ssrc) override; 395 size_t channels,
386 void OnIncomingCSRCChanged(uint32_t CSRC, bool added) override; 396 uint32_t rate) override;
387 397 void OnIncomingSSRCChanged(uint32_t ssrc) override;
388 // From RtpAudioFeedback in the RTP/RTCP module 398 void OnIncomingCSRCChanged(uint32_t CSRC, bool added) override;
389 void OnPlayTelephoneEvent(uint8_t event, 399
390 uint16_t lengthMs, 400 // From RtpAudioFeedback in the RTP/RTCP module
391 uint8_t volume) override; 401 void OnPlayTelephoneEvent(uint8_t event,
392 402 uint16_t lengthMs,
393 // From Transport (called by the RTP/RTCP module) 403 uint8_t volume) override;
394 bool SendRtp(const uint8_t* data, 404
395 size_t len, 405 // From Transport (called by the RTP/RTCP module)
396 const PacketOptions& packet_options) override; 406 bool SendRtp(const uint8_t* data,
397 bool SendRtcp(const uint8_t* data, size_t len) override; 407 size_t len,
398 408 const PacketOptions& packet_options) override;
399 // From MixerParticipant 409 bool SendRtcp(const uint8_t* data, size_t len) override;
400 int32_t GetAudioFrame(int32_t id, AudioFrame* audioFrame) override; 410
401 int32_t NeededFrequency(int32_t id) const override; 411 // From MixerParticipant
402 412 int32_t GetAudioFrame(int32_t id, AudioFrame* audioFrame) override;
403 // From FileCallback 413 int32_t NeededFrequency(int32_t id) const override;
404 void PlayNotification(int32_t id, uint32_t durationMs) override; 414
405 void RecordNotification(int32_t id, uint32_t durationMs) override; 415 // From FileCallback
406 void PlayFileEnded(int32_t id) override; 416 void PlayNotification(int32_t id, uint32_t durationMs) override;
407 void RecordFileEnded(int32_t id) override; 417 void RecordNotification(int32_t id, uint32_t durationMs) override;
408 418 void PlayFileEnded(int32_t id) override;
409 uint32_t InstanceId() const 419 void RecordFileEnded(int32_t id) override;
410 { 420
411 return _instanceId; 421 uint32_t InstanceId() const { return _instanceId; }
412 } 422 int32_t ChannelId() const { return _channelId; }
413 int32_t ChannelId() const 423 bool Playing() const { return channel_state_.Get().playing; }
414 { 424 bool Sending() const { return channel_state_.Get().sending; }
415 return _channelId; 425 bool Receiving() const { return channel_state_.Get().receiving; }
416 } 426 bool ExternalTransport() const {
417 bool Playing() const 427 rtc::CritScope cs(&_callbackCritSect);
418 { 428 return _externalTransport;
419 return channel_state_.Get().playing; 429 }
420 } 430 bool ExternalMixing() const { return _externalMixing; }
421 bool Sending() const 431 RtpRtcp* RtpRtcpModulePtr() const { return _rtpRtcpModule.get(); }
422 { 432 int8_t OutputEnergyLevel() const { return _outputAudioLevel.Level(); }
423 return channel_state_.Get().sending; 433 uint32_t Demultiplex(const AudioFrame& audioFrame);
424 } 434 // Demultiplex the data to the channel's |_audioFrame|. The difference
425 bool Receiving() const 435 // between this method and the overloaded method above is that |audio_data|
426 { 436 // does not go through transmit_mixer and APM.
427 return channel_state_.Get().receiving; 437 void Demultiplex(const int16_t* audio_data,
428 } 438 int sample_rate,
429 bool ExternalTransport() const 439 size_t number_of_frames,
430 { 440 size_t number_of_channels);
431 rtc::CritScope cs(&_callbackCritSect); 441 uint32_t PrepareEncodeAndSend(int mixingFrequency);
432 return _externalTransport; 442 uint32_t EncodeAndSend();
433 } 443
434 bool ExternalMixing() const 444 // Associate to a send channel.
435 { 445 // Used for obtaining RTT for a receive-only channel.
436 return _externalMixing; 446 void set_associate_send_channel(const ChannelOwner& channel) {
437 } 447 assert(_channelId != channel.channel()->ChannelId());
438 RtpRtcp* RtpRtcpModulePtr() const 448 rtc::CritScope lock(&assoc_send_channel_lock_);
439 { 449 associate_send_channel_ = channel;
440 return _rtpRtcpModule.get(); 450 }
441 } 451
442 int8_t OutputEnergyLevel() const 452 // Disassociate a send channel if it was associated.
443 { 453 void DisassociateSendChannel(int channel_id);
444 return _outputAudioLevel.Level(); 454
445 } 455 protected:
446 uint32_t Demultiplex(const AudioFrame& audioFrame); 456 void OnIncomingFractionLoss(int fraction_lost);
447 // Demultiplex the data to the channel's |_audioFrame|. The difference 457
448 // between this method and the overloaded method above is that |audio_data| 458 private:
449 // does not go through transmit_mixer and APM. 459 bool ReceivePacket(const uint8_t* packet,
450 void Demultiplex(const int16_t* audio_data, 460 size_t packet_length,
451 int sample_rate, 461 const RTPHeader& header,
452 size_t number_of_frames, 462 bool in_order);
453 size_t number_of_channels); 463 bool HandleRtxPacket(const uint8_t* packet,
454 uint32_t PrepareEncodeAndSend(int mixingFrequency); 464 size_t packet_length,
455 uint32_t EncodeAndSend(); 465 const RTPHeader& header);
456 466 bool IsPacketInOrder(const RTPHeader& header) const;
457 // Associate to a send channel. 467 bool IsPacketRetransmitted(const RTPHeader& header, bool in_order) const;
458 // Used for obtaining RTT for a receive-only channel. 468 int ResendPackets(const uint16_t* sequence_numbers, int length);
459 void set_associate_send_channel(const ChannelOwner& channel) { 469 int InsertInbandDtmfTone();
460 assert(_channelId != channel.channel()->ChannelId()); 470 int32_t MixOrReplaceAudioWithFile(int mixingFrequency);
461 rtc::CritScope lock(&assoc_send_channel_lock_); 471 int32_t MixAudioWithFile(AudioFrame& audioFrame, int mixingFrequency);
462 associate_send_channel_ = channel; 472 void UpdatePlayoutTimestamp(bool rtcp);
463 } 473 void UpdatePacketDelay(uint32_t timestamp, uint16_t sequenceNumber);
464 474 void RegisterReceiveCodecsToRTPModule();
465 // Disassociate a send channel if it was associated. 475
466 void DisassociateSendChannel(int channel_id); 476 int SetRedPayloadType(int red_payload_type);
467 477 int SetSendRtpHeaderExtension(bool enable,
468 protected: 478 RTPExtensionType type,
469 void OnIncomingFractionLoss(int fraction_lost); 479 unsigned char id);
470 480
471 private: 481 int32_t GetPlayoutFrequency();
472 bool ReceivePacket(const uint8_t* packet, size_t packet_length, 482 int64_t GetRTT(bool allow_associate_channel) const;
473 const RTPHeader& header, bool in_order); 483
474 bool HandleRtxPacket(const uint8_t* packet, 484 mutable rtc::CriticalSection _fileCritSect;
475 size_t packet_length, 485 mutable rtc::CriticalSection _callbackCritSect;
476 const RTPHeader& header); 486 mutable rtc::CriticalSection volume_settings_critsect_;
477 bool IsPacketInOrder(const RTPHeader& header) const; 487 uint32_t _instanceId;
478 bool IsPacketRetransmitted(const RTPHeader& header, bool in_order) const; 488 int32_t _channelId;
479 int ResendPackets(const uint16_t* sequence_numbers, int length); 489
480 int InsertInbandDtmfTone(); 490 ChannelState channel_state_;
481 int32_t MixOrReplaceAudioWithFile(int mixingFrequency); 491
482 int32_t MixAudioWithFile(AudioFrame& audioFrame, int mixingFrequency); 492 RtcEventLog* const event_log_;
483 void UpdatePlayoutTimestamp(bool rtcp); 493
484 void UpdatePacketDelay(uint32_t timestamp, 494 rtc::scoped_ptr<RtpHeaderParser> rtp_header_parser_;
485 uint16_t sequenceNumber); 495 rtc::scoped_ptr<RTPPayloadRegistry> rtp_payload_registry_;
486 void RegisterReceiveCodecsToRTPModule(); 496 rtc::scoped_ptr<ReceiveStatistics> rtp_receive_statistics_;
487 497 rtc::scoped_ptr<StatisticsProxy> statistics_proxy_;
488 int SetRedPayloadType(int red_payload_type); 498 rtc::scoped_ptr<RtpReceiver> rtp_receiver_;
489 int SetSendRtpHeaderExtension(bool enable, RTPExtensionType type, 499 TelephoneEventHandler* telephone_event_handler_;
490 unsigned char id); 500 rtc::scoped_ptr<RtpRtcp> _rtpRtcpModule;
491 501 rtc::scoped_ptr<AudioCodingModule> audio_coding_;
492 int32_t GetPlayoutFrequency(); 502 rtc::scoped_ptr<AudioSinkInterface> audio_sink_;
493 int64_t GetRTT(bool allow_associate_channel) const; 503 AudioLevel _outputAudioLevel;
494 504 bool _externalTransport;
495 mutable rtc::CriticalSection _fileCritSect; 505 AudioFrame _audioFrame;
496 mutable rtc::CriticalSection _callbackCritSect; 506 // Downsamples to the codec rate if necessary.
497 mutable rtc::CriticalSection volume_settings_critsect_; 507 PushResampler<int16_t> input_resampler_;
498 uint32_t _instanceId; 508 FilePlayer* _inputFilePlayerPtr;
499 int32_t _channelId; 509 FilePlayer* _outputFilePlayerPtr;
500 510 FileRecorder* _outputFileRecorderPtr;
501 ChannelState channel_state_; 511 int _inputFilePlayerId;
502 512 int _outputFilePlayerId;
503 RtcEventLog* const event_log_; 513 int _outputFileRecorderId;
504 514 bool _outputFileRecording;
505 rtc::scoped_ptr<RtpHeaderParser> rtp_header_parser_; 515 DtmfInbandQueue _inbandDtmfQueue;
506 rtc::scoped_ptr<RTPPayloadRegistry> rtp_payload_registry_; 516 DtmfInband _inbandDtmfGenerator;
507 rtc::scoped_ptr<ReceiveStatistics> rtp_receive_statistics_; 517 bool _outputExternalMedia;
508 rtc::scoped_ptr<StatisticsProxy> statistics_proxy_; 518 VoEMediaProcess* _inputExternalMediaCallbackPtr;
509 rtc::scoped_ptr<RtpReceiver> rtp_receiver_; 519 VoEMediaProcess* _outputExternalMediaCallbackPtr;
510 TelephoneEventHandler* telephone_event_handler_; 520 uint32_t _timeStamp;
511 rtc::scoped_ptr<RtpRtcp> _rtpRtcpModule; 521 uint8_t _sendTelephoneEventPayloadType;
512 rtc::scoped_ptr<AudioCodingModule> audio_coding_; 522
513 rtc::scoped_ptr<AudioSinkInterface> audio_sink_; 523 RemoteNtpTimeEstimator ntp_estimator_ GUARDED_BY(ts_stats_lock_);
514 AudioLevel _outputAudioLevel; 524
515 bool _externalTransport; 525 // Timestamp of the audio pulled from NetEq.
516 AudioFrame _audioFrame; 526 uint32_t jitter_buffer_playout_timestamp_;
517 // Downsamples to the codec rate if necessary. 527 uint32_t playout_timestamp_rtp_ GUARDED_BY(video_sync_lock_);
518 PushResampler<int16_t> input_resampler_; 528 uint32_t playout_timestamp_rtcp_;
519 FilePlayer* _inputFilePlayerPtr; 529 uint32_t playout_delay_ms_ GUARDED_BY(video_sync_lock_);
520 FilePlayer* _outputFilePlayerPtr; 530 uint32_t _numberOfDiscardedPackets;
521 FileRecorder* _outputFileRecorderPtr; 531 uint16_t send_sequence_number_;
522 int _inputFilePlayerId; 532 uint8_t restored_packet_[kVoiceEngineMaxIpPacketSizeBytes];
523 int _outputFilePlayerId; 533
524 int _outputFileRecorderId; 534 mutable rtc::CriticalSection ts_stats_lock_;
525 bool _outputFileRecording; 535
526 DtmfInbandQueue _inbandDtmfQueue; 536 rtc::scoped_ptr<rtc::TimestampWrapAroundHandler> rtp_ts_wraparound_handler_;
527 DtmfInband _inbandDtmfGenerator; 537 // The rtp timestamp of the first played out audio frame.
528 bool _outputExternalMedia; 538 int64_t capture_start_rtp_time_stamp_;
529 VoEMediaProcess* _inputExternalMediaCallbackPtr; 539 // The capture ntp time (in local timebase) of the first played out audio
530 VoEMediaProcess* _outputExternalMediaCallbackPtr; 540 // frame.
531 uint32_t _timeStamp; 541 int64_t capture_start_ntp_time_ms_ GUARDED_BY(ts_stats_lock_);
532 uint8_t _sendTelephoneEventPayloadType; 542
533 543 // uses
534 RemoteNtpTimeEstimator ntp_estimator_ GUARDED_BY(ts_stats_lock_); 544 Statistics* _engineStatisticsPtr;
535 545 OutputMixer* _outputMixerPtr;
536 // Timestamp of the audio pulled from NetEq. 546 TransmitMixer* _transmitMixerPtr;
537 uint32_t jitter_buffer_playout_timestamp_; 547 ProcessThread* _moduleProcessThreadPtr;
538 uint32_t playout_timestamp_rtp_ GUARDED_BY(video_sync_lock_); 548 AudioDeviceModule* _audioDeviceModulePtr;
539 uint32_t playout_timestamp_rtcp_; 549 VoiceEngineObserver* _voiceEngineObserverPtr; // owned by base
540 uint32_t playout_delay_ms_ GUARDED_BY(video_sync_lock_); 550 rtc::CriticalSection* _callbackCritSectPtr; // owned by base
541 uint32_t _numberOfDiscardedPackets; 551 Transport* _transportPtr; // WebRtc socket or external transport
542 uint16_t send_sequence_number_; 552 RMSLevel rms_level_;
543 uint8_t restored_packet_[kVoiceEngineMaxIpPacketSizeBytes]; 553 rtc::scoped_ptr<AudioProcessing> rx_audioproc_; // far end AudioProcessing
544 554 VoERxVadCallback* _rxVadObserverPtr;
545 mutable rtc::CriticalSection ts_stats_lock_; 555 int32_t _oldVadDecision;
546 556 int32_t _sendFrameType; // Send data is voice, 1-voice, 0-otherwise
547 rtc::scoped_ptr<rtc::TimestampWrapAroundHandler> rtp_ts_wraparound_handler_; 557 // VoEBase
548 // The rtp timestamp of the first played out audio frame. 558 bool _externalMixing;
549 int64_t capture_start_rtp_time_stamp_; 559 bool _mixFileWithMicrophone;
550 // The capture ntp time (in local timebase) of the first played out audio 560 // VoEVolumeControl
551 // frame. 561 bool _mute;
552 int64_t capture_start_ntp_time_ms_ GUARDED_BY(ts_stats_lock_); 562 float _panLeft;
553 563 float _panRight;
554 // uses 564 float _outputGain;
555 Statistics* _engineStatisticsPtr; 565 // VoEDtmf
556 OutputMixer* _outputMixerPtr; 566 bool _playOutbandDtmfEvent;
557 TransmitMixer* _transmitMixerPtr; 567 bool _playInbandDtmfEvent;
558 ProcessThread* _moduleProcessThreadPtr; 568 // VoeRTP_RTCP
559 AudioDeviceModule* _audioDeviceModulePtr; 569 uint32_t _lastLocalTimeStamp;
560 VoiceEngineObserver* _voiceEngineObserverPtr; // owned by base 570 int8_t _lastPayloadType;
561 rtc::CriticalSection* _callbackCritSectPtr; // owned by base 571 bool _includeAudioLevelIndication;
562 Transport* _transportPtr; // WebRtc socket or external transport 572 // VoENetwork
563 RMSLevel rms_level_; 573 AudioFrame::SpeechType _outputSpeechType;
564 rtc::scoped_ptr<AudioProcessing> rx_audioproc_; // far end AudioProcessing 574 // VoEVideoSync
565 VoERxVadCallback* _rxVadObserverPtr; 575 mutable rtc::CriticalSection video_sync_lock_;
566 int32_t _oldVadDecision; 576 uint32_t _average_jitter_buffer_delay_us GUARDED_BY(video_sync_lock_);
567 int32_t _sendFrameType; // Send data is voice, 1-voice, 0-otherwise 577 uint32_t _previousTimestamp;
568 // VoEBase 578 uint16_t _recPacketDelayMs GUARDED_BY(video_sync_lock_);
569 bool _externalMixing; 579 // VoEAudioProcessing
570 bool _mixFileWithMicrophone; 580 bool _RxVadDetection;
571 // VoEVolumeControl 581 bool _rxAgcIsEnabled;
572 bool _mute; 582 bool _rxNsIsEnabled;
573 float _panLeft; 583 bool restored_packet_in_use_;
574 float _panRight; 584 // RtcpBandwidthObserver
575 float _outputGain; 585 rtc::scoped_ptr<VoERtcpObserver> rtcp_observer_;
576 // VoEDtmf 586 rtc::scoped_ptr<NetworkPredictor> network_predictor_;
577 bool _playOutbandDtmfEvent; 587 // An associated send channel.
578 bool _playInbandDtmfEvent; 588 mutable rtc::CriticalSection assoc_send_channel_lock_;
579 // VoeRTP_RTCP 589 ChannelOwner associate_send_channel_ GUARDED_BY(assoc_send_channel_lock_);
580 uint32_t _lastLocalTimeStamp; 590
581 int8_t _lastPayloadType; 591 bool pacing_enabled_;
582 bool _includeAudioLevelIndication; 592 PacketRouter* packet_router_ = nullptr;
583 // VoENetwork 593 rtc::scoped_ptr<TransportFeedbackProxy> feedback_observer_proxy_;
584 AudioFrame::SpeechType _outputSpeechType; 594 rtc::scoped_ptr<TransportSequenceNumberProxy> seq_num_allocator_proxy_;
585 // VoEVideoSync 595 rtc::scoped_ptr<RtpPacketSenderProxy> rtp_packet_sender_proxy_;
586 mutable rtc::CriticalSection video_sync_lock_;
587 uint32_t _average_jitter_buffer_delay_us GUARDED_BY(video_sync_lock_);
588 uint32_t _previousTimestamp;
589 uint16_t _recPacketDelayMs GUARDED_BY(video_sync_lock_);
590 // VoEAudioProcessing
591 bool _RxVadDetection;
592 bool _rxAgcIsEnabled;
593 bool _rxNsIsEnabled;
594 bool restored_packet_in_use_;
595 // RtcpBandwidthObserver
596 rtc::scoped_ptr<VoERtcpObserver> rtcp_observer_;
597 rtc::scoped_ptr<NetworkPredictor> network_predictor_;
598 // An associated send channel.
599 mutable rtc::CriticalSection assoc_send_channel_lock_;
600 ChannelOwner associate_send_channel_ GUARDED_BY(assoc_send_channel_lock_);
601
602 bool pacing_enabled_;
603 PacketRouter* packet_router_ = nullptr;
604 rtc::scoped_ptr<TransportFeedbackProxy> feedback_observer_proxy_;
605 rtc::scoped_ptr<TransportSequenceNumberProxy> seq_num_allocator_proxy_;
606 rtc::scoped_ptr<RtpPacketSenderProxy> rtp_packet_sender_proxy_;
607 }; 596 };
608 597
609 } // namespace voe 598 } // namespace voe
610 } // namespace webrtc 599 } // namespace webrtc
611 600
612 #endif // WEBRTC_VOICE_ENGINE_CHANNEL_H_ 601 #endif // WEBRTC_VOICE_ENGINE_CHANNEL_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/voice_engine/channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698