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

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

Issue 2855143002: Removed RtcEventLog deps to call:call_interfaces. (Closed)
Patch Set: Made GetSend/ReceiveConfig private. Created 3 years, 6 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) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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.h" 11 #include "webrtc/logging/rtc_event_log/rtc_event_log.h"
12 12
13 #include <limits> 13 #include <limits>
14 #include <vector> 14 #include <vector>
15 15
16 #include "webrtc/base/checks.h" 16 #include "webrtc/base/checks.h"
17 #include "webrtc/base/constructormagic.h" 17 #include "webrtc/base/constructormagic.h"
18 #include "webrtc/base/event.h" 18 #include "webrtc/base/event.h"
19 #include "webrtc/base/logging.h" 19 #include "webrtc/base/logging.h"
20 #include "webrtc/base/protobuf_utils.h" 20 #include "webrtc/base/protobuf_utils.h"
21 #include "webrtc/base/swap_queue.h" 21 #include "webrtc/base/swap_queue.h"
22 #include "webrtc/base/thread_checker.h" 22 #include "webrtc/base/thread_checker.h"
23 #include "webrtc/base/timeutils.h" 23 #include "webrtc/base/timeutils.h"
24 #include "webrtc/call/call.h"
25 #include "webrtc/logging/rtc_event_log/rtc_event_log_helper_thread.h" 24 #include "webrtc/logging/rtc_event_log/rtc_event_log_helper_thread.h"
26 #include "webrtc/modules/audio_coding/audio_network_adaptor/include/audio_networ k_adaptor.h" 25 #include "webrtc/modules/audio_coding/audio_network_adaptor/include/audio_networ k_adaptor.h"
27 #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h" 26 #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h"
28 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" 27 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
29 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" 28 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
30 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/app.h" 29 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/app.h"
31 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h" 30 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h"
32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h" 31 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h"
33 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_jitter_report.h" 32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_jitter_report.h"
34 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h" 33 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h"
(...skipping 25 matching lines...) Expand all
60 bool StartLogging(const std::string& file_name, 59 bool StartLogging(const std::string& file_name,
61 int64_t max_size_bytes) override; 60 int64_t max_size_bytes) override;
62 bool StartLogging(rtc::PlatformFile platform_file, 61 bool StartLogging(rtc::PlatformFile platform_file,
63 int64_t max_size_bytes) override; 62 int64_t max_size_bytes) override;
64 void StopLogging() override; 63 void StopLogging() override;
65 void LogVideoReceiveStreamConfig(const rtclog::StreamConfig& config) override; 64 void LogVideoReceiveStreamConfig(const rtclog::StreamConfig& config) override;
66 void LogVideoSendStreamConfig(const rtclog::StreamConfig& config) override; 65 void LogVideoSendStreamConfig(const rtclog::StreamConfig& config) override;
67 void LogAudioReceiveStreamConfig(const rtclog::StreamConfig& config) override; 66 void LogAudioReceiveStreamConfig(const rtclog::StreamConfig& config) override;
68 void LogAudioSendStreamConfig(const rtclog::StreamConfig& config) override; 67 void LogAudioSendStreamConfig(const rtclog::StreamConfig& config) override;
69 void LogRtpHeader(PacketDirection direction, 68 void LogRtpHeader(PacketDirection direction,
70 MediaType media_type,
71 const uint8_t* header, 69 const uint8_t* header,
72 size_t packet_length) override; 70 size_t packet_length) override;
73 void LogRtpHeader(PacketDirection direction, 71 void LogRtpHeader(PacketDirection direction,
74 MediaType media_type,
75 const uint8_t* header, 72 const uint8_t* header,
76 size_t packet_length, 73 size_t packet_length,
77 int probe_cluster_id) override; 74 int probe_cluster_id) override;
78 void LogRtcpPacket(PacketDirection direction, 75 void LogRtcpPacket(PacketDirection direction,
79 MediaType media_type,
80 const uint8_t* packet, 76 const uint8_t* packet,
81 size_t length) override; 77 size_t length) override;
82 void LogAudioPlayout(uint32_t ssrc) override; 78 void LogAudioPlayout(uint32_t ssrc) override;
83 void LogLossBasedBweUpdate(int32_t bitrate_bps, 79 void LogLossBasedBweUpdate(int32_t bitrate_bps,
84 uint8_t fraction_loss, 80 uint8_t fraction_loss,
85 int32_t total_packets) override; 81 int32_t total_packets) override;
86 void LogDelayBasedBweUpdate(int32_t bitrate_bps, 82 void LogDelayBasedBweUpdate(int32_t bitrate_bps,
87 BandwidthUsage detector_state) override; 83 BandwidthUsage detector_state) override;
88 void LogAudioNetworkAdaptation( 84 void LogAudioNetworkAdaptation(
89 const AudioEncoderRuntimeConfig& config) override; 85 const AudioEncoderRuntimeConfig& config) override;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 case RtcpMode::kReducedSize: 121 case RtcpMode::kReducedSize:
126 return rtclog::VideoReceiveConfig::RTCP_REDUCEDSIZE; 122 return rtclog::VideoReceiveConfig::RTCP_REDUCEDSIZE;
127 case RtcpMode::kOff: 123 case RtcpMode::kOff:
128 RTC_NOTREACHED(); 124 RTC_NOTREACHED();
129 return rtclog::VideoReceiveConfig::RTCP_COMPOUND; 125 return rtclog::VideoReceiveConfig::RTCP_COMPOUND;
130 } 126 }
131 RTC_NOTREACHED(); 127 RTC_NOTREACHED();
132 return rtclog::VideoReceiveConfig::RTCP_COMPOUND; 128 return rtclog::VideoReceiveConfig::RTCP_COMPOUND;
133 } 129 }
134 130
135 rtclog::MediaType ConvertMediaType(MediaType media_type) {
136 switch (media_type) {
137 case MediaType::ANY:
138 return rtclog::MediaType::ANY;
139 case MediaType::AUDIO:
140 return rtclog::MediaType::AUDIO;
141 case MediaType::VIDEO:
142 return rtclog::MediaType::VIDEO;
143 case MediaType::DATA:
144 return rtclog::MediaType::DATA;
145 }
146 RTC_NOTREACHED();
147 return rtclog::ANY;
148 }
149
150 rtclog::DelayBasedBweUpdate::DetectorState ConvertDetectorState( 131 rtclog::DelayBasedBweUpdate::DetectorState ConvertDetectorState(
151 BandwidthUsage state) { 132 BandwidthUsage state) {
152 switch (state) { 133 switch (state) {
153 case BandwidthUsage::kBwNormal: 134 case BandwidthUsage::kBwNormal:
154 return rtclog::DelayBasedBweUpdate::BWE_NORMAL; 135 return rtclog::DelayBasedBweUpdate::BWE_NORMAL;
155 case BandwidthUsage::kBwUnderusing: 136 case BandwidthUsage::kBwUnderusing:
156 return rtclog::DelayBasedBweUpdate::BWE_UNDERUSING; 137 return rtclog::DelayBasedBweUpdate::BWE_UNDERUSING;
157 case BandwidthUsage::kBwOverusing: 138 case BandwidthUsage::kBwOverusing:
158 return rtclog::DelayBasedBweUpdate::BWE_OVERUSING; 139 return rtclog::DelayBasedBweUpdate::BWE_OVERUSING;
159 } 140 }
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 rtclog::RtpHeaderExtension* extension = 364 rtclog::RtpHeaderExtension* extension =
384 sender_config->add_header_extensions(); 365 sender_config->add_header_extensions();
385 extension->set_name(e.uri); 366 extension->set_name(e.uri);
386 extension->set_id(e.id); 367 extension->set_id(e.id);
387 } 368 }
388 369
389 StoreEvent(&event); 370 StoreEvent(&event);
390 } 371 }
391 372
392 void RtcEventLogImpl::LogRtpHeader(PacketDirection direction, 373 void RtcEventLogImpl::LogRtpHeader(PacketDirection direction,
393 MediaType media_type,
394 const uint8_t* header, 374 const uint8_t* header,
395 size_t packet_length) { 375 size_t packet_length) {
396 LogRtpHeader(direction, media_type, header, packet_length, 376 LogRtpHeader(direction, header, packet_length, PacedPacketInfo::kNotAProbe);
397 PacedPacketInfo::kNotAProbe);
398 } 377 }
399 378
400 void RtcEventLogImpl::LogRtpHeader(PacketDirection direction, 379 void RtcEventLogImpl::LogRtpHeader(PacketDirection direction,
401 MediaType media_type,
402 const uint8_t* header, 380 const uint8_t* header,
403 size_t packet_length, 381 size_t packet_length,
404 int probe_cluster_id) { 382 int probe_cluster_id) {
405 // Read header length (in bytes) from packet data. 383 // Read header length (in bytes) from packet data.
406 if (packet_length < 12u) { 384 if (packet_length < 12u) {
407 return; // Don't read outside the packet. 385 return; // Don't read outside the packet.
408 } 386 }
409 const bool x = (header[0] & 0x10) != 0; 387 const bool x = (header[0] & 0x10) != 0;
410 const uint8_t cc = header[0] & 0x0f; 388 const uint8_t cc = header[0] & 0x0f;
411 size_t header_length = 12u + cc * 4u; 389 size_t header_length = 12u + cc * 4u;
412 390
413 if (x) { 391 if (x) {
414 if (packet_length < 12u + cc * 4u + 4u) { 392 if (packet_length < 12u + cc * 4u + 4u) {
415 return; // Don't read outside the packet. 393 return; // Don't read outside the packet.
416 } 394 }
417 size_t x_len = ByteReader<uint16_t>::ReadBigEndian(header + 14 + cc * 4); 395 size_t x_len = ByteReader<uint16_t>::ReadBigEndian(header + 14 + cc * 4);
418 header_length += (x_len + 1) * 4; 396 header_length += (x_len + 1) * 4;
419 } 397 }
420 398
421 std::unique_ptr<rtclog::Event> rtp_event(new rtclog::Event()); 399 std::unique_ptr<rtclog::Event> rtp_event(new rtclog::Event());
422 rtp_event->set_timestamp_us(rtc::TimeMicros()); 400 rtp_event->set_timestamp_us(rtc::TimeMicros());
423 rtp_event->set_type(rtclog::Event::RTP_EVENT); 401 rtp_event->set_type(rtclog::Event::RTP_EVENT);
424 rtp_event->mutable_rtp_packet()->set_incoming(direction == kIncomingPacket); 402 rtp_event->mutable_rtp_packet()->set_incoming(direction == kIncomingPacket);
425 rtp_event->mutable_rtp_packet()->set_type(ConvertMediaType(media_type));
426 rtp_event->mutable_rtp_packet()->set_packet_length(packet_length); 403 rtp_event->mutable_rtp_packet()->set_packet_length(packet_length);
427 rtp_event->mutable_rtp_packet()->set_header(header, header_length); 404 rtp_event->mutable_rtp_packet()->set_header(header, header_length);
428 if (probe_cluster_id != PacedPacketInfo::kNotAProbe) 405 if (probe_cluster_id != PacedPacketInfo::kNotAProbe)
429 rtp_event->mutable_rtp_packet()->set_probe_cluster_id(probe_cluster_id); 406 rtp_event->mutable_rtp_packet()->set_probe_cluster_id(probe_cluster_id);
430 StoreEvent(&rtp_event); 407 StoreEvent(&rtp_event);
431 } 408 }
432 409
433 void RtcEventLogImpl::LogRtcpPacket(PacketDirection direction, 410 void RtcEventLogImpl::LogRtcpPacket(PacketDirection direction,
434 MediaType media_type,
435 const uint8_t* packet, 411 const uint8_t* packet,
436 size_t length) { 412 size_t length) {
437 std::unique_ptr<rtclog::Event> rtcp_event(new rtclog::Event()); 413 std::unique_ptr<rtclog::Event> rtcp_event(new rtclog::Event());
438 rtcp_event->set_timestamp_us(rtc::TimeMicros()); 414 rtcp_event->set_timestamp_us(rtc::TimeMicros());
439 rtcp_event->set_type(rtclog::Event::RTCP_EVENT); 415 rtcp_event->set_type(rtclog::Event::RTCP_EVENT);
440 rtcp_event->mutable_rtcp_packet()->set_incoming(direction == kIncomingPacket); 416 rtcp_event->mutable_rtcp_packet()->set_incoming(direction == kIncomingPacket);
441 rtcp_event->mutable_rtcp_packet()->set_type(ConvertMediaType(media_type));
442 417
443 rtcp::CommonHeader header; 418 rtcp::CommonHeader header;
444 const uint8_t* block_begin = packet; 419 const uint8_t* block_begin = packet;
445 const uint8_t* packet_end = packet + length; 420 const uint8_t* packet_end = packet + length;
446 RTC_DCHECK(length <= IP_PACKET_SIZE); 421 RTC_DCHECK(length <= IP_PACKET_SIZE);
447 uint8_t buffer[IP_PACKET_SIZE]; 422 uint8_t buffer[IP_PACKET_SIZE];
448 uint32_t buffer_length = 0; 423 uint32_t buffer_length = 0;
449 while (block_begin < packet_end) { 424 while (block_begin < packet_end) {
450 if (!header.Parse(block_begin, packet_end - block_begin)) { 425 if (!header.Parse(block_begin, packet_end - block_begin)) {
451 break; // Incorrect message header. 426 break; // Incorrect message header.
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 #else 596 #else
622 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); 597 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl());
623 #endif // ENABLE_RTC_EVENT_LOG 598 #endif // ENABLE_RTC_EVENT_LOG
624 } 599 }
625 600
626 std::unique_ptr<RtcEventLog> RtcEventLog::CreateNull() { 601 std::unique_ptr<RtcEventLog> RtcEventLog::CreateNull() {
627 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); 602 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl());
628 } 603 }
629 604
630 } // namespace webrtc 605 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/logging/rtc_event_log/rtc_event_log.h ('k') | webrtc/logging/rtc_event_log/rtc_event_log.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698