Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 <memory> | |
| 14 #include <set> | |
| 15 #include <utility> | |
| 16 | |
| 17 #include "webrtc/base/pathutils.h" | |
| 18 | |
| 19 namespace webrtc { | |
| 20 namespace test { | |
| 21 namespace conversational_speech { | |
| 22 | |
| 23 MultiEndCall::MultiEndCall( | |
| 24 rtc::ArrayView<const Turn> timing, const std::string& audiotracks_path, | |
| 25 std::unique_ptr<WavReaderAbstractFactory> wavreader_abstract_factory) | |
| 26 : timing_(timing), audiotracks_path_(audiotracks_path), | |
| 27 wavreader_abstract_factory_(std::move(wavreader_abstract_factory)) { | |
| 28 FindSpeakerNames(); | |
| 29 CreateAudioTrackReaders(); | |
| 30 CheckTiming(); | |
| 31 } | |
| 32 | |
| 33 MultiEndCall::~MultiEndCall() = default; | |
| 34 | |
| 35 rtc::ArrayView<const std::string> MultiEndCall::speaker_names() const { | |
| 36 return speaker_names_; | |
| 37 } | |
| 38 | |
| 39 const std::map<std::string, std::unique_ptr<WavReaderInterface>>& | |
| 40 MultiEndCall::audiotrack_readers() const { | |
| 41 return audiotrack_readers_; | |
| 42 } | |
| 43 | |
| 44 void MultiEndCall::FindSpeakerNames() { | |
| 45 RTC_DCHECK(speaker_names_.empty()); | |
| 46 std::set<std::string> speaker_names_set; | |
| 47 for (const Turn& turn : timing_) { | |
| 48 speaker_names_set.insert(turn.speaker_name); | |
| 49 } | |
| 50 speaker_names_.assign(speaker_names_set.begin(), speaker_names_set.end()); | |
| 51 } | |
| 52 | |
| 53 void MultiEndCall::CreateAudioTrackReaders() { | |
| 54 RTC_DCHECK(audiotrack_readers_.empty()); | |
| 55 for (const Turn& turn : timing_) { | |
| 56 auto it = audiotrack_readers_.find(turn.audiotrack_file_name); | |
|
hlundin-webrtc
2017/03/27 09:46:35
There is no guarantee that audiotrack_file_names a
AleBzk
2017/03/27 11:17:06
Nope. This allows more flexibility.
hlundin-webrtc
2017/03/28 11:36:03
Acknowledged.
| |
| 57 if (it != audiotrack_readers_.end()) | |
| 58 continue; | |
| 59 | |
| 60 // Instance Pathname to retrieve the full path to the audiotrack file. | |
| 61 const rtc::Pathname audiotrack_file_path( | |
| 62 audiotracks_path_, turn.audiotrack_file_name); | |
| 63 | |
| 64 // Map the audiotrack file name to a new instance of WavReaderInterface. | |
| 65 std::unique_ptr<WavReaderInterface> wavreader = | |
| 66 wavreader_abstract_factory_->Create(audiotrack_file_path.pathname()); | |
| 67 audiotrack_readers_.insert(std::make_pair( | |
| 68 turn.audiotrack_file_name, std::move(wavreader))); | |
| 69 } | |
| 70 } | |
| 71 | |
| 72 void MultiEndCall::CheckTiming() { | |
| 73 // TODO(alessiob): use audiotrack lengths and offset to check whether the | |
| 74 // timing is valid. | |
| 75 } | |
| 76 | |
| 77 } // namespace conversational_speech | |
| 78 } // namespace test | |
| 79 } // namespace webrtc | |
| OLD | NEW |