diff --git a/src/modules/media_file/source/media_file_impl.cc b/src/modules/media_file/source/media_file_impl.cc index 3199c1246..869830f78 100644 --- a/src/modules/media_file/source/media_file_impl.cc +++ b/src/modules/media_file/source/media_file_impl.cc @@ -1150,9 +1150,9 @@ WebRtc_Word32 MediaFileImpl::StartRecordingStream( StopRecording(); return -1; } - if((STR_NCASE_CMP(codec_info_.plname, "L16", 4) != 0) && - (STR_NCASE_CMP(codec_info_.plname, "PCMU", 5) != 0) && - (STR_NCASE_CMP(codec_info_.plname, "PCMA", 5) != 0)) + if((STR_NCASE_CMP(tmpAudioCodec.plname, "L16", 4) != 0) && + (STR_NCASE_CMP(tmpAudioCodec.plname, "PCMU", 5) != 0) && + (STR_NCASE_CMP(tmpAudioCodec.plname, "PCMA", 5) != 0)) { WEBRTC_TRACE( kTraceWarning, diff --git a/src/modules/utility/source/file_recorder_impl.cc b/src/modules/utility/source/file_recorder_impl.cc index ecba43579..7fff4b4a9 100644 --- a/src/modules/utility/source/file_recorder_impl.cc +++ b/src/modules/utility/source/file_recorder_impl.cc @@ -204,8 +204,10 @@ WebRtc_Word32 FileRecorderImpl::RecordAudioToFile( // Recording mono but incoming audio is (interleaved) stereo. tempAudioFrame._audioChannel = 1; tempAudioFrame._frequencyInHz = incomingAudioFrame._frequencyInHz; + tempAudioFrame._payloadDataLengthInSamples = + incomingAudioFrame._payloadDataLengthInSamples; for (WebRtc_UWord16 i = 0; - i < (incomingAudioFrame._payloadDataLengthInSamples >> 1); i++) + i < (incomingAudioFrame._payloadDataLengthInSamples); i++) { // Sample value is the average of left and right buffer rounded to // closest integer value. Note samples can be either 1 or 2 byte. @@ -213,8 +215,24 @@ WebRtc_Word32 FileRecorderImpl::RecordAudioToFile( ((incomingAudioFrame._payloadData[2 * i] + incomingAudioFrame._payloadData[(2 * i) + 1] + 1) >> 1); } + } + else if( incomingAudioFrame._audioChannel == 1 && + _moduleFile->IsStereo()) + { + // Recording stereo but incoming audio is mono. + tempAudioFrame._audioChannel = 2; + tempAudioFrame._frequencyInHz = incomingAudioFrame._frequencyInHz; tempAudioFrame._payloadDataLengthInSamples = - incomingAudioFrame._payloadDataLengthInSamples / 2; + incomingAudioFrame._payloadDataLengthInSamples; + for (WebRtc_UWord16 i = 0; + i < (incomingAudioFrame._payloadDataLengthInSamples); i++) + { + // Duplicate sample to both channels + tempAudioFrame._payloadData[2*i] = + incomingAudioFrame._payloadData[i]; + tempAudioFrame._payloadData[2*i+1] = + incomingAudioFrame._payloadData[i]; + } } const AudioFrame* ptrAudioFrame = &incomingAudioFrame; @@ -254,7 +272,8 @@ WebRtc_Word32 FileRecorderImpl::RecordAudioToFile( codec_info_.plfreq, kResamplerSynchronousStereo); _audioResampler.Push(ptrAudioFrame->_payloadData, - ptrAudioFrame->_payloadDataLengthInSamples, + ptrAudioFrame->_payloadDataLengthInSamples * + ptrAudioFrame->_audioChannel, (WebRtc_Word16*)_audioBuffer, MAX_AUDIO_BUFFER_IN_BYTES, outLen); } else { @@ -266,7 +285,7 @@ WebRtc_Word32 FileRecorderImpl::RecordAudioToFile( (WebRtc_Word16*)_audioBuffer, MAX_AUDIO_BUFFER_IN_BYTES, outLen); } - encodedLenInBytes = outLen*2; + encodedLenInBytes = outLen * sizeof(WebRtc_Word16); } // Codec may not be operating at a frame rate of 10 ms. Whenever enough diff --git a/src/voice_engine/main/source/transmit_mixer.cc b/src/voice_engine/main/source/transmit_mixer.cc index 25f70d37c..d131a8574 100644 --- a/src/voice_engine/main/source/transmit_mixer.cc +++ b/src/voice_engine/main/source/transmit_mixer.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -722,7 +722,8 @@ int TransmitMixer::StartRecordingMicrophone(const WebRtc_Word8* fileName, const WebRtc_UWord32 notificationTime(0); // Not supported in VoE CodecInst dummyCodec = { 100, "L16", 16000, 320, 1, 320000 }; - if (codecInst != NULL && codecInst->channels != 1) + if (codecInst != NULL && + (codecInst->channels < 0 || codecInst->channels > 2)) { _engineStatisticsPtr->SetLastError( VE_BAD_ARGUMENT, kTraceError, @@ -1194,8 +1195,6 @@ TransmitMixer::GenerateAudioFrame(const WebRtc_Word16 audioSamples[], WebRtc_Word32 TransmitMixer::RecordAudioToFile( const WebRtc_UWord32 mixingFrequency) { - assert(_audioFrame._audioChannel == 1); - CriticalSectionScoped cs(_critSect); if (_fileRecorderPtr == NULL) {