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_PACKET_SOURCE_INPUT_H_ 12 #define MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_PACKET_SOURCE_INPUT_H_ 13 14 #include <map> 15 #include <memory> 16 #include <string> 17 18 #include "absl/strings/string_view.h" 19 #include "absl/types/optional.h" 20 #include "modules/audio_coding/neteq/tools/neteq_input.h" 21 #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" 22 23 namespace webrtc { 24 namespace test { 25 26 class RtpFileSource; 27 28 // An adapter class to dress up a PacketSource object as a NetEqInput. 29 class NetEqPacketSourceInput : public NetEqInput { 30 public: 31 using RtpHeaderExtensionMap = std::map<int, webrtc::RTPExtensionType>; 32 33 NetEqPacketSourceInput(); 34 absl::optional<int64_t> NextPacketTime() const override; 35 std::unique_ptr<PacketData> PopPacket() override; 36 absl::optional<RTPHeader> NextHeader() const override; ended()37 bool ended() const override { return !next_output_event_ms_; } 38 39 protected: 40 virtual PacketSource* source() = 0; 41 void LoadNextPacket(); 42 43 absl::optional<int64_t> next_output_event_ms_; 44 45 private: 46 std::unique_ptr<Packet> packet_; 47 }; 48 49 // Implementation of NetEqPacketSourceInput to be used with an RtpFileSource. 50 class NetEqRtpDumpInput final : public NetEqPacketSourceInput { 51 public: 52 NetEqRtpDumpInput(absl::string_view file_name, 53 const RtpHeaderExtensionMap& hdr_ext_map, 54 absl::optional<uint32_t> ssrc_filter); 55 56 absl::optional<int64_t> NextOutputEventTime() const override; 57 void AdvanceOutputEvent() override; 58 59 protected: 60 PacketSource* source() override; 61 62 private: 63 static constexpr int64_t kOutputPeriodMs = 10; 64 65 std::unique_ptr<RtpFileSource> source_; 66 }; 67 68 } // namespace test 69 } // namespace webrtc 70 #endif // MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_PACKET_SOURCE_INPUT_H_ 71