2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
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.
14 #include "webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp.h"
15 #include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h"
16 #include "webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h"
17 #include "webrtc/system_wrappers/interface/scoped_ptr.h"
18 #include "webrtc/test/rtp_file_reader.h"
20 int main(int argc, char** argv) {
22 fprintf(stderr, "Usage: rtp_to_text <extension type> <extension id>"
23 " <input_file.rtp> [-t]\n");
24 fprintf(stderr, "<extension type> can either be:\n"
25 " abs for absolute send time or\n"
26 " tsoffset for timestamp offset.\n"
27 "<extension id> is the id associated with the extension.\n"
28 " -t is an optional flag, if set only packet arrival time will be"
32 webrtc::test::RtpFileReader* reader;
33 webrtc::RtpHeaderParser* parser;
34 if (!ParseArgsAndSetupEstimator(argc, argv, NULL, NULL, &reader, &parser,
38 bool arrival_time_only = (argc >= 5 && strncmp(argv[4], "-t", 2) == 0);
39 webrtc::scoped_ptr<webrtc::test::RtpFileReader> rtp_reader(reader);
40 webrtc::scoped_ptr<webrtc::RtpHeaderParser> rtp_parser(parser);
41 fprintf(stdout, "seqnum timestamp ts_offset abs_sendtime recvtime "
42 "markerbit ssrc size\n");
43 int packet_counter = 0;
44 int non_zero_abs_send_time = 0;
45 int non_zero_ts_offsets = 0;
46 webrtc::test::RtpFileReader::Packet packet;
47 while (rtp_reader->NextPacket(&packet)) {
48 webrtc::RTPHeader header;
49 parser->Parse(packet.data, packet.length, &header);
50 if (header.extension.absoluteSendTime != 0)
51 ++non_zero_abs_send_time;
52 if (header.extension.transmissionTimeOffset != 0)
53 ++non_zero_ts_offsets;
54 if (arrival_time_only) {
56 ss << static_cast<int64_t>(packet.time_ms) * 1000000;
57 fprintf(stdout, "%s\n", ss.str().c_str());
60 "%u %u %d %u %u %d %u %d\n",
61 header.sequenceNumber,
63 header.extension.transmissionTimeOffset,
64 header.extension.absoluteSendTime,
68 static_cast<int>(packet.length));
72 fprintf(stderr, "Parsed %d packets\n", packet_counter);
73 fprintf(stderr, "Packets with non-zero absolute send time: %d\n",
74 non_zero_abs_send_time);
75 fprintf(stderr, "Packets with non-zero timestamp offset: %d\n",