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 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 clock.AdvanceTimeMilliseconds(rtcp_iterator->first / 1000 - | |
terelius
2016/08/02 09:01:33
What's the purpose of this line? We already advanc
stefan-webrtc
2016/08/02 09:28:11
Oh, I must have left it there by accident.
| |
848 clock.TimeInMilliseconds()); | |
849 const LoggedRtcpPacket& rtcp = *rtcp_iterator->second; | |
850 if (rtcp.type == kRtcpTransportFeedback) { | |
851 std::vector<PacketInfo> feedback = | |
852 feedback_adapter.GetPacketFeedbackVector( | |
853 *static_cast<rtcp::TransportFeedback*>(rtcp.packet.get())); | |
854 for (const PacketInfo& packet : feedback) { | |
855 int64_t y = packet.arrival_time_ms - packet.send_time_ms; | |
856 float x = | |
857 static_cast<float>(clock.TimeInMicroseconds() - begin_time_) / | |
858 1000000; | |
859 estimated_base_delay_ms = std::min(y, estimated_base_delay_ms); | |
860 time_series.points.emplace_back(x, y); | |
861 } | |
862 } | |
863 ++rtcp_iterator; | |
864 } | |
865 if (clock.TimeInMicroseconds() >= NextRtpTime()) { | |
866 clock.AdvanceTimeMilliseconds(rtp_iterator->first / 1000 - | |
terelius
2016/08/02 09:01:33
Same here, and in CreateBweGraph.
stefan-webrtc
2016/08/02 09:28:11
Done.
| |
867 clock.TimeInMilliseconds()); | |
868 const LoggedRtpPacket& rtp = *rtp_iterator->second; | |
869 if (rtp.header.extension.hasTransportSequenceNumber) { | |
870 RTC_DCHECK(rtp.header.extension.hasTransportSequenceNumber); | |
871 feedback_adapter.AddPacket(rtp.header.extension.transportSequenceNumber, | |
872 rtp.total_length, 0); | |
873 feedback_adapter.OnSentPacket( | |
874 rtp.header.extension.transportSequenceNumber, rtp.timestamp / 1000); | |
875 } | |
876 ++rtp_iterator; | |
877 } | |
878 time_us = std::min(NextRtpTime(), NextRtcpTime()); | |
879 } | |
880 // We assume that the base network delay (w/o queues) is the min delay | |
881 // observed during the call. | |
882 for (TimeSeriesPoint& point : time_series.points) | |
883 point.y -= estimated_base_delay_ms; | |
884 // Add the data set to the plot. | |
885 plot->series_list_.push_back(std::move(time_series)); | |
886 | |
887 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); | |
888 plot->SetSuggestedYAxis(0, 10, "Delay (ms)", kBottomMargin, kTopMargin); | |
889 plot->SetTitle("Network Delay Change."); | |
890 } | |
801 } // namespace plotting | 891 } // namespace plotting |
802 } // namespace webrtc | 892 } // namespace webrtc |
OLD | NEW |