Post corruption score aggregation to worker thread.

Bug: webrtc:358039777
Change-Id: Ia7196436aaa024019869a7521243da0576dbb148
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/365600
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Åsa Persson <asapersson@webrtc.org>
Auto-Submit: Emil Vardar (xWF) <vardar@google.com>
Reviewed-by: Åsa Persson <asapersson@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43238}
This commit is contained in:
Emil Vardar 2024-10-14 14:40:56 +00:00 committed by WebRTC LUCI CQ
parent 6f99dba4c2
commit 129f228f59
2 changed files with 18 additions and 13 deletions

View File

@ -825,6 +825,8 @@ void ReceiveStatisticsProxy::OnRttUpdate(int64_t avg_rtt_ms) {
void ReceiveStatisticsProxy::OnCorruptionScore(double corruption_score,
VideoContentType content_type) {
worker_thread_->PostTask(SafeTask(task_safety_.flag(), [corruption_score,
content_type, this] {
RTC_DCHECK_RUN_ON(&main_thread_);
if (!stats_.corruption_score_sum.has_value()) {
@ -840,6 +842,7 @@ void ReceiveStatisticsProxy::OnCorruptionScore(double corruption_score,
ContentSpecificStats* content_specific_stats =
&content_specific_stats_[content_type];
content_specific_stats->corruption_score.AddSample(corruption_score);
}));
}
void ReceiveStatisticsProxy::DecoderThreadStarting() {

View File

@ -555,6 +555,8 @@ TEST_F(ReceiveStatisticsProxyTest, GetStatsReportsOnCorruptionScore) {
VideoContentType::UNSPECIFIED);
}
time_controller_.AdvanceTime(TimeDelta::Zero());
VideoReceiveStreamInterface::Stats stats = statistics_proxy_->GetStats();
EXPECT_THAT(kExpectedCorruptionScoreSum,
DoubleEq(*stats.corruption_score_sum));