Home | History | Annotate | Download | only in tools
      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 #include <sstream>
     13 
     14 #include "webrtc/base/format_macros.h"
     15 #include "webrtc/base/scoped_ptr.h"
     16 #include "webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp.h"
     17 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
     18 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h"
     19 #include "webrtc/test/rtp_file_reader.h"
     20 
     21 int main(int argc, char** argv) {
     22   webrtc::test::RtpFileReader* reader;
     23   webrtc::RtpHeaderParser* parser;
     24   if (!ParseArgsAndSetupEstimator(argc, argv, NULL, NULL, &reader, &parser,
     25                                   NULL, NULL)) {
     26     return -1;
     27   }
     28   bool arrival_time_only = (argc >= 5 && strncmp(argv[4], "-t", 2) == 0);
     29   rtc::scoped_ptr<webrtc::test::RtpFileReader> rtp_reader(reader);
     30   rtc::scoped_ptr<webrtc::RtpHeaderParser> rtp_parser(parser);
     31   fprintf(stdout, "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 (rtp_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       std::stringstream 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,
     50               "%u %u %d %u %u %d %u %" PRIuS " %" PRIuS "\n",
     51               header.sequenceNumber,
     52               header.timestamp,
     53               header.extension.transmissionTimeOffset,
     54               header.extension.absoluteSendTime,
     55               packet.time_ms,
     56               header.markerBit,
     57               header.ssrc,
     58               packet.length,
     59               packet.original_length);
     60     }
     61     ++packet_counter;
     62   }
     63   fprintf(stderr, "Parsed %d packets\n", packet_counter);
     64   fprintf(stderr, "Packets with non-zero absolute send time: %d\n",
     65          non_zero_abs_send_time);
     66   fprintf(stderr, "Packets with non-zero timestamp offset: %d\n",
     67          non_zero_ts_offsets);
     68   return 0;
     69 }
     70