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

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

Issue 1316523002: Convert channel counts to size_t. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Fix compile Created 4 years, 11 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 | « webrtc/voice_engine/channel.h ('k') | webrtc/voice_engine/output_mixer.h » ('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 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 void Channel::OnIncomingCSRCChanged(uint32_t CSRC, bool added) { 412 void Channel::OnIncomingCSRCChanged(uint32_t CSRC, bool added) {
413 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), 413 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
414 "Channel::OnIncomingCSRCChanged(CSRC=%d, added=%d)", CSRC, 414 "Channel::OnIncomingCSRCChanged(CSRC=%d, added=%d)", CSRC,
415 added); 415 added);
416 } 416 }
417 417
418 int32_t Channel::OnInitializeDecoder( 418 int32_t Channel::OnInitializeDecoder(
419 int8_t payloadType, 419 int8_t payloadType,
420 const char payloadName[RTP_PAYLOAD_NAME_SIZE], 420 const char payloadName[RTP_PAYLOAD_NAME_SIZE],
421 int frequency, 421 int frequency,
422 uint8_t channels, 422 size_t channels,
423 uint32_t rate) { 423 uint32_t rate) {
424 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), 424 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId),
425 "Channel::OnInitializeDecoder(payloadType=%d, " 425 "Channel::OnInitializeDecoder(payloadType=%d, "
426 "payloadName=%s, frequency=%u, channels=%u, rate=%u)", 426 "payloadName=%s, frequency=%u, channels=%" PRIuS ", rate=%u)",
427 payloadType, payloadName, frequency, channels, rate); 427 payloadType, payloadName, frequency, channels, rate);
428 428
429 CodecInst receiveCodec = {0}; 429 CodecInst receiveCodec = {0};
430 CodecInst dummyCodec = {0}; 430 CodecInst dummyCodec = {0};
431 431
432 receiveCodec.pltype = payloadType; 432 receiveCodec.pltype = payloadType;
433 receiveCodec.plfreq = frequency; 433 receiveCodec.plfreq = frequency;
434 receiveCodec.channels = channels; 434 receiveCodec.channels = channels;
435 receiveCodec.rate = rate; 435 receiveCodec.rate = rate;
436 strncpy(receiveCodec.plname, payloadName, RTP_PAYLOAD_NAME_SIZE - 1); 436 strncpy(receiveCodec.plname, payloadName, RTP_PAYLOAD_NAME_SIZE - 1);
(...skipping 15 matching lines...) Expand all
452 return 0; 452 return 0;
453 } 453 }
454 454
455 int32_t 455 int32_t
456 Channel::OnReceivedPayloadData(const uint8_t* payloadData, 456 Channel::OnReceivedPayloadData(const uint8_t* payloadData,
457 size_t payloadSize, 457 size_t payloadSize,
458 const WebRtcRTPHeader* rtpHeader) 458 const WebRtcRTPHeader* rtpHeader)
459 { 459 {
460 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId), 460 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId),
461 "Channel::OnReceivedPayloadData(payloadSize=%" PRIuS "," 461 "Channel::OnReceivedPayloadData(payloadSize=%" PRIuS ","
462 " payloadType=%u, audioChannel=%u)", 462 " payloadType=%u, audioChannel=%" PRIuS ")",
463 payloadSize, 463 payloadSize,
464 rtpHeader->header.payloadType, 464 rtpHeader->header.payloadType,
465 rtpHeader->type.Audio.channel); 465 rtpHeader->type.Audio.channel);
466 466
467 if (!channel_state_.Get().playing) 467 if (!channel_state_.Get().playing)
468 { 468 {
469 // Avoid inserting into NetEQ when we are not playing. Count the 469 // Avoid inserting into NetEQ when we are not playing. Count the
470 // packet as discarded. 470 // packet as discarded.
471 WEBRTC_TRACE(kTraceStream, kTraceVoice, 471 WEBRTC_TRACE(kTraceStream, kTraceVoice,
472 VoEId(_instanceId, _channelId), 472 VoEId(_instanceId, _channelId),
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 if ((audio_coding_->Codec(idx, &codec) == -1) || 1072 if ((audio_coding_->Codec(idx, &codec) == -1) ||
1073 (rtp_receiver_->RegisterReceivePayload( 1073 (rtp_receiver_->RegisterReceivePayload(
1074 codec.plname, 1074 codec.plname,
1075 codec.pltype, 1075 codec.pltype,
1076 codec.plfreq, 1076 codec.plfreq,
1077 codec.channels, 1077 codec.channels,
1078 (codec.rate < 0) ? 0 : codec.rate) == -1)) 1078 (codec.rate < 0) ? 0 : codec.rate) == -1))
1079 { 1079 {
1080 WEBRTC_TRACE(kTraceWarning, kTraceVoice, 1080 WEBRTC_TRACE(kTraceWarning, kTraceVoice,
1081 VoEId(_instanceId,_channelId), 1081 VoEId(_instanceId,_channelId),
1082 "Channel::Init() unable to register %s (%d/%d/%d/%d) " 1082 "Channel::Init() unable to register %s "
1083 "to RTP/RTCP receiver", 1083 "(%d/%d/%" PRIuS "/%d) to RTP/RTCP receiver",
1084 codec.plname, codec.pltype, codec.plfreq, 1084 codec.plname, codec.pltype, codec.plfreq,
1085 codec.channels, codec.rate); 1085 codec.channels, codec.rate);
1086 } 1086 }
1087 else 1087 else
1088 { 1088 {
1089 WEBRTC_TRACE(kTraceInfo, kTraceVoice, 1089 WEBRTC_TRACE(kTraceInfo, kTraceVoice,
1090 VoEId(_instanceId,_channelId), 1090 VoEId(_instanceId,_channelId),
1091 "Channel::Init() %s (%d/%d/%d/%d) has been added to " 1091 "Channel::Init() %s (%d/%d/%" PRIuS "/%d) has been "
1092 "the RTP/RTCP receiver", 1092 "added to the RTP/RTCP receiver",
1093 codec.plname, codec.pltype, codec.plfreq, 1093 codec.plname, codec.pltype, codec.plfreq,
1094 codec.channels, codec.rate); 1094 codec.channels, codec.rate);
1095 } 1095 }
1096 1096
1097 // Ensure that PCMU is used as default codec on the sending side 1097 // Ensure that PCMU is used as default codec on the sending side
1098 if (!STR_CASE_CMP(codec.plname, "PCMU") && (codec.channels == 1)) 1098 if (!STR_CASE_CMP(codec.plname, "PCMU") && (codec.channels == 1))
1099 { 1099 {
1100 SetSendCodec(codec); 1100 SetSendCodec(codec);
1101 } 1101 }
1102 1102
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
1584 } 1584 }
1585 1585
1586 int32_t 1586 int32_t
1587 Channel::SetSendCNPayloadType(int type, PayloadFrequencies frequency) 1587 Channel::SetSendCNPayloadType(int type, PayloadFrequencies frequency)
1588 { 1588 {
1589 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), 1589 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId),
1590 "Channel::SetSendCNPayloadType()"); 1590 "Channel::SetSendCNPayloadType()");
1591 1591
1592 CodecInst codec; 1592 CodecInst codec;
1593 int32_t samplingFreqHz(-1); 1593 int32_t samplingFreqHz(-1);
1594 const int kMono = 1; 1594 const size_t kMono = 1;
1595 if (frequency == kFreq32000Hz) 1595 if (frequency == kFreq32000Hz)
1596 samplingFreqHz = 32000; 1596 samplingFreqHz = 32000;
1597 else if (frequency == kFreq16000Hz) 1597 else if (frequency == kFreq16000Hz)
1598 samplingFreqHz = 16000; 1598 samplingFreqHz = 16000;
1599 1599
1600 if (audio_coding_->Codec("CN", &codec, samplingFreqHz, kMono) == -1) 1600 if (audio_coding_->Codec("CN", &codec, samplingFreqHz, kMono) == -1)
1601 { 1601 {
1602 _engineStatisticsPtr->SetLastError( 1602 _engineStatisticsPtr->SetLastError(
1603 VE_AUDIO_CODING_MODULE_ERROR, kTraceError, 1603 VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
1604 "SetSendCNPayloadType() failed to retrieve default CN codec " 1604 "SetSendCNPayloadType() failed to retrieve default CN codec "
(...skipping 1743 matching lines...) Expand 10 before | Expand all | Expand 10 after
3348 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId), 3348 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId),
3349 "Channel::Demultiplex()"); 3349 "Channel::Demultiplex()");
3350 _audioFrame.CopyFrom(audioFrame); 3350 _audioFrame.CopyFrom(audioFrame);
3351 _audioFrame.id_ = _channelId; 3351 _audioFrame.id_ = _channelId;
3352 return 0; 3352 return 0;
3353 } 3353 }
3354 3354
3355 void Channel::Demultiplex(const int16_t* audio_data, 3355 void Channel::Demultiplex(const int16_t* audio_data,
3356 int sample_rate, 3356 int sample_rate,
3357 size_t number_of_frames, 3357 size_t number_of_frames,
3358 int number_of_channels) { 3358 size_t number_of_channels) {
3359 CodecInst codec; 3359 CodecInst codec;
3360 GetSendCodec(codec); 3360 GetSendCodec(codec);
3361 3361
3362 // Never upsample or upmix the capture signal here. This should be done at the 3362 // Never upsample or upmix the capture signal here. This should be done at the
3363 // end of the send chain. 3363 // end of the send chain.
3364 _audioFrame.sample_rate_hz_ = std::min(codec.plfreq, sample_rate); 3364 _audioFrame.sample_rate_hz_ = std::min(codec.plfreq, sample_rate);
3365 _audioFrame.num_channels_ = std::min(number_of_channels, codec.channels); 3365 _audioFrame.num_channels_ = std::min(number_of_channels, codec.channels);
3366 RemixAndResample(audio_data, number_of_frames, number_of_channels, 3366 RemixAndResample(audio_data, number_of_frames, number_of_channels,
3367 sample_rate, &input_resampler_, &_audioFrame); 3367 sample_rate, &input_resampler_, &_audioFrame);
3368 } 3368 }
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
3835 VoEId(_instanceId, _channelId), 3835 VoEId(_instanceId, _channelId),
3836 "Channel::EncodeAndSend() inserting Dtmf failed"); 3836 "Channel::EncodeAndSend() inserting Dtmf failed");
3837 return -1; 3837 return -1;
3838 } 3838 }
3839 3839
3840 // Replace mixed audio with DTMF tone. 3840 // Replace mixed audio with DTMF tone.
3841 for (size_t sample = 0; 3841 for (size_t sample = 0;
3842 sample < _audioFrame.samples_per_channel_; 3842 sample < _audioFrame.samples_per_channel_;
3843 sample++) 3843 sample++)
3844 { 3844 {
3845 for (int channel = 0; 3845 for (size_t channel = 0;
3846 channel < _audioFrame.num_channels_; 3846 channel < _audioFrame.num_channels_;
3847 channel++) 3847 channel++)
3848 { 3848 {
3849 const size_t index = 3849 const size_t index =
3850 sample * _audioFrame.num_channels_ + channel; 3850 sample * _audioFrame.num_channels_ + channel;
3851 _audioFrame.data_[index] = toneBuffer[sample]; 3851 _audioFrame.data_[index] = toneBuffer[sample];
3852 } 3852 }
3853 } 3853 }
3854 3854
3855 assert(_audioFrame.samples_per_channel_ == toneSamples); 3855 assert(_audioFrame.samples_per_channel_ == toneSamples);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
3969 codec.plname, 3969 codec.plname,
3970 codec.pltype, 3970 codec.pltype,
3971 codec.plfreq, 3971 codec.plfreq,
3972 codec.channels, 3972 codec.channels,
3973 (codec.rate < 0) ? 0 : codec.rate) == -1)) 3973 (codec.rate < 0) ? 0 : codec.rate) == -1))
3974 { 3974 {
3975 WEBRTC_TRACE(kTraceWarning, 3975 WEBRTC_TRACE(kTraceWarning,
3976 kTraceVoice, 3976 kTraceVoice,
3977 VoEId(_instanceId, _channelId), 3977 VoEId(_instanceId, _channelId),
3978 "Channel::RegisterReceiveCodecsToRTPModule() unable" 3978 "Channel::RegisterReceiveCodecsToRTPModule() unable"
3979 " to register %s (%d/%d/%d/%d) to RTP/RTCP receiver", 3979 " to register %s (%d/%d/%" PRIuS "/%d) to RTP/RTCP "
3980 "receiver",
3980 codec.plname, codec.pltype, codec.plfreq, 3981 codec.plname, codec.pltype, codec.plfreq,
3981 codec.channels, codec.rate); 3982 codec.channels, codec.rate);
3982 } 3983 }
3983 else 3984 else
3984 { 3985 {
3985 WEBRTC_TRACE(kTraceInfo, 3986 WEBRTC_TRACE(kTraceInfo,
3986 kTraceVoice, 3987 kTraceVoice,
3987 VoEId(_instanceId, _channelId), 3988 VoEId(_instanceId, _channelId),
3988 "Channel::RegisterReceiveCodecsToRTPModule() %s " 3989 "Channel::RegisterReceiveCodecsToRTPModule() %s "
3989 "(%d/%d/%d/%d) has been added to the RTP/RTCP " 3990 "(%d/%d/%" PRIuS "/%d) has been added to the RTP/RTCP "
3990 "receiver", 3991 "receiver",
3991 codec.plname, codec.pltype, codec.plfreq, 3992 codec.plname, codec.pltype, codec.plfreq,
3992 codec.channels, codec.rate); 3993 codec.channels, codec.rate);
3993 } 3994 }
3994 } 3995 }
3995 } 3996 }
3996 3997
3997 // Assuming this method is called with valid payload type. 3998 // Assuming this method is called with valid payload type.
3998 int Channel::SetRedPayloadType(int red_payload_type) { 3999 int Channel::SetRedPayloadType(int red_payload_type) {
3999 CodecInst codec; 4000 CodecInst codec;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
4108 int64_t min_rtt = 0; 4109 int64_t min_rtt = 0;
4109 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) 4110 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt)
4110 != 0) { 4111 != 0) {
4111 return 0; 4112 return 0;
4112 } 4113 }
4113 return rtt; 4114 return rtt;
4114 } 4115 }
4115 4116
4116 } // namespace voe 4117 } // namespace voe
4117 } // namespace webrtc 4118 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/voice_engine/channel.h ('k') | webrtc/voice_engine/output_mixer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698