Index: webrtc/tools/network_tester/packet_logger.cc |
diff --git a/webrtc/tools/network_tester/packet_logger.cc b/webrtc/tools/network_tester/packet_logger.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8d20d5ede14d1280ea54d817108e41bd54ae2124 |
--- /dev/null |
+++ b/webrtc/tools/network_tester/packet_logger.cc |
@@ -0,0 +1,33 @@ |
+/* |
+ * Copyright 2017 The WebRTC project authors. All Rights Reserved. |
+ * |
+ * Use of this source code is governed by a BSD-style license |
+ * that can be found in the LICENSE file in the root of the source |
+ * tree. An additional intellectual property rights grant can be found |
+ * in the file PATENTS. All contributing project authors may |
+ * be found in the AUTHORS file in the root of the source tree. |
+ */ |
+#include "webrtc/tools/network_tester/packet_logger.h" |
+ |
+#include "webrtc/base/checks.h" |
+ |
+namespace webrtc { |
+ |
+PacketLogger::PacketLogger(const std::string& log_file_path) |
+ : packet_logger_stream_(log_file_path, |
+ std::ios_base::out | std::ios_base::binary) { |
+ RTC_DCHECK(packet_logger_stream_.is_open()); |
+ RTC_DCHECK(packet_logger_stream_.good()); |
+} |
+ |
+PacketLogger::~PacketLogger() = default; |
+ |
+void PacketLogger::LogPacket(const NetworkTesterPacket& packet) { |
+ std::string log_data; |
+ packet.SerializeToString(&log_data); |
+ char size = packet.ByteSize(); |
+ packet_logger_stream_.write(&size, sizeof(size)); |
nisse-webrtc
2017/04/06 12:46:29
This looks confusing.
If the intention is to writ
michaelt
2017/04/06 14:42:11
Done
|
+ packet_logger_stream_.write(log_data.data(), log_data.length()); |
+} |
+ |
+} // namespace webrtc |