| OLD | NEW |
| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 case rtclog::Event::LOG_START: | 62 case rtclog::Event::LOG_START: |
| 63 return ParsedRtcEventLog::EventType::LOG_START; | 63 return ParsedRtcEventLog::EventType::LOG_START; |
| 64 case rtclog::Event::LOG_END: | 64 case rtclog::Event::LOG_END: |
| 65 return ParsedRtcEventLog::EventType::LOG_END; | 65 return ParsedRtcEventLog::EventType::LOG_END; |
| 66 case rtclog::Event::RTP_EVENT: | 66 case rtclog::Event::RTP_EVENT: |
| 67 return ParsedRtcEventLog::EventType::RTP_EVENT; | 67 return ParsedRtcEventLog::EventType::RTP_EVENT; |
| 68 case rtclog::Event::RTCP_EVENT: | 68 case rtclog::Event::RTCP_EVENT: |
| 69 return ParsedRtcEventLog::EventType::RTCP_EVENT; | 69 return ParsedRtcEventLog::EventType::RTCP_EVENT; |
| 70 case rtclog::Event::AUDIO_PLAYOUT_EVENT: | 70 case rtclog::Event::AUDIO_PLAYOUT_EVENT: |
| 71 return ParsedRtcEventLog::EventType::AUDIO_PLAYOUT_EVENT; | 71 return ParsedRtcEventLog::EventType::AUDIO_PLAYOUT_EVENT; |
| 72 case rtclog::Event::BWE_PACKET_LOSS_EVENT: | 72 case rtclog::Event::LOSS_BASED_BWE_UPDATE: |
| 73 return ParsedRtcEventLog::EventType::BWE_PACKET_LOSS_EVENT; | 73 return ParsedRtcEventLog::EventType::LOSS_BASED_BWE_UPDATE; |
| 74 case rtclog::Event::BWE_PACKET_DELAY_EVENT: | 74 case rtclog::Event::DELAY_BASED_BWE_UPDATE: |
| 75 return ParsedRtcEventLog::EventType::BWE_PACKET_DELAY_EVENT; | 75 return ParsedRtcEventLog::EventType::DELAY_BASED_BWE_UPDATE; |
| 76 case rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT: | 76 case rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT: |
| 77 return ParsedRtcEventLog::EventType::VIDEO_RECEIVER_CONFIG_EVENT; | 77 return ParsedRtcEventLog::EventType::VIDEO_RECEIVER_CONFIG_EVENT; |
| 78 case rtclog::Event::VIDEO_SENDER_CONFIG_EVENT: | 78 case rtclog::Event::VIDEO_SENDER_CONFIG_EVENT: |
| 79 return ParsedRtcEventLog::EventType::VIDEO_SENDER_CONFIG_EVENT; | 79 return ParsedRtcEventLog::EventType::VIDEO_SENDER_CONFIG_EVENT; |
| 80 case rtclog::Event::AUDIO_RECEIVER_CONFIG_EVENT: | 80 case rtclog::Event::AUDIO_RECEIVER_CONFIG_EVENT: |
| 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::DelayBasedBweUpdate::DetectorState detector_state) { |
| 93 switch (detector_state) { |
| 94 case rtclog::DelayBasedBweUpdate::BWE_NORMAL: |
| 95 return kBwNormal; |
| 96 case rtclog::DelayBasedBweUpdate::BWE_UNDERUSING: |
| 97 return kBwUnderusing; |
| 98 case rtclog::DelayBasedBweUpdate::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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 RTC_CHECK(event.has_type()); | 454 RTC_CHECK(event.has_type()); |
| 441 RTC_CHECK_EQ(event.type(), rtclog::Event::AUDIO_PLAYOUT_EVENT); | 455 RTC_CHECK_EQ(event.type(), rtclog::Event::AUDIO_PLAYOUT_EVENT); |
| 442 RTC_CHECK(event.has_audio_playout_event()); | 456 RTC_CHECK(event.has_audio_playout_event()); |
| 443 const rtclog::AudioPlayoutEvent& loss_event = event.audio_playout_event(); | 457 const rtclog::AudioPlayoutEvent& loss_event = event.audio_playout_event(); |
| 444 RTC_CHECK(loss_event.has_local_ssrc()); | 458 RTC_CHECK(loss_event.has_local_ssrc()); |
| 445 if (ssrc != nullptr) { | 459 if (ssrc != nullptr) { |
| 446 *ssrc = loss_event.local_ssrc(); | 460 *ssrc = loss_event.local_ssrc(); |
| 447 } | 461 } |
| 448 } | 462 } |
| 449 | 463 |
| 450 void ParsedRtcEventLog::GetBwePacketLossEvent(size_t index, | 464 void ParsedRtcEventLog::GetLossBasedBweUpdate(size_t index, |
| 451 int32_t* bitrate, | 465 int32_t* bitrate_bps, |
| 452 uint8_t* fraction_loss, | 466 uint8_t* fraction_loss, |
| 453 int32_t* total_packets) const { | 467 int32_t* total_packets) const { |
| 454 RTC_CHECK_LT(index, GetNumberOfEvents()); | 468 RTC_CHECK_LT(index, GetNumberOfEvents()); |
| 455 const rtclog::Event& event = events_[index]; | 469 const rtclog::Event& event = events_[index]; |
| 456 RTC_CHECK(event.has_type()); | 470 RTC_CHECK(event.has_type()); |
| 457 RTC_CHECK_EQ(event.type(), rtclog::Event::BWE_PACKET_LOSS_EVENT); | 471 RTC_CHECK_EQ(event.type(), rtclog::Event::LOSS_BASED_BWE_UPDATE); |
| 458 RTC_CHECK(event.has_bwe_packet_loss_event()); | 472 RTC_CHECK(event.has_loss_based_bwe_update()); |
| 459 const rtclog::BwePacketLossEvent& loss_event = event.bwe_packet_loss_event(); | 473 const rtclog::LossBasedBweUpdate& loss_event = event.loss_based_bwe_update(); |
| 460 RTC_CHECK(loss_event.has_bitrate()); | 474 RTC_CHECK(loss_event.has_bitrate_bps()); |
| 461 if (bitrate != nullptr) { | 475 if (bitrate_bps != nullptr) { |
| 462 *bitrate = loss_event.bitrate(); | 476 *bitrate_bps = loss_event.bitrate_bps(); |
| 463 } | 477 } |
| 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::GetDelayBasedBweUpdate( |
| 489 size_t index, |
| 490 int32_t* bitrate_bps, |
| 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::DELAY_BASED_BWE_UPDATE); |
| 496 RTC_CHECK(event.has_delay_based_bwe_update()); |
| 497 const rtclog::DelayBasedBweUpdate& delay_event = |
| 498 event.delay_based_bwe_update(); |
| 499 RTC_CHECK(delay_event.has_bitrate_bps()); |
| 500 if (bitrate_bps != nullptr) { |
| 501 *bitrate_bps = delay_event.bitrate_bps(); |
| 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 |
| OLD | NEW |