Inband DTMF stereo support

Review URL: http://webrtc-codereview.appspot.com/267011

git-svn-id: http://webrtc.googlecode.com/svn/trunk@956 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
niklas.enbom@webrtc.org 2011-11-16 12:41:36 +00:00
parent e33a102eee
commit af26f64616

View File

@ -5931,7 +5931,7 @@ Channel::EncodeAndSend()
WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId), WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId),
"Channel::EncodeAndSend()"); "Channel::EncodeAndSend()");
assert(_audioFrame._audioChannel == 1); assert(_audioFrame._audioChannel <= 2);
if (_audioFrame._payloadDataLengthInSamples == 0) if (_audioFrame._payloadDataLengthInSamples == 0)
{ {
WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId,_channelId), WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId,_channelId),
@ -6370,6 +6370,7 @@ Channel::MixAudioWithFile(AudioFrame& audioFrame,
int int
Channel::InsertInbandDtmfTone() Channel::InsertInbandDtmfTone()
{ {
// Check if we should start a new tone.
if (_inbandDtmfQueue.PendingDtmf() && if (_inbandDtmfQueue.PendingDtmf() &&
!_inbandDtmfGenerator.IsAddingTone() && !_inbandDtmfGenerator.IsAddingTone() &&
_inbandDtmfGenerator.DelaySinceLastTone() > _inbandDtmfGenerator.DelaySinceLastTone() >
@ -6405,7 +6406,7 @@ Channel::InsertInbandDtmfTone()
// account. // account.
_inbandDtmfGenerator.ResetTone(); _inbandDtmfGenerator.ResetTone();
} }
WebRtc_Word16 toneBuffer[320]; WebRtc_Word16 toneBuffer[320];
WebRtc_UWord16 toneSamples(0); WebRtc_UWord16 toneSamples(0);
// Get 10ms tone segment and set time since last tone to zero // Get 10ms tone segment and set time since last tone to zero
@ -6417,11 +6418,20 @@ Channel::InsertInbandDtmfTone()
return -1; return -1;
} }
// Replace mixed audio with Dtmf tone // Replace mixed audio with DTMF tone.
memcpy(_audioFrame._payloadData, toneBuffer, sizeof(WebRtc_Word16) for (int sample = 0;
* toneSamples); sample < _audioFrame._payloadDataLengthInSamples;
sample++)
assert(_audioFrame._audioChannel == 1); {
for (int channel = 0;
channel < _audioFrame._audioChannel;
channel++)
{
_audioFrame._payloadData[sample * _audioFrame._audioChannel + channel] =
toneBuffer[sample];
}
}
assert(_audioFrame._payloadDataLengthInSamples == toneSamples); assert(_audioFrame._payloadDataLengthInSamples == toneSamples);
} else } else
{ {