From af26f646165e7e2a8747fd54e92e73f48118a807 Mon Sep 17 00:00:00 2001 From: "niklas.enbom@webrtc.org" Date: Wed, 16 Nov 2011 12:41:36 +0000 Subject: [PATCH] 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 --- src/voice_engine/main/source/channel.cc | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/voice_engine/main/source/channel.cc b/src/voice_engine/main/source/channel.cc index 461c05525f..34a8190b33 100644 --- a/src/voice_engine/main/source/channel.cc +++ b/src/voice_engine/main/source/channel.cc @@ -5931,7 +5931,7 @@ Channel::EncodeAndSend() WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId), "Channel::EncodeAndSend()"); - assert(_audioFrame._audioChannel == 1); + assert(_audioFrame._audioChannel <= 2); if (_audioFrame._payloadDataLengthInSamples == 0) { WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId,_channelId), @@ -6370,6 +6370,7 @@ Channel::MixAudioWithFile(AudioFrame& audioFrame, int Channel::InsertInbandDtmfTone() { + // Check if we should start a new tone. if (_inbandDtmfQueue.PendingDtmf() && !_inbandDtmfGenerator.IsAddingTone() && _inbandDtmfGenerator.DelaySinceLastTone() > @@ -6405,7 +6406,7 @@ Channel::InsertInbandDtmfTone() // account. _inbandDtmfGenerator.ResetTone(); } - + WebRtc_Word16 toneBuffer[320]; WebRtc_UWord16 toneSamples(0); // Get 10ms tone segment and set time since last tone to zero @@ -6417,11 +6418,20 @@ Channel::InsertInbandDtmfTone() return -1; } - // Replace mixed audio with Dtmf tone - memcpy(_audioFrame._payloadData, toneBuffer, sizeof(WebRtc_Word16) - * toneSamples); - - assert(_audioFrame._audioChannel == 1); + // Replace mixed audio with DTMF tone. + for (int sample = 0; + sample < _audioFrame._payloadDataLengthInSamples; + sample++) + { + for (int channel = 0; + channel < _audioFrame._audioChannel; + channel++) + { + _audioFrame._payloadData[sample * _audioFrame._audioChannel + channel] = + toneBuffer[sample]; + } + } + assert(_audioFrame._payloadDataLengthInSamples == toneSamples); } else {