webrtc/modules/remote_bitrate_estimator/tools/rtp_to_text.cc
Tommi 25eb47ccf1 Make the RtpHeaderParserImpl available to tests and tools only.
There are a few reasons for making this test only:
* The code is only used by tests and utilities.
* The pure interface has only a single implementation so an interface isn't really needed.
  (a followup change could remove it altogether)
* The implementation always incorporates locking regardless of how the class gets used.
  See e.g. previous use in the Packet class.
* The implementation is a layer on top of RtpUtility::RtpHeaderParser which is
  sufficient for most production cases.

Change-Id: Ide6d50567cf8ae5127a2eb04cceeb10cf317ec36
Bug: none
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/150658
Commit-Queue: Tommi <tommi@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29010}
2019-08-29 15:56:40 +00:00

64 lines
2.3 KiB
C++

/*
* Copyright (c) 2014 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 <memory>
#include "modules/remote_bitrate_estimator/tools/bwe_rtp.h"
#include "rtc_base/format_macros.h"
#include "rtc_base/strings/string_builder.h"
#include "test/rtp_file_reader.h"
#include "test/rtp_header_parser.h"
int main(int argc, char* argv[]) {
std::unique_ptr<webrtc::test::RtpFileReader> reader;
std::unique_ptr<webrtc::RtpHeaderParser> parser(ParseArgsAndSetupEstimator(
argc, argv, nullptr, nullptr, &reader, nullptr, nullptr));
if (!parser)
return -1;
bool arrival_time_only = (argc >= 5 && strncmp(argv[4], "-t", 2) == 0);
fprintf(stdout,
"seqnum timestamp ts_offset abs_sendtime recvtime "
"markerbit ssrc size original_size\n");
int packet_counter = 0;
int non_zero_abs_send_time = 0;
int non_zero_ts_offsets = 0;
webrtc::test::RtpPacket packet;
while (reader->NextPacket(&packet)) {
webrtc::RTPHeader header;
parser->Parse(packet.data, packet.length, &header);
if (header.extension.absoluteSendTime != 0)
++non_zero_abs_send_time;
if (header.extension.transmissionTimeOffset != 0)
++non_zero_ts_offsets;
if (arrival_time_only) {
rtc::StringBuilder ss;
ss << static_cast<int64_t>(packet.time_ms) * 1000000;
fprintf(stdout, "%s\n", ss.str().c_str());
} else {
fprintf(stdout, "%u %u %d %u %u %d %u %" RTC_PRIuS " %" RTC_PRIuS "\n",
header.sequenceNumber, header.timestamp,
header.extension.transmissionTimeOffset,
header.extension.absoluteSendTime, packet.time_ms,
header.markerBit, header.ssrc, packet.length,
packet.original_length);
}
++packet_counter;
}
fprintf(stderr, "Parsed %d packets\n", packet_counter);
fprintf(stderr, "Packets with non-zero absolute send time: %d\n",
non_zero_abs_send_time);
fprintf(stderr, "Packets with non-zero timestamp offset: %d\n",
non_zero_ts_offsets);
return 0;
}