Add a tool for parsing an RTP file and outputting the BWE relevant fields.
R=henrik.lundin@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/2237005
git-svn-id: http://webrtc.googlecode.com/svn/trunk@4934 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator.gypi b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator.gypi
index f8f7e43..9f02619 100644
--- a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator.gypi
+++ b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator.gypi
@@ -27,5 +27,26 @@
'rtp_to_ntp.cc',
], # source
},
+ {
+ 'target_name': 'bwe_rtp_to_text',
+ 'type': 'executable',
+ 'includes': [
+ '../rtp_rtcp/source/rtp_rtcp.gypi',
+ ],
+ 'dependencies': [
+ '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers',
+ 'rtp_rtcp',
+ ],
+ 'direct_dependent_settings': {
+ 'include_dirs': [
+ 'include',
+ ],
+ },
+ 'sources': [
+ 'tools/rtp_to_text.cc',
+ '<(webrtc_root)/modules/video_coding/main/test/rtp_file_reader.cc',
+ '<(webrtc_root)/modules/video_coding/main/test/rtp_file_reader.h',
+ ], # source
+ },
], # targets
}
diff --git a/webrtc/modules/remote_bitrate_estimator/tools/rtp_to_text.cc b/webrtc/modules/remote_bitrate_estimator/tools/rtp_to_text.cc
new file mode 100644
index 0000000..30e386b
--- /dev/null
+++ b/webrtc/modules/remote_bitrate_estimator/tools/rtp_to_text.cc
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2013 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 <stdio.h>
+
+#include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h"
+#include "webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h"
+#include "webrtc/modules/video_coding/main/test/rtp_file_reader.h"
+#include "webrtc/modules/video_coding/main/test/rtp_player.h"
+#include "webrtc/system_wrappers/interface/scoped_ptr.h"
+
+using namespace webrtc::rtpplayer;
+
+const uint32_t kMaxPacketSize = 1500;
+const int kDefaultTransmissionTimeOffsetExtensionId = 2;
+
+int main(int argc, char** argv) {
+ if (argc < 2) {
+ printf("Usage: rtp_to_text <input_file.rtp> <output_file.rtp>\n")
+ return -1;
+ }
+ webrtc::scoped_ptr<RtpPacketSourceInterface> rtp_reader(
+ CreateRtpFileReader(argv[1]));
+ if (!rtp_reader.get()) {
+ printf("Cannot open input file %s\n", argv[1]);
+ return -1;
+ }
+ uint8_t packet_buffer[kMaxPacketSize];
+ uint8_t* packet = packet_buffer;
+ uint32_t packet_length = kMaxPacketSize;
+ uint32_t time_ms = 0;
+ FILE* out_file = fopen(argv[2], "wt");
+ if (!out_file) {
+ printf("Cannot open output file %s\n", argv[2]);
+ return -1;
+ }
+ printf("Input file: %s, Output file: %s\n\n", argv[1], argv[2]);
+ fprintf(out_file, "seqnum timestamp ts_offset abs_sendtime recvtime "
+ "markerbit ssrc size\n");
+ webrtc::scoped_ptr<webrtc::RtpHeaderParser> parser(
+ webrtc::RtpHeaderParser::Create());
+ parser->RegisterRtpHeaderExtension(
+ webrtc::kRtpExtensionTransmissionTimeOffset,
+ kDefaultTransmissionTimeOffsetExtensionId);
+ int packet_counter = 0;
+ while (rtp_reader->NextPacket(packet, &packet_length, &time_ms) == 0) {
+ webrtc::RTPHeader header;
+ parser->Parse(packet, packet_length, &header);
+ fprintf(out_file, "%u %u %d %u %u %d %u %u\n", header.sequenceNumber,
+ header.timestamp, header.extension.transmissionTimeOffset,
+ header.extension.absoluteSendTime, time_ms, header.markerBit,
+ header.ssrc, packet_length);
+ packet_length = kMaxPacketSize;
+ ++packet_counter;
+ }
+ printf("Parsed %d packets\n", packet_counter);
+ return 0;
+}