| Index: media/cast/sender/video_sender_unittest.cc
|
| diff --git a/media/cast/sender/video_sender_unittest.cc b/media/cast/sender/video_sender_unittest.cc
|
| index 1dbccf0ddc0e210cd67249d2eabc629568579543..655b3bd6a3a68fec93f31927ea4a9bd3e74dacd4 100644
|
| --- a/media/cast/sender/video_sender_unittest.cc
|
| +++ b/media/cast/sender/video_sender_unittest.cc
|
| @@ -563,5 +563,39 @@ TEST_F(VideoSenderTest, CheckVideoFrameFactoryIsNull) {
|
| EXPECT_EQ(nullptr, video_sender_->CreateVideoFrameFactory().get());
|
| }
|
|
|
| +TEST_F(VideoSenderTest, PopulatesStressLevelInFrameMetadata) {
|
| + InitEncoder(false, true);
|
| + ASSERT_EQ(STATUS_INITIALIZED, operational_status_);
|
| +
|
| + for (int i = 0; i < 3; ++i) {
|
| + scoped_refptr<media::VideoFrame> video_frame = GetNewVideoFrame();
|
| + ASSERT_FALSE(video_frame->metadata()->HasKey(
|
| + media::VideoFrameMetadata::STRESS_LEVEL));
|
| +
|
| + const base::TimeTicks reference_time = testing_clock_->NowTicks();
|
| + video_sender_->InsertRawVideoFrame(video_frame, reference_time);
|
| +
|
| + // Run encode tasks. VideoSender::OnEncodedVideoFrame() will be called once
|
| + // encoding of the frame is complete, and this is when the STRESS_LEVEL
|
| + // metadata is populated.
|
| + RunTasks(33);
|
| +
|
| + // The first frame will be a key frame, so no stress level will be reported.
|
| + // The second and third frames should have non-negative values. We don't
|
| + // check for specific values because they are dependent on real-world CPU
|
| + // encode time.
|
| + if (i == 0) {
|
| + EXPECT_FALSE(video_frame->metadata()->HasKey(
|
| + media::VideoFrameMetadata::STRESS_LEVEL));
|
| + } else {
|
| + double stress_level = -1.0;
|
| + EXPECT_TRUE(video_frame->metadata()->GetDouble(
|
| + media::VideoFrameMetadata::STRESS_LEVEL, &stress_level));
|
| + EXPECT_LE(0.0, stress_level);
|
| + DVLOG(1) << "Stress level computed by VideoSender is: " << stress_level;
|
| + }
|
| + }
|
| +}
|
| +
|
| } // namespace cast
|
| } // namespace media
|
|
|