diff --git a/webrtc/modules/audio_processing/test/conversational_speech/BUILD.gn b/webrtc/modules/audio_processing/test/conversational_speech/BUILD.gn index 4375c4efb3..ca5977fae8 100644 --- a/webrtc/modules/audio_processing/test/conversational_speech/BUILD.gn +++ b/webrtc/modules/audio_processing/test/conversational_speech/BUILD.gn @@ -33,11 +33,21 @@ rtc_static_library("lib") { sources = [ "config.cc", "config.h", + "multiend_call.cc", + "multiend_call.h", "timing.cc", "timing.h", + "wavreader_abstract_factory.h", + "wavreader_adaptor.cc", + "wavreader_adaptor.h", + "wavreader_factory.cc", + "wavreader_factory.h", + "wavreader_interface.h", ] deps = [ + "//webrtc:webrtc_common", "//webrtc/base:rtc_base_approved", + "//webrtc/common_audio", ] visibility = [ ":*" ] # Only targets in this file can depend on this. } @@ -46,11 +56,15 @@ rtc_source_set("unittest") { testonly = true sources = [ "generator_unittest.cc", + "mock_wavreader.h", + "mock_wavreader_factory.cc", + "mock_wavreader_factory.h", ] deps = [ ":lib", "//testing/gmock", "//testing/gtest", + "//webrtc:webrtc_common", "//webrtc/test:test_support", ] } diff --git a/webrtc/modules/audio_processing/test/conversational_speech/generator_unittest.cc b/webrtc/modules/audio_processing/test/conversational_speech/generator_unittest.cc index 221ad7c706..59454d9d47 100644 --- a/webrtc/modules/audio_processing/test/conversational_speech/generator_unittest.cc +++ b/webrtc/modules/audio_processing/test/conversational_speech/generator_unittest.cc @@ -8,11 +8,14 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include +#include #include #include "webrtc/modules/audio_processing/test/conversational_speech/config.h" +#include "webrtc/modules/audio_processing/test/conversational_speech/mock_wavreader_factory.h" +#include "webrtc/modules/audio_processing/test/conversational_speech/multiend_call.h" #include "webrtc/modules/audio_processing/test/conversational_speech/timing.h" +#include "webrtc/test/gmock.h" #include "webrtc/test/gtest.h" #include "webrtc/test/testsupport/fileutils.h" @@ -22,7 +25,10 @@ namespace { using conversational_speech::LoadTiming; using conversational_speech::SaveTiming; +using conversational_speech::MockWavReaderFactory; +using conversational_speech::MultiEndCall; using conversational_speech::Turn; +using conversational_speech::WavReaderAbstractFactory; const char* const audiotracks_path = "/path/to/audiotracks"; const char* const timing_filepath = "/path/to/timing_file.txt"; @@ -34,7 +40,7 @@ const std::vector expected_timing = { {"A", "a2", 100}, {"B", "b2", -200}, {"A", "a3", 0}, - {"A", "a4", 0}, + {"A", "a3", 0}, }; const std::size_t kNumberOfTurns = expected_timing.size(); @@ -50,11 +56,6 @@ TEST(ConversationalSpeechTest, Settings) { EXPECT_EQ(output_path, config.output_path()); } -TEST(ConversationalSpeechTest, ExpectedTimingSize) { - // Check the expected timing size. - EXPECT_EQ(kNumberOfTurns, 6u); -} - TEST(ConversationalSpeechTest, TimingSaveLoad) { // Save test timing. const std::string temporary_filepath = webrtc::test::TempFilename( @@ -75,5 +76,21 @@ TEST(ConversationalSpeechTest, TimingSaveLoad) { } } +TEST(ConversationalSpeechTest, MultiEndCallCreate) { + auto mock_wavreader_factory = std::unique_ptr( + new MockWavReaderFactory()); + + // There are 5 unique audio tracks to read. + EXPECT_CALL(*mock_wavreader_factory, Create(testing::_)).Times(5); + + // Inject the mock wav reader factory. + conversational_speech::MultiEndCall multiend_call( + expected_timing, audiotracks_path, std::move(mock_wavreader_factory)); + + // Test. + EXPECT_EQ(2u, multiend_call.speaker_names().size()); + EXPECT_EQ(5u, multiend_call.audiotrack_readers().size()); +} + } // namespace test } // namespace webrtc diff --git a/webrtc/modules/audio_processing/test/conversational_speech/mock_wavreader.h b/webrtc/modules/audio_processing/test/conversational_speech/mock_wavreader.h new file mode 100644 index 0000000000..83aa9382e5 --- /dev/null +++ b/webrtc/modules/audio_processing/test/conversational_speech/mock_wavreader.h @@ -0,0 +1,52 @@ +/* + * 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. + */ + +#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_MOCK_WAVREADER_H_ +#define WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_MOCK_WAVREADER_H_ + +#include +#include + +#include "webrtc/modules/audio_processing/test/conversational_speech/wavreader_interface.h" +#include "webrtc/test/gmock.h" +#include "webrtc/typedefs.h" + +namespace webrtc { +namespace test { +namespace conversational_speech { + +class MockWavReader : public WavReaderInterface { + public: + MockWavReader( + int sample_rate, size_t num_channels, size_t num_samples) + : sample_rate_(sample_rate), num_channels_(num_channels), + num_samples_(num_samples) {} + ~MockWavReader() = default; + + // TOOD(alessiob): use ON_CALL to return random samples. + MOCK_METHOD2(ReadFloatSamples, size_t(size_t, float*)); + MOCK_METHOD2(ReadInt16Samples, size_t(size_t, int16_t*)); + + // TOOD(alessiob): use ON_CALL to return properties. + MOCK_CONST_METHOD0(sample_rate, int()); + MOCK_CONST_METHOD0(num_channels, size_t()); + MOCK_CONST_METHOD0(num_samples, size_t()); + + private: + const int sample_rate_; + const size_t num_channels_; + const size_t num_samples_; +}; + +} // namespace conversational_speech +} // namespace test +} // namespace webrtc + +#endif // WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_MOCK_WAVREADER_H_ diff --git a/webrtc/modules/audio_processing/test/conversational_speech/mock_wavreader_factory.cc b/webrtc/modules/audio_processing/test/conversational_speech/mock_wavreader_factory.cc new file mode 100644 index 0000000000..1097639527 --- /dev/null +++ b/webrtc/modules/audio_processing/test/conversational_speech/mock_wavreader_factory.cc @@ -0,0 +1,23 @@ +/* + * 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/mock_wavreader_factory.h" + +namespace webrtc { +namespace test { +namespace conversational_speech { + +MockWavReaderFactory::MockWavReaderFactory() = default; + +MockWavReaderFactory::~MockWavReaderFactory() = default; + +} // namespace conversational_speech +} // namespace test +} // namespace webrtc diff --git a/webrtc/modules/audio_processing/test/conversational_speech/mock_wavreader_factory.h b/webrtc/modules/audio_processing/test/conversational_speech/mock_wavreader_factory.h new file mode 100644 index 0000000000..3686d12dd7 --- /dev/null +++ b/webrtc/modules/audio_processing/test/conversational_speech/mock_wavreader_factory.h @@ -0,0 +1,42 @@ +/* + * 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. + */ + +#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_MOCK_WAVREADER_FACTORY_H_ +#define WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_MOCK_WAVREADER_FACTORY_H_ + +#include +#include + +#include "webrtc/modules/audio_processing/test/conversational_speech/wavreader_abstract_factory.h" +#include "webrtc/modules/audio_processing/test/conversational_speech/wavreader_interface.h" +#include "webrtc/test/gmock.h" + +namespace webrtc { +namespace test { +namespace conversational_speech { + +class MockWavReaderFactory : public WavReaderAbstractFactory { + public: + MockWavReaderFactory(); + // TODO(alessiob): add ctor that gets map string->(sr, #samples, #channels). + ~MockWavReaderFactory(); + + // TODO(alessiob): use ON_CALL to return MockWavReader with desired params. + MOCK_CONST_METHOD1(Create, std::unique_ptr( + const std::string&)); + + // TODO(alessiob): add const ref to map (see ctor to add). +}; + +} // namespace conversational_speech +} // namespace test +} // namespace webrtc + +#endif // WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_MOCK_WAVREADER_FACTORY_H_ 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 0000000000..f16aa753fa --- /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 + +#include "webrtc/base/pathutils.h" + +namespace webrtc { +namespace test { +namespace conversational_speech { + +MultiEndCall::MultiEndCall( + rtc::ArrayView timing, const std::string& audiotracks_path, + std::unique_ptr 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& MultiEndCall::speaker_names() const { + return speaker_names_; +} + +const std::map>& + 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 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 diff --git a/webrtc/modules/audio_processing/test/conversational_speech/multiend_call.h b/webrtc/modules/audio_processing/test/conversational_speech/multiend_call.h new file mode 100644 index 0000000000..234cb2799e --- /dev/null +++ b/webrtc/modules/audio_processing/test/conversational_speech/multiend_call.h @@ -0,0 +1,64 @@ +/* + * 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. + */ + +#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_MULTIEND_CALL_H_ +#define WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_MULTIEND_CALL_H_ + +#include +#include +#include +#include + +#include "webrtc/base/array_view.h" +#include "webrtc/base/constructormagic.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 { + +class MultiEndCall { + public: + MultiEndCall( + rtc::ArrayView timing, const std::string& audiotracks_path, + std::unique_ptr wavreader_abstract_factory); + ~MultiEndCall(); + + const std::set& speaker_names() const; + const std::map>& + audiotrack_readers() const; + + private: + // Find unique speaker names. + void FindSpeakerNames(); + + // Create one WavReader instance for each unique audiotrack. + void CreateAudioTrackReaders(); + + // Check the speaking turns timing. + void CheckTiming(); + + rtc::ArrayView timing_; + const std::string& audiotracks_path_; + std::unique_ptr wavreader_abstract_factory_; + std::set speaker_names_; + std::map> + audiotrack_readers_; + + RTC_DISALLOW_COPY_AND_ASSIGN(MultiEndCall); +}; + +} // namespace conversational_speech +} // namespace test +} // namespace webrtc + +#endif // WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_MULTIEND_CALL_H_ diff --git a/webrtc/modules/audio_processing/test/conversational_speech/timing.cc b/webrtc/modules/audio_processing/test/conversational_speech/timing.cc index dd2fdc4ca4..0aa44fa42c 100644 --- a/webrtc/modules/audio_processing/test/conversational_speech/timing.cc +++ b/webrtc/modules/audio_processing/test/conversational_speech/timing.cc @@ -13,7 +13,6 @@ #include #include -#include "webrtc/base/array_view.h" #include "webrtc/base/stringencode.h" namespace webrtc { diff --git a/webrtc/modules/audio_processing/test/conversational_speech/wavreader_abstract_factory.h b/webrtc/modules/audio_processing/test/conversational_speech/wavreader_abstract_factory.h new file mode 100644 index 0000000000..b48245b1ba --- /dev/null +++ b/webrtc/modules/audio_processing/test/conversational_speech/wavreader_abstract_factory.h @@ -0,0 +1,34 @@ +/* + * 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. + */ + +#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_WAVREADER_ABSTRACT_FACTORY_H_ +#define WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_WAVREADER_ABSTRACT_FACTORY_H_ + +#include +#include + +#include "webrtc/modules/audio_processing/test/conversational_speech/wavreader_interface.h" + +namespace webrtc { +namespace test { +namespace conversational_speech { + +class WavReaderAbstractFactory { + public: + virtual ~WavReaderAbstractFactory() = default; + virtual std::unique_ptr Create( + const std::string& filepath) const = 0; +}; + +} // namespace conversational_speech +} // namespace test +} // namespace webrtc + +#endif // WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_WAVREADER_ABSTRACT_FACTORY_H_ diff --git a/webrtc/modules/audio_processing/test/conversational_speech/wavreader_adaptor.cc b/webrtc/modules/audio_processing/test/conversational_speech/wavreader_adaptor.cc new file mode 100644 index 0000000000..b441a044ee --- /dev/null +++ b/webrtc/modules/audio_processing/test/conversational_speech/wavreader_adaptor.cc @@ -0,0 +1,58 @@ +/* + * 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/wavreader_adaptor.h" + +#include "webrtc/base/checks.h" + +namespace webrtc { +namespace test { +namespace conversational_speech { + +WavReaderAdaptor::WavReaderAdaptor(const std::string& filepath) { + // TODO(alessiob): implement. +} + +WavReaderAdaptor::~WavReaderAdaptor() {} + +size_t WavReaderAdaptor::ReadFloatSamples(size_t num_samples, float* samples) { + // TODO(alessiob): implement. + FATAL(); + return 0u; +} + +size_t WavReaderAdaptor::ReadInt16Samples( + size_t num_samples, int16_t* samples) { + // TODO(alessiob): implement. + FATAL(); + return 0u; +} + +int WavReaderAdaptor::sample_rate() const { + // TODO(alessiob): implement. + FATAL(); + return 0; +} + +size_t WavReaderAdaptor::num_channels() const { + // TODO(alessiob): implement. + FATAL(); + return 0u; +} + +size_t WavReaderAdaptor::num_samples() const { + // TODO(alessiob): implement. + FATAL(); + return 0u; +} + +} // namespace conversational_speech +} // namespace test +} // namespace webrtc diff --git a/webrtc/modules/audio_processing/test/conversational_speech/wavreader_adaptor.h b/webrtc/modules/audio_processing/test/conversational_speech/wavreader_adaptor.h new file mode 100644 index 0000000000..54894934db --- /dev/null +++ b/webrtc/modules/audio_processing/test/conversational_speech/wavreader_adaptor.h @@ -0,0 +1,42 @@ +/* + * 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. + */ + +#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_WAVREADER_ADAPTOR_H_ +#define WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_WAVREADER_ADAPTOR_H_ + +#include "webrtc/modules/audio_processing/test/conversational_speech/wavreader_interface.h" + +#include +#include + +#include "webrtc/typedefs.h" + +namespace webrtc { +namespace test { +namespace conversational_speech { + +class WavReaderAdaptor : public WavReaderInterface { + public: + explicit WavReaderAdaptor(const std::string& filepath); + ~WavReaderAdaptor() override; + + size_t ReadFloatSamples(size_t num_samples, float* samples) override; + size_t ReadInt16Samples(size_t num_samples, int16_t* samples) override; + + int sample_rate() const override; + size_t num_channels() const override; + size_t num_samples() const override; +}; + +} // namespace conversational_speech +} // namespace test +} // namespace webrtc + +#endif // WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_WAVREADER_ADAPTOR_H_ diff --git a/webrtc/modules/audio_processing/test/conversational_speech/wavreader_factory.cc b/webrtc/modules/audio_processing/test/conversational_speech/wavreader_factory.cc new file mode 100644 index 0000000000..f9d43f8070 --- /dev/null +++ b/webrtc/modules/audio_processing/test/conversational_speech/wavreader_factory.cc @@ -0,0 +1,30 @@ +/* + * 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/wavreader_factory.h" + +#include "webrtc/modules/audio_processing/test/conversational_speech/wavreader_adaptor.h" + +namespace webrtc { +namespace test { +namespace conversational_speech { + +WavReaderFactory::WavReaderFactory() = default; + +WavReaderFactory::~WavReaderFactory() = default; + +std::unique_ptr WavReaderFactory::Create( + const std::string& filepath) const { + return std::unique_ptr(new WavReaderAdaptor(filepath)); +} + +} // namespace conversational_speech +} // namespace test +} // namespace webrtc diff --git a/webrtc/modules/audio_processing/test/conversational_speech/wavreader_factory.h b/webrtc/modules/audio_processing/test/conversational_speech/wavreader_factory.h new file mode 100644 index 0000000000..5c46af025a --- /dev/null +++ b/webrtc/modules/audio_processing/test/conversational_speech/wavreader_factory.h @@ -0,0 +1,36 @@ +/* + * 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. + */ + +#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_WAVREADER_FACTORY_H_ +#define WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_WAVREADER_FACTORY_H_ + +#include +#include + +#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 { + +class WavReaderFactory : public WavReaderAbstractFactory { + public: + WavReaderFactory(); + ~WavReaderFactory() override; + std::unique_ptr Create(const std::string& filepath) const + override; +}; + +} // namespace conversational_speech +} // namespace test +} // namespace webrtc + +#endif // WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_WAVREADER_FACTORY_H_ diff --git a/webrtc/modules/audio_processing/test/conversational_speech/wavreader_interface.h b/webrtc/modules/audio_processing/test/conversational_speech/wavreader_interface.h new file mode 100644 index 0000000000..0c99591788 --- /dev/null +++ b/webrtc/modules/audio_processing/test/conversational_speech/wavreader_interface.h @@ -0,0 +1,40 @@ +/* + * 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. + */ + +#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_WAVREADER_INTERFACE_H_ +#define WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_WAVREADER_INTERFACE_H_ + +#include + +#include "webrtc/typedefs.h" + +namespace webrtc { +namespace test { +namespace conversational_speech { + +class WavReaderInterface { + public: + virtual ~WavReaderInterface() = default; + + // Returns the number of samples read. + virtual size_t ReadFloatSamples(size_t num_samples, float* samples) = 0; + virtual size_t ReadInt16Samples(size_t num_samples, int16_t* samples) = 0; + + // Getters. + virtual int sample_rate() const = 0; + virtual size_t num_channels() const = 0; + virtual size_t num_samples() const = 0; +}; + +} // namespace conversational_speech +} // namespace test +} // namespace webrtc + +#endif // WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_WAVREADER_INTERFACE_H_