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 """Parses protobuf RTC dumps.""" | 9 """Parses protobuf RTC dumps.""" |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 """Builds a data point by parsing an RTP header, size and arrival time. | 21 """Builds a data point by parsing an RTP header, size and arrival time. |
22 | 22 |
23 RTP header structure is defined in RFC 3550 section 5.1. | 23 RTP header structure is defined in RFC 3550 section 5.1. |
24 """ | 24 """ |
25 self.size = packet_size | 25 self.size = packet_size |
26 self.arrival_timestamp_ms = arrival_timestamp_us / 1000 | 26 self.arrival_timestamp_ms = arrival_timestamp_us / 1000 |
27 header = struct.unpack_from("!HHII", rtp_header_str, 0) | 27 header = struct.unpack_from("!HHII", rtp_header_str, 0) |
28 (first2header_bytes, self.sequence_number, self.timestamp, | 28 (first2header_bytes, self.sequence_number, self.timestamp, |
29 self.ssrc) = header | 29 self.ssrc) = header |
30 self.payload_type = first2header_bytes & 0b01111111 | 30 self.payload_type = first2header_bytes & 0b01111111 |
| 31 self.marker_bit = (first2header_bytes & 0b10000000) >> 7 |
31 | 32 |
32 | 33 |
33 def parse_protobuf(file_path): | 34 def parse_protobuf(file_path): |
34 """Parses RTC event log from protobuf file. | 35 """Parses RTC event log from protobuf file. |
35 | 36 |
36 Args: | 37 Args: |
37 file_path: path to protobuf file of RTC event stream | 38 file_path: path to protobuf file of RTC event stream |
38 | 39 |
39 Returns: | 40 Returns: |
40 all RTP packet events from the event stream as a list of DataPoints | 41 all RTP packet events from the event stream as a list of DataPoints |
41 """ | 42 """ |
42 event_stream = rtc_pb.EventStream() | 43 event_stream = rtc_pb.EventStream() |
43 with open(file_path, "rb") as f: | 44 with open(file_path, "rb") as f: |
44 event_stream.ParseFromString(f.read()) | 45 event_stream.ParseFromString(f.read()) |
45 | 46 |
46 return [DataPoint(event.rtp_packet.header, | 47 return [DataPoint(event.rtp_packet.header, |
47 event.rtp_packet.packet_length, | 48 event.rtp_packet.packet_length, |
48 event.timestamp_us) | 49 event.timestamp_us) |
49 for event in event_stream.stream | 50 for event in event_stream.stream |
50 if event.HasField("rtp_packet")] | 51 if event.HasField("rtp_packet")] |
OLD | NEW |