Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | |
| 2 # | |
| 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 | |
| 5 # tree. An additional intellectual property rights grant can be found | |
| 6 # in the file PATENTS. All contributing project authors may | |
| 7 # be found in the AUTHORS file in the root of the source tree. | |
| 8 | |
| 9 """Parses protobuf RTC dumps.""" | |
| 10 | |
| 11 from __future__ import division | |
| 12 | |
| 13 import struct | |
| 14 import sys | |
| 15 | |
| 16 sys.path.append("../../third_party/protobuf/python/") | |
| 17 | |
| 18 import pyproto.webrtc.call.rtc_event_log_pb2 as rtc_pb | |
| 19 | |
| 20 | |
| 21 class DataPoint(object): | |
| 22 """Simple container class for RTP events.""" | |
| 23 | |
| 24 def __init__(self, rtp_header_str, packet_size, | |
| 25 arrival_timestamp_us): | |
| 26 """Builds a data point by parsing an RTP header, size and arrival time. | |
| 27 | |
| 28 RTP header structure is defined in RFC 3550 section 5.1. | |
| 29 """ | |
| 30 self.size = packet_size | |
| 31 self.arrival_timestamp_ms = arrival_timestamp_us / 1000 | |
| 32 (first2header_bytes, self.sequence_number, | |
|
phoglund
2016/06/03 08:11:07
Try this instead:
header = struct.unpack_from("!
aleloi
2016/06/09 12:00:44
Here there are also divided views between differen
kwiberg-webrtc
2016/06/09 12:27:20
Pro tip: If two reviewers give you conflicting adv
phoglund
2016/06/09 12:47:08
All right, I won't fight you on this.
| |
| 33 self.timestamp, self.ssrc | |
| 34 ) = struct.unpack_from("!HHII", rtp_header_str, 0) | |
| 35 self.payload_type = first2header_bytes & 0b01111111 | |
| 36 | |
| 37 | |
| 38 def parse_protobuf(file_path): | |
| 39 """Parses RTC event log from protobuf file. | |
| 40 | |
| 41 Args: | |
| 42 file_path: path to protobuf file of RTC event stream | |
| 43 | |
| 44 Returns: | |
| 45 all RTP packet events from the event stream as a list of DataPoints | |
| 46 """ | |
| 47 event_stream = rtc_pb.EventStream() | |
| 48 with open(file_path, "rb") as f: | |
| 49 event_stream.ParseFromString(f.read()) | |
| 50 | |
| 51 return [DataPoint(event.rtp_packet.header, | |
| 52 event.rtp_packet.packet_length, | |
| 53 event.timestamp_us) | |
| 54 for event in event_stream.stream | |
| 55 if event.HasField("rtp_packet")] | |
| OLD | NEW |