Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright (c) 2016 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 #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_FAKE_DECODE_FROM_FILE_H_ | |
| 12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_FAKE_DECODE_FROM_FILE_H_ | |
| 13 | |
| 14 #include <memory> | |
| 15 | |
| 16 #include "webrtc/base/array_view.h" | |
| 17 #include "webrtc/base/optional.h" | |
| 18 #include "webrtc/modules/audio_coding/codecs/audio_decoder.h" | |
| 19 #include "webrtc/modules/audio_coding/neteq/tools/input_audio_file.h" | |
| 20 | |
| 21 namespace webrtc { | |
| 22 namespace test { | |
| 23 | |
| 24 // Provides an AudioDecoder implementation that delivers audio data from a file. | |
| 25 // The "encoded" input should contain information about what RTP timestamp the | |
| 26 // encoding represents, and how many samples the decoder should produce for that | |
| 27 // encoding. A helper method PrepareEncoded is provided to prepare such | |
| 28 // encodings. If packets are missing, as determined from the timestamps, the | |
| 29 // file reading will skip forward to match the loss. | |
| 30 class FakeDecodeFromFile : public AudioDecoder { | |
| 31 public: | |
| 32 FakeDecodeFromFile(std::unique_ptr<InputAudioFile> input, bool stereo) | |
| 33 : input_(std::move(input)), stereo_(stereo) {} | |
| 34 | |
| 35 ~FakeDecodeFromFile() = default; | |
| 36 | |
| 37 void Reset() override {} | |
| 38 | |
| 39 size_t Channels() const override { return stereo_ ? 2 : 1; } | |
| 40 | |
| 41 int DecodeInternal(const uint8_t* encoded, | |
| 42 size_t encoded_len, | |
| 43 int sample_rate_hz, | |
| 44 int16_t* decoded, | |
| 45 SpeechType* speech_type) override; | |
| 46 | |
| 47 // Helper method. Writes |timestamp| and |samples| to |encoded| in a format | |
| 48 // that the FakeDecpdeFromFile decoder will understand. |encoded| must be at | |
|
ivoc
2016/06/14 16:39:56
Looks like a typo here.
| |
| 49 // least 8 bytes long. | |
| 50 static void PrepareEncoded(uint32_t timestamp, | |
| 51 size_t samples, | |
| 52 rtc::ArrayView<uint8_t> encoded); | |
| 53 | |
| 54 private: | |
| 55 std::unique_ptr<InputAudioFile> input_; | |
| 56 rtc::Optional<uint32_t> next_timestamp_from_input_; | |
| 57 bool stereo_; | |
| 58 }; | |
| 59 | |
| 60 } // namespace test | |
| 61 } // namespace webrtc | |
| 62 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_FAKE_DECODE_FROM_FILE_H_ | |
| OLD | NEW |