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

Side by Side 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, 8 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "webrtc/modules/audio_processing/test/conversational_speech/multiend_ca ll.h"
12
13 #include <utility>
14
15 #include "webrtc/base/pathutils.h"
16
17 namespace webrtc {
18 namespace test {
19 namespace conversational_speech {
20
21 MultiEndCall::MultiEndCall(
22 rtc::ArrayView<const Turn> timing, const std::string& audiotracks_path,
23 std::unique_ptr<WavReaderAbstractFactory> wavreader_abstract_factory)
24 : timing_(timing), audiotracks_path_(audiotracks_path),
25 wavreader_abstract_factory_(std::move(wavreader_abstract_factory)) {
26 FindSpeakerNames();
27 CreateAudioTrackReaders();
28 CheckTiming();
29 }
30
31 MultiEndCall::~MultiEndCall() = default;
32
33 const std::set<std::string>& MultiEndCall::speaker_names() const {
34 return speaker_names_;
35 }
36
37 const std::map<std::string, std::unique_ptr<WavReaderInterface>>&
38 MultiEndCall::audiotrack_readers() const {
39 return audiotrack_readers_;
40 }
41
42 void MultiEndCall::FindSpeakerNames() {
43 RTC_DCHECK(speaker_names_.empty());
44 for (const Turn& turn : timing_) {
45 speaker_names_.insert(turn.speaker_name);
46 }
47 }
48
49 void MultiEndCall::CreateAudioTrackReaders() {
50 RTC_DCHECK(audiotrack_readers_.empty());
51 for (const Turn& turn : timing_) {
52 auto it = audiotrack_readers_.find(turn.audiotrack_file_name);
53 if (it != audiotrack_readers_.end())
54 continue;
55
56 // Instance Pathname to retrieve the full path to the audiotrack file.
57 const rtc::Pathname audiotrack_file_path(
58 audiotracks_path_, turn.audiotrack_file_name);
59
60 // Map the audiotrack file name to a new instance of WavReaderInterface.
61 std::unique_ptr<WavReaderInterface> wavreader =
62 wavreader_abstract_factory_->Create(audiotrack_file_path.pathname());
63 audiotrack_readers_.insert(std::make_pair(
64 turn.audiotrack_file_name, std::move(wavreader)));
65 }
66 }
67
68 void MultiEndCall::CheckTiming() {
69 // TODO(alessiob): use audiotrack lengths and offset to check whether the
70 // timing is valid.
71 }
72
73 } // namespace conversational_speech
74 } // namespace test
75 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698