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 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 return clock.TimeInMicroseconds() + | 750 return clock.TimeInMicroseconds() + |
751 std::max<int64_t>(cc.TimeUntilNextProcess() * 1000, 0); | 751 std::max<int64_t>(cc.TimeUntilNextProcess() * 1000, 0); |
752 } | 752 } |
753 return std::numeric_limits<int64_t>::max(); | 753 return std::numeric_limits<int64_t>::max(); |
754 }; | 754 }; |
755 | 755 |
756 int64_t time_us = std::min(NextRtpTime(), NextRtcpTime()); | 756 int64_t time_us = std::min(NextRtpTime(), NextRtcpTime()); |
757 while (time_us != std::numeric_limits<int64_t>::max()) { | 757 while (time_us != std::numeric_limits<int64_t>::max()) { |
758 clock.AdvanceTimeMicroseconds(time_us - clock.TimeInMicroseconds()); | 758 clock.AdvanceTimeMicroseconds(time_us - clock.TimeInMicroseconds()); |
759 if (clock.TimeInMicroseconds() >= NextRtcpTime()) { | 759 if (clock.TimeInMicroseconds() >= NextRtcpTime()) { |
760 clock.AdvanceTimeMilliseconds(rtcp_iterator->first / 1000 - | 760 RTC_DCHECK_EQ(clock.TimeInMicroseconds(), NextRtcpTime()); |
761 clock.TimeInMilliseconds()); | |
762 const LoggedRtcpPacket& rtcp = *rtcp_iterator->second; | 761 const LoggedRtcpPacket& rtcp = *rtcp_iterator->second; |
763 if (rtcp.type == kRtcpTransportFeedback) { | 762 if (rtcp.type == kRtcpTransportFeedback) { |
764 cc.GetTransportFeedbackObserver()->OnTransportFeedback( | 763 cc.GetTransportFeedbackObserver()->OnTransportFeedback( |
765 *static_cast<rtcp::TransportFeedback*>(rtcp.packet.get())); | 764 *static_cast<rtcp::TransportFeedback*>(rtcp.packet.get())); |
766 } | 765 } |
767 ++rtcp_iterator; | 766 ++rtcp_iterator; |
768 } | 767 } |
769 if (clock.TimeInMicroseconds() >= NextRtpTime()) { | 768 if (clock.TimeInMicroseconds() >= NextRtpTime()) { |
770 clock.AdvanceTimeMilliseconds(rtp_iterator->first / 1000 - | 769 RTC_DCHECK_EQ(clock.TimeInMicroseconds(), NextRtpTime()); |
771 clock.TimeInMilliseconds()); | |
772 const LoggedRtpPacket& rtp = *rtp_iterator->second; | 770 const LoggedRtpPacket& rtp = *rtp_iterator->second; |
773 if (rtp.header.extension.hasTransportSequenceNumber) { | 771 if (rtp.header.extension.hasTransportSequenceNumber) { |
774 RTC_DCHECK(rtp.header.extension.hasTransportSequenceNumber); | 772 RTC_DCHECK(rtp.header.extension.hasTransportSequenceNumber); |
775 cc.GetTransportFeedbackObserver()->AddPacket( | 773 cc.GetTransportFeedbackObserver()->AddPacket( |
776 rtp.header.extension.transportSequenceNumber, rtp.total_length, 0); | 774 rtp.header.extension.transportSequenceNumber, rtp.total_length, 0); |
777 rtc::SentPacket sent_packet( | 775 rtc::SentPacket sent_packet( |
778 rtp.header.extension.transportSequenceNumber, rtp.timestamp / 1000); | 776 rtp.header.extension.transportSequenceNumber, rtp.timestamp / 1000); |
779 cc.OnSentPacket(sent_packet); | 777 cc.OnSentPacket(sent_packet); |
780 } | 778 } |
781 ++rtp_iterator; | 779 ++rtp_iterator; |
782 } | 780 } |
783 if (clock.TimeInMicroseconds() >= NextProcessTime()) | 781 if (clock.TimeInMicroseconds() >= NextProcessTime()) { |
| 782 RTC_DCHECK_EQ(clock.TimeInMicroseconds(), NextProcessTime()); |
784 cc.Process(); | 783 cc.Process(); |
| 784 } |
785 if (observer.GetAndResetBitrateUpdated()) { | 785 if (observer.GetAndResetBitrateUpdated()) { |
786 uint32_t y = observer.last_bitrate_bps() / 1000; | 786 uint32_t y = observer.last_bitrate_bps() / 1000; |
787 float x = static_cast<float>(clock.TimeInMicroseconds() - begin_time_) / | 787 float x = static_cast<float>(clock.TimeInMicroseconds() - begin_time_) / |
788 1000000; | 788 1000000; |
789 time_series.points.emplace_back(x, y); | 789 time_series.points.emplace_back(x, y); |
790 } | 790 } |
791 time_us = std::min({NextRtpTime(), NextRtcpTime(), NextProcessTime()}); | 791 time_us = std::min({NextRtpTime(), NextRtcpTime(), NextProcessTime()}); |
792 } | 792 } |
793 // Add the data set to the plot. | 793 // Add the data set to the plot. |
794 plot->series_list_.push_back(std::move(time_series)); | 794 plot->series_list_.push_back(std::move(time_series)); |
795 | 795 |
796 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); | 796 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); |
797 plot->SetSuggestedYAxis(0, 10, "Bitrate (kbps)", kBottomMargin, kTopMargin); | 797 plot->SetSuggestedYAxis(0, 10, "Bitrate (kbps)", kBottomMargin, kTopMargin); |
798 plot->SetTitle("Simulated BWE behavior"); | 798 plot->SetTitle("Simulated BWE behavior"); |
799 } | 799 } |
800 | 800 |
| 801 void EventLogAnalyzer::CreateNetworkDelayFeebackGraph(Plot* plot) { |
| 802 std::map<uint64_t, const LoggedRtpPacket*> outgoing_rtp; |
| 803 std::map<uint64_t, const LoggedRtcpPacket*> incoming_rtcp; |
| 804 |
| 805 for (const auto& kv : rtp_packets_) { |
| 806 if (kv.first.GetDirection() == PacketDirection::kOutgoingPacket) { |
| 807 for (const LoggedRtpPacket& rtp_packet : kv.second) |
| 808 outgoing_rtp.insert(std::make_pair(rtp_packet.timestamp, &rtp_packet)); |
| 809 } |
| 810 } |
| 811 |
| 812 for (const auto& kv : rtcp_packets_) { |
| 813 if (kv.first.GetDirection() == PacketDirection::kIncomingPacket) { |
| 814 for (const LoggedRtcpPacket& rtcp_packet : kv.second) |
| 815 incoming_rtcp.insert( |
| 816 std::make_pair(rtcp_packet.timestamp, &rtcp_packet)); |
| 817 } |
| 818 } |
| 819 |
| 820 SimulatedClock clock(0); |
| 821 TransportFeedbackAdapter feedback_adapter(nullptr, &clock); |
| 822 |
| 823 TimeSeries time_series; |
| 824 time_series.label = "Network Delay Change"; |
| 825 time_series.style = LINE_DOT_GRAPH; |
| 826 int64_t estimated_base_delay_ms = std::numeric_limits<int64_t>::max(); |
| 827 |
| 828 auto rtp_iterator = outgoing_rtp.begin(); |
| 829 auto rtcp_iterator = incoming_rtcp.begin(); |
| 830 |
| 831 auto NextRtpTime = [&]() { |
| 832 if (rtp_iterator != outgoing_rtp.end()) |
| 833 return static_cast<int64_t>(rtp_iterator->first); |
| 834 return std::numeric_limits<int64_t>::max(); |
| 835 }; |
| 836 |
| 837 auto NextRtcpTime = [&]() { |
| 838 if (rtcp_iterator != incoming_rtcp.end()) |
| 839 return static_cast<int64_t>(rtcp_iterator->first); |
| 840 return std::numeric_limits<int64_t>::max(); |
| 841 }; |
| 842 |
| 843 int64_t time_us = std::min(NextRtpTime(), NextRtcpTime()); |
| 844 while (time_us != std::numeric_limits<int64_t>::max()) { |
| 845 clock.AdvanceTimeMicroseconds(time_us - clock.TimeInMicroseconds()); |
| 846 if (clock.TimeInMicroseconds() >= NextRtcpTime()) { |
| 847 RTC_DCHECK_EQ(clock.TimeInMicroseconds(), NextRtcpTime()); |
| 848 const LoggedRtcpPacket& rtcp = *rtcp_iterator->second; |
| 849 if (rtcp.type == kRtcpTransportFeedback) { |
| 850 std::vector<PacketInfo> feedback = |
| 851 feedback_adapter.GetPacketFeedbackVector( |
| 852 *static_cast<rtcp::TransportFeedback*>(rtcp.packet.get())); |
| 853 for (const PacketInfo& packet : feedback) { |
| 854 int64_t y = packet.arrival_time_ms - packet.send_time_ms; |
| 855 float x = |
| 856 static_cast<float>(clock.TimeInMicroseconds() - begin_time_) / |
| 857 1000000; |
| 858 estimated_base_delay_ms = std::min(y, estimated_base_delay_ms); |
| 859 time_series.points.emplace_back(x, y); |
| 860 } |
| 861 } |
| 862 ++rtcp_iterator; |
| 863 } |
| 864 if (clock.TimeInMicroseconds() >= NextRtpTime()) { |
| 865 RTC_DCHECK_EQ(clock.TimeInMicroseconds(), NextRtpTime()); |
| 866 const LoggedRtpPacket& rtp = *rtp_iterator->second; |
| 867 if (rtp.header.extension.hasTransportSequenceNumber) { |
| 868 RTC_DCHECK(rtp.header.extension.hasTransportSequenceNumber); |
| 869 feedback_adapter.AddPacket(rtp.header.extension.transportSequenceNumber, |
| 870 rtp.total_length, 0); |
| 871 feedback_adapter.OnSentPacket( |
| 872 rtp.header.extension.transportSequenceNumber, rtp.timestamp / 1000); |
| 873 } |
| 874 ++rtp_iterator; |
| 875 } |
| 876 time_us = std::min(NextRtpTime(), NextRtcpTime()); |
| 877 } |
| 878 // We assume that the base network delay (w/o queues) is the min delay |
| 879 // observed during the call. |
| 880 for (TimeSeriesPoint& point : time_series.points) |
| 881 point.y -= estimated_base_delay_ms; |
| 882 // Add the data set to the plot. |
| 883 plot->series_list_.push_back(std::move(time_series)); |
| 884 |
| 885 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); |
| 886 plot->SetSuggestedYAxis(0, 10, "Delay (ms)", kBottomMargin, kTopMargin); |
| 887 plot->SetTitle("Network Delay Change."); |
| 888 } |
801 } // namespace plotting | 889 } // namespace plotting |
802 } // namespace webrtc | 890 } // namespace webrtc |
OLD | NEW |