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

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

Issue 2695923004: Add logging of delay-based bandwidth estimate. (Closed)
Patch Set: Only log BWE update if bitrate or state has changed. Created 3 years, 10 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
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 return ParsedRtcEventLog::EventType::AUDIO_RECEIVER_CONFIG_EVENT; 81 return ParsedRtcEventLog::EventType::AUDIO_RECEIVER_CONFIG_EVENT;
82 case rtclog::Event::AUDIO_SENDER_CONFIG_EVENT: 82 case rtclog::Event::AUDIO_SENDER_CONFIG_EVENT:
83 return ParsedRtcEventLog::EventType::AUDIO_SENDER_CONFIG_EVENT; 83 return ParsedRtcEventLog::EventType::AUDIO_SENDER_CONFIG_EVENT;
84 case rtclog::Event::AUDIO_NETWORK_ADAPTATION_EVENT: 84 case rtclog::Event::AUDIO_NETWORK_ADAPTATION_EVENT:
85 return ParsedRtcEventLog::EventType::AUDIO_NETWORK_ADAPTATION_EVENT; 85 return ParsedRtcEventLog::EventType::AUDIO_NETWORK_ADAPTATION_EVENT;
86 } 86 }
87 RTC_NOTREACHED(); 87 RTC_NOTREACHED();
88 return ParsedRtcEventLog::EventType::UNKNOWN_EVENT; 88 return ParsedRtcEventLog::EventType::UNKNOWN_EVENT;
89 } 89 }
90 90
91 BandwidthUsage GetRuntimeDetectorState(
92 rtclog::BwePacketDelayEvent::DetectorState detector_state) {
93 switch (detector_state) {
94 case rtclog::BwePacketDelayEvent::BWE_NORMAL:
95 return kBwNormal;
96 case rtclog::BwePacketDelayEvent::BWE_UNDERUSING:
97 return kBwUnderusing;
98 case rtclog::BwePacketDelayEvent::BWE_OVERUSING:
99 return kBwOverusing;
100 }
101 RTC_NOTREACHED();
102 return kBwNormal;
103 }
104
91 std::pair<uint64_t, bool> ParseVarInt(std::istream& stream) { 105 std::pair<uint64_t, bool> ParseVarInt(std::istream& stream) {
92 uint64_t varint = 0; 106 uint64_t varint = 0;
93 for (size_t bytes_read = 0; bytes_read < 10; ++bytes_read) { 107 for (size_t bytes_read = 0; bytes_read < 10; ++bytes_read) {
94 // The most significant bit of each byte is 0 if it is the last byte in 108 // The most significant bit of each byte is 0 if it is the last byte in
95 // the varint and 1 otherwise. Thus, we take the 7 least significant bits 109 // the varint and 1 otherwise. Thus, we take the 7 least significant bits
96 // of each byte and shift them 7 bits for each byte read previously to get 110 // of each byte and shift them 7 bits for each byte read previously to get
97 // the (unsigned) integer. 111 // the (unsigned) integer.
98 int byte = stream.get(); 112 int byte = stream.get();
99 if (stream.eof()) { 113 if (stream.eof()) {
100 return std::make_pair(varint, false); 114 return std::make_pair(varint, false);
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 RTC_CHECK(loss_event.has_fraction_loss()); 478 RTC_CHECK(loss_event.has_fraction_loss());
465 if (fraction_loss != nullptr) { 479 if (fraction_loss != nullptr) {
466 *fraction_loss = loss_event.fraction_loss(); 480 *fraction_loss = loss_event.fraction_loss();
467 } 481 }
468 RTC_CHECK(loss_event.has_total_packets()); 482 RTC_CHECK(loss_event.has_total_packets());
469 if (total_packets != nullptr) { 483 if (total_packets != nullptr) {
470 *total_packets = loss_event.total_packets(); 484 *total_packets = loss_event.total_packets();
471 } 485 }
472 } 486 }
473 487
488 void ParsedRtcEventLog::GetBwePacketDelayEvent(
489 size_t index,
490 int32_t* bitrate,
491 BandwidthUsage* detector_state) const {
492 RTC_CHECK_LT(index, GetNumberOfEvents());
493 const rtclog::Event& event = events_[index];
494 RTC_CHECK(event.has_type());
495 RTC_CHECK_EQ(event.type(), rtclog::Event::BWE_PACKET_DELAY_EVENT);
496 RTC_CHECK(event.has_bwe_packet_delay_event());
497 const rtclog::BwePacketDelayEvent& delay_event =
498 event.bwe_packet_delay_event();
499 RTC_CHECK(delay_event.has_bitrate());
500 if (bitrate != nullptr) {
501 *bitrate = delay_event.bitrate();
502 }
503 RTC_CHECK(delay_event.has_detector_state());
504 if (detector_state != nullptr) {
505 *detector_state = GetRuntimeDetectorState(delay_event.detector_state());
506 }
507 }
508
474 void ParsedRtcEventLog::GetAudioNetworkAdaptation( 509 void ParsedRtcEventLog::GetAudioNetworkAdaptation(
475 size_t index, 510 size_t index,
476 AudioNetworkAdaptor::EncoderRuntimeConfig* config) const { 511 AudioNetworkAdaptor::EncoderRuntimeConfig* config) const {
477 RTC_CHECK_LT(index, GetNumberOfEvents()); 512 RTC_CHECK_LT(index, GetNumberOfEvents());
478 const rtclog::Event& event = events_[index]; 513 const rtclog::Event& event = events_[index];
479 RTC_CHECK(event.has_type()); 514 RTC_CHECK(event.has_type());
480 RTC_CHECK_EQ(event.type(), rtclog::Event::AUDIO_NETWORK_ADAPTATION_EVENT); 515 RTC_CHECK_EQ(event.type(), rtclog::Event::AUDIO_NETWORK_ADAPTATION_EVENT);
481 RTC_CHECK(event.has_audio_network_adaptation()); 516 RTC_CHECK(event.has_audio_network_adaptation());
482 const rtclog::AudioNetworkAdaptation& ana_event = 517 const rtclog::AudioNetworkAdaptation& ana_event =
483 event.audio_network_adaptation(); 518 event.audio_network_adaptation();
484 if (ana_event.has_bitrate_bps()) 519 if (ana_event.has_bitrate_bps())
485 config->bitrate_bps = rtc::Optional<int>(ana_event.bitrate_bps()); 520 config->bitrate_bps = rtc::Optional<int>(ana_event.bitrate_bps());
486 if (ana_event.has_enable_fec()) 521 if (ana_event.has_enable_fec())
487 config->enable_fec = rtc::Optional<bool>(ana_event.enable_fec()); 522 config->enable_fec = rtc::Optional<bool>(ana_event.enable_fec());
488 if (ana_event.has_enable_dtx()) 523 if (ana_event.has_enable_dtx())
489 config->enable_dtx = rtc::Optional<bool>(ana_event.enable_dtx()); 524 config->enable_dtx = rtc::Optional<bool>(ana_event.enable_dtx());
490 if (ana_event.has_frame_length_ms()) 525 if (ana_event.has_frame_length_ms())
491 config->frame_length_ms = rtc::Optional<int>(ana_event.frame_length_ms()); 526 config->frame_length_ms = rtc::Optional<int>(ana_event.frame_length_ms());
492 if (ana_event.has_num_channels()) 527 if (ana_event.has_num_channels())
493 config->num_channels = rtc::Optional<size_t>(ana_event.num_channels()); 528 config->num_channels = rtc::Optional<size_t>(ana_event.num_channels());
494 if (ana_event.has_uplink_packet_loss_fraction()) 529 if (ana_event.has_uplink_packet_loss_fraction())
495 config->uplink_packet_loss_fraction = 530 config->uplink_packet_loss_fraction =
496 rtc::Optional<float>(ana_event.uplink_packet_loss_fraction()); 531 rtc::Optional<float>(ana_event.uplink_packet_loss_fraction());
497 } 532 }
498 533
499 } // namespace webrtc 534 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/logging/rtc_event_log/rtc_event_log_parser.h ('k') | webrtc/logging/rtc_event_log/rtc_event_log_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698