diff --git a/test/pc/e2e/analyzer/audio/default_audio_quality_analyzer.cc b/test/pc/e2e/analyzer/audio/default_audio_quality_analyzer.cc index 07f3d63b8b..b448dc218e 100644 --- a/test/pc/e2e/analyzer/audio/default_audio_quality_analyzer.cc +++ b/test/pc/e2e/analyzer/audio/default_audio_quality_analyzer.cc @@ -45,10 +45,24 @@ void DefaultAudioQualityAnalyzer::OnStatsReports( if (strcmp(media_type->static_string_val(), kStatsAudioMediaType) != 0) { continue; } + if (stats_report->FindValue( webrtc::StatsReport::kStatsValueNameBytesSent)) { - // If kStatsValueNameBytesSent is present, it means it's a send stream, - // but we need audio metrics for receive stream, so skip it. + // If kStatsValueNameBytesSent is present, it means it's a send stream. + // All we need from a send stream is bytes sent. + const webrtc::StatsReport::Value* bytes_sent = stats_report->FindValue( + StatsReport::StatsValueName::kStatsValueNameBytesSent); + const webrtc::StatsReport::Value* report_track_id = + stats_report->FindValue( + StatsReport::StatsValueName::kStatsValueNameTrackId); + + rtc::CritScope crit(&lock_); + // Note: outgoing streams have their "stream label" directly in the + // report's track id field. There is no need to look it up using + // GetStreamLabelFromStatsReport(), and in fact doing so will crash. + AudioStreamStats& audio_stream_stats = + streams_stats_[report_track_id->string_val()]; + audio_stream_stats.bytes_sent = bytes_sent->int64_val(); continue; } @@ -112,6 +126,9 @@ void DefaultAudioQualityAnalyzer::Stop() { item.second.speech_expand_rate, "unitless"); ReportResult("preferred_buffer_size_ms", item.first, item.second.preferred_buffer_size_ms, "ms"); + test::PrintResult("bytes_sent", "", GetTestCaseName(item.first), + item.second.bytes_sent, "sizeInBytes", + /*important=*/false); } } diff --git a/test/pc/e2e/analyzer/audio/default_audio_quality_analyzer.h b/test/pc/e2e/analyzer/audio/default_audio_quality_analyzer.h index ee34ed345b..824da607d9 100644 --- a/test/pc/e2e/analyzer/audio/default_audio_quality_analyzer.h +++ b/test/pc/e2e/analyzer/audio/default_audio_quality_analyzer.h @@ -29,6 +29,7 @@ struct AudioStreamStats { SamplesStatsCounter preemptive_rate; SamplesStatsCounter speech_expand_rate; SamplesStatsCounter preferred_buffer_size_ms; + int64_t bytes_sent; }; // TODO(bugs.webrtc.org/10430): Migrate to the new GetStats as soon as diff --git a/test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc b/test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc index 499d04e2d5..45516d2ea4 100644 --- a/test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc +++ b/test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc @@ -27,6 +27,7 @@ constexpr int kMaxActiveComparisons = 10; constexpr int kFreezeThresholdMs = 150; constexpr int kMicrosPerSecond = 1000000; constexpr int kBitsInByte = 8; +constexpr char kStatsVideoMediaType[] = "video"; void LogFrameCounters(const std::string& name, const FrameCounters& counters) { RTC_LOG(INFO) << "[" << name << "] Captured : " << counters.captured; @@ -373,7 +374,28 @@ void DefaultVideoQualityAnalyzer::OnStatsReports( const std::string& pc_label, const StatsReports& stats_reports) { for (const StatsReport* stats_report : stats_reports) { - // The only stats collected by this analyzer are present in + // Record the number of video bytes sent from outgoing SSRC reports. + if (stats_report->type() == StatsReport::StatsType::kStatsReportTypeSsrc && + strcmp(stats_report + ->FindValue( + StatsReport::StatsValueName::kStatsValueNameMediaType) + ->static_string_val(), + kStatsVideoMediaType) == 0 && + stats_report->FindValue(StatsReport::kStatsValueNameBytesSent)) { + const webrtc::StatsReport::Value* bytes_sent = stats_report->FindValue( + StatsReport::StatsValueName::kStatsValueNameBytesSent); + const webrtc::StatsReport::Value* track_id = stats_report->FindValue( + StatsReport::StatsValueName::kStatsValueNameTrackId); + + rtc::CritScope crit(&comparison_lock_); + // Note: outgoing streams have their "stream label" directly in the + // report's track id field. There is no need to look it up using + // GetStreamLabelFromStatsReport(), and in fact doing so will crash. + StreamStats& stream_stats = stream_stats_[track_id->string_val()]; + stream_stats.bytes_sent = bytes_sent->int64_val(); + } + + // The only other stats collected by this analyzer are present in // kStatsReportTypeBwe reports, so all other reports are just ignored. if (stats_report->type() != StatsReport::StatsType::kStatsReportTypeBwe) { continue; @@ -629,6 +651,8 @@ void DefaultVideoQualityAnalyzer::ReportResults( /*important=*/false); ReportResult("max_skipped", test_case_name, stats.skipped_between_rendered, "unitless"); + test::PrintResult("bytes_sent", "", test_case_name, stats.bytes_sent, + "sizeInBytes", /*important=*/false); } void DefaultVideoQualityAnalyzer::ReportResult( diff --git a/test/pc/e2e/analyzer/video/default_video_quality_analyzer.h b/test/pc/e2e/analyzer/video/default_video_quality_analyzer.h index e7be2b5af9..ef10d27c54 100644 --- a/test/pc/e2e/analyzer/video/default_video_quality_analyzer.h +++ b/test/pc/e2e/analyzer/video/default_video_quality_analyzer.h @@ -96,6 +96,8 @@ struct StreamStats { int64_t dropped_by_encoder = 0; int64_t dropped_before_encoder = 0; + + int64_t bytes_sent = 0; }; struct AnalyzerStats {