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

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

Issue 2761853002: Conversational Speech tool, MultiEndCall class and unit tests via mocking (Closed)
Patch Set: BUILD deps fixed 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/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
new file mode 100644
index 0000000000000000000000000000000000000000..f16aa753fa427a42b7def1298c145a52f3154afd
--- /dev/null
+++ b/webrtc/modules/audio_processing/test/conversational_speech/multiend_call.cc
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2017 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
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "webrtc/modules/audio_processing/test/conversational_speech/multiend_call.h"
+
+#include <utility>
+
+#include "webrtc/base/pathutils.h"
+
+namespace webrtc {
+namespace test {
+namespace conversational_speech {
+
+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)) {
+ FindSpeakerNames();
+ CreateAudioTrackReaders();
+ CheckTiming();
+}
+
+MultiEndCall::~MultiEndCall() = default;
+
+const std::set<std::string>& MultiEndCall::speaker_names() const {
+ return speaker_names_;
+}
+
+const std::map<std::string, std::unique_ptr<WavReaderInterface>>&
+ MultiEndCall::audiotrack_readers() const {
+ return audiotrack_readers_;
+}
+
+void MultiEndCall::FindSpeakerNames() {
+ RTC_DCHECK(speaker_names_.empty());
+ for (const Turn& turn : timing_) {
+ speaker_names_.insert(turn.speaker_name);
+ }
+}
+
+void MultiEndCall::CreateAudioTrackReaders() {
+ RTC_DCHECK(audiotrack_readers_.empty());
+ for (const Turn& turn : timing_) {
+ auto it = audiotrack_readers_.find(turn.audiotrack_file_name);
+ if (it != audiotrack_readers_.end())
+ continue;
+
+ // Instance Pathname to retrieve the full path to the audiotrack file.
+ const rtc::Pathname audiotrack_file_path(
+ audiotracks_path_, turn.audiotrack_file_name);
+
+ // Map the audiotrack file name to a new instance of WavReaderInterface.
+ std::unique_ptr<WavReaderInterface> wavreader =
+ wavreader_abstract_factory_->Create(audiotrack_file_path.pathname());
+ audiotrack_readers_.insert(std::make_pair(
+ turn.audiotrack_file_name, std::move(wavreader)));
+ }
+}
+
+void MultiEndCall::CheckTiming() {
+ // TODO(alessiob): use audiotrack lengths and offset to check whether the
+ // timing is valid.
+}
+
+} // namespace conversational_speech
+} // namespace test
+} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698