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

Unified Diff: webrtc/modules/audio_processing/test/conversational_speech/multiend_call.cc

Issue 2790933002: Conversational speech tool, simualtor + unit tests (Closed)
Patch Set: map iterators simplified Created 3 years, 7 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/modules/audio_processing/test/conversational_speech/multiend_call.cc
diff --git a/webrtc/modules/audio_processing/test/conversational_speech/multiend_call.cc b/webrtc/modules/audio_processing/test/conversational_speech/multiend_call.cc
index 624f981ae51f0e22b3928652a875c2e1618812f2..b796e7dc733e5b0761a5f8ae037e550754e5d20d 100644
--- a/webrtc/modules/audio_processing/test/conversational_speech/multiend_call.cc
+++ b/webrtc/modules/audio_processing/test/conversational_speech/multiend_call.cc
@@ -24,10 +24,11 @@ MultiEndCall::MultiEndCall(
rtc::ArrayView<const Turn> timing, const std::string& audiotracks_path,
std::unique_ptr<WavReaderAbstractFactory> wavreader_abstract_factory)
: timing_(timing), audiotracks_path_(audiotracks_path),
- wavreader_abstract_factory_(std::move(wavreader_abstract_factory)) {
+ wavreader_abstract_factory_(std::move(wavreader_abstract_factory)),
+ valid_(false) {
FindSpeakerNames();
- CreateAudioTrackReaders();
- valid_ = CheckTiming();
+ if (CreateAudioTrackReaders())
+ valid_ = CheckTiming();
}
MultiEndCall::~MultiEndCall() = default;
@@ -45,6 +46,10 @@ bool MultiEndCall::valid() const {
return valid_;
}
+int MultiEndCall::sample_rate() const {
+ return sample_rate_;
+}
+
size_t MultiEndCall::total_duration_samples() const {
return total_duration_samples_;
}
@@ -61,8 +66,9 @@ void MultiEndCall::FindSpeakerNames() {
}
}
-void MultiEndCall::CreateAudioTrackReaders() {
+bool MultiEndCall::CreateAudioTrackReaders() {
RTC_DCHECK(audiotrack_readers_.empty());
+ sample_rate_ = 0; // Sample rate will be set when reading the first track.
for (const Turn& turn : timing_) {
auto it = audiotrack_readers_.find(turn.audiotrack_file_name);
if (it != audiotrack_readers_.end())
minyue-webrtc 2017/05/16 15:05:16 If this is supposed to be incremental, why doesn't
AleBzk 2017/05/17 12:49:37 Here I check if the audio track file has already b
@@ -75,9 +81,24 @@ void MultiEndCall::CreateAudioTrackReaders() {
// Map the audiotrack file name to a new instance of WavReaderInterface.
std::unique_ptr<WavReaderInterface> wavreader =
wavreader_abstract_factory_->Create(audiotrack_file_path.pathname());
+
+ if (sample_rate_ == 0) {
+ sample_rate_ = wavreader->SampleRate();
+ } else if (sample_rate_ != wavreader->SampleRate()) {
+ LOG(LS_ERROR) << "all the audio tracks should have the same sample rate";
minyue-webrtc 2017/05/16 15:05:16 "A"ll and add full stop at the end of the sentence
AleBzk 2017/05/17 12:49:37 Done.
+ return false;
+ }
+
+ if (wavreader->NumChannels() != 1) {
+ LOG(LS_ERROR) << "only mono audio tracks supported";
minyue-webrtc 2017/05/16 15:05:16 "O"nly and full stop.
AleBzk 2017/05/17 12:49:37 Done.
+ return false;
+ }
+
audiotrack_readers_.emplace(
minyue-webrtc 2017/05/16 15:05:16 Is this emplace allowed? try a few trybots.
AleBzk 2017/05/17 12:49:37 No need to try. This line was landed in a previous
minyue-webrtc 2017/05/18 13:35:13 Acknowledged.
turn.audiotrack_file_name, std::move(wavreader));
}
+
+ return true;
}
bool MultiEndCall::CheckTiming() {

Powered by Google App Engine
This is Rietveld 408576698