Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include "webrtc/modules/audio_processing/test/conversational_speech/wavreader_a daptor.h" | 11 #include "webrtc/modules/audio_processing/test/conversational_speech/wavreader_a daptor.h" |
| 12 | 12 |
| 13 #include <cstddef> | |
| 14 | |
| 15 #include "webrtc/base/array_view.h" | |
| 13 #include "webrtc/base/checks.h" | 16 #include "webrtc/base/checks.h" |
| 17 #include "webrtc/common_audio/wav_file.h" | |
| 18 #include "webrtc/typedefs.h" | |
| 14 | 19 |
| 15 namespace webrtc { | 20 namespace webrtc { |
| 16 namespace test { | 21 namespace test { |
| 22 namespace { | |
| 23 | |
| 24 using conversational_speech::WavReaderInterface; | |
| 25 | |
| 26 class WavReaderAdaptor : public WavReaderInterface { | |
|
kwiberg-webrtc
2017/03/29 09:08:28
final? Like const, it's usually a good idea to use
AleBzk
2017/03/29 09:34:43
Done.
| |
| 27 public: | |
| 28 explicit WavReaderAdaptor(const std::string& filepath) | |
| 29 : wav_reader_(filepath) {} | |
| 30 ~WavReaderAdaptor() override = default; | |
| 31 | |
| 32 size_t ReadFloatSamples(rtc::ArrayView<float> samples) override { | |
| 33 return wav_reader_.ReadSamples(samples.size(), samples.begin()); | |
| 34 } | |
| 35 | |
| 36 size_t ReadInt16Samples(rtc::ArrayView<int16_t> samples) override { | |
| 37 return wav_reader_.ReadSamples(samples.size(), samples.begin()); | |
| 38 } | |
| 39 | |
| 40 int sample_rate() const override { | |
| 41 return wav_reader_.sample_rate(); | |
| 42 } | |
| 43 | |
| 44 size_t num_channels() const override { | |
| 45 return wav_reader_.num_channels(); | |
| 46 } | |
| 47 | |
| 48 size_t num_samples() const override { | |
| 49 return wav_reader_.num_samples(); | |
| 50 } | |
| 51 | |
| 52 private: | |
| 53 WavReader wav_reader_; | |
| 54 }; | |
| 55 | |
| 56 } // namespace | |
| 57 | |
| 17 namespace conversational_speech { | 58 namespace conversational_speech { |
| 18 | 59 |
| 19 WavReaderAdaptor::WavReaderAdaptor(const std::string& filepath) { | 60 std::unique_ptr<WavReaderInterface> CreateWavReaderAdaptor( |
| 20 // TODO(alessiob): implement. | 61 const std::string& filepath) { |
| 21 } | 62 return std::unique_ptr<WavReaderAdaptor>(new WavReaderAdaptor(filepath)); |
| 22 | |
| 23 WavReaderAdaptor::~WavReaderAdaptor() {} | |
| 24 | |
| 25 size_t WavReaderAdaptor::ReadFloatSamples(size_t num_samples, float* samples) { | |
| 26 // TODO(alessiob): implement. | |
| 27 FATAL(); | |
| 28 return 0u; | |
| 29 } | |
| 30 | |
| 31 size_t WavReaderAdaptor::ReadInt16Samples( | |
| 32 size_t num_samples, int16_t* samples) { | |
| 33 // TODO(alessiob): implement. | |
| 34 FATAL(); | |
| 35 return 0u; | |
| 36 } | |
| 37 | |
| 38 int WavReaderAdaptor::sample_rate() const { | |
| 39 // TODO(alessiob): implement. | |
| 40 FATAL(); | |
| 41 return 0; | |
| 42 } | |
| 43 | |
| 44 size_t WavReaderAdaptor::num_channels() const { | |
| 45 // TODO(alessiob): implement. | |
| 46 FATAL(); | |
| 47 return 0u; | |
| 48 } | |
| 49 | |
| 50 size_t WavReaderAdaptor::num_samples() const { | |
| 51 // TODO(alessiob): implement. | |
| 52 FATAL(); | |
| 53 return 0u; | |
| 54 } | 63 } |
| 55 | 64 |
| 56 } // namespace conversational_speech | 65 } // namespace conversational_speech |
| 57 } // namespace test | 66 } // namespace test |
| 58 } // namespace webrtc | 67 } // namespace webrtc |
| OLD | NEW |