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}
This commit is contained in:
Fanny Linderborg 2024-10-10 09:45:41 +02:00 committed by WebRTC LUCI CQ
parent 2d75cd3664
commit 518bd61cec
4 changed files with 26 additions and 8 deletions

View File

@ -134,14 +134,13 @@ void VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage,
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 @@ void VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage,
.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(

View File

@ -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 @@ class ReceiveCallback : public VCMReceiveCallback {
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 @@ class ReceiveCallback : public VCMReceiveCallback {
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, IsLowLatencyStreamActivatedByPlayoutDelay) {
}
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

View File

@ -59,6 +59,7 @@ class VCMReceiveCallback {
TimeDelta decode_time;
VideoContentType content_type;
VideoFrameType frame_type;
std::optional<double> corruption_score;
};
// TODO: bugs.webrtc.org/358039777 - Delete this function.

View File

@ -66,6 +66,10 @@ int32_t VideoStreamDecoder::OnFrameToRender(
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;
}