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 |
11 #include "webrtc/tools/event_log_visualizer/analyzer.h" | 11 #include "webrtc/tools/event_log_visualizer/analyzer.h" |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
14 #include <limits> | 14 #include <limits> |
15 #include <map> | 15 #include <map> |
16 #include <sstream> | 16 #include <sstream> |
17 #include <string> | 17 #include <string> |
18 #include <utility> | 18 #include <utility> |
19 | 19 |
20 #include "webrtc/base/checks.h" | 20 #include "webrtc/base/checks.h" |
| 21 #include "webrtc/base/format_macros.h" |
21 #include "webrtc/base/logging.h" | 22 #include "webrtc/base/logging.h" |
22 #include "webrtc/base/ptr_util.h" | 23 #include "webrtc/base/ptr_util.h" |
23 #include "webrtc/base/rate_statistics.h" | 24 #include "webrtc/base/rate_statistics.h" |
24 #include "webrtc/call/audio_receive_stream.h" | 25 #include "webrtc/call/audio_receive_stream.h" |
25 #include "webrtc/call/audio_send_stream.h" | 26 #include "webrtc/call/audio_send_stream.h" |
26 #include "webrtc/call/call.h" | 27 #include "webrtc/call/call.h" |
27 #include "webrtc/common_types.h" | 28 #include "webrtc/common_types.h" |
| 29 #include "webrtc/modules/audio_coding/neteq/tools/audio_sink.h" |
| 30 #include "webrtc/modules/audio_coding/neteq/tools/fake_decode_from_file.h" |
| 31 #include "webrtc/modules/audio_coding/neteq/tools/neteq_delay_analyzer.h" |
| 32 #include "webrtc/modules/audio_coding/neteq/tools/neteq_replacement_input.h" |
| 33 #include "webrtc/modules/audio_coding/neteq/tools/neteq_test.h" |
| 34 #include "webrtc/modules/audio_coding/neteq/tools/resample_input_audio_file.h" |
28 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" | 35 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" |
29 #include "webrtc/modules/include/module_common_types.h" | 36 #include "webrtc/modules/include/module_common_types.h" |
30 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | 37 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" |
31 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 38 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h" | 39 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h" |
33 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" | 40 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" |
34 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/remb.h" | 41 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/remb.h" |
35 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h" | 42 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h" |
36 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" | 43 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" |
37 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h" | 44 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h" |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 size_t total_length; | 306 size_t total_length; |
300 | 307 |
301 uint8_t last_incoming_rtcp_packet[IP_PACKET_SIZE]; | 308 uint8_t last_incoming_rtcp_packet[IP_PACKET_SIZE]; |
302 uint8_t last_incoming_rtcp_packet_length = 0; | 309 uint8_t last_incoming_rtcp_packet_length = 0; |
303 | 310 |
304 // Make a default extension map for streams without configuration information. | 311 // Make a default extension map for streams without configuration information. |
305 // TODO(ivoc): Once configuration of audio streams is stored in the event log, | 312 // TODO(ivoc): Once configuration of audio streams is stored in the event log, |
306 // this can be removed. Tracking bug: webrtc:6399 | 313 // this can be removed. Tracking bug: webrtc:6399 |
307 RtpHeaderExtensionMap default_extension_map = GetDefaultHeaderExtensionMap(); | 314 RtpHeaderExtensionMap default_extension_map = GetDefaultHeaderExtensionMap(); |
308 | 315 |
| 316 rtc::Optional<uint64_t> last_log_start; |
| 317 |
309 for (size_t i = 0; i < parsed_log_.GetNumberOfEvents(); i++) { | 318 for (size_t i = 0; i < parsed_log_.GetNumberOfEvents(); i++) { |
310 ParsedRtcEventLog::EventType event_type = parsed_log_.GetEventType(i); | 319 ParsedRtcEventLog::EventType event_type = parsed_log_.GetEventType(i); |
311 if (event_type != ParsedRtcEventLog::VIDEO_RECEIVER_CONFIG_EVENT && | 320 if (event_type != ParsedRtcEventLog::VIDEO_RECEIVER_CONFIG_EVENT && |
312 event_type != ParsedRtcEventLog::VIDEO_SENDER_CONFIG_EVENT && | 321 event_type != ParsedRtcEventLog::VIDEO_SENDER_CONFIG_EVENT && |
313 event_type != ParsedRtcEventLog::AUDIO_RECEIVER_CONFIG_EVENT && | 322 event_type != ParsedRtcEventLog::AUDIO_RECEIVER_CONFIG_EVENT && |
314 event_type != ParsedRtcEventLog::AUDIO_SENDER_CONFIG_EVENT && | 323 event_type != ParsedRtcEventLog::AUDIO_SENDER_CONFIG_EVENT && |
315 event_type != ParsedRtcEventLog::LOG_START && | 324 event_type != ParsedRtcEventLog::LOG_START && |
316 event_type != ParsedRtcEventLog::LOG_END) { | 325 event_type != ParsedRtcEventLog::LOG_END) { |
317 uint64_t timestamp = parsed_log_.GetTimestamp(i); | 326 uint64_t timestamp = parsed_log_.GetTimestamp(i); |
318 first_timestamp = std::min(first_timestamp, timestamp); | 327 first_timestamp = std::min(first_timestamp, timestamp); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 StreamId stream(ssrc, direction); | 456 StreamId stream(ssrc, direction); |
448 uint64_t timestamp = parsed_log_.GetTimestamp(i); | 457 uint64_t timestamp = parsed_log_.GetTimestamp(i); |
449 rtcp_packets_[stream].push_back(LoggedRtcpPacket( | 458 rtcp_packets_[stream].push_back(LoggedRtcpPacket( |
450 timestamp, kRtcpRemb, std::move(rtcp_packet))); | 459 timestamp, kRtcpRemb, std::move(rtcp_packet))); |
451 } | 460 } |
452 } | 461 } |
453 } | 462 } |
454 break; | 463 break; |
455 } | 464 } |
456 case ParsedRtcEventLog::LOG_START: { | 465 case ParsedRtcEventLog::LOG_START: { |
| 466 if (last_log_start) { |
| 467 // A LOG_END event was missing. Use last_timestamp. |
| 468 RTC_DCHECK_GE(last_timestamp, *last_log_start); |
| 469 log_segments_.push_back( |
| 470 std::make_pair(*last_log_start, last_timestamp)); |
| 471 } |
| 472 last_log_start = rtc::Optional<uint64_t>(parsed_log_.GetTimestamp(i)); |
457 break; | 473 break; |
458 } | 474 } |
459 case ParsedRtcEventLog::LOG_END: { | 475 case ParsedRtcEventLog::LOG_END: { |
| 476 RTC_DCHECK(last_log_start); |
| 477 log_segments_.push_back( |
| 478 std::make_pair(*last_log_start, parsed_log_.GetTimestamp(i))); |
| 479 last_log_start.reset(); |
460 break; | 480 break; |
461 } | 481 } |
462 case ParsedRtcEventLog::AUDIO_PLAYOUT_EVENT: { | 482 case ParsedRtcEventLog::AUDIO_PLAYOUT_EVENT: { |
| 483 uint32_t this_ssrc; |
| 484 parsed_log_.GetAudioPlayout(i, &this_ssrc); |
| 485 audio_playout_events_[this_ssrc].push_back(parsed_log_.GetTimestamp(i)); |
463 break; | 486 break; |
464 } | 487 } |
465 case ParsedRtcEventLog::LOSS_BASED_BWE_UPDATE: { | 488 case ParsedRtcEventLog::LOSS_BASED_BWE_UPDATE: { |
466 LossBasedBweUpdate bwe_update; | 489 LossBasedBweUpdate bwe_update; |
467 bwe_update.timestamp = parsed_log_.GetTimestamp(i); | 490 bwe_update.timestamp = parsed_log_.GetTimestamp(i); |
468 parsed_log_.GetLossBasedBweUpdate(i, &bwe_update.new_bitrate, | 491 parsed_log_.GetLossBasedBweUpdate(i, &bwe_update.new_bitrate, |
469 &bwe_update.fraction_loss, | 492 &bwe_update.fraction_loss, |
470 &bwe_update.expected_packets); | 493 &bwe_update.expected_packets); |
471 bwe_loss_updates_.push_back(bwe_update); | 494 bwe_loss_updates_.push_back(bwe_update); |
472 break; | 495 break; |
(...skipping 24 matching lines...) Expand all Loading... |
497 } | 520 } |
498 } | 521 } |
499 | 522 |
500 if (last_timestamp < first_timestamp) { | 523 if (last_timestamp < first_timestamp) { |
501 // No useful events in the log. | 524 // No useful events in the log. |
502 first_timestamp = last_timestamp = 0; | 525 first_timestamp = last_timestamp = 0; |
503 } | 526 } |
504 begin_time_ = first_timestamp; | 527 begin_time_ = first_timestamp; |
505 end_time_ = last_timestamp; | 528 end_time_ = last_timestamp; |
506 call_duration_s_ = static_cast<float>(end_time_ - begin_time_) / 1000000; | 529 call_duration_s_ = static_cast<float>(end_time_ - begin_time_) / 1000000; |
| 530 if (last_log_start) { |
| 531 // The log was missing the last LOG_END event. Fake it. |
| 532 log_segments_.push_back(std::make_pair(*last_log_start, end_time_)); |
| 533 } |
507 } | 534 } |
508 | 535 |
509 class BitrateObserver : public CongestionController::Observer, | 536 class BitrateObserver : public CongestionController::Observer, |
510 public RemoteBitrateObserver { | 537 public RemoteBitrateObserver { |
511 public: | 538 public: |
512 BitrateObserver() : last_bitrate_bps_(0), bitrate_updated_(false) {} | 539 BitrateObserver() : last_bitrate_bps_(0), bitrate_updated_(false) {} |
513 | 540 |
514 // TODO(minyue): remove this when old OnNetworkChanged is deprecated. See | 541 // TODO(minyue): remove this when old OnNetworkChanged is deprecated. See |
515 // https://bugs.chromium.org/p/webrtc/issues/detail?id=6796 | 542 // https://bugs.chromium.org/p/webrtc/issues/detail?id=6796 |
516 using CongestionController::Observer::OnNetworkChanged; | 543 using CongestionController::Observer::OnNetworkChanged; |
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1416 static_cast<float>(*ana_event.config.num_channels)); | 1443 static_cast<float>(*ana_event.config.num_channels)); |
1417 return rtc::Optional<float>(); | 1444 return rtc::Optional<float>(); |
1418 }, | 1445 }, |
1419 audio_network_adaptation_events_, begin_time_, &time_series); | 1446 audio_network_adaptation_events_, begin_time_, &time_series); |
1420 plot->AppendTimeSeries(std::move(time_series)); | 1447 plot->AppendTimeSeries(std::move(time_series)); |
1421 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); | 1448 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); |
1422 plot->SetSuggestedYAxis(0, 1, "Number of channels (1 (mono)/2 (stereo))", | 1449 plot->SetSuggestedYAxis(0, 1, "Number of channels (1 (mono)/2 (stereo))", |
1423 kBottomMargin, kTopMargin); | 1450 kBottomMargin, kTopMargin); |
1424 plot->SetTitle("Reported audio encoder number of channels"); | 1451 plot->SetTitle("Reported audio encoder number of channels"); |
1425 } | 1452 } |
| 1453 |
| 1454 class NetEqStreamInput : public test::NetEqInput { |
| 1455 public: |
| 1456 // Does not take any ownership, and all pointers must refer to valid objects |
| 1457 // that outlive the one constructed. |
| 1458 NetEqStreamInput(const std::vector<LoggedRtpPacket>* packet_stream, |
| 1459 const std::vector<uint64_t>* output_events_us, |
| 1460 rtc::Optional<uint64_t> end_time_us) |
| 1461 : packet_stream_(*packet_stream), |
| 1462 packet_stream_it_(packet_stream_.begin()), |
| 1463 output_events_us_it_(output_events_us->begin()), |
| 1464 output_events_us_end_(output_events_us->end()), |
| 1465 end_time_us_(end_time_us) { |
| 1466 RTC_DCHECK(packet_stream); |
| 1467 RTC_DCHECK(output_events_us); |
| 1468 } |
| 1469 |
| 1470 rtc::Optional<int64_t> NextPacketTime() const override { |
| 1471 if (packet_stream_it_ == packet_stream_.end()) { |
| 1472 return rtc::Optional<int64_t>(); |
| 1473 } |
| 1474 if (end_time_us_ && packet_stream_it_->timestamp > *end_time_us_) { |
| 1475 return rtc::Optional<int64_t>(); |
| 1476 } |
| 1477 // Convert from us to ms. |
| 1478 return rtc::Optional<int64_t>(packet_stream_it_->timestamp / 1000); |
| 1479 } |
| 1480 |
| 1481 rtc::Optional<int64_t> NextOutputEventTime() const override { |
| 1482 if (output_events_us_it_ == output_events_us_end_) { |
| 1483 return rtc::Optional<int64_t>(); |
| 1484 } |
| 1485 if (end_time_us_ && *output_events_us_it_ > *end_time_us_) { |
| 1486 return rtc::Optional<int64_t>(); |
| 1487 } |
| 1488 // Convert from us to ms. |
| 1489 return rtc::Optional<int64_t>( |
| 1490 rtc::checked_cast<int64_t>(*output_events_us_it_ / 1000)); |
| 1491 } |
| 1492 |
| 1493 std::unique_ptr<PacketData> PopPacket() override { |
| 1494 if (packet_stream_it_ == packet_stream_.end()) { |
| 1495 return std::unique_ptr<PacketData>(); |
| 1496 } |
| 1497 std::unique_ptr<PacketData> packet_data(new PacketData()); |
| 1498 packet_data->header = packet_stream_it_->header; |
| 1499 // Convert from us to ms. |
| 1500 packet_data->time_ms = packet_stream_it_->timestamp / 1000.0; |
| 1501 |
| 1502 // This is a header-only "dummy" packet. Set the payload to all zeros, with |
| 1503 // length according to the virtual length. |
| 1504 packet_data->payload.SetSize(packet_stream_it_->total_length); |
| 1505 std::fill_n(packet_data->payload.data(), packet_data->payload.size(), 0); |
| 1506 |
| 1507 ++packet_stream_it_; |
| 1508 return packet_data; |
| 1509 } |
| 1510 |
| 1511 void AdvanceOutputEvent() override { |
| 1512 if (output_events_us_it_ != output_events_us_end_) { |
| 1513 ++output_events_us_it_; |
| 1514 } |
| 1515 } |
| 1516 |
| 1517 bool ended() const override { return !NextEventTime(); } |
| 1518 |
| 1519 rtc::Optional<RTPHeader> NextHeader() const override { |
| 1520 if (packet_stream_it_ == packet_stream_.end()) { |
| 1521 return rtc::Optional<RTPHeader>(); |
| 1522 } |
| 1523 return rtc::Optional<RTPHeader>(packet_stream_it_->header); |
| 1524 } |
| 1525 |
| 1526 private: |
| 1527 const std::vector<LoggedRtpPacket>& packet_stream_; |
| 1528 std::vector<LoggedRtpPacket>::const_iterator packet_stream_it_; |
| 1529 std::vector<uint64_t>::const_iterator output_events_us_it_; |
| 1530 const std::vector<uint64_t>::const_iterator output_events_us_end_; |
| 1531 const rtc::Optional<uint64_t> end_time_us_; |
| 1532 }; |
| 1533 |
| 1534 namespace { |
| 1535 // Creates a NetEq test object and all necessary input and output helpers. Runs |
| 1536 // the test and returns the NetEqDelayAnalyzer object that was used to |
| 1537 // instrument the test. |
| 1538 std::unique_ptr<test::NetEqDelayAnalyzer> CreateNetEqTestAndRun( |
| 1539 const std::vector<LoggedRtpPacket>* packet_stream, |
| 1540 const std::vector<uint64_t>* output_events_us, |
| 1541 rtc::Optional<uint64_t> end_time_us, |
| 1542 const std::string& replacement_file_name, |
| 1543 int file_sample_rate_hz) { |
| 1544 std::unique_ptr<test::NetEqInput> input( |
| 1545 new NetEqStreamInput(packet_stream, output_events_us, end_time_us)); |
| 1546 |
| 1547 constexpr int kReplacementPt = 127; |
| 1548 std::set<uint8_t> cn_types; |
| 1549 std::set<uint8_t> forbidden_types; |
| 1550 input.reset(new test::NetEqReplacementInput(std::move(input), kReplacementPt, |
| 1551 cn_types, forbidden_types)); |
| 1552 |
| 1553 NetEq::Config config; |
| 1554 config.max_packets_in_buffer = 200; |
| 1555 config.enable_fast_accelerate = true; |
| 1556 |
| 1557 std::unique_ptr<test::VoidAudioSink> output(new test::VoidAudioSink()); |
| 1558 |
| 1559 test::NetEqTest::DecoderMap codecs; |
| 1560 |
| 1561 // Create a "replacement decoder" that produces the decoded audio by reading |
| 1562 // from a file rather than from the encoded payloads. |
| 1563 std::unique_ptr<test::ResampleInputAudioFile> replacement_file( |
| 1564 new test::ResampleInputAudioFile(replacement_file_name, |
| 1565 file_sample_rate_hz)); |
| 1566 replacement_file->set_output_rate_hz(48000); |
| 1567 std::unique_ptr<AudioDecoder> replacement_decoder( |
| 1568 new test::FakeDecodeFromFile(std::move(replacement_file), 48000, false)); |
| 1569 test::NetEqTest::ExtDecoderMap ext_codecs; |
| 1570 ext_codecs[kReplacementPt] = {replacement_decoder.get(), |
| 1571 NetEqDecoder::kDecoderArbitrary, |
| 1572 "replacement codec"}; |
| 1573 |
| 1574 std::unique_ptr<test::NetEqDelayAnalyzer> delay_cb( |
| 1575 new test::NetEqDelayAnalyzer); |
| 1576 test::DefaultNetEqTestErrorCallback error_cb; |
| 1577 test::NetEqTest::Callbacks callbacks; |
| 1578 callbacks.error_callback = &error_cb; |
| 1579 callbacks.post_insert_packet = delay_cb.get(); |
| 1580 callbacks.get_audio_callback = delay_cb.get(); |
| 1581 |
| 1582 test::NetEqTest test(config, codecs, ext_codecs, std::move(input), |
| 1583 std::move(output), callbacks); |
| 1584 test.Run(); |
| 1585 return delay_cb; |
| 1586 } |
| 1587 } // namespace |
| 1588 |
| 1589 // Plots the jitter buffer delay profile. This will plot only for the first |
| 1590 // incoming audio SSRC. If the stream contains more than one incoming audio |
| 1591 // SSRC, all but the first will be ignored. |
| 1592 void EventLogAnalyzer::CreateAudioJitterBufferGraph( |
| 1593 const std::string& replacement_file_name, |
| 1594 int file_sample_rate_hz, |
| 1595 Plot* plot) { |
| 1596 const auto& incoming_audio_kv = std::find_if( |
| 1597 rtp_packets_.begin(), rtp_packets_.end(), |
| 1598 [this](std::pair<StreamId, std::vector<LoggedRtpPacket>> kv) { |
| 1599 return kv.first.GetDirection() == kIncomingPacket && |
| 1600 this->IsAudioSsrc(kv.first); |
| 1601 }); |
| 1602 if (incoming_audio_kv == rtp_packets_.end()) { |
| 1603 // No incoming audio stream found. |
| 1604 return; |
| 1605 } |
| 1606 |
| 1607 const uint32_t ssrc = incoming_audio_kv->first.GetSsrc(); |
| 1608 |
| 1609 std::map<uint32_t, std::vector<uint64_t>>::const_iterator output_events_it = |
| 1610 audio_playout_events_.find(ssrc); |
| 1611 if (output_events_it == audio_playout_events_.end()) { |
| 1612 // Could not find output events with SSRC matching the input audio stream. |
| 1613 // Using the first available stream of output events. |
| 1614 output_events_it = audio_playout_events_.cbegin(); |
| 1615 } |
| 1616 |
| 1617 rtc::Optional<uint64_t> end_time_us = |
| 1618 log_segments_.empty() |
| 1619 ? rtc::Optional<uint64_t>() |
| 1620 : rtc::Optional<uint64_t>(log_segments_.front().second); |
| 1621 |
| 1622 auto delay_cb = CreateNetEqTestAndRun( |
| 1623 &incoming_audio_kv->second, &output_events_it->second, end_time_us, |
| 1624 replacement_file_name, file_sample_rate_hz); |
| 1625 |
| 1626 std::vector<float> send_times_s; |
| 1627 std::vector<float> arrival_delay_ms; |
| 1628 std::vector<float> corrected_arrival_delay_ms; |
| 1629 std::vector<rtc::Optional<float>> playout_delay_ms; |
| 1630 std::vector<rtc::Optional<float>> target_delay_ms; |
| 1631 delay_cb->CreateGraphs(&send_times_s, &arrival_delay_ms, |
| 1632 &corrected_arrival_delay_ms, &playout_delay_ms, |
| 1633 &target_delay_ms); |
| 1634 RTC_DCHECK_EQ(send_times_s.size(), arrival_delay_ms.size()); |
| 1635 RTC_DCHECK_EQ(send_times_s.size(), corrected_arrival_delay_ms.size()); |
| 1636 RTC_DCHECK_EQ(send_times_s.size(), playout_delay_ms.size()); |
| 1637 RTC_DCHECK_EQ(send_times_s.size(), target_delay_ms.size()); |
| 1638 |
| 1639 std::map<StreamId, TimeSeries> time_series_packet_arrival; |
| 1640 std::map<StreamId, TimeSeries> time_series_relative_packet_arrival; |
| 1641 std::map<StreamId, TimeSeries> time_series_play_time; |
| 1642 std::map<StreamId, TimeSeries> time_series_target_time; |
| 1643 float min_y_axis = 0.f; |
| 1644 float max_y_axis = 0.f; |
| 1645 const StreamId stream_id = incoming_audio_kv->first; |
| 1646 for (size_t i = 0; i < send_times_s.size(); ++i) { |
| 1647 time_series_packet_arrival[stream_id].points.emplace_back( |
| 1648 TimeSeriesPoint(send_times_s[i], arrival_delay_ms[i])); |
| 1649 time_series_relative_packet_arrival[stream_id].points.emplace_back( |
| 1650 TimeSeriesPoint(send_times_s[i], corrected_arrival_delay_ms[i])); |
| 1651 min_y_axis = std::min(min_y_axis, corrected_arrival_delay_ms[i]); |
| 1652 max_y_axis = std::max(max_y_axis, corrected_arrival_delay_ms[i]); |
| 1653 if (playout_delay_ms[i]) { |
| 1654 time_series_play_time[stream_id].points.emplace_back( |
| 1655 TimeSeriesPoint(send_times_s[i], *playout_delay_ms[i])); |
| 1656 min_y_axis = std::min(min_y_axis, *playout_delay_ms[i]); |
| 1657 max_y_axis = std::max(max_y_axis, *playout_delay_ms[i]); |
| 1658 } |
| 1659 if (target_delay_ms[i]) { |
| 1660 time_series_target_time[stream_id].points.emplace_back( |
| 1661 TimeSeriesPoint(send_times_s[i], *target_delay_ms[i])); |
| 1662 min_y_axis = std::min(min_y_axis, *target_delay_ms[i]); |
| 1663 max_y_axis = std::max(max_y_axis, *target_delay_ms[i]); |
| 1664 } |
| 1665 } |
| 1666 |
| 1667 // This code is adapted for a single stream. The creation of the streams above |
| 1668 // guarantee that no more than one steam is included. If multiple streams are |
| 1669 // to be plotted, they should likely be given distinct labels below. |
| 1670 RTC_DCHECK_EQ(time_series_relative_packet_arrival.size(), 1); |
| 1671 for (auto& series : time_series_relative_packet_arrival) { |
| 1672 series.second.label = "Relative packet arrival delay"; |
| 1673 series.second.style = LINE_GRAPH; |
| 1674 plot->AppendTimeSeries(std::move(series.second)); |
| 1675 } |
| 1676 RTC_DCHECK_EQ(time_series_play_time.size(), 1); |
| 1677 for (auto& series : time_series_play_time) { |
| 1678 series.second.label = "Playout delay"; |
| 1679 series.second.style = LINE_GRAPH; |
| 1680 plot->AppendTimeSeries(std::move(series.second)); |
| 1681 } |
| 1682 RTC_DCHECK_EQ(time_series_target_time.size(), 1); |
| 1683 for (auto& series : time_series_target_time) { |
| 1684 series.second.label = "Target delay"; |
| 1685 series.second.style = LINE_DOT_GRAPH; |
| 1686 plot->AppendTimeSeries(std::move(series.second)); |
| 1687 } |
| 1688 |
| 1689 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); |
| 1690 plot->SetYAxis(min_y_axis, max_y_axis, "Relative delay (ms)", kBottomMargin, |
| 1691 kTopMargin); |
| 1692 plot->SetTitle("NetEq timing"); |
| 1693 } |
1426 } // namespace plotting | 1694 } // namespace plotting |
1427 } // namespace webrtc | 1695 } // namespace webrtc |
OLD | NEW |