xref: /aosp_15_r20/external/webrtc/rtc_tools/network_tester/packet_logger.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright 2017 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 RTC_TOOLS_NETWORK_TESTER_PACKET_LOGGER_H_
12 #define RTC_TOOLS_NETWORK_TESTER_PACKET_LOGGER_H_
13 
14 #include <fstream>
15 #include <string>
16 
17 #include "rtc_base/ignore_wundef.h"
18 
19 #ifdef WEBRTC_NETWORK_TESTER_PROTO
20 RTC_PUSH_IGNORING_WUNDEF()
21 #include "rtc_tools/network_tester/network_tester_packet.pb.h"
22 RTC_POP_IGNORING_WUNDEF()
23 using webrtc::network_tester::packet::NetworkTesterPacket;
24 #else
25 class NetworkTesterPacket;
26 #endif  // WEBRTC_NETWORK_TESTER_PROTO
27 
28 namespace webrtc {
29 
30 class PacketLogger {
31  public:
32   explicit PacketLogger(const std::string& log_file_path);
33   ~PacketLogger();
34 
35   PacketLogger(const PacketLogger&) = delete;
36   PacketLogger& operator=(const PacketLogger&) = delete;
37 
38   void LogPacket(const NetworkTesterPacket& packet);
39 
40  private:
41   std::ofstream packet_logger_stream_;
42 };
43 
44 }  // namespace webrtc
45 
46 #endif  // RTC_TOOLS_NETWORK_TESTER_PACKET_LOGGER_H_
47