From 184b913eb52b8a4bdb9a64a750e3f8ea1295b54c Mon Sep 17 00:00:00 2001 From: "henrik.lundin@webrtc.org" Date: Wed, 2 Apr 2014 20:56:17 +0000 Subject: [PATCH] Rename RTPanalyze to rtp_analyze and remove old version The tool RTPanalyze (used to process an input RTP dump into a text file of RTP header info) was present in both the neteq and neteq4 folders. This change pulls in changes from the old to the new and renames the source file and tool to rtp_analyze. Removing special code for dummy-rtp files (it is supported without special code), and making the RED payload type settable using flags. Moving from test/ to tools/ folder. BUG=2692 R=turaj@webrtc.org Review URL: https://webrtc-codereview.appspot.com/10789004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5832 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../audio_coding/neteq/test/RTPanalyze.cc | 73 ------------ .../audio_coding/neteq4/neteq_tests.gypi | 5 +- .../audio_coding/neteq4/test/RTPanalyze.cc | 72 ------------ .../audio_coding/neteq4/tools/rtp_analyze.cc | 110 ++++++++++++++++++ 4 files changed, 113 insertions(+), 147 deletions(-) delete mode 100644 webrtc/modules/audio_coding/neteq/test/RTPanalyze.cc delete mode 100644 webrtc/modules/audio_coding/neteq4/test/RTPanalyze.cc create mode 100644 webrtc/modules/audio_coding/neteq4/tools/rtp_analyze.cc diff --git a/webrtc/modules/audio_coding/neteq/test/RTPanalyze.cc b/webrtc/modules/audio_coding/neteq/test/RTPanalyze.cc deleted file mode 100644 index 6a4c6b1190..0000000000 --- a/webrtc/modules/audio_coding/neteq/test/RTPanalyze.cc +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2012 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 -#include -#include - -#include "modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.h" -#include "modules/audio_coding/neteq/test/NETEQTEST_DummyRTPpacket.h" - -//#define WEBRTC_DUMMY_RTP - -enum { - kRedPayloadType = 127 -}; - -int main(int argc, char* argv[]) { - FILE* in_file = fopen(argv[1], "rb"); - if (!in_file) { - printf("Cannot open input file %s\n", argv[1]); - return -1; - } - printf("Input file: %s\n", argv[1]); - - FILE* out_file = fopen(argv[2], "wt"); - if (!out_file) { - printf("Cannot open output file %s\n", argv[2]); - return -1; - } - printf("Output file: %s\n\n", argv[2]); - - // Print file header. - fprintf(out_file, "SeqNo TimeStamp SendTime Size PT M SSRC\n"); - - // Read file header. - NETEQTEST_RTPpacket::skipFileHeader(in_file); -#ifdef WEBRTC_DUMMY_RTP - NETEQTEST_DummyRTPpacket packet; -#else - NETEQTEST_RTPpacket packet; -#endif - - while (packet.readFromFile(in_file) >= 0) { - // Write packet data to file. - fprintf(out_file, "%5u %10u %10u %5i %5i %2i %#08X\n", - packet.sequenceNumber(), packet.timeStamp(), packet.time(), - packet.dataLen(), packet.payloadType(), packet.markerBit(), - packet.SSRC()); - if (packet.payloadType() == kRedPayloadType) { - WebRtcNetEQ_RTPInfo red_header; - int len; - int red_index = 0; - while ((len = packet.extractRED(red_index++, red_header)) >= 0) { - fprintf(out_file, "* %5u %10u %10u %5i %5i\n", - red_header.sequenceNumber, red_header.timeStamp, - packet.time(), len, red_header.payloadType); - } - assert(red_index > 1); // We must get at least one payload. - } - } - - fclose(in_file); - fclose(out_file); - - return 0; -} diff --git a/webrtc/modules/audio_coding/neteq4/neteq_tests.gypi b/webrtc/modules/audio_coding/neteq4/neteq_tests.gypi index a73c8a2790..9d0aa42339 100644 --- a/webrtc/modules/audio_coding/neteq4/neteq_tests.gypi +++ b/webrtc/modules/audio_coding/neteq4/neteq_tests.gypi @@ -81,14 +81,15 @@ }, { - 'target_name': 'RTPanalyze', + 'target_name': 'rtp_analyze', 'type': 'executable', 'dependencies': [ 'NetEq4TestTools', '<(DEPTH)/testing/gtest.gyp:gtest', + '<(DEPTH)/third_party/gflags/gflags.gyp:gflags', ], 'sources': [ - 'test/RTPanalyze.cc', + 'tools/rtp_analyze.cc', ], }, diff --git a/webrtc/modules/audio_coding/neteq4/test/RTPanalyze.cc b/webrtc/modules/audio_coding/neteq4/test/RTPanalyze.cc deleted file mode 100644 index 8df47dd0a9..0000000000 --- a/webrtc/modules/audio_coding/neteq4/test/RTPanalyze.cc +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2012 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 -#include -#include - -#include "webrtc/modules/audio_coding/neteq4/test/NETEQTEST_DummyRTPpacket.h" -#include "webrtc/modules/audio_coding/neteq4/test/NETEQTEST_RTPpacket.h" - -//#define WEBRTC_DUMMY_RTP - -enum { - kRedPayloadType = 127 -}; - -int main(int argc, char* argv[]) { - FILE* in_file = fopen(argv[1], "rb"); - if (!in_file) { - printf("Cannot open input file %s\n", argv[1]); - return -1; - } - printf("Input file: %s\n", argv[1]); - - FILE* out_file = fopen(argv[2], "wt"); - if (!out_file) { - printf("Cannot open output file %s\n", argv[2]); - return -1; - } - printf("Output file: %s\n\n", argv[2]); - - // Print file header. - fprintf(out_file, "SeqNo TimeStamp SendTime Size PT M\n"); - - // Read file header. - NETEQTEST_RTPpacket::skipFileHeader(in_file); -#ifdef WEBRTC_DUMMY_RTP - NETEQTEST_DummyRTPpacket packet; -#else - NETEQTEST_RTPpacket packet; -#endif - - while (packet.readFromFile(in_file) >= 0) { - // Write packet data to file. - fprintf(out_file, "%5u %10u %10u %5i %5i %2i\n", - packet.sequenceNumber(), packet.timeStamp(), packet.time(), - packet.dataLen(), packet.payloadType(), packet.markerBit()); - if (packet.payloadType() == kRedPayloadType) { - webrtc::WebRtcRTPHeader red_header; - int len; - int red_index = 0; - while ((len = packet.extractRED(red_index++, red_header)) >= 0) { - fprintf(out_file, "* %5u %10u %10u %5i %5i\n", - red_header.header.sequenceNumber, red_header.header.timestamp, - packet.time(), len, red_header.header.payloadType); - } - assert(red_index > 1); // We must get at least one payload. - } - } - - fclose(in_file); - fclose(out_file); - - return 0; -} diff --git a/webrtc/modules/audio_coding/neteq4/tools/rtp_analyze.cc b/webrtc/modules/audio_coding/neteq4/tools/rtp_analyze.cc new file mode 100644 index 0000000000..63786ec56c --- /dev/null +++ b/webrtc/modules/audio_coding/neteq4/tools/rtp_analyze.cc @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2012 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 +#include +#include + +#include "google/gflags.h" +#include "webrtc/modules/audio_coding/neteq4/test/NETEQTEST_DummyRTPpacket.h" +#include "webrtc/modules/audio_coding/neteq4/test/NETEQTEST_RTPpacket.h" + +// Flag validator. +static bool ValidatePayloadType(const char* flagname, int32_t value) { + if (value >= 0 && value <= 127) // Value is ok. + return true; + printf("Invalid value for --%s: %d\n", flagname, static_cast(value)); + return false; +} + +// Define command line flags. +DEFINE_int32(red, 117, "RTP payload type for RED"); +static const bool pcmu_dummy = + google::RegisterFlagValidator(&FLAGS_red, &ValidatePayloadType); + +int main(int argc, char* argv[]) { + std::string program_name = argv[0]; + std::string usage = + "Tool for parsing an RTP dump file to text output.\n" + "Run " + + program_name + + " --helpshort for usage.\n" + "Example usage:\n" + + program_name + " input.rtp output.txt\n\n" + + "Output is sent to stdout if no output file is given." + + "Note that this tool can read files with our without payloads."; + google::SetUsageMessage(usage); + google::ParseCommandLineFlags(&argc, &argv, true); + + if (argc != 2 && argc != 3) { + // Print usage information. + printf("%s", google::ProgramUsage()); + return 0; + } + + FILE* in_file = fopen(argv[1], "rb"); + if (!in_file) { + printf("Cannot open input file %s\n", argv[1]); + return -1; + } + printf("Input file: %s\n", argv[1]); + + FILE* out_file; + if (argc == 3) { + out_file = fopen(argv[2], "wt"); + if (!out_file) { + printf("Cannot open output file %s\n", argv[2]); + return -1; + } + printf("Output file: %s\n\n", argv[2]); + } else { + out_file = stdout; + } + + // Print file header. + fprintf(out_file, "SeqNo TimeStamp SendTime Size PT M SSRC\n"); + + // Read file header. + NETEQTEST_RTPpacket::skipFileHeader(in_file); + NETEQTEST_RTPpacket packet; + + while (packet.readFromFile(in_file) >= 0) { + // Write packet data to file. + fprintf(out_file, + "%5u %10u %10u %5i %5i %2i %#08X\n", + packet.sequenceNumber(), + packet.timeStamp(), + packet.time(), + packet.dataLen(), + packet.payloadType(), + packet.markerBit(), + packet.SSRC()); + if (packet.payloadType() == FLAGS_red) { + webrtc::WebRtcRTPHeader red_header; + int len; + int red_index = 0; + while ((len = packet.extractRED(red_index++, red_header)) >= 0) { + fprintf(out_file, + "* %5u %10u %10u %5i %5i\n", + red_header.header.sequenceNumber, + red_header.header.timestamp, + packet.time(), + len, + red_header.header.payloadType); + } + assert(red_index > 1); // We must get at least one payload. + } + } + + fclose(in_file); + fclose(out_file); + + return 0; +}