1 /* 2 * Copyright (c) 2015 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_RTC_EVENT_LOG_SOURCE_H_ 12 #define MODULES_AUDIO_CODING_NETEQ_TOOLS_RTC_EVENT_LOG_SOURCE_H_ 13 14 #include <memory> 15 #include <string> 16 #include <vector> 17 18 #include "absl/types/optional.h" 19 #include "logging/rtc_event_log/rtc_event_log_parser.h" 20 #include "modules/audio_coding/neteq/tools/packet_source.h" 21 #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" 22 #include "rtc_base/constructor_magic.h" 23 24 namespace webrtc { 25 26 class RtpHeaderParser; 27 28 namespace test { 29 30 class Packet; 31 32 class RtcEventLogSource : public PacketSource { 33 public: 34 // Creates an RtcEventLogSource reading from |file_name|. If the file cannot 35 // be opened, or has the wrong format, NULL will be returned. 36 static std::unique_ptr<RtcEventLogSource> CreateFromFile( 37 const std::string& file_name, 38 absl::optional<uint32_t> ssrc_filter); 39 // Same as above, but uses a string with the file contents. 40 static std::unique_ptr<RtcEventLogSource> CreateFromString( 41 const std::string& file_contents, 42 absl::optional<uint32_t> ssrc_filter); 43 44 virtual ~RtcEventLogSource(); 45 46 std::unique_ptr<Packet> NextPacket() override; 47 48 // Returns the timestamp of the next audio output event, in milliseconds. The 49 // maximum value of int64_t is returned if there are no more audio output 50 // events available. 51 int64_t NextAudioOutputEventMs(); 52 53 private: 54 RtcEventLogSource(); 55 56 bool Initialize(const ParsedRtcEventLog& parsed_log, 57 absl::optional<uint32_t> ssrc_filter); 58 59 std::vector<std::unique_ptr<Packet>> rtp_packets_; 60 size_t rtp_packet_index_ = 0; 61 std::vector<int64_t> audio_outputs_; 62 size_t audio_output_index_ = 0; 63 64 RTC_DISALLOW_COPY_AND_ASSIGN(RtcEventLogSource); 65 }; 66 67 } // namespace test 68 } // namespace webrtc 69 70 #endif // MODULES_AUDIO_CODING_NETEQ_TOOLS_RTC_EVENT_LOG_SOURCE_H_ 71