OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 uint64_t varint = 0; | 47 uint64_t varint = 0; |
48 for (size_t bytes_read = 0; bytes_read < 10; ++bytes_read) { | 48 for (size_t bytes_read = 0; bytes_read < 10; ++bytes_read) { |
49 // The most significant bit of each byte is 0 if it is the last byte in | 49 // The most significant bit of each byte is 0 if it is the last byte in |
50 // the varint and 1 otherwise. Thus, we take the 7 least significant bits | 50 // the varint and 1 otherwise. Thus, we take the 7 least significant bits |
51 // of each byte and shift them 7 bits for each byte read previously to get | 51 // of each byte and shift them 7 bits for each byte read previously to get |
52 // the (unsigned) integer. | 52 // the (unsigned) integer. |
53 int byte = stream.get(); | 53 int byte = stream.get(); |
54 if (stream.eof()) { | 54 if (stream.eof()) { |
55 return std::make_pair(varint, false); | 55 return std::make_pair(varint, false); |
56 } | 56 } |
57 RTC_DCHECK(0 <= byte && byte <= 255); | 57 RTC_DCHECK_GE(byte, 0); |
| 58 RTC_DCHECK_LE(byte, 255); |
58 varint |= static_cast<uint64_t>(byte & 0x7F) << (7 * bytes_read); | 59 varint |= static_cast<uint64_t>(byte & 0x7F) << (7 * bytes_read); |
59 if ((byte & 0x80) == 0) { | 60 if ((byte & 0x80) == 0) { |
60 return std::make_pair(varint, true); | 61 return std::make_pair(varint, true); |
61 } | 62 } |
62 } | 63 } |
63 return std::make_pair(varint, false); | 64 return std::make_pair(varint, false); |
64 } | 65 } |
65 | 66 |
66 bool ParseEvents(const std::string& filename, | 67 bool ParseEvents(const std::string& filename, |
67 std::vector<webrtc::rtclog::Event>* events) { | 68 std::vector<webrtc::rtclog::Event>* events) { |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 static_cast<double>(malformed_event_size) / malformed_events, | 244 static_cast<double>(malformed_event_size) / malformed_events, |
244 static_cast<double>(malformed_event_size) / file_size * 100); | 245 static_cast<double>(malformed_event_size) / file_size * 100); |
245 } | 246 } |
246 if (file_size - accumulated_event_size != 0) { | 247 if (file_size - accumulated_event_size != 0) { |
247 printf("WARNING: %" PRId64 " bytes not accounted for\n", | 248 printf("WARNING: %" PRId64 " bytes not accounted for\n", |
248 file_size - accumulated_event_size); | 249 file_size - accumulated_event_size); |
249 } | 250 } |
250 | 251 |
251 return 0; | 252 return 0; |
252 } | 253 } |
OLD | NEW |