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

Unified Diff: webrtc/voice_engine/file_recorder.cc

Issue 2750783004: Add mute state field to AudioFrame. (Closed)
Patch Set: Update new usages of AudioFrame::data_ Created 3 years, 6 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
« no previous file with comments | « webrtc/voice_engine/file_player.cc ('k') | webrtc/voice_engine/transmit_mixer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/voice_engine/file_recorder.cc
diff --git a/webrtc/voice_engine/file_recorder.cc b/webrtc/voice_engine/file_recorder.cc
index 5448451a05bfd9a6bd454e6c6bd5302255b15b6b..eed3c0799a28cbf6171a13835abb961a392965ad 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/logging.h"
#include "webrtc/base/platform_thread.h"
#include "webrtc/common_audio/resampler/include/resampler.h"
@@ -159,12 +160,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.
- 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.
@@ -172,10 +171,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());
}
}
@@ -204,8 +203,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);
« no previous file with comments | « webrtc/voice_engine/file_player.cc ('k') | webrtc/voice_engine/transmit_mixer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698