Chromium Code Reviews| 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..c8734de791a207fe8f637a12b18d7022296f4236 |
| --- /dev/null |
| +++ b/webrtc/modules/audio_processing/test/conversational_speech/multiend_call.cc |
| @@ -0,0 +1,82 @@ |
| +/* |
| + * 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 <memory> |
| +#include <set> |
| +#include <utility> |
| + |
| +#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.
|
| +#include "webrtc/base/pathutils.h" |
| +#include "webrtc/modules/audio_processing/test/conversational_speech/timing.h" |
| +#include "webrtc/modules/audio_processing/test/conversational_speech/wavreader_abstract_factory.h" |
| +#include "webrtc/modules/audio_processing/test/conversational_speech/wavreader_interface.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() {} |
|
hlundin-webrtc
2017/03/24 13:44:05
= default;
AleBzk
2017/03/27 08:24:13
Done.
|
| + |
| +rtc::ArrayView<const 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() { |
|
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
|
| + std::set<std::string> speaker_names_set; |
| + for (const Turn& turn : timing_) { |
| + speaker_names_set.insert(turn.speaker_name); |
| + } |
| + speaker_names_.assign(speaker_names_set.begin(), speaker_names_set.end()); |
| +} |
| + |
| +void MultiEndCall::CreateAudioTrackReaders() { |
| + for (const Turn& turn : timing_) { |
| + auto it = audiotrack_readers_.find(turn.audiotrack_file_name); |
| + 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
|
| + 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( |
|
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
|
| + std::pair<std::string, std::unique_ptr<WavReaderInterface>>( |
| + 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 |