• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_REPLACEMENT_INPUT_H_
12 #define MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_REPLACEMENT_INPUT_H_
13 
14 #include <memory>
15 #include <set>
16 
17 #include "modules/audio_coding/neteq/tools/neteq_input.h"
18 
19 namespace webrtc {
20 namespace test {
21 
22 // This class converts the packets from a NetEqInput to fake encodings to be
23 // decoded by a FakeDecodeFromFile decoder.
24 class NetEqReplacementInput : public NetEqInput {
25  public:
26   NetEqReplacementInput(std::unique_ptr<NetEqInput> source,
27                         uint8_t replacement_payload_type,
28                         const std::set<uint8_t>& comfort_noise_types,
29                         const std::set<uint8_t>& forbidden_types);
30 
31   absl::optional<int64_t> NextPacketTime() const override;
32   absl::optional<int64_t> NextOutputEventTime() const override;
33   std::unique_ptr<PacketData> PopPacket() override;
34   void AdvanceOutputEvent() override;
35   bool ended() const override;
36   absl::optional<RTPHeader> NextHeader() const override;
37 
38  private:
39   void ReplacePacket();
40 
41   std::unique_ptr<NetEqInput> source_;
42   const uint8_t replacement_payload_type_;
43   const std::set<uint8_t> comfort_noise_types_;
44   const std::set<uint8_t> forbidden_types_;
45   std::unique_ptr<PacketData> packet_;         // The next packet to deliver.
46   uint32_t last_frame_size_timestamps_ = 960;  // Initial guess: 20 ms @ 48 kHz.
47 };
48 
49 }  // namespace test
50 }  // namespace webrtc
51 #endif  // MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_REPLACEMENT_INPUT_H_
52