OLD | NEW |
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 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 void LogAudioSendStreamConfig(const AudioSendStream::Config& config) override; | 67 void LogAudioSendStreamConfig(const AudioSendStream::Config& config) override; |
68 void LogRtpHeader(PacketDirection direction, | 68 void LogRtpHeader(PacketDirection direction, |
69 MediaType media_type, | 69 MediaType media_type, |
70 const uint8_t* header, | 70 const uint8_t* header, |
71 size_t packet_length) override; | 71 size_t packet_length) override; |
72 void LogRtcpPacket(PacketDirection direction, | 72 void LogRtcpPacket(PacketDirection direction, |
73 MediaType media_type, | 73 MediaType media_type, |
74 const uint8_t* packet, | 74 const uint8_t* packet, |
75 size_t length) override; | 75 size_t length) override; |
76 void LogAudioPlayout(uint32_t ssrc) override; | 76 void LogAudioPlayout(uint32_t ssrc) override; |
77 void LogBwePacketLossEvent(int32_t bitrate, | 77 void LogLossBasedBweUpdate(int32_t bitrate_bps, |
78 uint8_t fraction_loss, | 78 uint8_t fraction_loss, |
79 int32_t total_packets) override; | 79 int32_t total_packets) override; |
| 80 void LogDelayBasedBweUpdate(int32_t bitrate_bps, |
| 81 BandwidthUsage detector_state) override; |
80 void LogAudioNetworkAdaptation( | 82 void LogAudioNetworkAdaptation( |
81 const AudioNetworkAdaptor::EncoderRuntimeConfig& config) override; | 83 const AudioNetworkAdaptor::EncoderRuntimeConfig& config) override; |
82 | 84 |
83 private: | 85 private: |
84 void StoreEvent(std::unique_ptr<rtclog::Event>* event); | 86 void StoreEvent(std::unique_ptr<rtclog::Event>* event); |
85 | 87 |
86 // Message queue for passing control messages to the logging thread. | 88 // Message queue for passing control messages to the logging thread. |
87 SwapQueue<RtcEventLogHelperThread::ControlMessage> message_queue_; | 89 SwapQueue<RtcEventLogHelperThread::ControlMessage> message_queue_; |
88 | 90 |
89 // Message queue for passing events to the logging thread. | 91 // Message queue for passing events to the logging thread. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 return rtclog::MediaType::AUDIO; | 124 return rtclog::MediaType::AUDIO; |
123 case MediaType::VIDEO: | 125 case MediaType::VIDEO: |
124 return rtclog::MediaType::VIDEO; | 126 return rtclog::MediaType::VIDEO; |
125 case MediaType::DATA: | 127 case MediaType::DATA: |
126 return rtclog::MediaType::DATA; | 128 return rtclog::MediaType::DATA; |
127 } | 129 } |
128 RTC_NOTREACHED(); | 130 RTC_NOTREACHED(); |
129 return rtclog::ANY; | 131 return rtclog::ANY; |
130 } | 132 } |
131 | 133 |
| 134 rtclog::DelayBasedBweUpdate::DetectorState ConvertDetectorState( |
| 135 BandwidthUsage state) { |
| 136 switch (state) { |
| 137 case BandwidthUsage::kBwNormal: |
| 138 return rtclog::DelayBasedBweUpdate::BWE_NORMAL; |
| 139 case BandwidthUsage::kBwUnderusing: |
| 140 return rtclog::DelayBasedBweUpdate::BWE_UNDERUSING; |
| 141 case BandwidthUsage::kBwOverusing: |
| 142 return rtclog::DelayBasedBweUpdate::BWE_OVERUSING; |
| 143 } |
| 144 RTC_NOTREACHED(); |
| 145 return rtclog::DelayBasedBweUpdate::BWE_NORMAL; |
| 146 } |
| 147 |
132 // The RTP and RTCP buffers reserve space for twice the expected number of | 148 // The RTP and RTCP buffers reserve space for twice the expected number of |
133 // sent packets because they also contain received packets. | 149 // sent packets because they also contain received packets. |
134 static const int kEventsPerSecond = 1000; | 150 static const int kEventsPerSecond = 1000; |
135 static const int kControlMessagesPerSecond = 10; | 151 static const int kControlMessagesPerSecond = 10; |
136 } // namespace | 152 } // namespace |
137 | 153 |
138 // RtcEventLogImpl member functions. | 154 // RtcEventLogImpl member functions. |
139 RtcEventLogImpl::RtcEventLogImpl() | 155 RtcEventLogImpl::RtcEventLogImpl() |
140 // Allocate buffers for roughly one second of history. | 156 // Allocate buffers for roughly one second of history. |
141 : message_queue_(kControlMessagesPerSecond), | 157 : message_queue_(kControlMessagesPerSecond), |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 | 432 |
417 void RtcEventLogImpl::LogAudioPlayout(uint32_t ssrc) { | 433 void RtcEventLogImpl::LogAudioPlayout(uint32_t ssrc) { |
418 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); | 434 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); |
419 event->set_timestamp_us(rtc::TimeMicros()); | 435 event->set_timestamp_us(rtc::TimeMicros()); |
420 event->set_type(rtclog::Event::AUDIO_PLAYOUT_EVENT); | 436 event->set_type(rtclog::Event::AUDIO_PLAYOUT_EVENT); |
421 auto playout_event = event->mutable_audio_playout_event(); | 437 auto playout_event = event->mutable_audio_playout_event(); |
422 playout_event->set_local_ssrc(ssrc); | 438 playout_event->set_local_ssrc(ssrc); |
423 StoreEvent(&event); | 439 StoreEvent(&event); |
424 } | 440 } |
425 | 441 |
426 void RtcEventLogImpl::LogBwePacketLossEvent(int32_t bitrate, | 442 void RtcEventLogImpl::LogLossBasedBweUpdate(int32_t bitrate_bps, |
427 uint8_t fraction_loss, | 443 uint8_t fraction_loss, |
428 int32_t total_packets) { | 444 int32_t total_packets) { |
429 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); | 445 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); |
430 event->set_timestamp_us(rtc::TimeMicros()); | 446 event->set_timestamp_us(rtc::TimeMicros()); |
431 event->set_type(rtclog::Event::BWE_PACKET_LOSS_EVENT); | 447 event->set_type(rtclog::Event::LOSS_BASED_BWE_UPDATE); |
432 auto bwe_event = event->mutable_bwe_packet_loss_event(); | 448 auto bwe_event = event->mutable_loss_based_bwe_update(); |
433 bwe_event->set_bitrate(bitrate); | 449 bwe_event->set_bitrate_bps(bitrate_bps); |
434 bwe_event->set_fraction_loss(fraction_loss); | 450 bwe_event->set_fraction_loss(fraction_loss); |
435 bwe_event->set_total_packets(total_packets); | 451 bwe_event->set_total_packets(total_packets); |
436 StoreEvent(&event); | 452 StoreEvent(&event); |
437 } | 453 } |
438 | 454 |
| 455 void RtcEventLogImpl::LogDelayBasedBweUpdate(int32_t bitrate_bps, |
| 456 BandwidthUsage detector_state) { |
| 457 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); |
| 458 event->set_timestamp_us(rtc::TimeMicros()); |
| 459 event->set_type(rtclog::Event::DELAY_BASED_BWE_UPDATE); |
| 460 auto bwe_event = event->mutable_delay_based_bwe_update(); |
| 461 bwe_event->set_bitrate_bps(bitrate_bps); |
| 462 bwe_event->set_detector_state(ConvertDetectorState(detector_state)); |
| 463 StoreEvent(&event); |
| 464 } |
| 465 |
439 void RtcEventLogImpl::LogAudioNetworkAdaptation( | 466 void RtcEventLogImpl::LogAudioNetworkAdaptation( |
440 const AudioNetworkAdaptor::EncoderRuntimeConfig& config) { | 467 const AudioNetworkAdaptor::EncoderRuntimeConfig& config) { |
441 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); | 468 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); |
442 event->set_timestamp_us(rtc::TimeMicros()); | 469 event->set_timestamp_us(rtc::TimeMicros()); |
443 event->set_type(rtclog::Event::AUDIO_NETWORK_ADAPTATION_EVENT); | 470 event->set_type(rtclog::Event::AUDIO_NETWORK_ADAPTATION_EVENT); |
444 auto audio_network_adaptation = event->mutable_audio_network_adaptation(); | 471 auto audio_network_adaptation = event->mutable_audio_network_adaptation(); |
445 if (config.bitrate_bps) | 472 if (config.bitrate_bps) |
446 audio_network_adaptation->set_bitrate_bps(*config.bitrate_bps); | 473 audio_network_adaptation->set_bitrate_bps(*config.bitrate_bps); |
447 if (config.frame_length_ms) | 474 if (config.frame_length_ms) |
448 audio_network_adaptation->set_frame_length_ms(*config.frame_length_ms); | 475 audio_network_adaptation->set_frame_length_ms(*config.frame_length_ms); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 #else | 527 #else |
501 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); | 528 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); |
502 #endif // ENABLE_RTC_EVENT_LOG | 529 #endif // ENABLE_RTC_EVENT_LOG |
503 } | 530 } |
504 | 531 |
505 std::unique_ptr<RtcEventLog> RtcEventLog::CreateNull() { | 532 std::unique_ptr<RtcEventLog> RtcEventLog::CreateNull() { |
506 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); | 533 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); |
507 } | 534 } |
508 | 535 |
509 } // namespace webrtc | 536 } // namespace webrtc |
OLD | NEW |