Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: webrtc/modules/audio_coding/neteq/tools/fake_decode_from_file.h

Issue 2020363003: Refactor neteq_rtpplay (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing win compilation and gyp dependencies Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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,
33 int sample_rate_hz,
34 bool stereo)
35 : input_(std::move(input)),
36 sample_rate_hz_(sample_rate_hz),
37 stereo_(stereo) {}
38
39 ~FakeDecodeFromFile() = default;
40
41 void Reset() override {}
42
43 int SampleRateHz() const override { return sample_rate_hz_; }
44
45 size_t Channels() const override { return stereo_ ? 2 : 1; }
46
47 int DecodeInternal(const uint8_t* encoded,
48 size_t encoded_len,
49 int sample_rate_hz,
50 int16_t* decoded,
51 SpeechType* speech_type) override;
52
53 // Helper method. Writes |timestamp| and |samples| to |encoded| in a format
54 // that the FakeDecpdeFromFile decoder will understand. |encoded| must be at
55 // least 8 bytes long.
56 static void PrepareEncoded(uint32_t timestamp,
57 size_t samples,
58 rtc::ArrayView<uint8_t> encoded);
59
60 private:
61 std::unique_ptr<InputAudioFile> input_;
62 rtc::Optional<uint32_t> next_timestamp_from_input_;
63 const int sample_rate_hz_;
64 const bool stereo_;
65 };
66
67 } // namespace test
68 } // namespace webrtc
69 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_FAKE_DECODE_FROM_FILE_H_
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/neteq_tests.gypi ('k') | webrtc/modules/audio_coding/neteq/tools/fake_decode_from_file.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698