Record audio/video bytes sent in analyzer stream stats.
For each SSRC report, record the number of bytes sent for that stream and expose them in analyzer stats. These numbers can be used to determine useful metrics such as total media throughput (by adding the bytes sent for all streams) and overhead (by subtracting that amount from the total bytes sent to the network). Bug: webrtc:9719 Change-Id: I977bbd40acdd0a1ec64763ddd55a642b9a50f309 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146240 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Artem Titov <titovartem@webrtc.org> Commit-Queue: Bjorn Mellem <mellem@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28637}
This commit is contained in:

committed by
Commit Bot

parent
432fe68af8
commit
d978cb43c2
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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(
|
||||
|
@ -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 {
|
||||
|
Reference in New Issue
Block a user