OLD | NEW |
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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 CriticalSectionScoped cs(&_callbackCritSect); | 210 CriticalSectionScoped cs(&_callbackCritSect); |
211 if (_rxVadObserverPtr) | 211 if (_rxVadObserverPtr) |
212 { | 212 { |
213 _rxVadObserverPtr->OnRxVad(_channelId, vadDecision); | 213 _rxVadObserverPtr->OnRxVad(_channelId, vadDecision); |
214 } | 214 } |
215 | 215 |
216 return 0; | 216 return 0; |
217 } | 217 } |
218 | 218 |
219 int | 219 int |
220 Channel::SendPacket(int channel, const void *data, size_t len) | 220 Channel::SendPacket(const void *data, size_t len) |
221 { | 221 { |
222 channel = VoEChannelId(channel); | |
223 assert(channel == _channelId); | |
224 | |
225 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId), | 222 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId), |
226 "Channel::SendPacket(channel=%d, len=%" PRIuS ")", channel, | 223 "Channel::SendPacket(channel=%d, len=%" PRIuS ")", len); |
227 len); | |
228 | 224 |
229 CriticalSectionScoped cs(&_callbackCritSect); | 225 CriticalSectionScoped cs(&_callbackCritSect); |
230 | 226 |
231 if (_transportPtr == NULL) | 227 if (_transportPtr == NULL) |
232 { | 228 { |
233 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,_channelId), | 229 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,_channelId), |
234 "Channel::SendPacket() failed to send RTP packet due to" | 230 "Channel::SendPacket() failed to send RTP packet due to" |
235 " invalid transport object"); | 231 " invalid transport object"); |
236 return -1; | 232 return -1; |
237 } | 233 } |
238 | 234 |
239 uint8_t* bufferToSendPtr = (uint8_t*)data; | 235 uint8_t* bufferToSendPtr = (uint8_t*)data; |
240 size_t bufferLength = len; | 236 size_t bufferLength = len; |
241 | 237 |
242 int n = _transportPtr->SendPacket(channel, bufferToSendPtr, | 238 int n = _transportPtr->SendPacket(bufferToSendPtr, bufferLength); |
243 bufferLength); | |
244 if (n < 0) { | 239 if (n < 0) { |
245 std::string transport_name = | 240 std::string transport_name = |
246 _externalTransport ? "external transport" : "WebRtc sockets"; | 241 _externalTransport ? "external transport" : "WebRtc sockets"; |
247 WEBRTC_TRACE(kTraceError, kTraceVoice, | 242 WEBRTC_TRACE(kTraceError, kTraceVoice, |
248 VoEId(_instanceId,_channelId), | 243 VoEId(_instanceId,_channelId), |
249 "Channel::SendPacket() RTP transmission using %s failed", | 244 "Channel::SendPacket() RTP transmission using %s failed", |
250 transport_name.c_str()); | 245 transport_name.c_str()); |
251 return -1; | 246 return -1; |
252 } | 247 } |
253 return n; | 248 return n; |
254 } | 249 } |
255 | 250 |
256 int | 251 int |
257 Channel::SendRTCPPacket(int channel, const void *data, size_t len) | 252 Channel::SendRTCPPacket(const void *data, size_t len) |
258 { | 253 { |
259 channel = VoEChannelId(channel); | |
260 assert(channel == _channelId); | |
261 | |
262 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId), | 254 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId), |
263 "Channel::SendRTCPPacket(channel=%d, len=%" PRIuS ")", channel, | 255 "Channel::SendRTCPPacket(len=%" PRIuS ")", len); |
264 len); | |
265 | 256 |
266 CriticalSectionScoped cs(&_callbackCritSect); | 257 CriticalSectionScoped cs(&_callbackCritSect); |
267 if (_transportPtr == NULL) | 258 if (_transportPtr == NULL) |
268 { | 259 { |
269 WEBRTC_TRACE(kTraceError, kTraceVoice, | 260 WEBRTC_TRACE(kTraceError, kTraceVoice, |
270 VoEId(_instanceId,_channelId), | 261 VoEId(_instanceId,_channelId), |
271 "Channel::SendRTCPPacket() failed to send RTCP packet" | 262 "Channel::SendRTCPPacket() failed to send RTCP packet" |
272 " due to invalid transport object"); | 263 " due to invalid transport object"); |
273 return -1; | 264 return -1; |
274 } | 265 } |
275 | 266 |
276 uint8_t* bufferToSendPtr = (uint8_t*)data; | 267 uint8_t* bufferToSendPtr = (uint8_t*)data; |
277 size_t bufferLength = len; | 268 size_t bufferLength = len; |
278 | 269 |
279 int n = _transportPtr->SendRTCPPacket(channel, | 270 int n = _transportPtr->SendRTCPPacket(bufferToSendPtr, bufferLength); |
280 bufferToSendPtr, | |
281 bufferLength); | |
282 if (n < 0) { | 271 if (n < 0) { |
283 std::string transport_name = | 272 std::string transport_name = |
284 _externalTransport ? "external transport" : "WebRtc sockets"; | 273 _externalTransport ? "external transport" : "WebRtc sockets"; |
285 WEBRTC_TRACE(kTraceInfo, kTraceVoice, | 274 WEBRTC_TRACE(kTraceInfo, kTraceVoice, |
286 VoEId(_instanceId,_channelId), | 275 VoEId(_instanceId,_channelId), |
287 "Channel::SendRTCPPacket() transmission using %s failed", | 276 "Channel::SendRTCPPacket() transmission using %s failed", |
288 transport_name.c_str()); | 277 transport_name.c_str()); |
289 return -1; | 278 return -1; |
290 } | 279 } |
291 return n; | 280 return n; |
292 } | 281 } |
293 | 282 |
294 void | 283 void Channel::OnPlayTelephoneEvent(uint8_t event, |
295 Channel::OnPlayTelephoneEvent(int32_t id, | 284 uint16_t lengthMs, |
296 uint8_t event, | 285 uint8_t volume) { |
297 uint16_t lengthMs, | |
298 uint8_t volume) | |
299 { | |
300 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId), | 286 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId), |
301 "Channel::OnPlayTelephoneEvent(id=%d, event=%u, lengthMs=%u," | 287 "Channel::OnPlayTelephoneEvent(event=%u, lengthMs=%u," |
302 " volume=%u)", id, event, lengthMs, volume); | 288 " volume=%u)", event, lengthMs, volume); |
303 | 289 |
304 if (!_playOutbandDtmfEvent || (event > 15)) | 290 if (!_playOutbandDtmfEvent || (event > 15)) |
305 { | 291 { |
306 // Ignore callback since feedback is disabled or event is not a | 292 // Ignore callback since feedback is disabled or event is not a |
307 // Dtmf tone event. | 293 // Dtmf tone event. |
308 return; | 294 return; |
309 } | 295 } |
310 | 296 |
311 assert(_outputMixerPtr != NULL); | 297 assert(_outputMixerPtr != NULL); |
312 | 298 |
313 // Start playing out the Dtmf tone (if playout is enabled). | 299 // Start playing out the Dtmf tone (if playout is enabled). |
314 // Reduce length of tone with 80ms to the reduce risk of echo. | 300 // Reduce length of tone with 80ms to the reduce risk of echo. |
315 _outputMixerPtr->PlayDtmfTone(event, lengthMs - 80, volume); | 301 _outputMixerPtr->PlayDtmfTone(event, lengthMs - 80, volume); |
316 } | 302 } |
317 | 303 |
318 void | 304 void |
319 Channel::OnIncomingSSRCChanged(int32_t id, uint32_t ssrc) | 305 Channel::OnIncomingSSRCChanged(uint32_t ssrc) |
320 { | 306 { |
321 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), | 307 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), |
322 "Channel::OnIncomingSSRCChanged(id=%d, SSRC=%d)", | 308 "Channel::OnIncomingSSRCChanged(SSRC=%d)", ssrc); |
323 id, ssrc); | |
324 | 309 |
325 // Update ssrc so that NTP for AV sync can be updated. | 310 // Update ssrc so that NTP for AV sync can be updated. |
326 _rtpRtcpModule->SetRemoteSSRC(ssrc); | 311 _rtpRtcpModule->SetRemoteSSRC(ssrc); |
327 } | 312 } |
328 | 313 |
329 void Channel::OnIncomingCSRCChanged(int32_t id, | 314 void Channel::OnIncomingCSRCChanged(uint32_t CSRC, bool added) { |
330 uint32_t CSRC, | 315 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
331 bool added) | 316 "Channel::OnIncomingCSRCChanged(CSRC=%d, added=%d)", CSRC, |
332 { | 317 added); |
333 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), | |
334 "Channel::OnIncomingCSRCChanged(id=%d, CSRC=%d, added=%d)", | |
335 id, CSRC, added); | |
336 } | 318 } |
337 | 319 |
338 int32_t | 320 int32_t Channel::OnInitializeDecoder( |
339 Channel::OnInitializeDecoder( | |
340 int32_t id, | |
341 int8_t payloadType, | 321 int8_t payloadType, |
342 const char payloadName[RTP_PAYLOAD_NAME_SIZE], | 322 const char payloadName[RTP_PAYLOAD_NAME_SIZE], |
343 int frequency, | 323 int frequency, |
344 uint8_t channels, | 324 uint8_t channels, |
345 uint32_t rate) | 325 uint32_t rate) { |
346 { | |
347 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), | 326 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), |
348 "Channel::OnInitializeDecoder(id=%d, payloadType=%d, " | 327 "Channel::OnInitializeDecoder(payloadType=%d, " |
349 "payloadName=%s, frequency=%u, channels=%u, rate=%u)", | 328 "payloadName=%s, frequency=%u, channels=%u, rate=%u)", |
350 id, payloadType, payloadName, frequency, channels, rate); | 329 payloadType, payloadName, frequency, channels, rate); |
351 | |
352 assert(VoEChannelId(id) == _channelId); | |
353 | 330 |
354 CodecInst receiveCodec = {0}; | 331 CodecInst receiveCodec = {0}; |
355 CodecInst dummyCodec = {0}; | 332 CodecInst dummyCodec = {0}; |
356 | 333 |
357 receiveCodec.pltype = payloadType; | 334 receiveCodec.pltype = payloadType; |
358 receiveCodec.plfreq = frequency; | 335 receiveCodec.plfreq = frequency; |
359 receiveCodec.channels = channels; | 336 receiveCodec.channels = channels; |
360 receiveCodec.rate = rate; | 337 receiveCodec.rate = rate; |
361 strncpy(receiveCodec.plname, payloadName, RTP_PAYLOAD_NAME_SIZE - 1); | 338 strncpy(receiveCodec.plname, payloadName, RTP_PAYLOAD_NAME_SIZE - 1); |
362 | 339 |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 _callbackCritSect(*CriticalSectionWrapper::CreateCriticalSection()), | 695 _callbackCritSect(*CriticalSectionWrapper::CreateCriticalSection()), |
719 volume_settings_critsect_(*CriticalSectionWrapper::CreateCriticalSection()), | 696 volume_settings_critsect_(*CriticalSectionWrapper::CreateCriticalSection()), |
720 _instanceId(instanceId), | 697 _instanceId(instanceId), |
721 _channelId(channelId), | 698 _channelId(channelId), |
722 rtp_header_parser_(RtpHeaderParser::Create()), | 699 rtp_header_parser_(RtpHeaderParser::Create()), |
723 rtp_payload_registry_( | 700 rtp_payload_registry_( |
724 new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(true))), | 701 new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(true))), |
725 rtp_receive_statistics_( | 702 rtp_receive_statistics_( |
726 ReceiveStatistics::Create(Clock::GetRealTimeClock())), | 703 ReceiveStatistics::Create(Clock::GetRealTimeClock())), |
727 rtp_receiver_( | 704 rtp_receiver_( |
728 RtpReceiver::CreateAudioReceiver(VoEModuleId(instanceId, channelId), | 705 RtpReceiver::CreateAudioReceiver(Clock::GetRealTimeClock(), |
729 Clock::GetRealTimeClock(), | |
730 this, | 706 this, |
731 this, | 707 this, |
732 this, | 708 this, |
733 rtp_payload_registry_.get())), | 709 rtp_payload_registry_.get())), |
734 telephone_event_handler_(rtp_receiver_->GetTelephoneEventHandler()), | 710 telephone_event_handler_(rtp_receiver_->GetTelephoneEventHandler()), |
735 _outputAudioLevel(), | 711 _outputAudioLevel(), |
736 _externalTransport(false), | 712 _externalTransport(false), |
737 _inputFilePlayerPtr(NULL), | 713 _inputFilePlayerPtr(NULL), |
738 _outputFilePlayerPtr(NULL), | 714 _outputFilePlayerPtr(NULL), |
739 _outputFileRecorderPtr(NULL), | 715 _outputFileRecorderPtr(NULL), |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 acm_config.neteq_config.enable_fast_accelerate = | 786 acm_config.neteq_config.enable_fast_accelerate = |
811 config.Get<NetEqFastAccelerate>().enabled; | 787 config.Get<NetEqFastAccelerate>().enabled; |
812 acm_config.event_log = event_log; | 788 acm_config.event_log = event_log; |
813 audio_coding_.reset(AudioCodingModule::Create(acm_config)); | 789 audio_coding_.reset(AudioCodingModule::Create(acm_config)); |
814 | 790 |
815 _inbandDtmfQueue.ResetDtmf(); | 791 _inbandDtmfQueue.ResetDtmf(); |
816 _inbandDtmfGenerator.Init(); | 792 _inbandDtmfGenerator.Init(); |
817 _outputAudioLevel.Clear(); | 793 _outputAudioLevel.Clear(); |
818 | 794 |
819 RtpRtcp::Configuration configuration; | 795 RtpRtcp::Configuration configuration; |
820 configuration.id = VoEModuleId(instanceId, channelId); | |
821 configuration.audio = true; | 796 configuration.audio = true; |
822 configuration.outgoing_transport = this; | 797 configuration.outgoing_transport = this; |
823 configuration.audio_messages = this; | 798 configuration.audio_messages = this; |
824 configuration.receive_statistics = rtp_receive_statistics_.get(); | 799 configuration.receive_statistics = rtp_receive_statistics_.get(); |
825 configuration.bandwidth_callback = rtcp_observer_.get(); | 800 configuration.bandwidth_callback = rtcp_observer_.get(); |
826 | 801 |
827 _rtpRtcpModule.reset(RtpRtcp::CreateRtpRtcp(configuration)); | 802 _rtpRtcpModule.reset(RtpRtcp::CreateRtpRtcp(configuration)); |
828 | 803 |
829 statistics_proxy_.reset(new StatisticsProxy(_rtpRtcpModule->SSRC())); | 804 statistics_proxy_.reset(new StatisticsProxy(_rtpRtcpModule->SSRC())); |
830 rtp_receive_statistics_->RegisterRtcpStatisticsCallback( | 805 rtp_receive_statistics_->RegisterRtcpStatisticsCallback( |
(...skipping 3052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3883 int32_t | 3858 int32_t |
3884 Channel::SendPacketRaw(const void *data, size_t len, bool RTCP) | 3859 Channel::SendPacketRaw(const void *data, size_t len, bool RTCP) |
3885 { | 3860 { |
3886 CriticalSectionScoped cs(&_callbackCritSect); | 3861 CriticalSectionScoped cs(&_callbackCritSect); |
3887 if (_transportPtr == NULL) | 3862 if (_transportPtr == NULL) |
3888 { | 3863 { |
3889 return -1; | 3864 return -1; |
3890 } | 3865 } |
3891 if (!RTCP) | 3866 if (!RTCP) |
3892 { | 3867 { |
3893 return _transportPtr->SendPacket(_channelId, data, len); | 3868 return _transportPtr->SendPacket(data, len); |
3894 } | 3869 } |
3895 else | 3870 else |
3896 { | 3871 { |
3897 return _transportPtr->SendRTCPPacket(_channelId, data, len); | 3872 return _transportPtr->SendRTCPPacket(data, len); |
3898 } | 3873 } |
3899 } | 3874 } |
3900 | 3875 |
3901 void Channel::UpdatePlayoutTimestamp(bool rtcp) { | 3876 void Channel::UpdatePlayoutTimestamp(bool rtcp) { |
3902 uint32_t playout_timestamp = 0; | 3877 uint32_t playout_timestamp = 0; |
3903 | 3878 |
3904 if (audio_coding_->PlayoutTimestamp(&playout_timestamp) == -1) { | 3879 if (audio_coding_->PlayoutTimestamp(&playout_timestamp) == -1) { |
3905 // This can happen if this channel has not been received any RTP packet. In | 3880 // This can happen if this channel has not been received any RTP packet. In |
3906 // this case, NetEq is not capable of computing playout timestamp. | 3881 // this case, NetEq is not capable of computing playout timestamp. |
3907 return; | 3882 return; |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4148 int64_t min_rtt = 0; | 4123 int64_t min_rtt = 0; |
4149 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) | 4124 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) |
4150 != 0) { | 4125 != 0) { |
4151 return 0; | 4126 return 0; |
4152 } | 4127 } |
4153 return rtt; | 4128 return rtt; |
4154 } | 4129 } |
4155 | 4130 |
4156 } // namespace voe | 4131 } // namespace voe |
4157 } // namespace webrtc | 4132 } // namespace webrtc |
OLD | NEW |