This CL will look a bit strange. Essentially I've removed sanity checks for > 1 channel and then fixed the bugs that remained. Will add testing in a separate CL.
BUG= TEST= Review URL: https://webrtc-codereview.appspot.com/390001 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1623 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
2726cd22c9
commit
87885e8409
@ -1150,9 +1150,9 @@ WebRtc_Word32 MediaFileImpl::StartRecordingStream(
|
|||||||
StopRecording();
|
StopRecording();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if((STR_NCASE_CMP(codec_info_.plname, "L16", 4) != 0) &&
|
if((STR_NCASE_CMP(tmpAudioCodec.plname, "L16", 4) != 0) &&
|
||||||
(STR_NCASE_CMP(codec_info_.plname, "PCMU", 5) != 0) &&
|
(STR_NCASE_CMP(tmpAudioCodec.plname, "PCMU", 5) != 0) &&
|
||||||
(STR_NCASE_CMP(codec_info_.plname, "PCMA", 5) != 0))
|
(STR_NCASE_CMP(tmpAudioCodec.plname, "PCMA", 5) != 0))
|
||||||
{
|
{
|
||||||
WEBRTC_TRACE(
|
WEBRTC_TRACE(
|
||||||
kTraceWarning,
|
kTraceWarning,
|
||||||
|
@ -204,8 +204,10 @@ WebRtc_Word32 FileRecorderImpl::RecordAudioToFile(
|
|||||||
// Recording mono but incoming audio is (interleaved) stereo.
|
// Recording mono but incoming audio is (interleaved) stereo.
|
||||||
tempAudioFrame._audioChannel = 1;
|
tempAudioFrame._audioChannel = 1;
|
||||||
tempAudioFrame._frequencyInHz = incomingAudioFrame._frequencyInHz;
|
tempAudioFrame._frequencyInHz = incomingAudioFrame._frequencyInHz;
|
||||||
|
tempAudioFrame._payloadDataLengthInSamples =
|
||||||
|
incomingAudioFrame._payloadDataLengthInSamples;
|
||||||
for (WebRtc_UWord16 i = 0;
|
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
|
// Sample value is the average of left and right buffer rounded to
|
||||||
// closest integer value. Note samples can be either 1 or 2 byte.
|
// 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] +
|
||||||
incomingAudioFrame._payloadData[(2 * i) + 1] + 1) >> 1);
|
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 =
|
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;
|
const AudioFrame* ptrAudioFrame = &incomingAudioFrame;
|
||||||
@ -254,7 +272,8 @@ WebRtc_Word32 FileRecorderImpl::RecordAudioToFile(
|
|||||||
codec_info_.plfreq,
|
codec_info_.plfreq,
|
||||||
kResamplerSynchronousStereo);
|
kResamplerSynchronousStereo);
|
||||||
_audioResampler.Push(ptrAudioFrame->_payloadData,
|
_audioResampler.Push(ptrAudioFrame->_payloadData,
|
||||||
ptrAudioFrame->_payloadDataLengthInSamples,
|
ptrAudioFrame->_payloadDataLengthInSamples *
|
||||||
|
ptrAudioFrame->_audioChannel,
|
||||||
(WebRtc_Word16*)_audioBuffer,
|
(WebRtc_Word16*)_audioBuffer,
|
||||||
MAX_AUDIO_BUFFER_IN_BYTES, outLen);
|
MAX_AUDIO_BUFFER_IN_BYTES, outLen);
|
||||||
} else {
|
} else {
|
||||||
@ -266,7 +285,7 @@ WebRtc_Word32 FileRecorderImpl::RecordAudioToFile(
|
|||||||
(WebRtc_Word16*)_audioBuffer,
|
(WebRtc_Word16*)_audioBuffer,
|
||||||
MAX_AUDIO_BUFFER_IN_BYTES, outLen);
|
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
|
// Codec may not be operating at a frame rate of 10 ms. Whenever enough
|
||||||
|
@ -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
|
* 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
|
* 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
|
const WebRtc_UWord32 notificationTime(0); // Not supported in VoE
|
||||||
CodecInst dummyCodec = { 100, "L16", 16000, 320, 1, 320000 };
|
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(
|
_engineStatisticsPtr->SetLastError(
|
||||||
VE_BAD_ARGUMENT, kTraceError,
|
VE_BAD_ARGUMENT, kTraceError,
|
||||||
@ -1194,8 +1195,6 @@ TransmitMixer::GenerateAudioFrame(const WebRtc_Word16 audioSamples[],
|
|||||||
WebRtc_Word32 TransmitMixer::RecordAudioToFile(
|
WebRtc_Word32 TransmitMixer::RecordAudioToFile(
|
||||||
const WebRtc_UWord32 mixingFrequency)
|
const WebRtc_UWord32 mixingFrequency)
|
||||||
{
|
{
|
||||||
assert(_audioFrame._audioChannel == 1);
|
|
||||||
|
|
||||||
CriticalSectionScoped cs(_critSect);
|
CriticalSectionScoped cs(_critSect);
|
||||||
if (_fileRecorderPtr == NULL)
|
if (_fileRecorderPtr == NULL)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user