| 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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 "Channel::OnIncomingCSRCChanged(id=%d, CSRC=%d, added=%d)", | 334 "Channel::OnIncomingCSRCChanged(id=%d, CSRC=%d, added=%d)", |
| 335 id, CSRC, added); | 335 id, CSRC, added); |
| 336 } | 336 } |
| 337 | 337 |
| 338 int32_t | 338 int32_t |
| 339 Channel::OnInitializeDecoder( | 339 Channel::OnInitializeDecoder( |
| 340 int32_t id, | 340 int32_t id, |
| 341 int8_t payloadType, | 341 int8_t payloadType, |
| 342 const char payloadName[RTP_PAYLOAD_NAME_SIZE], | 342 const char payloadName[RTP_PAYLOAD_NAME_SIZE], |
| 343 int frequency, | 343 int frequency, |
| 344 uint8_t channels, | 344 size_t channels, |
| 345 uint32_t rate) | 345 uint32_t rate) |
| 346 { | 346 { |
| 347 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), | 347 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), |
| 348 "Channel::OnInitializeDecoder(id=%d, payloadType=%d, " | 348 "Channel::OnInitializeDecoder(id=%d, payloadType=%d, " |
| 349 "payloadName=%s, frequency=%u, channels=%u, rate=%u)", | 349 "payloadName=%s, frequency=%u, channels=%" PRIuS ", rate=%u)", |
| 350 id, payloadType, payloadName, frequency, channels, rate); | 350 id, payloadType, payloadName, frequency, channels, rate); |
| 351 | 351 |
| 352 assert(VoEChannelId(id) == _channelId); | 352 assert(VoEChannelId(id) == _channelId); |
| 353 | 353 |
| 354 CodecInst receiveCodec = {0}; | 354 CodecInst receiveCodec = {0}; |
| 355 CodecInst dummyCodec = {0}; | 355 CodecInst dummyCodec = {0}; |
| 356 | 356 |
| 357 receiveCodec.pltype = payloadType; | 357 receiveCodec.pltype = payloadType; |
| 358 receiveCodec.plfreq = frequency; | 358 receiveCodec.plfreq = frequency; |
| 359 receiveCodec.channels = channels; | 359 receiveCodec.channels = channels; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 377 return 0; | 377 return 0; |
| 378 } | 378 } |
| 379 | 379 |
| 380 int32_t | 380 int32_t |
| 381 Channel::OnReceivedPayloadData(const uint8_t* payloadData, | 381 Channel::OnReceivedPayloadData(const uint8_t* payloadData, |
| 382 size_t payloadSize, | 382 size_t payloadSize, |
| 383 const WebRtcRTPHeader* rtpHeader) | 383 const WebRtcRTPHeader* rtpHeader) |
| 384 { | 384 { |
| 385 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId), | 385 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId), |
| 386 "Channel::OnReceivedPayloadData(payloadSize=%" PRIuS "," | 386 "Channel::OnReceivedPayloadData(payloadSize=%" PRIuS "," |
| 387 " payloadType=%u, audioChannel=%u)", | 387 " payloadType=%u, audioChannel=%" PRIuS ")", |
| 388 payloadSize, | 388 payloadSize, |
| 389 rtpHeader->header.payloadType, | 389 rtpHeader->header.payloadType, |
| 390 rtpHeader->type.Audio.channel); | 390 rtpHeader->type.Audio.channel); |
| 391 | 391 |
| 392 if (!channel_state_.Get().playing) | 392 if (!channel_state_.Get().playing) |
| 393 { | 393 { |
| 394 // Avoid inserting into NetEQ when we are not playing. Count the | 394 // Avoid inserting into NetEQ when we are not playing. Count the |
| 395 // packet as discarded. | 395 // packet as discarded. |
| 396 WEBRTC_TRACE(kTraceStream, kTraceVoice, | 396 WEBRTC_TRACE(kTraceStream, kTraceVoice, |
| 397 VoEId(_instanceId, _channelId), | 397 VoEId(_instanceId, _channelId), |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 974 if ((audio_coding_->Codec(idx, &codec) == -1) || | 974 if ((audio_coding_->Codec(idx, &codec) == -1) || |
| 975 (rtp_receiver_->RegisterReceivePayload( | 975 (rtp_receiver_->RegisterReceivePayload( |
| 976 codec.plname, | 976 codec.plname, |
| 977 codec.pltype, | 977 codec.pltype, |
| 978 codec.plfreq, | 978 codec.plfreq, |
| 979 codec.channels, | 979 codec.channels, |
| 980 (codec.rate < 0) ? 0 : codec.rate) == -1)) | 980 (codec.rate < 0) ? 0 : codec.rate) == -1)) |
| 981 { | 981 { |
| 982 WEBRTC_TRACE(kTraceWarning, kTraceVoice, | 982 WEBRTC_TRACE(kTraceWarning, kTraceVoice, |
| 983 VoEId(_instanceId,_channelId), | 983 VoEId(_instanceId,_channelId), |
| 984 "Channel::Init() unable to register %s (%d/%d/%d/%d) " | 984 "Channel::Init() unable to register %s " |
| 985 "to RTP/RTCP receiver", | 985 "(%d/%d/%" PRIuS "/%d) to RTP/RTCP receiver", |
| 986 codec.plname, codec.pltype, codec.plfreq, | 986 codec.plname, codec.pltype, codec.plfreq, |
| 987 codec.channels, codec.rate); | 987 codec.channels, codec.rate); |
| 988 } | 988 } |
| 989 else | 989 else |
| 990 { | 990 { |
| 991 WEBRTC_TRACE(kTraceInfo, kTraceVoice, | 991 WEBRTC_TRACE(kTraceInfo, kTraceVoice, |
| 992 VoEId(_instanceId,_channelId), | 992 VoEId(_instanceId,_channelId), |
| 993 "Channel::Init() %s (%d/%d/%d/%d) has been added to " | 993 "Channel::Init() %s (%d/%d/%" PRIuS "/%d) has been " |
| 994 "the RTP/RTCP receiver", | 994 "added to the RTP/RTCP receiver", |
| 995 codec.plname, codec.pltype, codec.plfreq, | 995 codec.plname, codec.pltype, codec.plfreq, |
| 996 codec.channels, codec.rate); | 996 codec.channels, codec.rate); |
| 997 } | 997 } |
| 998 | 998 |
| 999 // Ensure that PCMU is used as default codec on the sending side | 999 // Ensure that PCMU is used as default codec on the sending side |
| 1000 if (!STR_CASE_CMP(codec.plname, "PCMU") && (codec.channels == 1)) | 1000 if (!STR_CASE_CMP(codec.plname, "PCMU") && (codec.channels == 1)) |
| 1001 { | 1001 { |
| 1002 SetSendCodec(codec); | 1002 SetSendCodec(codec); |
| 1003 } | 1003 } |
| 1004 | 1004 |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1482 } | 1482 } |
| 1483 | 1483 |
| 1484 int32_t | 1484 int32_t |
| 1485 Channel::SetSendCNPayloadType(int type, PayloadFrequencies frequency) | 1485 Channel::SetSendCNPayloadType(int type, PayloadFrequencies frequency) |
| 1486 { | 1486 { |
| 1487 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), | 1487 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), |
| 1488 "Channel::SetSendCNPayloadType()"); | 1488 "Channel::SetSendCNPayloadType()"); |
| 1489 | 1489 |
| 1490 CodecInst codec; | 1490 CodecInst codec; |
| 1491 int32_t samplingFreqHz(-1); | 1491 int32_t samplingFreqHz(-1); |
| 1492 const int kMono = 1; | 1492 const size_t kMono = 1; |
| 1493 if (frequency == kFreq32000Hz) | 1493 if (frequency == kFreq32000Hz) |
| 1494 samplingFreqHz = 32000; | 1494 samplingFreqHz = 32000; |
| 1495 else if (frequency == kFreq16000Hz) | 1495 else if (frequency == kFreq16000Hz) |
| 1496 samplingFreqHz = 16000; | 1496 samplingFreqHz = 16000; |
| 1497 | 1497 |
| 1498 if (audio_coding_->Codec("CN", &codec, samplingFreqHz, kMono) == -1) | 1498 if (audio_coding_->Codec("CN", &codec, samplingFreqHz, kMono) == -1) |
| 1499 { | 1499 { |
| 1500 _engineStatisticsPtr->SetLastError( | 1500 _engineStatisticsPtr->SetLastError( |
| 1501 VE_AUDIO_CODING_MODULE_ERROR, kTraceError, | 1501 VE_AUDIO_CODING_MODULE_ERROR, kTraceError, |
| 1502 "SetSendCNPayloadType() failed to retrieve default CN codec " | 1502 "SetSendCNPayloadType() failed to retrieve default CN codec " |
| (...skipping 1827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3330 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId), | 3330 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId), |
| 3331 "Channel::Demultiplex()"); | 3331 "Channel::Demultiplex()"); |
| 3332 _audioFrame.CopyFrom(audioFrame); | 3332 _audioFrame.CopyFrom(audioFrame); |
| 3333 _audioFrame.id_ = _channelId; | 3333 _audioFrame.id_ = _channelId; |
| 3334 return 0; | 3334 return 0; |
| 3335 } | 3335 } |
| 3336 | 3336 |
| 3337 void Channel::Demultiplex(const int16_t* audio_data, | 3337 void Channel::Demultiplex(const int16_t* audio_data, |
| 3338 int sample_rate, | 3338 int sample_rate, |
| 3339 size_t number_of_frames, | 3339 size_t number_of_frames, |
| 3340 int number_of_channels) { | 3340 size_t number_of_channels) { |
| 3341 CodecInst codec; | 3341 CodecInst codec; |
| 3342 GetSendCodec(codec); | 3342 GetSendCodec(codec); |
| 3343 | 3343 |
| 3344 if (!mono_recording_audio_.get()) { | 3344 if (!mono_recording_audio_.get()) { |
| 3345 // Temporary space for DownConvertToCodecFormat. | 3345 // Temporary space for DownConvertToCodecFormat. |
| 3346 mono_recording_audio_.reset(new int16_t[kMaxMonoDataSizeSamples]); | 3346 mono_recording_audio_.reset(new int16_t[kMaxMonoDataSizeSamples]); |
| 3347 } | 3347 } |
| 3348 DownConvertToCodecFormat(audio_data, | 3348 DownConvertToCodecFormat(audio_data, |
| 3349 number_of_frames, | 3349 number_of_frames, |
| 3350 number_of_channels, | 3350 number_of_channels, |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3880 VoEId(_instanceId, _channelId), | 3880 VoEId(_instanceId, _channelId), |
| 3881 "Channel::EncodeAndSend() inserting Dtmf failed"); | 3881 "Channel::EncodeAndSend() inserting Dtmf failed"); |
| 3882 return -1; | 3882 return -1; |
| 3883 } | 3883 } |
| 3884 | 3884 |
| 3885 // Replace mixed audio with DTMF tone. | 3885 // Replace mixed audio with DTMF tone. |
| 3886 for (size_t sample = 0; | 3886 for (size_t sample = 0; |
| 3887 sample < _audioFrame.samples_per_channel_; | 3887 sample < _audioFrame.samples_per_channel_; |
| 3888 sample++) | 3888 sample++) |
| 3889 { | 3889 { |
| 3890 for (int channel = 0; | 3890 for (size_t channel = 0; |
| 3891 channel < _audioFrame.num_channels_; | 3891 channel < _audioFrame.num_channels_; |
| 3892 channel++) | 3892 channel++) |
| 3893 { | 3893 { |
| 3894 const size_t index = | 3894 const size_t index = |
| 3895 sample * _audioFrame.num_channels_ + channel; | 3895 sample * _audioFrame.num_channels_ + channel; |
| 3896 _audioFrame.data_[index] = toneBuffer[sample]; | 3896 _audioFrame.data_[index] = toneBuffer[sample]; |
| 3897 } | 3897 } |
| 3898 } | 3898 } |
| 3899 | 3899 |
| 3900 assert(_audioFrame.samples_per_channel_ == toneSamples); | 3900 assert(_audioFrame.samples_per_channel_ == toneSamples); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3993 codec.pltype, | 3993 codec.pltype, |
| 3994 codec.plfreq, | 3994 codec.plfreq, |
| 3995 codec.channels, | 3995 codec.channels, |
| 3996 (codec.rate < 0) ? 0 : codec.rate) == -1)) | 3996 (codec.rate < 0) ? 0 : codec.rate) == -1)) |
| 3997 { | 3997 { |
| 3998 WEBRTC_TRACE( | 3998 WEBRTC_TRACE( |
| 3999 kTraceWarning, | 3999 kTraceWarning, |
| 4000 kTraceVoice, | 4000 kTraceVoice, |
| 4001 VoEId(_instanceId, _channelId), | 4001 VoEId(_instanceId, _channelId), |
| 4002 "Channel::RegisterReceiveCodecsToRTPModule() unable" | 4002 "Channel::RegisterReceiveCodecsToRTPModule() unable" |
| 4003 " to register %s (%d/%d/%d/%d) to RTP/RTCP receiver", | 4003 " to register %s (%d/%d/%" PRIuS "/%d) to RTP/RTCP " |
| 4004 "receiver", |
| 4004 codec.plname, codec.pltype, codec.plfreq, | 4005 codec.plname, codec.pltype, codec.plfreq, |
| 4005 codec.channels, codec.rate); | 4006 codec.channels, codec.rate); |
| 4006 } | 4007 } |
| 4007 else | 4008 else |
| 4008 { | 4009 { |
| 4009 WEBRTC_TRACE( | 4010 WEBRTC_TRACE( |
| 4010 kTraceInfo, | 4011 kTraceInfo, |
| 4011 kTraceVoice, | 4012 kTraceVoice, |
| 4012 VoEId(_instanceId, _channelId), | 4013 VoEId(_instanceId, _channelId), |
| 4013 "Channel::RegisterReceiveCodecsToRTPModule() %s " | 4014 "Channel::RegisterReceiveCodecsToRTPModule() %s " |
| 4014 "(%d/%d/%d/%d) has been added to the RTP/RTCP " | 4015 "(%d/%d/%" PRIuS "/%d) has been added to the RTP/RTCP " |
| 4015 "receiver", | 4016 "receiver", |
| 4016 codec.plname, codec.pltype, codec.plfreq, | 4017 codec.plname, codec.pltype, codec.plfreq, |
| 4017 codec.channels, codec.rate); | 4018 codec.channels, codec.rate); |
| 4018 } | 4019 } |
| 4019 } | 4020 } |
| 4020 } | 4021 } |
| 4021 | 4022 |
| 4022 // Assuming this method is called with valid payload type. | 4023 // Assuming this method is called with valid payload type. |
| 4023 int Channel::SetRedPayloadType(int red_payload_type) { | 4024 int Channel::SetRedPayloadType(int red_payload_type) { |
| 4024 CodecInst codec; | 4025 CodecInst codec; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4133 int64_t min_rtt = 0; | 4134 int64_t min_rtt = 0; |
| 4134 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) | 4135 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) |
| 4135 != 0) { | 4136 != 0) { |
| 4136 return 0; | 4137 return 0; |
| 4137 } | 4138 } |
| 4138 return rtt; | 4139 return rtt; |
| 4139 } | 4140 } |
| 4140 | 4141 |
| 4141 } // namespace voe | 4142 } // namespace voe |
| 4142 } // namespace webrtc | 4143 } // namespace webrtc |
| OLD | NEW |