diff --git a/rtc_tools/event_log_visualizer/analyzer.cc b/rtc_tools/event_log_visualizer/analyzer.cc index 89cf890591..efb14eb8ea 100644 --- a/rtc_tools/event_log_visualizer/analyzer.cc +++ b/rtc_tools/event_log_visualizer/analyzer.cc @@ -1640,7 +1640,7 @@ namespace { // Creates a NetEq test object and all necessary input and output helpers. Runs // the test and returns the NetEqDelayAnalyzer object that was used to // instrument the test. -std::unique_ptr CreateNetEqTestAndRun( +std::unique_ptr CreateNetEqTestAndRun( const std::vector* packet_stream, const std::vector* output_events_us, rtc::Optional end_time_us, @@ -1678,26 +1678,26 @@ std::unique_ptr CreateNetEqTestAndRun( std::unique_ptr delay_cb( new test::NetEqDelayAnalyzer); + std::unique_ptr neteq_stats_getter( + new test::NetEqStatsGetter(std::move(delay_cb))); test::DefaultNetEqTestErrorCallback error_cb; test::NetEqTest::Callbacks callbacks; callbacks.error_callback = &error_cb; - callbacks.post_insert_packet = delay_cb.get(); - callbacks.get_audio_callback = delay_cb.get(); + callbacks.post_insert_packet = neteq_stats_getter->delay_analyzer(); + callbacks.get_audio_callback = neteq_stats_getter.get(); test::NetEqTest test(config, codecs, ext_codecs, std::move(input), std::move(output), callbacks); test.Run(); - return delay_cb; + return neteq_stats_getter; } } // namespace -// Plots the jitter buffer delay profile. This will plot only for the first -// incoming audio SSRC. If the stream contains more than one incoming audio -// SSRC, all but the first will be ignored. -void EventLogAnalyzer::CreateAudioJitterBufferGraph( +EventLogAnalyzer::NetEqStatsGetterMap EventLogAnalyzer::SimulateNetEq( const std::string& replacement_file_name, - int file_sample_rate_hz, - Plot* plot) { + int file_sample_rate_hz) const { + NetEqStatsGetterMap neteq_stats; + const std::vector* audio_packets = nullptr; uint32_t ssrc; for (const auto& stream : parsed_log_.incoming_rtp_packets_by_ssrc()) { @@ -1709,7 +1709,7 @@ void EventLogAnalyzer::CreateAudioJitterBufferGraph( } if (audio_packets == nullptr) { // No incoming audio stream found. - return; + return neteq_stats; } std::map>::const_iterator output_events_it = @@ -1725,18 +1725,32 @@ void EventLogAnalyzer::CreateAudioJitterBufferGraph( ? rtc::nullopt : rtc::Optional(log_segments_.front().second); - auto delay_cb = CreateNetEqTestAndRun( + neteq_stats[ssrc] = CreateNetEqTestAndRun( audio_packets, &output_events_it->second, end_time_us, replacement_file_name, file_sample_rate_hz); + return neteq_stats; +} + +// Plots the jitter buffer delay profile. This will plot only for the first +// incoming audio SSRC. If the stream contains more than one incoming audio +// SSRC, all but the first will be ignored. +void EventLogAnalyzer::CreateAudioJitterBufferGraph( + const NetEqStatsGetterMap& neteq_stats, + Plot* plot) const { + if (neteq_stats.size() < 1) + return; + + const uint32_t ssrc = neteq_stats.begin()->first; + std::vector send_times_s; std::vector arrival_delay_ms; std::vector corrected_arrival_delay_ms; std::vector> playout_delay_ms; std::vector> target_delay_ms; - delay_cb->CreateGraphs(&send_times_s, &arrival_delay_ms, - &corrected_arrival_delay_ms, &playout_delay_ms, - &target_delay_ms); + neteq_stats.at(ssrc)->delay_analyzer()->CreateGraphs( + &send_times_s, &arrival_delay_ms, &corrected_arrival_delay_ms, + &playout_delay_ms, &target_delay_ms); RTC_DCHECK_EQ(send_times_s.size(), arrival_delay_ms.size()); RTC_DCHECK_EQ(send_times_s.size(), corrected_arrival_delay_ms.size()); RTC_DCHECK_EQ(send_times_s.size(), playout_delay_ms.size()); diff --git a/rtc_tools/event_log_visualizer/analyzer.h b/rtc_tools/event_log_visualizer/analyzer.h index 7ed65a76e0..572884cc60 100644 --- a/rtc_tools/event_log_visualizer/analyzer.h +++ b/rtc_tools/event_log_visualizer/analyzer.h @@ -19,6 +19,7 @@ #include #include "logging/rtc_event_log/rtc_event_log_parser_new.h" +#include "modules/audio_coding/neteq/tools/neteq_stats_getter.h" #include "rtc_base/strings/string_builder.h" #include "rtc_tools/event_log_visualizer/plot_base.h" #include "rtc_tools/event_log_visualizer/triage_notifications.h" @@ -70,9 +71,14 @@ class EventLogAnalyzer { void CreateAudioEncoderEnableFecGraph(Plot* plot); void CreateAudioEncoderEnableDtxGraph(Plot* plot); void CreateAudioEncoderNumChannelsGraph(Plot* plot); - void CreateAudioJitterBufferGraph(const std::string& replacement_file_name, - int file_sample_rate_hz, - Plot* plot); + + using NetEqStatsGetterMap = + std::map>; + NetEqStatsGetterMap SimulateNetEq(const std::string& replacement_file_name, + int file_sample_rate_hz) const; + void CreateAudioJitterBufferGraph( + const NetEqStatsGetterMap& neteq_stats_getters, + Plot* plot) const; void CreateIceCandidatePairConfigGraph(Plot* plot); void CreateIceConnectivityCheckGraph(Plot* plot); diff --git a/rtc_tools/event_log_visualizer/main.cc b/rtc_tools/event_log_visualizer/main.cc index 4d752fd213..d12935d0cd 100644 --- a/rtc_tools/event_log_visualizer/main.cc +++ b/rtc_tools/event_log_visualizer/main.cc @@ -333,7 +333,8 @@ int main(int argc, char* argv[]) { wav_path = webrtc::test::ResourcePath( "audio_processing/conversational_speech/EN_script2_F_sp2_B1", "wav"); } - analyzer.CreateAudioJitterBufferGraph(wav_path, 48000, + auto neteq_stats = analyzer.SimulateNetEq(wav_path, 48000); + analyzer.CreateAudioJitterBufferGraph(neteq_stats, collection->AppendNewPlot()); }