• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/strings/string_view.h"
19 #include "absl/types/optional.h"
20 #include "logging/rtc_event_log/rtc_event_log_parser.h"
21 #include "modules/audio_coding/neteq/tools/packet_source.h"
22 #include "modules/rtp_rtcp/include/rtp_rtcp_defines.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       absl::string_view 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       absl::string_view file_contents,
42       absl::optional<uint32_t> ssrc_filter);
43 
44   virtual ~RtcEventLogSource();
45 
46   RtcEventLogSource(const RtcEventLogSource&) = delete;
47   RtcEventLogSource& operator=(const RtcEventLogSource&) = delete;
48 
49   std::unique_ptr<Packet> NextPacket() override;
50 
51   // Returns the timestamp of the next audio output event, in milliseconds. The
52   // maximum value of int64_t is returned if there are no more audio output
53   // events available.
54   int64_t NextAudioOutputEventMs();
55 
56  private:
57   RtcEventLogSource();
58 
59   bool Initialize(const ParsedRtcEventLog& parsed_log,
60                   absl::optional<uint32_t> ssrc_filter);
61 
62   std::vector<std::unique_ptr<Packet>> rtp_packets_;
63   size_t rtp_packet_index_ = 0;
64   std::vector<int64_t> audio_outputs_;
65   size_t audio_output_index_ = 0;
66 };
67 
68 }  // namespace test
69 }  // namespace webrtc
70 
71 #endif  // MODULES_AUDIO_CODING_NETEQ_TOOLS_RTC_EVENT_LOG_SOURCE_H_
72