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