• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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>
12 
13 #include <memory>
14 
15 #include "modules/remote_bitrate_estimator/tools/bwe_rtp.h"
16 #include "rtc_base/format_macros.h"
17 #include "rtc_base/strings/string_builder.h"
18 #include "test/rtp_file_reader.h"
19 #include "test/rtp_header_parser.h"
20 
main(int argc,char * argv[])21 int main(int argc, char* argv[]) {
22   std::unique_ptr<webrtc::test::RtpFileReader> reader;
23   std::unique_ptr<webrtc::RtpHeaderParser> parser(ParseArgsAndSetupEstimator(
24       argc, argv, nullptr, nullptr, &reader, nullptr, nullptr));
25   if (!parser)
26     return -1;
27 
28   bool arrival_time_only = (argc >= 5 && strncmp(argv[4], "-t", 2) == 0);
29 
30   fprintf(stdout,
31           "seqnum timestamp ts_offset abs_sendtime recvtime "
32           "markerbit ssrc size original_size\n");
33   int packet_counter = 0;
34   int non_zero_abs_send_time = 0;
35   int non_zero_ts_offsets = 0;
36   webrtc::test::RtpPacket packet;
37   while (reader->NextPacket(&packet)) {
38     webrtc::RTPHeader header;
39     parser->Parse(packet.data, packet.length, &header);
40     if (header.extension.absoluteSendTime != 0)
41       ++non_zero_abs_send_time;
42     if (header.extension.transmissionTimeOffset != 0)
43       ++non_zero_ts_offsets;
44     if (arrival_time_only) {
45       rtc::StringBuilder ss;
46       ss << static_cast<int64_t>(packet.time_ms) * 1000000;
47       fprintf(stdout, "%s\n", ss.str().c_str());
48     } else {
49       fprintf(stdout, "%u %u %d %u %u %d %u %" RTC_PRIuS " %" RTC_PRIuS "\n",
50               header.sequenceNumber, header.timestamp,
51               header.extension.transmissionTimeOffset,
52               header.extension.absoluteSendTime, packet.time_ms,
53               header.markerBit, header.ssrc, packet.length,
54               packet.original_length);
55     }
56     ++packet_counter;
57   }
58   fprintf(stderr, "Parsed %d packets\n", packet_counter);
59   fprintf(stderr, "Packets with non-zero absolute send time: %d\n",
60           non_zero_abs_send_time);
61   fprintf(stderr, "Packets with non-zero timestamp offset: %d\n",
62           non_zero_ts_offsets);
63   return 0;
64 }
65