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/array_view.h" | |
|
hlundin-webrtc
2017/03/24 13:44:05
Skip this; already included in header.
AleBzk
2017/03/27 08:24:14
Same for the includes below except for the first t
hlundin-webrtc
2017/03/27 09:46:34
https://google.github.io/styleguide/cppguide.html#
AleBzk
2017/03/27 11:17:06
Acknowledged.
| |
| 18 #include "webrtc/base/pathutils.h" | |
| 19 #include "webrtc/modules/audio_processing/test/conversational_speech/timing.h" | |
| 20 #include "webrtc/modules/audio_processing/test/conversational_speech/wavreader_a bstract_factory.h" | |
| 21 #include "webrtc/modules/audio_processing/test/conversational_speech/wavreader_i nterface.h" | |
| 22 | |
| 23 namespace webrtc { | |
| 24 namespace test { | |
| 25 namespace conversational_speech { | |
| 26 | |
| 27 MultiEndCall::MultiEndCall( | |
| 28 rtc::ArrayView<const Turn> timing, const std::string& audiotracks_path, | |
| 29 std::unique_ptr<WavReaderAbstractFactory> wavreader_abstract_factory) | |
| 30 : timing_(timing), audiotracks_path_(audiotracks_path), | |
| 31 wavreader_abstract_factory_(std::move(wavreader_abstract_factory)) { | |
| 32 FindSpeakerNames(); | |
| 33 CreateAudioTrackReaders(); | |
| 34 CheckTiming(); | |
| 35 } | |
| 36 | |
| 37 MultiEndCall::~MultiEndCall() {} | |
|
hlundin-webrtc
2017/03/24 13:44:05
= default;
AleBzk
2017/03/27 08:24:13
Done.
| |
| 38 | |
| 39 rtc::ArrayView<const std::string> MultiEndCall::speaker_names() const { | |
| 40 return speaker_names_; | |
| 41 } | |
| 42 | |
| 43 const std::map<std::string, std::unique_ptr<WavReaderInterface>>& | |
| 44 MultiEndCall::audiotrack_readers() const { | |
| 45 return audiotrack_readers_; | |
| 46 } | |
| 47 | |
| 48 void MultiEndCall::FindSpeakerNames() { | |
|
hlundin-webrtc
2017/03/24 13:44:05
This is only going to be called from the construct
AleBzk
2017/03/27 08:24:14
Note that speaker_names_ is std::vector.
I use spe
hlundin-webrtc
2017/03/27 09:46:34
I think you should consider sticking with the set
| |
| 49 std::set<std::string> speaker_names_set; | |
| 50 for (const Turn& turn : timing_) { | |
| 51 speaker_names_set.insert(turn.speaker_name); | |
| 52 } | |
| 53 speaker_names_.assign(speaker_names_set.begin(), speaker_names_set.end()); | |
| 54 } | |
| 55 | |
| 56 void MultiEndCall::CreateAudioTrackReaders() { | |
| 57 for (const Turn& turn : timing_) { | |
| 58 auto it = audiotrack_readers_.find(turn.audiotrack_file_name); | |
| 59 if (it != audiotrack_readers_.end()) | |
|
hlundin-webrtc
2017/03/24 13:44:05
This method is also supposed to be called from the
AleBzk
2017/03/27 08:24:13
Yes
| |
| 60 continue; | |
| 61 | |
| 62 // Instance Pathname to retrieve the full path to the audiotrack file. | |
| 63 const rtc::Pathname audiotrack_file_path( | |
| 64 audiotracks_path_, turn.audiotrack_file_name); | |
| 65 | |
| 66 // Map the audiotrack file name to a new instance of WavReaderInterface. | |
| 67 std::unique_ptr<WavReaderInterface> wavreader = | |
| 68 wavreader_abstract_factory_->Create(audiotrack_file_path.pathname()); | |
| 69 audiotrack_readers_.insert( | |
|
hlundin-webrtc
2017/03/24 13:44:05
I think you can make this somewhat shorter, like
a
AleBzk
2017/03/27 08:24:14
Done.
hlundin-webrtc
2017/03/27 09:46:34
Did you try emplace?
AleBzk
2017/03/27 11:17:06
As far as I understand from http://www.cplusplus.c
| |
| 70 std::pair<std::string, std::unique_ptr<WavReaderInterface>>( | |
| 71 turn.audiotrack_file_name, std::move(wavreader))); | |
| 72 } | |
| 73 } | |
| 74 | |
| 75 void MultiEndCall::CheckTiming() { | |
| 76 // TODO(alessiob): use audiotrack lengths and offset to check whether the | |
| 77 // timing is valid. | |
| 78 } | |
| 79 | |
| 80 } // namespace conversational_speech | |
| 81 } // namespace test | |
| 82 } // namespace webrtc | |
| OLD | NEW |