Forward the corruption score from the decoder to ReceiveStatisticsProxy
Bug: webrtc:358039777
Change-Id: Iace01daa53d08b5d0c484b5f55da73ba230317da
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/365095
Reviewed-by: Erik Språng <sprang@webrtc.org>
Auto-Submit: Fanny Linderborg <linderborg@webrtc.org>
Commit-Queue: Fanny Linderborg <linderborg@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43213}
diff --git a/modules/video_coding/generic_decoder.cc b/modules/video_coding/generic_decoder.cc
index 166ce1d..23199f7 100644
--- a/modules/video_coding/generic_decoder.cc
+++ b/modules/video_coding/generic_decoder.cc
@@ -134,14 +134,13 @@
return;
}
- // TODO: bugs.webrtc.org/358039777 - Use the score.
- std::optional<double> score;
+ std::optional<double> corruption_score;
if (corruption_score_calculator_ &&
frame_info->frame_instrumentation_data.has_value()) {
if (const FrameInstrumentationData* data =
absl::get_if<FrameInstrumentationData>(
&*frame_info->frame_instrumentation_data)) {
- score = corruption_score_calculator_->CalculateCorruptionScore(
+ corruption_score = corruption_score_calculator_->CalculateCorruptionScore(
decodedImage, *data);
}
}
@@ -242,7 +241,8 @@
.qp = qp,
.decode_time = decode_time,
.content_type = frame_info->content_type,
- .frame_type = frame_info->frame_type});
+ .frame_type = frame_info->frame_type,
+ .corruption_score = corruption_score});
}
void VCMDecodedFrameCallback::OnDecoderInfoChanged(
diff --git a/modules/video_coding/generic_decoder_unittest.cc b/modules/video_coding/generic_decoder_unittest.cc
index 9f362e4..8300292 100644
--- a/modules/video_coding/generic_decoder_unittest.cc
+++ b/modules/video_coding/generic_decoder_unittest.cc
@@ -37,6 +37,8 @@
#include "test/scoped_key_value_config.h"
#include "test/time_controller/simulated_time_controller.h"
+using ::testing::Return;
+
namespace webrtc {
namespace video_coding {
@@ -65,6 +67,7 @@
int32_t OnFrameToRender(const struct FrameToRender& arguments) override {
frames_.push_back(arguments.video_frame);
+ last_corruption_score_ = arguments.corruption_score;
return 0;
}
@@ -84,9 +87,14 @@
uint32_t frames_dropped() const { return frames_dropped_; }
+ std::optional<double> last_corruption_score() const {
+ return last_corruption_score_;
+ }
+
private:
std::vector<VideoFrame> frames_;
uint32_t frames_dropped_ = 0;
+ std::optional<double> last_corruption_score_;
};
class GenericDecoderTest : public ::testing::Test {
@@ -220,22 +228,27 @@
}
TEST_F(GenericDecoderTest, CallCalculateCorruptionScoreInDecoded) {
- EXPECT_CALL(corruption_score_calculator_, CalculateCorruptionScore);
+ constexpr double kCorruptionScore = 0.76;
- uint32_t rtp_timestamp = 1;
+ EXPECT_CALL(corruption_score_calculator_, CalculateCorruptionScore)
+ .WillOnce(Return(kCorruptionScore));
+
+ constexpr uint32_t kRtpTimestamp = 1;
FrameInfo frame_info;
frame_info.frame_instrumentation_data = FrameInstrumentationData{};
- frame_info.rtp_timestamp = rtp_timestamp;
+ frame_info.rtp_timestamp = kRtpTimestamp;
frame_info.decode_start = Timestamp::Zero();
frame_info.content_type = VideoContentType::UNSPECIFIED;
frame_info.frame_type = VideoFrameType::kVideoFrameDelta;
VideoFrame video_frame = VideoFrame::Builder()
.set_video_frame_buffer(I420Buffer::Create(5, 5))
- .set_rtp_timestamp(rtp_timestamp)
+ .set_rtp_timestamp(kRtpTimestamp)
.build();
vcm_callback_.Map(std::move(frame_info));
vcm_callback_.Decoded(video_frame);
+
+ EXPECT_EQ(user_callback_.last_corruption_score(), kCorruptionScore);
}
} // namespace video_coding
diff --git a/modules/video_coding/include/video_coding_defines.h b/modules/video_coding/include/video_coding_defines.h
index 1347431..c5d8e75 100644
--- a/modules/video_coding/include/video_coding_defines.h
+++ b/modules/video_coding/include/video_coding_defines.h
@@ -59,6 +59,7 @@
TimeDelta decode_time;
VideoContentType content_type;
VideoFrameType frame_type;
+ std::optional<double> corruption_score;
};
// TODO: bugs.webrtc.org/358039777 - Delete this function.
diff --git a/video/video_stream_decoder2.cc b/video/video_stream_decoder2.cc
index c8bec27..30ea4c3 100644
--- a/video/video_stream_decoder2.cc
+++ b/video/video_stream_decoder2.cc
@@ -66,6 +66,10 @@
receive_stats_callback_->OnDecodedFrame(
arguments.video_frame, arguments.qp, arguments.decode_time,
arguments.content_type, arguments.frame_type);
+ if (arguments.corruption_score.has_value()) {
+ receive_stats_callback_->OnCorruptionScore(*arguments.corruption_score,
+ arguments.content_type);
+ }
incoming_video_stream_->OnFrame(arguments.video_frame);
return 0;
}