Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1266)

Side by Side Diff: webrtc/logging/rtc_event_log/rtc_event_log_parser.cc

Issue 2855143002: Removed RtcEventLog deps to call:call_interfaces. (Closed)
Patch Set: Rebased Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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
11 #include "webrtc/logging/rtc_event_log/rtc_event_log_parser.h" 11 #include "webrtc/logging/rtc_event_log/rtc_event_log_parser.h"
12 12
13 #include <stdint.h> 13 #include <stdint.h>
14 #include <string.h> 14 #include <string.h>
15 15
16 #include <algorithm> 16 #include <algorithm>
17 #include <fstream> 17 #include <fstream>
18 #include <istream> 18 #include <istream>
19 #include <map> 19 #include <map>
20 #include <utility> 20 #include <utility>
21 21
22 #include "webrtc/base/checks.h" 22 #include "webrtc/base/checks.h"
23 #include "webrtc/base/logging.h" 23 #include "webrtc/base/logging.h"
24 #include "webrtc/base/protobuf_utils.h" 24 #include "webrtc/base/protobuf_utils.h"
25 #include "webrtc/call/call.h"
26 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" 25 #include "webrtc/logging/rtc_event_log/rtc_event_log.h"
27 #include "webrtc/modules/audio_coding/audio_network_adaptor/include/audio_networ k_adaptor.h" 26 #include "webrtc/modules/audio_coding/audio_network_adaptor/include/audio_networ k_adaptor.h"
28 #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h" 27 #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h"
29 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" 28 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
30 29
31 namespace webrtc { 30 namespace webrtc {
32 31
33 namespace { 32 namespace {
34 MediaType GetRuntimeMediaType(rtclog::MediaType media_type) {
35 switch (media_type) {
36 case rtclog::MediaType::ANY:
37 return MediaType::ANY;
38 case rtclog::MediaType::AUDIO:
39 return MediaType::AUDIO;
40 case rtclog::MediaType::VIDEO:
41 return MediaType::VIDEO;
42 case rtclog::MediaType::DATA:
43 return MediaType::DATA;
44 }
45 RTC_NOTREACHED();
46 return MediaType::ANY;
47 }
48
49 RtcpMode GetRuntimeRtcpMode(rtclog::VideoReceiveConfig::RtcpMode rtcp_mode) { 33 RtcpMode GetRuntimeRtcpMode(rtclog::VideoReceiveConfig::RtcpMode rtcp_mode) {
50 switch (rtcp_mode) { 34 switch (rtcp_mode) {
51 case rtclog::VideoReceiveConfig::RTCP_COMPOUND: 35 case rtclog::VideoReceiveConfig::RTCP_COMPOUND:
52 return RtcpMode::kCompound; 36 return RtcpMode::kCompound;
53 case rtclog::VideoReceiveConfig::RTCP_REDUCEDSIZE: 37 case rtclog::VideoReceiveConfig::RTCP_REDUCEDSIZE:
54 return RtcpMode::kReducedSize; 38 return RtcpMode::kReducedSize;
55 } 39 }
56 RTC_NOTREACHED(); 40 RTC_NOTREACHED();
57 return RtcpMode::kOff; 41 return RtcpMode::kOff;
58 } 42 }
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 156
173 while (1) { 157 while (1) {
174 // Check whether we have reached end of file. 158 // Check whether we have reached end of file.
175 stream.peek(); 159 stream.peek();
176 if (stream.eof()) { 160 if (stream.eof()) {
177 return true; 161 return true;
178 } 162 }
179 163
180 // Read the next message tag. The tag number is defined as 164 // Read the next message tag. The tag number is defined as
181 // (fieldnumber << 3) | wire_type. In our case, the field number is 165 // (fieldnumber << 3) | wire_type. In our case, the field number is
182 // supposed to be 1 and the wire type for an length-delimited field is 2. 166 // supposed to be 1 and the wire type for an
167 // length-deli"../call:call_interfaces",mited field is 2.
183 const uint64_t kExpectedTag = (1 << 3) | 2; 168 const uint64_t kExpectedTag = (1 << 3) | 2;
184 std::tie(tag, success) = ParseVarInt(stream); 169 std::tie(tag, success) = ParseVarInt(stream);
185 if (!success) { 170 if (!success) {
186 LOG(LS_WARNING) << "Missing field tag from beginning of protobuf event."; 171 LOG(LS_WARNING) << "Missing field tag from beginning of protobuf event.";
187 return false; 172 return false;
188 } else if (tag != kExpectedTag) { 173 } else if (tag != kExpectedTag) {
189 LOG(LS_WARNING) << "Unexpected field tag at beginning of protobuf event."; 174 LOG(LS_WARNING) << "Unexpected field tag at beginning of protobuf event.";
190 return false; 175 return false;
191 } 176 }
192 177
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 size_t index) const { 217 size_t index) const {
233 RTC_CHECK_LT(index, GetNumberOfEvents()); 218 RTC_CHECK_LT(index, GetNumberOfEvents());
234 const rtclog::Event& event = events_[index]; 219 const rtclog::Event& event = events_[index];
235 RTC_CHECK(event.has_type()); 220 RTC_CHECK(event.has_type());
236 return GetRuntimeEventType(event.type()); 221 return GetRuntimeEventType(event.type());
237 } 222 }
238 223
239 // The header must have space for at least IP_PACKET_SIZE bytes. 224 // The header must have space for at least IP_PACKET_SIZE bytes.
240 void ParsedRtcEventLog::GetRtpHeader(size_t index, 225 void ParsedRtcEventLog::GetRtpHeader(size_t index,
241 PacketDirection* incoming, 226 PacketDirection* incoming,
242 MediaType* media_type,
243 uint8_t* header, 227 uint8_t* header,
244 size_t* header_length, 228 size_t* header_length,
245 size_t* total_length) const { 229 size_t* total_length) const {
246 RTC_CHECK_LT(index, GetNumberOfEvents()); 230 RTC_CHECK_LT(index, GetNumberOfEvents());
247 const rtclog::Event& event = events_[index]; 231 const rtclog::Event& event = events_[index];
248 RTC_CHECK(event.has_type()); 232 RTC_CHECK(event.has_type());
249 RTC_CHECK_EQ(event.type(), rtclog::Event::RTP_EVENT); 233 RTC_CHECK_EQ(event.type(), rtclog::Event::RTP_EVENT);
250 RTC_CHECK(event.has_rtp_packet()); 234 RTC_CHECK(event.has_rtp_packet());
251 const rtclog::RtpPacket& rtp_packet = event.rtp_packet(); 235 const rtclog::RtpPacket& rtp_packet = event.rtp_packet();
252 // Get direction of packet. 236 // Get direction of packet.
253 RTC_CHECK(rtp_packet.has_incoming()); 237 RTC_CHECK(rtp_packet.has_incoming());
254 if (incoming != nullptr) { 238 if (incoming != nullptr) {
255 *incoming = rtp_packet.incoming() ? kIncomingPacket : kOutgoingPacket; 239 *incoming = rtp_packet.incoming() ? kIncomingPacket : kOutgoingPacket;
256 } 240 }
257 // Get media type.
258 RTC_CHECK(rtp_packet.has_type());
259 if (media_type != nullptr) {
260 *media_type = GetRuntimeMediaType(rtp_packet.type());
261 }
262 // Get packet length. 241 // Get packet length.
263 RTC_CHECK(rtp_packet.has_packet_length()); 242 RTC_CHECK(rtp_packet.has_packet_length());
264 if (total_length != nullptr) { 243 if (total_length != nullptr) {
265 *total_length = rtp_packet.packet_length(); 244 *total_length = rtp_packet.packet_length();
266 } 245 }
267 // Get header length. 246 // Get header length.
268 RTC_CHECK(rtp_packet.has_header()); 247 RTC_CHECK(rtp_packet.has_header());
269 if (header_length != nullptr) { 248 if (header_length != nullptr) {
270 *header_length = rtp_packet.header().size(); 249 *header_length = rtp_packet.header().size();
271 } 250 }
272 // Get header contents. 251 // Get header contents.
273 if (header != nullptr) { 252 if (header != nullptr) {
274 const size_t kMinRtpHeaderSize = 12; 253 const size_t kMinRtpHeaderSize = 12;
275 RTC_CHECK_GE(rtp_packet.header().size(), kMinRtpHeaderSize); 254 RTC_CHECK_GE(rtp_packet.header().size(), kMinRtpHeaderSize);
276 RTC_CHECK_LE(rtp_packet.header().size(), 255 RTC_CHECK_LE(rtp_packet.header().size(),
277 static_cast<size_t>(IP_PACKET_SIZE)); 256 static_cast<size_t>(IP_PACKET_SIZE));
278 memcpy(header, rtp_packet.header().data(), rtp_packet.header().size()); 257 memcpy(header, rtp_packet.header().data(), rtp_packet.header().size());
279 } 258 }
280 } 259 }
281 260
282 // The packet must have space for at least IP_PACKET_SIZE bytes. 261 // The packet must have space for at least IP_PACKET_SIZE bytes.
283 void ParsedRtcEventLog::GetRtcpPacket(size_t index, 262 void ParsedRtcEventLog::GetRtcpPacket(size_t index,
284 PacketDirection* incoming, 263 PacketDirection* incoming,
285 MediaType* media_type,
286 uint8_t* packet, 264 uint8_t* packet,
287 size_t* length) const { 265 size_t* length) const {
288 RTC_CHECK_LT(index, GetNumberOfEvents()); 266 RTC_CHECK_LT(index, GetNumberOfEvents());
289 const rtclog::Event& event = events_[index]; 267 const rtclog::Event& event = events_[index];
290 RTC_CHECK(event.has_type()); 268 RTC_CHECK(event.has_type());
291 RTC_CHECK_EQ(event.type(), rtclog::Event::RTCP_EVENT); 269 RTC_CHECK_EQ(event.type(), rtclog::Event::RTCP_EVENT);
292 RTC_CHECK(event.has_rtcp_packet()); 270 RTC_CHECK(event.has_rtcp_packet());
293 const rtclog::RtcpPacket& rtcp_packet = event.rtcp_packet(); 271 const rtclog::RtcpPacket& rtcp_packet = event.rtcp_packet();
294 // Get direction of packet. 272 // Get direction of packet.
295 RTC_CHECK(rtcp_packet.has_incoming()); 273 RTC_CHECK(rtcp_packet.has_incoming());
296 if (incoming != nullptr) { 274 if (incoming != nullptr) {
297 *incoming = rtcp_packet.incoming() ? kIncomingPacket : kOutgoingPacket; 275 *incoming = rtcp_packet.incoming() ? kIncomingPacket : kOutgoingPacket;
298 } 276 }
299 // Get media type.
300 RTC_CHECK(rtcp_packet.has_type());
301 if (media_type != nullptr) {
302 *media_type = GetRuntimeMediaType(rtcp_packet.type());
303 }
304 // Get packet length. 277 // Get packet length.
305 RTC_CHECK(rtcp_packet.has_packet_data()); 278 RTC_CHECK(rtcp_packet.has_packet_data());
306 if (length != nullptr) { 279 if (length != nullptr) {
307 *length = rtcp_packet.packet_data().size(); 280 *length = rtcp_packet.packet_data().size();
308 } 281 }
309 // Get packet contents. 282 // Get packet contents.
310 if (packet != nullptr) { 283 if (packet != nullptr) {
311 RTC_CHECK_LE(rtcp_packet.packet_data().size(), 284 RTC_CHECK_LE(rtcp_packet.packet_data().size(),
312 static_cast<unsigned>(IP_PACKET_SIZE)); 285 static_cast<unsigned>(IP_PACKET_SIZE));
313 memcpy(packet, rtcp_packet.packet_data().data(), 286 memcpy(packet, rtcp_packet.packet_data().data(),
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 rtc::Optional<ProbeFailureReason>(kInvalidSendReceiveRatio); 555 rtc::Optional<ProbeFailureReason>(kInvalidSendReceiveRatio);
583 } else if (pr_event.result() == rtclog::BweProbeResult::TIMEOUT) { 556 } else if (pr_event.result() == rtclog::BweProbeResult::TIMEOUT) {
584 res.failure_reason = rtc::Optional<ProbeFailureReason>(kTimeout); 557 res.failure_reason = rtc::Optional<ProbeFailureReason>(kTimeout);
585 } else { 558 } else {
586 RTC_NOTREACHED(); 559 RTC_NOTREACHED();
587 } 560 }
588 561
589 return res; 562 return res;
590 } 563 }
591 } // namespace webrtc 564 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698