OLD | NEW |
---|---|
1 # Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 1 # Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
2 # | 2 # |
3 # Use of this source code is governed by a BSD-style license | 3 # Use of this source code is governed by a BSD-style license |
4 # that can be found in the LICENSE file in the root of the source | 4 # that can be found in the LICENSE file in the root of the source |
5 # tree. An additional intellectual property rights grant can be found | 5 # tree. An additional intellectual property rights grant can be found |
6 # in the file PATENTS. All contributing project authors may | 6 # in the file PATENTS. All contributing project authors may |
7 # be found in the AUTHORS file in the root of the source tree. | 7 # be found in the AUTHORS file in the root of the source tree. |
8 | 8 |
9 """Displays statistics and plots graphs from RTC protobuf dump.""" | 9 """Displays statistics and plots graphs from RTC protobuf dump.""" |
10 | 10 |
11 from __future__ import division | 11 from __future__ import division |
12 from __future__ import print_function | 12 from __future__ import print_function |
13 | 13 |
14 import collections | 14 import collections |
15 import optparse | 15 import optparse |
16 import os | |
16 import sys | 17 import sys |
17 | 18 |
18 import matplotlib.pyplot as plt | 19 import matplotlib.pyplot as plt |
19 import numpy | 20 import numpy |
20 | 21 |
21 import misc | 22 import misc |
22 import pb_parse | 23 import pb_parse |
23 | 24 |
24 | 25 |
25 class RTPStatistics(object): | 26 class RTPStatistics(object): |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
268 point in the time sequence start, start+step, start+2*step... Takes | 269 point in the time sequence start, start+step, start+2*step... Takes |
269 the average of the delays of points rounded to the same. Returns | 270 the average of the delays of points rounded to the same. Returns |
270 masked array, in which time points with no value are masked. | 271 masked array, in which time points with no value are masked. |
271 | 272 |
272 """ | 273 """ |
273 grouped_delays = [[] for _ in numpy.arange(start, stop, step)] | 274 grouped_delays = [[] for _ in numpy.arange(start, stop, step)] |
274 rounded_value_index = lambda x: int((x - start) / step) | 275 rounded_value_index = lambda x: int((x - start) / step) |
275 for point in points: | 276 for point in points: |
276 grouped_delays[rounded_value_index(point.real_send_time_ms) | 277 grouped_delays[rounded_value_index(point.real_send_time_ms) |
277 ].append(point.absdelay) | 278 ].append(point.absdelay) |
278 regularized_delays = [numpy.average(arr) if arr else None for arr in | 279 regularized_delays = [numpy.average(arr) if arr else -1 for arr in |
279 grouped_delays] | 280 grouped_delays] |
280 return numpy.ma.masked_values(regularized_delays, None) | 281 return numpy.ma.masked_values(regularized_delays, -1) |
aleloi
2016/08/29 11:37:33
masked_values(array, x) marks all positions |i| in
kwiberg-webrtc
2016/08/29 11:49:44
Acknowledged.
| |
281 | 282 |
282 | 283 |
283 def main(): | 284 def main(): |
284 usage = "Usage: %prog [options] <filename of rtc event log>" | 285 usage = "Usage: %prog [options] <filename of rtc event log>" |
285 parser = optparse.OptionParser(usage=usage) | 286 parser = optparse.OptionParser(usage=usage) |
286 parser.add_option("--dump_header_to_stdout", | 287 parser.add_option("--dump_header_to_stdout", |
287 default=False, action="store_true", | 288 default=False, action="store_true", |
288 help="print header info to stdout; similar to rtp_analyze") | 289 help="print header info to stdout; similar to rtp_analyze") |
289 parser.add_option("--query_sample_rate", | 290 parser.add_option("--query_sample_rate", |
290 default=False, action="store_true", | 291 default=False, action="store_true", |
291 help="always query user for real sample rate") | 292 help="always query user for real sample rate") |
292 | 293 |
294 parser.add_option("--working_directory", | |
295 default=None, action="store", | |
296 help="directory in which to search for relative paths") | |
297 | |
293 (options, args) = parser.parse_args() | 298 (options, args) = parser.parse_args() |
294 | 299 |
295 if len(args) < 1: | 300 if len(args) < 1: |
296 parser.print_help() | 301 parser.print_help() |
297 sys.exit(0) | 302 sys.exit(0) |
298 | 303 |
299 data_points = pb_parse.parse_protobuf(args[0]) | 304 input_file = args[0] |
305 | |
306 if options.working_directory and not os.path.isabs(input_file): | |
307 input_file = os.path.join(options.working_directory, input_file) | |
308 | |
309 data_points = pb_parse.parse_protobuf(input_file) | |
aleloi
2016/08/29 11:37:33
Previously, you had to specify a log file with an
kwiberg-webrtc
2016/08/29 11:49:44
Acknowledged.
| |
300 rtp_stats = RTPStatistics(data_points) | 310 rtp_stats = RTPStatistics(data_points) |
301 | 311 |
302 if options.dump_header_to_stdout: | 312 if options.dump_header_to_stdout: |
303 print("Printing header info to stdout.", file=sys.stderr) | 313 print("Printing header info to stdout.", file=sys.stderr) |
304 rtp_stats.print_header_statistics() | 314 rtp_stats.print_header_statistics() |
305 sys.exit(0) | 315 sys.exit(0) |
306 | 316 |
307 chosen_ssrc = rtp_stats.choose_ssrc() | 317 chosen_ssrc = rtp_stats.choose_ssrc() |
308 print("Chosen SSRC: 0X{:X}".format(chosen_ssrc)) | 318 print("Chosen SSRC: 0X{:X}".format(chosen_ssrc)) |
309 | 319 |
310 rtp_stats.filter_ssrc(chosen_ssrc) | 320 rtp_stats.filter_ssrc(chosen_ssrc) |
311 | 321 |
312 print("Statistics:") | 322 print("Statistics:") |
313 rtp_stats.print_sequence_number_statistics() | 323 rtp_stats.print_sequence_number_statistics() |
314 rtp_stats.estimate_frequency(options.query_sample_rate) | 324 rtp_stats.estimate_frequency(options.query_sample_rate) |
315 rtp_stats.print_duration_statistics() | 325 rtp_stats.print_duration_statistics() |
316 rtp_stats.remove_reordered() | 326 rtp_stats.remove_reordered() |
317 rtp_stats.compute_bandwidth() | 327 rtp_stats.compute_bandwidth() |
318 rtp_stats.plot_statistics() | 328 rtp_stats.plot_statistics() |
319 | 329 |
320 if __name__ == "__main__": | 330 if __name__ == "__main__": |
321 main() | 331 main() |
OLD | NEW |