blob: de7ff2ea99b1b2b58588cd15774a63a92a36659c [file] [log] [blame]
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +00001/*
2 * Copyright (c) 2013 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
henrik.lundin@webrtc.org8b65d512014-10-07 05:30:04 +000011#include <errno.h>
henrik.lundine8a77e32016-06-22 06:34:03 -070012#include <inttypes.h>
henrik.lundin@webrtc.org8b65d512014-10-07 05:30:04 +000013#include <limits.h> // For ULONG_MAX returned by strtoul.
pbos@webrtc.org12dc1a32013-08-05 16:22:53 +000014#include <stdio.h>
henrik.lundin@webrtc.org8b65d512014-10-07 05:30:04 +000015#include <stdlib.h> // For strtoul.
oprypin6e09d872017-08-31 03:21:39 -070016#include <string.h>
pbos@webrtc.org12dc1a32013-08-05 16:22:53 +000017
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000018#include <algorithm>
henrik.lundind4ec9702016-09-06 01:22:45 -070019#include <ios>
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000020#include <iostream>
kwiberg2d0c3322016-02-14 09:28:33 -080021#include <memory>
Henrik Lundina2af0002017-06-20 16:54:39 +020022#include <numeric>
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000023#include <string>
24
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020025#include "modules/audio_coding/neteq/include/neteq.h"
26#include "modules/audio_coding/neteq/tools/fake_decode_from_file.h"
27#include "modules/audio_coding/neteq/tools/input_audio_file.h"
28#include "modules/audio_coding/neteq/tools/neteq_delay_analyzer.h"
29#include "modules/audio_coding/neteq/tools/neteq_packet_source_input.h"
30#include "modules/audio_coding/neteq/tools/neteq_replacement_input.h"
31#include "modules/audio_coding/neteq/tools/neteq_test.h"
32#include "modules/audio_coding/neteq/tools/output_audio_file.h"
33#include "modules/audio_coding/neteq/tools/output_wav_file.h"
34#include "modules/audio_coding/neteq/tools/rtp_file_source.h"
35#include "modules/include/module_common_types.h"
36#include "rtc_base/checks.h"
37#include "rtc_base/flags.h"
38#include "test/testsupport/fileutils.h"
Mirko Bonadei71207422017-09-15 13:58:09 +020039#include "typedefs.h" // NOLINT(build/include)
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000040
henrik.lundince5570e2016-05-24 06:14:57 -070041namespace webrtc {
42namespace test {
henrik.lundin@webrtc.org8b65d512014-10-07 05:30:04 +000043namespace {
pkasting@chromium.org4dba2e92015-01-26 19:59:32 +000044
henrik.lundin@webrtc.org8b65d512014-10-07 05:30:04 +000045// Parses the input string for a valid SSRC (at the start of the string). If a
46// valid SSRC is found, it is written to the output variable |ssrc|, and true is
47// returned. Otherwise, false is returned.
48bool ParseSsrc(const std::string& str, uint32_t* ssrc) {
49 if (str.empty())
henrik.lundin@webrtc.org91039532014-10-07 07:18:36 +000050 return true;
henrik.lundin@webrtc.org8b65d512014-10-07 05:30:04 +000051 int base = 10;
52 // Look for "0x" or "0X" at the start and change base to 16 if found.
53 if ((str.compare(0, 2, "0x") == 0) || (str.compare(0, 2, "0X") == 0))
54 base = 16;
55 errno = 0;
56 char* end_ptr;
57 unsigned long value = strtoul(str.c_str(), &end_ptr, base);
58 if (value == ULONG_MAX && errno == ERANGE)
59 return false; // Value out of range for unsigned long.
60 if (sizeof(unsigned long) > sizeof(uint32_t) && value > 0xFFFFFFFF)
61 return false; // Value out of range for uint32_t.
62 if (end_ptr - str.c_str() < static_cast<ptrdiff_t>(str.length()))
63 return false; // Part of the string was not parsed.
64 *ssrc = static_cast<uint32_t>(value);
65 return true;
66}
67
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000068// Flag validators.
oprypin6e09d872017-08-31 03:21:39 -070069bool ValidatePayloadType(int value) {
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000070 if (value >= 0 && value <= 127) // Value is ok.
71 return true;
oprypin6e09d872017-08-31 03:21:39 -070072 printf("Payload type must be between 0 and 127, not %d\n",
73 static_cast<int>(value));
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000074 return false;
75}
76
oprypin6e09d872017-08-31 03:21:39 -070077bool ValidateSsrcValue(const std::string& str) {
henrik.lundin@webrtc.org8b65d512014-10-07 05:30:04 +000078 uint32_t dummy_ssrc;
oprypin6e09d872017-08-31 03:21:39 -070079 if (ParseSsrc(str, &dummy_ssrc)) // Value is ok.
80 return true;
81 printf("Invalid SSRC: %s\n", str.c_str());
82 return false;
henrik.lundin@webrtc.org8b65d512014-10-07 05:30:04 +000083}
84
oprypin6e09d872017-08-31 03:21:39 -070085static bool ValidateExtensionId(int value) {
henrik.lundin8a6a6002016-08-25 00:46:36 -070086 if (value > 0 && value <= 255) // Value is ok.
87 return true;
oprypin6e09d872017-08-31 03:21:39 -070088 printf("Extension ID must be between 1 and 255, not %d\n",
89 static_cast<int>(value));
henrik.lundin8a6a6002016-08-25 00:46:36 -070090 return false;
91}
92
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000093// Define command line flags.
oprypin6e09d872017-08-31 03:21:39 -070094DEFINE_int(pcmu, 0, "RTP payload type for PCM-u");
95DEFINE_int(pcma, 8, "RTP payload type for PCM-a");
96DEFINE_int(ilbc, 102, "RTP payload type for iLBC");
97DEFINE_int(isac, 103, "RTP payload type for iSAC");
98DEFINE_int(isac_swb, 104, "RTP payload type for iSAC-swb (32 kHz)");
99DEFINE_int(opus, 111, "RTP payload type for Opus");
100DEFINE_int(pcm16b, 93, "RTP payload type for PCM16b-nb (8 kHz)");
101DEFINE_int(pcm16b_wb, 94, "RTP payload type for PCM16b-wb (16 kHz)");
102DEFINE_int(pcm16b_swb32, 95, "RTP payload type for PCM16b-swb32 (32 kHz)");
103DEFINE_int(pcm16b_swb48, 96, "RTP payload type for PCM16b-swb48 (48 kHz)");
104DEFINE_int(g722, 9, "RTP payload type for G.722");
105DEFINE_int(avt, 106, "RTP payload type for AVT/DTMF (8 kHz)");
106DEFINE_int(avt_16, 114, "RTP payload type for AVT/DTMF (16 kHz)");
107DEFINE_int(avt_32, 115, "RTP payload type for AVT/DTMF (32 kHz)");
108DEFINE_int(avt_48, 116, "RTP payload type for AVT/DTMF (48 kHz)");
109DEFINE_int(red, 117, "RTP payload type for redundant audio (RED)");
110DEFINE_int(cn_nb, 13, "RTP payload type for comfort noise (8 kHz)");
111DEFINE_int(cn_wb, 98, "RTP payload type for comfort noise (16 kHz)");
112DEFINE_int(cn_swb32, 99, "RTP payload type for comfort noise (32 kHz)");
113DEFINE_int(cn_swb48, 100, "RTP payload type for comfort noise (48 kHz)");
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +0000114DEFINE_bool(codec_map, false, "Prints the mapping between RTP payload type and "
115 "codec");
henrik.lundin@webrtc.org75642fc2014-02-05 08:49:13 +0000116DEFINE_string(replacement_audio_file, "",
117 "A PCM file that will be used to populate ""dummy"" RTP packets");
henrik.lundin@webrtc.org8b65d512014-10-07 05:30:04 +0000118DEFINE_string(ssrc,
119 "",
120 "Only use packets with this SSRC (decimal or hex, the latter "
121 "starting with 0x)");
oprypin6e09d872017-08-31 03:21:39 -0700122DEFINE_int(audio_level, 1, "Extension ID for audio level (RFC 6464)");
123DEFINE_int(abs_send_time, 3, "Extension ID for absolute sender time");
124DEFINE_int(transport_seq_no, 5, "Extension ID for transport sequence number");
Henrik Lundin0bc0ccd2017-06-20 14:48:50 +0200125DEFINE_bool(matlabplot,
126 false,
127 "Generates a matlab script for plotting the delay profile");
Ivo Creusend1d8dfb2017-12-06 10:48:10 +0100128DEFINE_bool(pythonplot,
129 false,
130 "Generates a python script for plotting the delay profile");
oprypin6e09d872017-08-31 03:21:39 -0700131DEFINE_bool(help, false, "Prints this message");
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +0000132
pkasting@chromium.org4dba2e92015-01-26 19:59:32 +0000133// Maps a codec type to a printable name string.
henrik.lundince5570e2016-05-24 06:14:57 -0700134std::string CodecName(NetEqDecoder codec) {
pkasting@chromium.org4dba2e92015-01-26 19:59:32 +0000135 switch (codec) {
henrik.lundince5570e2016-05-24 06:14:57 -0700136 case NetEqDecoder::kDecoderPCMu:
pkasting@chromium.org4dba2e92015-01-26 19:59:32 +0000137 return "PCM-u";
henrik.lundince5570e2016-05-24 06:14:57 -0700138 case NetEqDecoder::kDecoderPCMa:
pkasting@chromium.org4dba2e92015-01-26 19:59:32 +0000139 return "PCM-a";
henrik.lundince5570e2016-05-24 06:14:57 -0700140 case NetEqDecoder::kDecoderILBC:
pkasting@chromium.org4dba2e92015-01-26 19:59:32 +0000141 return "iLBC";
henrik.lundince5570e2016-05-24 06:14:57 -0700142 case NetEqDecoder::kDecoderISAC:
pkasting@chromium.org4dba2e92015-01-26 19:59:32 +0000143 return "iSAC";
henrik.lundince5570e2016-05-24 06:14:57 -0700144 case NetEqDecoder::kDecoderISACswb:
pkasting@chromium.org4dba2e92015-01-26 19:59:32 +0000145 return "iSAC-swb (32 kHz)";
henrik.lundince5570e2016-05-24 06:14:57 -0700146 case NetEqDecoder::kDecoderOpus:
pkasting@chromium.org4dba2e92015-01-26 19:59:32 +0000147 return "Opus";
henrik.lundince5570e2016-05-24 06:14:57 -0700148 case NetEqDecoder::kDecoderPCM16B:
pkasting@chromium.org4dba2e92015-01-26 19:59:32 +0000149 return "PCM16b-nb (8 kHz)";
henrik.lundince5570e2016-05-24 06:14:57 -0700150 case NetEqDecoder::kDecoderPCM16Bwb:
pkasting@chromium.org4dba2e92015-01-26 19:59:32 +0000151 return "PCM16b-wb (16 kHz)";
henrik.lundince5570e2016-05-24 06:14:57 -0700152 case NetEqDecoder::kDecoderPCM16Bswb32kHz:
pkasting@chromium.org4dba2e92015-01-26 19:59:32 +0000153 return "PCM16b-swb32 (32 kHz)";
henrik.lundince5570e2016-05-24 06:14:57 -0700154 case NetEqDecoder::kDecoderPCM16Bswb48kHz:
pkasting@chromium.org4dba2e92015-01-26 19:59:32 +0000155 return "PCM16b-swb48 (48 kHz)";
henrik.lundince5570e2016-05-24 06:14:57 -0700156 case NetEqDecoder::kDecoderG722:
pkasting@chromium.org4dba2e92015-01-26 19:59:32 +0000157 return "G.722";
henrik.lundince5570e2016-05-24 06:14:57 -0700158 case NetEqDecoder::kDecoderRED:
pkasting@chromium.org4dba2e92015-01-26 19:59:32 +0000159 return "redundant audio (RED)";
henrik.lundince5570e2016-05-24 06:14:57 -0700160 case NetEqDecoder::kDecoderAVT:
solenberg2779bab2016-11-17 04:45:19 -0800161 return "AVT/DTMF (8 kHz)";
162 case NetEqDecoder::kDecoderAVT16kHz:
163 return "AVT/DTMF (16 kHz)";
164 case NetEqDecoder::kDecoderAVT32kHz:
165 return "AVT/DTMF (32 kHz)";
166 case NetEqDecoder::kDecoderAVT48kHz:
167 return "AVT/DTMF (48 kHz)";
henrik.lundince5570e2016-05-24 06:14:57 -0700168 case NetEqDecoder::kDecoderCNGnb:
pkasting@chromium.org4dba2e92015-01-26 19:59:32 +0000169 return "comfort noise (8 kHz)";
henrik.lundince5570e2016-05-24 06:14:57 -0700170 case NetEqDecoder::kDecoderCNGwb:
pkasting@chromium.org4dba2e92015-01-26 19:59:32 +0000171 return "comfort noise (16 kHz)";
henrik.lundince5570e2016-05-24 06:14:57 -0700172 case NetEqDecoder::kDecoderCNGswb32kHz:
pkasting@chromium.org4dba2e92015-01-26 19:59:32 +0000173 return "comfort noise (32 kHz)";
henrik.lundince5570e2016-05-24 06:14:57 -0700174 case NetEqDecoder::kDecoderCNGswb48kHz:
pkasting@chromium.org4dba2e92015-01-26 19:59:32 +0000175 return "comfort noise (48 kHz)";
176 default:
henrik.lundine8a77e32016-06-22 06:34:03 -0700177 FATAL();
pkasting@chromium.org4dba2e92015-01-26 19:59:32 +0000178 return "undefined";
179 }
180}
181
oprypin6e09d872017-08-31 03:21:39 -0700182void PrintCodecMappingEntry(NetEqDecoder codec, int flag) {
pkasting@chromium.orgd3245462015-02-23 21:28:22 +0000183 std::cout << CodecName(codec) << ": " << flag << std::endl;
pkasting@chromium.org4dba2e92015-01-26 19:59:32 +0000184}
185
186void PrintCodecMapping() {
oprypin6e09d872017-08-31 03:21:39 -0700187 PrintCodecMappingEntry(NetEqDecoder::kDecoderPCMu, FLAG_pcmu);
188 PrintCodecMappingEntry(NetEqDecoder::kDecoderPCMa, FLAG_pcma);
189 PrintCodecMappingEntry(NetEqDecoder::kDecoderILBC, FLAG_ilbc);
190 PrintCodecMappingEntry(NetEqDecoder::kDecoderISAC, FLAG_isac);
191 PrintCodecMappingEntry(NetEqDecoder::kDecoderISACswb, FLAG_isac_swb);
192 PrintCodecMappingEntry(NetEqDecoder::kDecoderOpus, FLAG_opus);
193 PrintCodecMappingEntry(NetEqDecoder::kDecoderPCM16B, FLAG_pcm16b);
194 PrintCodecMappingEntry(NetEqDecoder::kDecoderPCM16Bwb, FLAG_pcm16b_wb);
henrik.lundince5570e2016-05-24 06:14:57 -0700195 PrintCodecMappingEntry(NetEqDecoder::kDecoderPCM16Bswb32kHz,
oprypin6e09d872017-08-31 03:21:39 -0700196 FLAG_pcm16b_swb32);
henrik.lundince5570e2016-05-24 06:14:57 -0700197 PrintCodecMappingEntry(NetEqDecoder::kDecoderPCM16Bswb48kHz,
oprypin6e09d872017-08-31 03:21:39 -0700198 FLAG_pcm16b_swb48);
199 PrintCodecMappingEntry(NetEqDecoder::kDecoderG722, FLAG_g722);
200 PrintCodecMappingEntry(NetEqDecoder::kDecoderAVT, FLAG_avt);
201 PrintCodecMappingEntry(NetEqDecoder::kDecoderAVT16kHz, FLAG_avt_16);
202 PrintCodecMappingEntry(NetEqDecoder::kDecoderAVT32kHz, FLAG_avt_32);
203 PrintCodecMappingEntry(NetEqDecoder::kDecoderAVT48kHz, FLAG_avt_48);
204 PrintCodecMappingEntry(NetEqDecoder::kDecoderRED, FLAG_red);
205 PrintCodecMappingEntry(NetEqDecoder::kDecoderCNGnb, FLAG_cn_nb);
206 PrintCodecMappingEntry(NetEqDecoder::kDecoderCNGwb, FLAG_cn_wb);
207 PrintCodecMappingEntry(NetEqDecoder::kDecoderCNGswb32kHz, FLAG_cn_swb32);
208 PrintCodecMappingEntry(NetEqDecoder::kDecoderCNGswb48kHz, FLAG_cn_swb48);
pkasting@chromium.org4dba2e92015-01-26 19:59:32 +0000209}
210
Henrik Lundin0bc0ccd2017-06-20 14:48:50 +0200211rtc::Optional<int> CodecSampleRate(uint8_t payload_type) {
oprypin6e09d872017-08-31 03:21:39 -0700212 if (payload_type == FLAG_pcmu || payload_type == FLAG_pcma ||
213 payload_type == FLAG_ilbc || payload_type == FLAG_pcm16b ||
214 payload_type == FLAG_cn_nb || payload_type == FLAG_avt)
Oskar Sundbom12ab00b2017-11-16 15:31:38 +0100215 return 8000;
oprypin6e09d872017-08-31 03:21:39 -0700216 if (payload_type == FLAG_isac || payload_type == FLAG_pcm16b_wb ||
217 payload_type == FLAG_g722 || payload_type == FLAG_cn_wb ||
218 payload_type == FLAG_avt_16)
Oskar Sundbom12ab00b2017-11-16 15:31:38 +0100219 return 16000;
oprypin6e09d872017-08-31 03:21:39 -0700220 if (payload_type == FLAG_isac_swb || payload_type == FLAG_pcm16b_swb32 ||
221 payload_type == FLAG_cn_swb32 || payload_type == FLAG_avt_32)
Oskar Sundbom12ab00b2017-11-16 15:31:38 +0100222 return 32000;
oprypin6e09d872017-08-31 03:21:39 -0700223 if (payload_type == FLAG_opus || payload_type == FLAG_pcm16b_swb48 ||
224 payload_type == FLAG_cn_swb48 || payload_type == FLAG_avt_48)
Oskar Sundbom12ab00b2017-11-16 15:31:38 +0100225 return 48000;
oprypin6e09d872017-08-31 03:21:39 -0700226 if (payload_type == FLAG_red)
Oskar Sundbom12ab00b2017-11-16 15:31:38 +0100227 return 0;
228 return rtc::nullopt;
pkasting@chromium.org4dba2e92015-01-26 19:59:32 +0000229}
230
henrik.lundine8a77e32016-06-22 06:34:03 -0700231// Class to let through only the packets with a given SSRC. Should be used as an
232// outer layer on another NetEqInput object.
233class FilterSsrcInput : public NetEqInput {
234 public:
235 FilterSsrcInput(std::unique_ptr<NetEqInput> source, uint32_t ssrc)
236 : source_(std::move(source)), ssrc_(ssrc) {
237 FindNextWithCorrectSsrc();
henrik.lundind4ec9702016-09-06 01:22:45 -0700238 RTC_CHECK(source_->NextHeader()) << "Found no packet with SSRC = 0x"
239 << std::hex << ssrc_;
henrik.lundine8a77e32016-06-22 06:34:03 -0700240 }
pkasting@chromium.org4dba2e92015-01-26 19:59:32 +0000241
henrik.lundine8a77e32016-06-22 06:34:03 -0700242 // All methods but PopPacket() simply relay to the |source_| object.
243 rtc::Optional<int64_t> NextPacketTime() const override {
244 return source_->NextPacketTime();
245 }
246 rtc::Optional<int64_t> NextOutputEventTime() const override {
247 return source_->NextOutputEventTime();
248 }
249
250 // Returns the next packet, and throws away upcoming packets that do not match
251 // the desired SSRC.
252 std::unique_ptr<PacketData> PopPacket() override {
253 std::unique_ptr<PacketData> packet_to_return = source_->PopPacket();
henrik.lundin246ef3e2017-04-24 09:14:32 -0700254 RTC_DCHECK(!packet_to_return || packet_to_return->header.ssrc == ssrc_);
henrik.lundine8a77e32016-06-22 06:34:03 -0700255 // Pre-fetch the next packet with correct SSRC. Hence, |source_| will always
256 // be have a valid packet (or empty if no more packets are available) when
257 // this method returns.
258 FindNextWithCorrectSsrc();
259 return packet_to_return;
260 }
261
262 void AdvanceOutputEvent() override { source_->AdvanceOutputEvent(); }
263
264 bool ended() const override { return source_->ended(); }
265
266 rtc::Optional<RTPHeader> NextHeader() const override {
267 return source_->NextHeader();
268 }
269
270 private:
271 void FindNextWithCorrectSsrc() {
272 while (source_->NextHeader() && source_->NextHeader()->ssrc != ssrc_) {
273 source_->PopPacket();
pkasting@chromium.org4dba2e92015-01-26 19:59:32 +0000274 }
275 }
henrik.lundine8a77e32016-06-22 06:34:03 -0700276
277 std::unique_ptr<NetEqInput> source_;
278 uint32_t ssrc_;
279};
pkasting@chromium.org4dba2e92015-01-26 19:59:32 +0000280
Henrik Lundin0bc0ccd2017-06-20 14:48:50 +0200281// A callback class which prints whenver the inserted packet stream changes
282// the SSRC.
283class SsrcSwitchDetector : public NetEqPostInsertPacket {
284 public:
285 // Takes a pointer to another callback object, which will be invoked after
286 // this object finishes. This does not transfer ownership, and null is a
287 // valid value.
Henrik Lundina2af0002017-06-20 16:54:39 +0200288 explicit SsrcSwitchDetector(NetEqPostInsertPacket* other_callback)
Henrik Lundin0bc0ccd2017-06-20 14:48:50 +0200289 : other_callback_(other_callback) {}
290
Henrik Lundina2af0002017-06-20 16:54:39 +0200291 void AfterInsertPacket(const NetEqInput::PacketData& packet,
292 NetEq* neteq) override {
Henrik Lundin0bc0ccd2017-06-20 14:48:50 +0200293 if (last_ssrc_ && packet.header.ssrc != *last_ssrc_) {
294 std::cout << "Changing streams from 0x" << std::hex << *last_ssrc_
295 << " to 0x" << std::hex << packet.header.ssrc
296 << std::dec << " (payload type "
297 << static_cast<int>(packet.header.payloadType) << ")"
298 << std::endl;
299 }
Oskar Sundbom12ab00b2017-11-16 15:31:38 +0100300 last_ssrc_ = packet.header.ssrc;
Henrik Lundin0bc0ccd2017-06-20 14:48:50 +0200301 if (other_callback_) {
302 other_callback_->AfterInsertPacket(packet, neteq);
303 }
304 }
305
306 private:
307 NetEqPostInsertPacket* other_callback_;
308 rtc::Optional<uint32_t> last_ssrc_;
309};
310
Henrik Lundina2af0002017-06-20 16:54:39 +0200311class StatsGetter : public NetEqGetAudioCallback {
312 public:
313 // This struct is a replica of webrtc::NetEqNetworkStatistics, but with all
314 // values stored in double precision.
315 struct Stats {
316 double current_buffer_size_ms = 0.0;
317 double preferred_buffer_size_ms = 0.0;
318 double jitter_peaks_found = 0.0;
319 double packet_loss_rate = 0.0;
Henrik Lundina2af0002017-06-20 16:54:39 +0200320 double expand_rate = 0.0;
321 double speech_expand_rate = 0.0;
322 double preemptive_rate = 0.0;
323 double accelerate_rate = 0.0;
324 double secondary_decoded_rate = 0.0;
minyue-webrtc0c3ca752017-08-23 15:59:38 +0200325 double secondary_discarded_rate = 0.0;
Henrik Lundina2af0002017-06-20 16:54:39 +0200326 double clockdrift_ppm = 0.0;
327 double added_zero_samples = 0.0;
328 double mean_waiting_time_ms = 0.0;
329 double median_waiting_time_ms = 0.0;
330 double min_waiting_time_ms = 0.0;
331 double max_waiting_time_ms = 0.0;
332 };
333
334 // Takes a pointer to another callback object, which will be invoked after
335 // this object finishes. This does not transfer ownership, and null is a
336 // valid value.
337 explicit StatsGetter(NetEqGetAudioCallback* other_callback)
338 : other_callback_(other_callback) {}
339
340 void BeforeGetAudio(NetEq* neteq) override {
341 if (other_callback_) {
342 other_callback_->BeforeGetAudio(neteq);
343 }
344 }
345
346 void AfterGetAudio(int64_t time_now_ms,
347 const AudioFrame& audio_frame,
348 bool muted,
349 NetEq* neteq) override {
350 if (++counter_ >= 100) {
351 counter_ = 0;
352 NetEqNetworkStatistics stats;
353 RTC_CHECK_EQ(neteq->NetworkStatistics(&stats), 0);
354 stats_.push_back(stats);
355 }
356 if (other_callback_) {
henrik.lundinf09c9042017-08-29 09:14:08 -0700357 other_callback_->AfterGetAudio(time_now_ms, audio_frame, muted, neteq);
Henrik Lundina2af0002017-06-20 16:54:39 +0200358 }
359 }
360
361 double AverageSpeechExpandRate() const {
362 double sum_speech_expand =
363 std::accumulate(stats_.begin(), stats_.end(), double{0.0},
364 [](double a, NetEqNetworkStatistics b) {
365 return a + static_cast<double>(b.speech_expand_rate);
366 });
367 return sum_speech_expand / 16384.0 / stats_.size();
368 }
369
370 Stats AverageStats() const {
371 Stats sum_stats = std::accumulate(
372 stats_.begin(), stats_.end(), Stats(),
373 [](Stats a, NetEqNetworkStatistics b) {
374 a.current_buffer_size_ms += b.current_buffer_size_ms;
375 a.preferred_buffer_size_ms += b.preferred_buffer_size_ms;
376 a.jitter_peaks_found += b.jitter_peaks_found;
377 a.packet_loss_rate += b.packet_loss_rate / 16384.0;
Henrik Lundina2af0002017-06-20 16:54:39 +0200378 a.expand_rate += b.expand_rate / 16384.0;
379 a.speech_expand_rate += b.speech_expand_rate / 16384.0;
380 a.preemptive_rate += b.preemptive_rate / 16384.0;
381 a.accelerate_rate += b.accelerate_rate / 16384.0;
382 a.secondary_decoded_rate += b.secondary_decoded_rate / 16384.0;
minyue-webrtc0c3ca752017-08-23 15:59:38 +0200383 a.secondary_discarded_rate += b.secondary_discarded_rate / 16384.0;
Henrik Lundina2af0002017-06-20 16:54:39 +0200384 a.clockdrift_ppm += b.clockdrift_ppm;
385 a.added_zero_samples += b.added_zero_samples;
386 a.mean_waiting_time_ms += b.mean_waiting_time_ms;
387 a.median_waiting_time_ms += b.median_waiting_time_ms;
henrik.lundin96571722017-08-30 00:41:30 -0700388 a.min_waiting_time_ms =
389 std::min(a.min_waiting_time_ms,
390 static_cast<double>(b.min_waiting_time_ms));
391 a.max_waiting_time_ms =
392 std::max(a.max_waiting_time_ms,
393 static_cast<double>(b.max_waiting_time_ms));
Henrik Lundina2af0002017-06-20 16:54:39 +0200394 return a;
395 });
396
397 sum_stats.current_buffer_size_ms /= stats_.size();
398 sum_stats.preferred_buffer_size_ms /= stats_.size();
399 sum_stats.jitter_peaks_found /= stats_.size();
400 sum_stats.packet_loss_rate /= stats_.size();
Henrik Lundina2af0002017-06-20 16:54:39 +0200401 sum_stats.expand_rate /= stats_.size();
402 sum_stats.speech_expand_rate /= stats_.size();
403 sum_stats.preemptive_rate /= stats_.size();
404 sum_stats.accelerate_rate /= stats_.size();
405 sum_stats.secondary_decoded_rate /= stats_.size();
minyue-webrtc0c3ca752017-08-23 15:59:38 +0200406 sum_stats.secondary_discarded_rate /= stats_.size();
Henrik Lundina2af0002017-06-20 16:54:39 +0200407 sum_stats.clockdrift_ppm /= stats_.size();
408 sum_stats.added_zero_samples /= stats_.size();
409 sum_stats.mean_waiting_time_ms /= stats_.size();
410 sum_stats.median_waiting_time_ms /= stats_.size();
Henrik Lundina2af0002017-06-20 16:54:39 +0200411
412 return sum_stats;
413 }
414
415 private:
416 NetEqGetAudioCallback* other_callback_;
417 size_t counter_ = 0;
418 std::vector<NetEqNetworkStatistics> stats_;
419};
420
henrik.lundin303d3e12016-05-26 05:56:03 -0700421int RunTest(int argc, char* argv[]) {
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +0000422 std::string program_name = argv[0];
423 std::string usage = "Tool for decoding an RTP dump file using NetEq.\n"
oprypin6e09d872017-08-31 03:21:39 -0700424 "Run " + program_name + " --help for usage.\n"
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +0000425 "Example usage:\n" + program_name +
henrik.lundin@webrtc.org03499a02014-11-24 14:50:53 +0000426 " input.rtp output.{pcm, wav}\n";
oprypin6e09d872017-08-31 03:21:39 -0700427 if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true)) {
428 return 1;
429 }
430 if (FLAG_help) {
431 std::cout << usage;
432 rtc::FlagList::Print(nullptr, false);
433 return 0;
434 }
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +0000435
oprypin6e09d872017-08-31 03:21:39 -0700436 if (FLAG_codec_map) {
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +0000437 PrintCodecMapping();
438 }
439
440 if (argc != 3) {
oprypin6e09d872017-08-31 03:21:39 -0700441 if (FLAG_codec_map) {
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +0000442 // We have already printed the codec map. Just end the program.
443 return 0;
444 }
445 // Print usage information.
oprypin6e09d872017-08-31 03:21:39 -0700446 std::cout << usage;
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +0000447 return 0;
448 }
oprypin6e09d872017-08-31 03:21:39 -0700449 RTC_CHECK(ValidatePayloadType(FLAG_pcmu));
450 RTC_CHECK(ValidatePayloadType(FLAG_pcma));
451 RTC_CHECK(ValidatePayloadType(FLAG_ilbc));
452 RTC_CHECK(ValidatePayloadType(FLAG_isac));
453 RTC_CHECK(ValidatePayloadType(FLAG_isac_swb));
454 RTC_CHECK(ValidatePayloadType(FLAG_opus));
455 RTC_CHECK(ValidatePayloadType(FLAG_pcm16b));
456 RTC_CHECK(ValidatePayloadType(FLAG_pcm16b_wb));
457 RTC_CHECK(ValidatePayloadType(FLAG_pcm16b_swb32));
458 RTC_CHECK(ValidatePayloadType(FLAG_pcm16b_swb48));
459 RTC_CHECK(ValidatePayloadType(FLAG_g722));
460 RTC_CHECK(ValidatePayloadType(FLAG_avt));
461 RTC_CHECK(ValidatePayloadType(FLAG_avt_16));
462 RTC_CHECK(ValidatePayloadType(FLAG_avt_32));
463 RTC_CHECK(ValidatePayloadType(FLAG_avt_48));
464 RTC_CHECK(ValidatePayloadType(FLAG_red));
465 RTC_CHECK(ValidatePayloadType(FLAG_cn_nb));
466 RTC_CHECK(ValidatePayloadType(FLAG_cn_wb));
467 RTC_CHECK(ValidatePayloadType(FLAG_cn_swb32));
468 RTC_CHECK(ValidatePayloadType(FLAG_cn_swb48));
469 RTC_CHECK(ValidateSsrcValue(FLAG_ssrc));
470 RTC_CHECK(ValidateExtensionId(FLAG_audio_level));
471 RTC_CHECK(ValidateExtensionId(FLAG_abs_send_time));
472 RTC_CHECK(ValidateExtensionId(FLAG_transport_seq_no));
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +0000473
henrik.lundin8a6a6002016-08-25 00:46:36 -0700474 // Gather RTP header extensions in a map.
475 NetEqPacketSourceInput::RtpHeaderExtensionMap rtp_ext_map = {
oprypin6e09d872017-08-31 03:21:39 -0700476 {FLAG_audio_level, kRtpExtensionAudioLevel},
477 {FLAG_abs_send_time, kRtpExtensionAbsoluteSendTime},
478 {FLAG_transport_seq_no, kRtpExtensionTransportSequenceNumber}};
henrik.lundin8a6a6002016-08-25 00:46:36 -0700479
henrik.lundine8a77e32016-06-22 06:34:03 -0700480 const std::string input_file_name = argv[1];
481 std::unique_ptr<NetEqInput> input;
482 if (RtpFileSource::ValidRtpDump(input_file_name) ||
483 RtpFileSource::ValidPcap(input_file_name)) {
henrik.lundin8a6a6002016-08-25 00:46:36 -0700484 input.reset(new NetEqRtpDumpInput(input_file_name, rtp_ext_map));
ivoccaa5f4b2015-09-08 03:28:46 -0700485 } else {
henrik.lundin8a6a6002016-08-25 00:46:36 -0700486 input.reset(new NetEqEventLogInput(input_file_name, rtp_ext_map));
ivoccaa5f4b2015-09-08 03:28:46 -0700487 }
488
henrik.lundine8a77e32016-06-22 06:34:03 -0700489 std::cout << "Input file: " << input_file_name << std::endl;
490 RTC_CHECK(input) << "Cannot open input file";
491 RTC_CHECK(!input->ended()) << "Input file is empty";
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +0000492
henrik.lundin@webrtc.org8b65d512014-10-07 05:30:04 +0000493 // Check if an SSRC value was provided.
oprypin6e09d872017-08-31 03:21:39 -0700494 if (strlen(FLAG_ssrc) > 0) {
henrik.lundin@webrtc.org8b65d512014-10-07 05:30:04 +0000495 uint32_t ssrc;
oprypin6e09d872017-08-31 03:21:39 -0700496 RTC_CHECK(ParseSsrc(FLAG_ssrc, &ssrc)) << "Flag verification has failed.";
henrik.lundine8a77e32016-06-22 06:34:03 -0700497 input.reset(new FilterSsrcInput(std::move(input), ssrc));
ivoccaa5f4b2015-09-08 03:28:46 -0700498 }
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +0000499
henrik.lundin@webrtc.org03499a02014-11-24 14:50:53 +0000500 // Check the sample rate.
Henrik Lundin0bc0ccd2017-06-20 14:48:50 +0200501 rtc::Optional<int> sample_rate_hz;
502 std::set<std::pair<int, uint32_t>> discarded_pt_and_ssrc;
503 while (input->NextHeader()) {
504 rtc::Optional<RTPHeader> first_rtp_header = input->NextHeader();
505 RTC_DCHECK(first_rtp_header);
506 sample_rate_hz = CodecSampleRate(first_rtp_header->payloadType);
507 if (sample_rate_hz) {
508 std::cout << "Found valid packet with payload type "
509 << static_cast<int>(first_rtp_header->payloadType)
510 << " and SSRC 0x" << std::hex << first_rtp_header->ssrc
511 << std::dec << std::endl;
512 break;
513 }
514 // Discard this packet and move to the next. Keep track of discarded payload
515 // types and SSRCs.
516 discarded_pt_and_ssrc.emplace(first_rtp_header->payloadType,
517 first_rtp_header->ssrc);
518 input->PopPacket();
519 }
520 if (!discarded_pt_and_ssrc.empty()) {
521 std::cout << "Discarded initial packets with the following payload types "
522 "and SSRCs:"
523 << std::endl;
524 for (const auto& d : discarded_pt_and_ssrc) {
525 std::cout << "PT " << d.first << "; SSRC 0x" << std::hex
526 << static_cast<int>(d.second) << std::dec << std::endl;
527 }
528 }
529 if (!sample_rate_hz) {
530 std::cout << "Cannot find any packets with known payload types"
531 << std::endl;
532 RTC_NOTREACHED();
533 }
henrik.lundin@webrtc.org03499a02014-11-24 14:50:53 +0000534
535 // Open the output file now that we know the sample rate. (Rate is only needed
536 // for wav files.)
henrik.lundine8a77e32016-06-22 06:34:03 -0700537 const std::string output_file_name = argv[2];
henrik.lundince5570e2016-05-24 06:14:57 -0700538 std::unique_ptr<AudioSink> output;
henrik.lundin@webrtc.org03499a02014-11-24 14:50:53 +0000539 if (output_file_name.size() >= 4 &&
540 output_file_name.substr(output_file_name.size() - 4) == ".wav") {
541 // Open a wav file.
Henrik Lundin0bc0ccd2017-06-20 14:48:50 +0200542 output.reset(new OutputWavFile(output_file_name, *sample_rate_hz));
henrik.lundin@webrtc.org03499a02014-11-24 14:50:53 +0000543 } else {
544 // Open a pcm file.
henrik.lundince5570e2016-05-24 06:14:57 -0700545 output.reset(new OutputAudioFile(output_file_name));
henrik.lundin@webrtc.org03499a02014-11-24 14:50:53 +0000546 }
547
henrik.lundine8a77e32016-06-22 06:34:03 -0700548 std::cout << "Output file: " << output_file_name << std::endl;
henrik.lundin@webrtc.org03499a02014-11-24 14:50:53 +0000549
henrik.lundine8a77e32016-06-22 06:34:03 -0700550 NetEqTest::DecoderMap codecs = {
oprypin6e09d872017-08-31 03:21:39 -0700551 {FLAG_pcmu, std::make_pair(NetEqDecoder::kDecoderPCMu, "pcmu")},
552 {FLAG_pcma, std::make_pair(NetEqDecoder::kDecoderPCMa, "pcma")},
553 {FLAG_ilbc, std::make_pair(NetEqDecoder::kDecoderILBC, "ilbc")},
554 {FLAG_isac, std::make_pair(NetEqDecoder::kDecoderISAC, "isac")},
555 {FLAG_isac_swb,
henrik.lundine8a77e32016-06-22 06:34:03 -0700556 std::make_pair(NetEqDecoder::kDecoderISACswb, "isac-swb")},
oprypin6e09d872017-08-31 03:21:39 -0700557 {FLAG_opus, std::make_pair(NetEqDecoder::kDecoderOpus, "opus")},
558 {FLAG_pcm16b, std::make_pair(NetEqDecoder::kDecoderPCM16B, "pcm16-nb")},
559 {FLAG_pcm16b_wb,
henrik.lundine8a77e32016-06-22 06:34:03 -0700560 std::make_pair(NetEqDecoder::kDecoderPCM16Bwb, "pcm16-wb")},
oprypin6e09d872017-08-31 03:21:39 -0700561 {FLAG_pcm16b_swb32,
henrik.lundine8a77e32016-06-22 06:34:03 -0700562 std::make_pair(NetEqDecoder::kDecoderPCM16Bswb32kHz, "pcm16-swb32")},
oprypin6e09d872017-08-31 03:21:39 -0700563 {FLAG_pcm16b_swb48,
henrik.lundine8a77e32016-06-22 06:34:03 -0700564 std::make_pair(NetEqDecoder::kDecoderPCM16Bswb48kHz, "pcm16-swb48")},
oprypin6e09d872017-08-31 03:21:39 -0700565 {FLAG_g722, std::make_pair(NetEqDecoder::kDecoderG722, "g722")},
566 {FLAG_avt, std::make_pair(NetEqDecoder::kDecoderAVT, "avt")},
567 {FLAG_avt_16, std::make_pair(NetEqDecoder::kDecoderAVT16kHz, "avt-16")},
568 {FLAG_avt_32,
solenberg2779bab2016-11-17 04:45:19 -0800569 std::make_pair(NetEqDecoder::kDecoderAVT32kHz, "avt-32")},
oprypin6e09d872017-08-31 03:21:39 -0700570 {FLAG_avt_48,
solenberg2779bab2016-11-17 04:45:19 -0800571 std::make_pair(NetEqDecoder::kDecoderAVT48kHz, "avt-48")},
oprypin6e09d872017-08-31 03:21:39 -0700572 {FLAG_red, std::make_pair(NetEqDecoder::kDecoderRED, "red")},
573 {FLAG_cn_nb, std::make_pair(NetEqDecoder::kDecoderCNGnb, "cng-nb")},
574 {FLAG_cn_wb, std::make_pair(NetEqDecoder::kDecoderCNGwb, "cng-wb")},
575 {FLAG_cn_swb32,
henrik.lundine8a77e32016-06-22 06:34:03 -0700576 std::make_pair(NetEqDecoder::kDecoderCNGswb32kHz, "cng-swb32")},
oprypin6e09d872017-08-31 03:21:39 -0700577 {FLAG_cn_swb48,
henrik.lundine8a77e32016-06-22 06:34:03 -0700578 std::make_pair(NetEqDecoder::kDecoderCNGswb48kHz, "cng-swb48")}};
henrik.lundin@webrtc.org03499a02014-11-24 14:50:53 +0000579
henrik.lundine8a77e32016-06-22 06:34:03 -0700580 // Check if a replacement audio file was provided.
581 std::unique_ptr<AudioDecoder> replacement_decoder;
582 NetEqTest::ExtDecoderMap ext_codecs;
oprypin6e09d872017-08-31 03:21:39 -0700583 if (strlen(FLAG_replacement_audio_file) > 0) {
henrik.lundine8a77e32016-06-22 06:34:03 -0700584 // Find largest unused payload type.
585 int replacement_pt = 127;
586 while (!(codecs.find(replacement_pt) == codecs.end() &&
587 ext_codecs.find(replacement_pt) == ext_codecs.end())) {
588 --replacement_pt;
589 RTC_CHECK_GE(replacement_pt, 0);
590 }
591
592 auto std_set_int32_to_uint8 = [](const std::set<int32_t>& a) {
593 std::set<uint8_t> b;
594 for (auto& x : a) {
595 b.insert(static_cast<uint8_t>(x));
596 }
597 return b;
598 };
599
600 std::set<uint8_t> cn_types = std_set_int32_to_uint8(
oprypin6e09d872017-08-31 03:21:39 -0700601 {FLAG_cn_nb, FLAG_cn_wb, FLAG_cn_swb32, FLAG_cn_swb48});
henrik.lundine8a77e32016-06-22 06:34:03 -0700602 std::set<uint8_t> forbidden_types =
oprypin6e09d872017-08-31 03:21:39 -0700603 std_set_int32_to_uint8({FLAG_g722, FLAG_red, FLAG_avt,
604 FLAG_avt_16, FLAG_avt_32, FLAG_avt_48});
henrik.lundine8a77e32016-06-22 06:34:03 -0700605 input.reset(new NetEqReplacementInput(std::move(input), replacement_pt,
606 cn_types, forbidden_types));
607
608 replacement_decoder.reset(new FakeDecodeFromFile(
609 std::unique_ptr<InputAudioFile>(
oprypin6e09d872017-08-31 03:21:39 -0700610 new InputAudioFile(FLAG_replacement_audio_file)),
henrik.lundine8a77e32016-06-22 06:34:03 -0700611 48000, false));
612 NetEqTest::ExternalDecoderInfo ext_dec_info = {
613 replacement_decoder.get(), NetEqDecoder::kDecoderArbitrary,
614 "replacement codec"};
615 ext_codecs[replacement_pt] = ext_dec_info;
616 }
617
henrik.lundin02739d92017-05-04 06:09:06 -0700618 NetEqTest::Callbacks callbacks;
Henrik Lundin0bc0ccd2017-06-20 14:48:50 +0200619 std::unique_ptr<NetEqDelayAnalyzer> delay_analyzer;
Ivo Creusend1d8dfb2017-12-06 10:48:10 +0100620 if (FLAG_matlabplot || FLAG_pythonplot) {
Henrik Lundin0bc0ccd2017-06-20 14:48:50 +0200621 delay_analyzer.reset(new NetEqDelayAnalyzer);
622 }
623
624 SsrcSwitchDetector ssrc_switch_detector(delay_analyzer.get());
625 callbacks.post_insert_packet = &ssrc_switch_detector;
Henrik Lundina2af0002017-06-20 16:54:39 +0200626 StatsGetter stats_getter(delay_analyzer.get());
627 callbacks.get_audio_callback = &stats_getter;
henrik.lundin@webrtc.org03499a02014-11-24 14:50:53 +0000628 NetEq::Config config;
Henrik Lundin0bc0ccd2017-06-20 14:48:50 +0200629 config.sample_rate_hz = *sample_rate_hz;
henrik.lundine8a77e32016-06-22 06:34:03 -0700630 NetEqTest test(config, codecs, ext_codecs, std::move(input),
henrik.lundin02739d92017-05-04 06:09:06 -0700631 std::move(output), callbacks);
henrik.lundin@webrtc.org03499a02014-11-24 14:50:53 +0000632
henrik.lundine8a77e32016-06-22 06:34:03 -0700633 int64_t test_duration_ms = test.Run();
henrik.lundin@webrtc.org03499a02014-11-24 14:50:53 +0000634
oprypin6e09d872017-08-31 03:21:39 -0700635 if (FLAG_matlabplot) {
henrik.lundinf09c9042017-08-29 09:14:08 -0700636 auto matlab_script_name = output_file_name;
637 std::replace(matlab_script_name.begin(), matlab_script_name.end(), '.',
638 '_');
639 std::cout << "Creating Matlab plot script " << matlab_script_name + ".m"
Henrik Lundin0bc0ccd2017-06-20 14:48:50 +0200640 << std::endl;
henrik.lundinf09c9042017-08-29 09:14:08 -0700641 delay_analyzer->CreateMatlabScript(matlab_script_name + ".m");
Henrik Lundin0bc0ccd2017-06-20 14:48:50 +0200642 }
Ivo Creusend1d8dfb2017-12-06 10:48:10 +0100643 if (FLAG_pythonplot) {
644 auto python_script_name = output_file_name;
645 std::replace(python_script_name.begin(), python_script_name.end(), '.',
646 '_');
647 std::cout << "Creating Python plot script " << python_script_name + ".py"
648 << std::endl;
649 delay_analyzer->CreatePythonScript(python_script_name + ".py");
650 }
Henrik Lundin0bc0ccd2017-06-20 14:48:50 +0200651
henrik.lundine8a77e32016-06-22 06:34:03 -0700652 printf("Simulation statistics:\n");
653 printf(" output duration: %" PRId64 " ms\n", test_duration_ms);
Henrik Lundina2af0002017-06-20 16:54:39 +0200654 auto stats = stats_getter.AverageStats();
655 printf(" packet_loss_rate: %f %%\n", 100.0 * stats.packet_loss_rate);
Henrik Lundina2af0002017-06-20 16:54:39 +0200656 printf(" expand_rate: %f %%\n", 100.0 * stats.expand_rate);
657 printf(" speech_expand_rate: %f %%\n", 100.0 * stats.speech_expand_rate);
658 printf(" preemptive_rate: %f %%\n", 100.0 * stats.preemptive_rate);
659 printf(" accelerate_rate: %f %%\n", 100.0 * stats.accelerate_rate);
henrik.lundine8a77e32016-06-22 06:34:03 -0700660 printf(" secondary_decoded_rate: %f %%\n",
Henrik Lundina2af0002017-06-20 16:54:39 +0200661 100.0 * stats.secondary_decoded_rate);
minyue-webrtc0c3ca752017-08-23 15:59:38 +0200662 printf(" secondary_discarded_rate: %f %%\n",
663 100.0 * stats.secondary_discarded_rate);
Henrik Lundina2af0002017-06-20 16:54:39 +0200664 printf(" clockdrift_ppm: %f ppm\n", stats.clockdrift_ppm);
665 printf(" mean_waiting_time_ms: %f ms\n", stats.mean_waiting_time_ms);
666 printf(" median_waiting_time_ms: %f ms\n", stats.median_waiting_time_ms);
667 printf(" min_waiting_time_ms: %f ms\n", stats.min_waiting_time_ms);
668 printf(" max_waiting_time_ms: %f ms\n", stats.max_waiting_time_ms);
Henrik Lundin156af4a2017-11-17 16:46:18 +0100669 printf(" current_buffer_size_ms: %f ms\n", stats.current_buffer_size_ms);
670 printf(" preferred_buffer_size_ms: %f ms\n", stats.preferred_buffer_size_ms);
henrik.lundin@webrtc.org75642fc2014-02-05 08:49:13 +0000671
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +0000672 return 0;
673}
henrik.lundince5570e2016-05-24 06:14:57 -0700674
henrik.lundin303d3e12016-05-26 05:56:03 -0700675} // namespace
henrik.lundince5570e2016-05-24 06:14:57 -0700676} // namespace test
677} // namespace webrtc
henrik.lundin303d3e12016-05-26 05:56:03 -0700678
679int main(int argc, char* argv[]) {
Robin Raymond1c62ffa2017-12-03 16:45:56 -0500680 return webrtc::test::RunTest(argc, argv);
henrik.lundin303d3e12016-05-26 05:56:03 -0700681}