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

Unified Diff: webrtc/voice_engine/file_recorder.cc

Issue 2750783004: Add mute state field to AudioFrame. (Closed)
Patch Set: Address review comments Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/voice_engine/file_recorder.cc
diff --git a/webrtc/voice_engine/file_recorder.cc b/webrtc/voice_engine/file_recorder.cc
index 9a0edb057ba29bb3006b9a837fa7df7bfbc164e5..cb61c9a852c6407146a34f8b92cd062b85280fe1 100644
--- a/webrtc/voice_engine/file_recorder.cc
+++ b/webrtc/voice_engine/file_recorder.cc
@@ -12,6 +12,7 @@
#include <list>
+#include "webrtc/audio/utility/audio_frame_operations.h"
#include "webrtc/base/platform_thread.h"
#include "webrtc/common_audio/resampler/include/resampler.h"
#include "webrtc/common_types.h"
@@ -161,12 +162,10 @@ int32_t FileRecorderImpl::RecordAudioToFile(
tempAudioFrame.sample_rate_hz_ = incomingAudioFrame.sample_rate_hz_;
tempAudioFrame.samples_per_channel_ =
incomingAudioFrame.samples_per_channel_;
- for (size_t i = 0; i < (incomingAudioFrame.samples_per_channel_); 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.
hlundin-webrtc 2017/03/17 14:29:39 This comment must be off, right? The code could no
yujo 2017/03/17 23:55:55 Yeah, I thought so too.
- tempAudioFrame.data_[i] = ((incomingAudioFrame.data_[2 * i] +
- incomingAudioFrame.data_[(2 * i) + 1] + 1) >>
- 1);
+ if (!incomingAudioFrame.muted()) {
+ AudioFrameOperations::StereoToMono(
+ incomingAudioFrame.data(), incomingAudioFrame.samples_per_channel_,
+ tempAudioFrame.mutable_data());
}
} else if (incomingAudioFrame.num_channels_ == 1 && _moduleFile->IsStereo()) {
// Recording stereo but incoming audio is mono.
@@ -174,10 +173,10 @@ int32_t FileRecorderImpl::RecordAudioToFile(
tempAudioFrame.sample_rate_hz_ = incomingAudioFrame.sample_rate_hz_;
tempAudioFrame.samples_per_channel_ =
incomingAudioFrame.samples_per_channel_;
- for (size_t i = 0; i < (incomingAudioFrame.samples_per_channel_); i++) {
- // Duplicate sample to both channels
- tempAudioFrame.data_[2 * i] = incomingAudioFrame.data_[i];
- tempAudioFrame.data_[2 * i + 1] = incomingAudioFrame.data_[i];
+ if (!incomingAudioFrame.muted()) {
+ AudioFrameOperations::MonoToStereo(
+ incomingAudioFrame.data(), incomingAudioFrame.samples_per_channel_,
+ tempAudioFrame.mutable_data());
}
}
@@ -206,8 +205,9 @@ int32_t FileRecorderImpl::RecordAudioToFile(
_audioResampler.ResetIfNeeded(ptrAudioFrame->sample_rate_hz_,
codec_info_.plfreq,
ptrAudioFrame->num_channels_);
+ // TODO(yujo): skip resample if frame is muted.
_audioResampler.Push(
- ptrAudioFrame->data_,
+ ptrAudioFrame->data(),
ptrAudioFrame->samples_per_channel_ * ptrAudioFrame->num_channels_,
reinterpret_cast<int16_t*>(_audioBuffer), MAX_AUDIO_BUFFER_IN_BYTES,
outLen);

Powered by Google App Engine
This is Rietveld 408576698