blob: a85bca4f648b83f43c4e669fcf2f03a12cbcd26a [file] [log] [blame]
stefan@webrtc.org1dd9b4d2014-01-31 09:15:481/*
2 * Copyright (c) 2014 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#include <stdio.h>
stefan@webrtc.org9b5f4d82014-03-10 09:38:3912#include <sstream>
stefan@webrtc.org1dd9b4d2014-01-31 09:15:4813
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"
stefan@webrtc.org1dd9b4d2014-01-31 09:15:4817#include "webrtc/system_wrappers/interface/scoped_ptr.h"
pbos@webrtc.org4b5625e2014-08-06 16:26:5618#include "webrtc/test/rtp_file_reader.h"
stefan@webrtc.org1dd9b4d2014-01-31 09:15:4819
20int main(int argc, char** argv) {
stefan@webrtc.orgf9e7c9d2014-03-10 09:11:2121 if (argc < 4) {
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"
stefan@webrtc.org1dd9b4d2014-01-31 09:15:4825 " abs for absolute send time or\n"
26 " tsoffset for timestamp offset.\n"
stefan@webrtc.orgf9e7c9d2014-03-10 09:11:2127 "<extension id> is the id associated with the extension.\n"
28 " -t is an optional flag, if set only packet arrival time will be"
29 " output.\n");
stefan@webrtc.org1dd9b4d2014-01-31 09:15:4830 return -1;
31 }
pbos@webrtc.org4b5625e2014-08-06 16:26:5632 webrtc::test::RtpFileReader* reader;
stefan@webrtc.org1dd9b4d2014-01-31 09:15:4833 webrtc::RtpHeaderParser* parser;
34 if (!ParseArgsAndSetupEstimator(argc, argv, NULL, NULL, &reader, &parser,
35 NULL, NULL)) {
36 return -1;
37 }
stefan@webrtc.orgf9e7c9d2014-03-10 09:11:2138 bool arrival_time_only = (argc >= 5 && strncmp(argv[4], "-t", 2) == 0);
pbos@webrtc.org4b5625e2014-08-06 16:26:5639 webrtc::scoped_ptr<webrtc::test::RtpFileReader> rtp_reader(reader);
stefan@webrtc.org1dd9b4d2014-01-31 09:15:4840 webrtc::scoped_ptr<webrtc::RtpHeaderParser> rtp_parser(parser);
stefan@webrtc.orgf9e7c9d2014-03-10 09:11:2141 fprintf(stdout, "seqnum timestamp ts_offset abs_sendtime recvtime "
stefan@webrtc.org1dd9b4d2014-01-31 09:15:4842 "markerbit ssrc size\n");
43 int packet_counter = 0;
stefan@webrtc.org1dd9b4d2014-01-31 09:15:4844 int non_zero_abs_send_time = 0;
45 int non_zero_ts_offsets = 0;
pbos@webrtc.org4b5625e2014-08-06 16:26:5646 webrtc::test::RtpFileReader::Packet packet;
47 while (rtp_reader->NextPacket(&packet)) {
solenberg@webrtc.orgb1f50102014-03-24 10:38:2548 webrtc::RTPHeader header;
pbos@webrtc.org4b5625e2014-08-06 16:26:5649 parser->Parse(packet.data, packet.length, &header);
stefan@webrtc.org1dd9b4d2014-01-31 09:15:4850 if (header.extension.absoluteSendTime != 0)
51 ++non_zero_abs_send_time;
52 if (header.extension.transmissionTimeOffset != 0)
53 ++non_zero_ts_offsets;
stefan@webrtc.orgf9e7c9d2014-03-10 09:11:2154 if (arrival_time_only) {
stefan@webrtc.org9b5f4d82014-03-10 09:38:3955 std::stringstream ss;
pbos@webrtc.org4b5625e2014-08-06 16:26:5656 ss << static_cast<int64_t>(packet.time_ms) * 1000000;
stefan@webrtc.org9b5f4d82014-03-10 09:38:3957 fprintf(stdout, "%s\n", ss.str().c_str());
stefan@webrtc.orgf9e7c9d2014-03-10 09:11:2158 } else {
pbos@webrtc.org4b5625e2014-08-06 16:26:5659 fprintf(stdout,
60 "%u %u %d %u %u %d %u %d\n",
61 header.sequenceNumber,
62 header.timestamp,
63 header.extension.transmissionTimeOffset,
64 header.extension.absoluteSendTime,
65 packet.time_ms,
66 header.markerBit,
67 header.ssrc,
68 static_cast<int>(packet.length));
stefan@webrtc.orgf9e7c9d2014-03-10 09:11:2169 }
stefan@webrtc.org1dd9b4d2014-01-31 09:15:4870 ++packet_counter;
71 }
stefan@webrtc.orgf9e7c9d2014-03-10 09:11:2172 fprintf(stderr, "Parsed %d packets\n", packet_counter);
73 fprintf(stderr, "Packets with non-zero absolute send time: %d\n",
stefan@webrtc.org1dd9b4d2014-01-31 09:15:4874 non_zero_abs_send_time);
stefan@webrtc.orgf9e7c9d2014-03-10 09:11:2175 fprintf(stderr, "Packets with non-zero timestamp offset: %d\n",
stefan@webrtc.org1dd9b4d2014-01-31 09:15:4876 non_zero_ts_offsets);
77 return 0;
78}