|
|
|
@ -888,7 +888,8 @@ class VideoStreamEncoderTest : public ::testing::Test {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TEST_F(VideoStreamEncoderTest, EncodeOneFrame) {
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
rtc::Event frame_destroyed_event;
|
|
|
|
|
video_source_.IncomingCapturedFrame(CreateFrame(1, &frame_destroyed_event));
|
|
|
|
|
WaitForEncodedFrame(1);
|
|
|
|
@ -906,7 +907,8 @@ TEST_F(VideoStreamEncoderTest, DropsFramesBeforeFirstOnBitrateUpdated) {
|
|
|
|
|
video_source_.IncomingCapturedFrame(CreateFrame(2, nullptr));
|
|
|
|
|
EXPECT_TRUE(frame_destroyed_event.Wait(kDefaultTimeoutMs));
|
|
|
|
|
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
// The pending frame should be received.
|
|
|
|
|
WaitForEncodedFrame(2);
|
|
|
|
@ -917,18 +919,21 @@ TEST_F(VideoStreamEncoderTest, DropsFramesBeforeFirstOnBitrateUpdated) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(VideoStreamEncoderTest, DropsFramesWhenRateSetToZero) {
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr));
|
|
|
|
|
WaitForEncodedFrame(1);
|
|
|
|
|
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(0, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(0), DataRate::Zero(), 0,
|
|
|
|
|
0);
|
|
|
|
|
// The encoder will cache up to one frame for a short duration. Adding two
|
|
|
|
|
// frames means that the first frame will be dropped and the second frame will
|
|
|
|
|
// be sent when the encoder is resumed.
|
|
|
|
|
video_source_.IncomingCapturedFrame(CreateFrame(2, nullptr));
|
|
|
|
|
video_source_.IncomingCapturedFrame(CreateFrame(3, nullptr));
|
|
|
|
|
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
WaitForEncodedFrame(3);
|
|
|
|
|
video_source_.IncomingCapturedFrame(CreateFrame(4, nullptr));
|
|
|
|
|
WaitForEncodedFrame(4);
|
|
|
|
@ -936,7 +941,8 @@ TEST_F(VideoStreamEncoderTest, DropsFramesWhenRateSetToZero) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(VideoStreamEncoderTest, DropsFramesWithSameOrOldNtpTimestamp) {
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr));
|
|
|
|
|
WaitForEncodedFrame(1);
|
|
|
|
|
|
|
|
|
@ -949,7 +955,8 @@ TEST_F(VideoStreamEncoderTest, DropsFramesWithSameOrOldNtpTimestamp) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(VideoStreamEncoderTest, DropsFrameAfterStop) {
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr));
|
|
|
|
|
WaitForEncodedFrame(1);
|
|
|
|
@ -962,7 +969,8 @@ TEST_F(VideoStreamEncoderTest, DropsFrameAfterStop) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(VideoStreamEncoderTest, DropsPendingFramesOnSlowEncode) {
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
fake_encoder_.BlockNextEncode();
|
|
|
|
|
video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr));
|
|
|
|
@ -979,7 +987,8 @@ TEST_F(VideoStreamEncoderTest, DropsPendingFramesOnSlowEncode) {
|
|
|
|
|
|
|
|
|
|
TEST_F(VideoStreamEncoderTest,
|
|
|
|
|
ConfigureEncoderTriggersOnEncoderConfigurationChanged) {
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
EXPECT_EQ(0, sink_.number_of_reconfigurations());
|
|
|
|
|
|
|
|
|
|
// Capture a frame and wait for it to synchronize with the encoder thread.
|
|
|
|
@ -1005,7 +1014,8 @@ TEST_F(VideoStreamEncoderTest,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(VideoStreamEncoderTest, FrameResolutionChangeReconfigureEncoder) {
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
// Capture a frame and wait for it to synchronize with the encoder thread.
|
|
|
|
|
video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr));
|
|
|
|
@ -1056,7 +1066,8 @@ TEST_F(VideoStreamEncoderTest, TestCpuDowngrades_BalancedMode) {
|
|
|
|
|
video_source_.set_adaptation_enabled(true);
|
|
|
|
|
|
|
|
|
|
// Enable BALANCED preference, no initial limitation.
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
video_stream_encoder_->SetSource(&video_source_,
|
|
|
|
|
webrtc::DegradationPreference::BALANCED);
|
|
|
|
|
VerifyNoLimitation(video_source_.sink_wants());
|
|
|
|
@ -1138,7 +1149,8 @@ TEST_F(VideoStreamEncoderTest, TestCpuDowngrades_BalancedMode) {
|
|
|
|
|
video_stream_encoder_->Stop();
|
|
|
|
|
}
|
|
|
|
|
TEST_F(VideoStreamEncoderTest, SinkWantsStoredByDegradationPreference) {
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
VerifyNoLimitation(video_source_.sink_wants());
|
|
|
|
|
|
|
|
|
|
const int kFrameWidth = 1280;
|
|
|
|
@ -1226,7 +1238,8 @@ TEST_F(VideoStreamEncoderTest, SinkWantsStoredByDegradationPreference) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(VideoStreamEncoderTest, StatsTracksQualityAdaptationStats) {
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
const int kWidth = 1280;
|
|
|
|
|
const int kHeight = 720;
|
|
|
|
@ -1259,7 +1272,8 @@ TEST_F(VideoStreamEncoderTest, StatsTracksQualityAdaptationStats) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(VideoStreamEncoderTest, StatsTracksCpuAdaptationStats) {
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
const int kWidth = 1280;
|
|
|
|
|
const int kHeight = 720;
|
|
|
|
@ -1292,7 +1306,8 @@ TEST_F(VideoStreamEncoderTest, StatsTracksCpuAdaptationStats) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(VideoStreamEncoderTest, SwitchingSourceKeepsCpuAdaptation) {
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
const int kWidth = 1280;
|
|
|
|
|
const int kHeight = 720;
|
|
|
|
@ -1360,7 +1375,8 @@ TEST_F(VideoStreamEncoderTest, SwitchingSourceKeepsCpuAdaptation) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(VideoStreamEncoderTest, SwitchingSourceKeepsQualityAdaptation) {
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
const int kWidth = 1280;
|
|
|
|
|
const int kHeight = 720;
|
|
|
|
@ -1420,7 +1436,8 @@ TEST_F(VideoStreamEncoderTest, SwitchingSourceKeepsQualityAdaptation) {
|
|
|
|
|
|
|
|
|
|
TEST_F(VideoStreamEncoderTest,
|
|
|
|
|
QualityAdaptationStatsAreResetWhenScalerIsDisabled) {
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
const int kWidth = 1280;
|
|
|
|
|
const int kHeight = 720;
|
|
|
|
@ -1475,7 +1492,8 @@ TEST_F(VideoStreamEncoderTest,
|
|
|
|
|
|
|
|
|
|
TEST_F(VideoStreamEncoderTest,
|
|
|
|
|
StatsTracksCpuAdaptationStatsWhenSwitchingSource) {
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
const int kWidth = 1280;
|
|
|
|
|
const int kHeight = 720;
|
|
|
|
@ -1611,7 +1629,8 @@ TEST_F(VideoStreamEncoderTest,
|
|
|
|
|
ScalingUpAndDownDoesNothingWithMaintainResolution) {
|
|
|
|
|
const int kWidth = 1280;
|
|
|
|
|
const int kHeight = 720;
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
// Expect no scaling to begin with.
|
|
|
|
|
VerifyNoLimitation(video_source_.sink_wants());
|
|
|
|
@ -1659,7 +1678,8 @@ TEST_F(VideoStreamEncoderTest,
|
|
|
|
|
SkipsSameAdaptDownRequest_MaintainFramerateMode) {
|
|
|
|
|
const int kWidth = 1280;
|
|
|
|
|
const int kHeight = 720;
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
// Enable MAINTAIN_FRAMERATE preference, no initial limitation.
|
|
|
|
|
test::FrameForwarder source;
|
|
|
|
@ -1691,7 +1711,8 @@ TEST_F(VideoStreamEncoderTest,
|
|
|
|
|
TEST_F(VideoStreamEncoderTest, SkipsSameOrLargerAdaptDownRequest_BalancedMode) {
|
|
|
|
|
const int kWidth = 1280;
|
|
|
|
|
const int kHeight = 720;
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
// Enable BALANCED preference, no initial limitation.
|
|
|
|
|
test::FrameForwarder source;
|
|
|
|
@ -1731,7 +1752,8 @@ TEST_F(VideoStreamEncoderTest,
|
|
|
|
|
NoChangeForInitialNormalUsage_MaintainFramerateMode) {
|
|
|
|
|
const int kWidth = 1280;
|
|
|
|
|
const int kHeight = 720;
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
// Enable MAINTAIN_FRAMERATE preference, no initial limitation.
|
|
|
|
|
test::FrameForwarder source;
|
|
|
|
@ -1757,7 +1779,8 @@ TEST_F(VideoStreamEncoderTest,
|
|
|
|
|
NoChangeForInitialNormalUsage_MaintainResolutionMode) {
|
|
|
|
|
const int kWidth = 1280;
|
|
|
|
|
const int kHeight = 720;
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
// Enable MAINTAIN_RESOLUTION preference, no initial limitation.
|
|
|
|
|
test::FrameForwarder source;
|
|
|
|
@ -1782,7 +1805,8 @@ TEST_F(VideoStreamEncoderTest,
|
|
|
|
|
TEST_F(VideoStreamEncoderTest, NoChangeForInitialNormalUsage_BalancedMode) {
|
|
|
|
|
const int kWidth = 1280;
|
|
|
|
|
const int kHeight = 720;
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
// Enable BALANCED preference, no initial limitation.
|
|
|
|
|
test::FrameForwarder source;
|
|
|
|
@ -1809,7 +1833,8 @@ TEST_F(VideoStreamEncoderTest, NoChangeForInitialNormalUsage_BalancedMode) {
|
|
|
|
|
TEST_F(VideoStreamEncoderTest, NoChangeForInitialNormalUsage_DisabledMode) {
|
|
|
|
|
const int kWidth = 1280;
|
|
|
|
|
const int kHeight = 720;
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
// Enable DISABLED preference, no initial limitation.
|
|
|
|
|
test::FrameForwarder source;
|
|
|
|
@ -1837,7 +1862,8 @@ TEST_F(VideoStreamEncoderTest,
|
|
|
|
|
AdaptsResolutionForLowQuality_MaintainFramerateMode) {
|
|
|
|
|
const int kWidth = 1280;
|
|
|
|
|
const int kHeight = 720;
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
// Enable MAINTAIN_FRAMERATE preference, no initial limitation.
|
|
|
|
|
AdaptingFrameForwarder source;
|
|
|
|
@ -1874,7 +1900,8 @@ TEST_F(VideoStreamEncoderTest,
|
|
|
|
|
const int kWidth = 1280;
|
|
|
|
|
const int kHeight = 720;
|
|
|
|
|
const int kInputFps = 30;
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
VideoSendStream::Stats stats = stats_proxy_->GetStats();
|
|
|
|
|
stats.input_frame_rate = kInputFps;
|
|
|
|
@ -1915,7 +1942,8 @@ TEST_F(VideoStreamEncoderTest, DoesNotScaleBelowSetResolutionLimit) {
|
|
|
|
|
const int kHeight = 720;
|
|
|
|
|
const size_t kNumFrames = 10;
|
|
|
|
|
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
// Enable adapter, expected input resolutions when downscaling:
|
|
|
|
|
// 1280x720 -> 960x540 -> 640x360 -> 480x270 -> 320x180 (kMinPixelsPerFrame)
|
|
|
|
@ -1950,7 +1978,8 @@ TEST_F(VideoStreamEncoderTest,
|
|
|
|
|
AdaptsResolutionUpAndDownTwiceOnOveruse_MaintainFramerateMode) {
|
|
|
|
|
const int kWidth = 1280;
|
|
|
|
|
const int kHeight = 720;
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
// Enable MAINTAIN_FRAMERATE preference, no initial limitation.
|
|
|
|
|
AdaptingFrameForwarder source;
|
|
|
|
@ -2008,7 +2037,8 @@ TEST_F(VideoStreamEncoderTest,
|
|
|
|
|
AdaptsResolutionUpAndDownTwiceForLowQuality_BalancedMode_NoFpsLimit) {
|
|
|
|
|
const int kWidth = 1280;
|
|
|
|
|
const int kHeight = 720;
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
// Enable BALANCED preference, no initial limitation.
|
|
|
|
|
AdaptingFrameForwarder source;
|
|
|
|
@ -2066,7 +2096,8 @@ TEST_F(VideoStreamEncoderTest,
|
|
|
|
|
AdaptsResolutionOnOveruseAndLowQuality_MaintainFramerateMode) {
|
|
|
|
|
const int kWidth = 1280;
|
|
|
|
|
const int kHeight = 720;
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
// Enable MAINTAIN_FRAMERATE preference, no initial limitation.
|
|
|
|
|
AdaptingFrameForwarder source;
|
|
|
|
@ -2203,7 +2234,8 @@ TEST_F(VideoStreamEncoderTest, CpuLimitedHistogramIsReported) {
|
|
|
|
|
const int kWidth = 640;
|
|
|
|
|
const int kHeight = 360;
|
|
|
|
|
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
for (int i = 1; i <= SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) {
|
|
|
|
|
video_source_.IncomingCapturedFrame(CreateFrame(i, kWidth, kHeight));
|
|
|
|
@ -2229,7 +2261,8 @@ TEST_F(VideoStreamEncoderTest, CpuLimitedHistogramIsReported) {
|
|
|
|
|
|
|
|
|
|
TEST_F(VideoStreamEncoderTest,
|
|
|
|
|
CpuLimitedHistogramIsNotReportedForDisabledDegradation) {
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
const int kWidth = 640;
|
|
|
|
|
const int kHeight = 360;
|
|
|
|
|
|
|
|
|
@ -2260,7 +2293,8 @@ TEST_F(VideoStreamEncoderTest, CallsBitrateObserver) {
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(bitrate_observer, OnBitrateAllocationUpdated(expected_bitrate))
|
|
|
|
|
.Times(1);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kLowTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kLowTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
video_source_.IncomingCapturedFrame(
|
|
|
|
|
CreateFrame(rtc::TimeMillis(), codec_width_, codec_height_));
|
|
|
|
@ -2303,7 +2337,8 @@ TEST_F(VideoStreamEncoderTest, OveruseDetectorUpdatedOnReconfigureAndAdaption) {
|
|
|
|
|
const int kFrameHeight = 720;
|
|
|
|
|
const int kFramerate = 24;
|
|
|
|
|
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
test::FrameForwarder source;
|
|
|
|
|
video_stream_encoder_->SetSource(
|
|
|
|
|
&source, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
|
|
|
|
@ -2363,7 +2398,8 @@ TEST_F(VideoStreamEncoderTest,
|
|
|
|
|
const int kLowFramerate = 15;
|
|
|
|
|
const int kHighFramerate = 25;
|
|
|
|
|
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
test::FrameForwarder source;
|
|
|
|
|
video_stream_encoder_->SetSource(
|
|
|
|
|
&source, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
|
|
|
|
@ -2426,7 +2462,8 @@ TEST_F(VideoStreamEncoderTest,
|
|
|
|
|
const int kFrameHeight = 720;
|
|
|
|
|
const int kFramerate = 24;
|
|
|
|
|
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
test::FrameForwarder source;
|
|
|
|
|
video_stream_encoder_->SetSource(
|
|
|
|
|
&source, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
|
|
|
|
@ -2471,7 +2508,8 @@ TEST_F(VideoStreamEncoderTest,
|
|
|
|
|
|
|
|
|
|
TEST_F(VideoStreamEncoderTest, DropsFramesAndScalesWhenBitrateIsTooLow) {
|
|
|
|
|
const int kTooLowBitrateForFrameSizeBps = 10000;
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTooLowBitrateForFrameSizeBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(
|
|
|
|
|
DataRate::bps(kTooLowBitrateForFrameSizeBps), DataRate::Zero(), 0, 0);
|
|
|
|
|
const int kWidth = 640;
|
|
|
|
|
const int kHeight = 360;
|
|
|
|
|
|
|
|
|
@ -2500,7 +2538,8 @@ TEST_F(VideoStreamEncoderTest, DropsFramesAndScalesWhenBitrateIsTooLow) {
|
|
|
|
|
TEST_F(VideoStreamEncoderTest,
|
|
|
|
|
NumberOfDroppedFramesLimitedWhenBitrateIsTooLow) {
|
|
|
|
|
const int kTooLowBitrateForFrameSizeBps = 10000;
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTooLowBitrateForFrameSizeBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(
|
|
|
|
|
DataRate::bps(kTooLowBitrateForFrameSizeBps), DataRate::Zero(), 0, 0);
|
|
|
|
|
const int kWidth = 640;
|
|
|
|
|
const int kHeight = 360;
|
|
|
|
|
|
|
|
|
@ -2524,7 +2563,8 @@ TEST_F(VideoStreamEncoderTest,
|
|
|
|
|
InitialFrameDropOffWithMaintainResolutionPreference) {
|
|
|
|
|
const int kWidth = 640;
|
|
|
|
|
const int kHeight = 360;
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kLowTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kLowTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
// Set degradation preference.
|
|
|
|
|
video_stream_encoder_->SetSource(
|
|
|
|
@ -2548,7 +2588,8 @@ TEST_F(VideoStreamEncoderTest, InitialFrameDropOffWhenEncoderDisabledScaling) {
|
|
|
|
|
video_encoder_config.video_format.parameters["foo"] = "foo";
|
|
|
|
|
video_stream_encoder_->ConfigureEncoder(std::move(video_encoder_config),
|
|
|
|
|
kMaxPayloadLength);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kLowTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kLowTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
// Force quality scaler reconfiguration by resetting the source.
|
|
|
|
|
video_stream_encoder_->SetSource(&video_source_,
|
|
|
|
@ -2571,12 +2612,14 @@ TEST_F(VideoStreamEncoderTest, InitialFrameDropActivatesWhenBWEstimateReady) {
|
|
|
|
|
const int kWidth = 640;
|
|
|
|
|
const int kHeight = 360;
|
|
|
|
|
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
video_source_.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
|
|
|
|
|
// Frame should not be dropped.
|
|
|
|
|
WaitForEncodedFrame(1);
|
|
|
|
|
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTooLowBitrateForFrameSizeBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(
|
|
|
|
|
DataRate::bps(kTooLowBitrateForFrameSizeBps), DataRate::Zero(), 0, 0);
|
|
|
|
|
video_source_.IncomingCapturedFrame(CreateFrame(2, kWidth, kHeight));
|
|
|
|
|
// Expect to drop this frame, the wait should time out.
|
|
|
|
|
ExpectDroppedFrame();
|
|
|
|
@ -2590,7 +2633,8 @@ TEST_F(VideoStreamEncoderTest,
|
|
|
|
|
ResolutionNotAdaptedForTooSmallFrame_MaintainFramerateMode) {
|
|
|
|
|
const int kTooSmallWidth = 10;
|
|
|
|
|
const int kTooSmallHeight = 10;
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
// Enable MAINTAIN_FRAMERATE preference, no initial limitation.
|
|
|
|
|
test::FrameForwarder source;
|
|
|
|
@ -2615,7 +2659,8 @@ TEST_F(VideoStreamEncoderTest,
|
|
|
|
|
const int kTooSmallWidth = 10;
|
|
|
|
|
const int kTooSmallHeight = 10;
|
|
|
|
|
const int kFpsLimit = 7;
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
// Enable BALANCED preference, no initial limitation.
|
|
|
|
|
test::FrameForwarder source;
|
|
|
|
@ -2648,7 +2693,8 @@ TEST_F(VideoStreamEncoderTest,
|
|
|
|
|
|
|
|
|
|
TEST_F(VideoStreamEncoderTest, FailingInitEncodeDoesntCauseCrash) {
|
|
|
|
|
fake_encoder_.ForceInitEncodeFailure(true);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
ResetEncoder("VP8", 2, 1, 1, false);
|
|
|
|
|
const int kFrameWidth = 1280;
|
|
|
|
|
const int kFrameHeight = 720;
|
|
|
|
@ -2661,7 +2707,8 @@ TEST_F(VideoStreamEncoderTest, FailingInitEncodeDoesntCauseCrash) {
|
|
|
|
|
// TODO(sprang): Extend this with fps throttling and any "balanced" extensions.
|
|
|
|
|
TEST_F(VideoStreamEncoderTest,
|
|
|
|
|
AdaptsResolutionOnOveruse_MaintainFramerateMode) {
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
const int kFrameWidth = 1280;
|
|
|
|
|
const int kFrameHeight = 720;
|
|
|
|
@ -2694,7 +2741,8 @@ TEST_F(VideoStreamEncoderTest,
|
|
|
|
|
const int kFrameWidth = 1280;
|
|
|
|
|
const int kFrameHeight = 720;
|
|
|
|
|
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
video_stream_encoder_->SetSource(
|
|
|
|
|
&video_source_, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
|
|
|
|
|
video_source_.set_adaptation_enabled(true);
|
|
|
|
@ -2795,7 +2843,8 @@ TEST_F(VideoStreamEncoderTest, DoesntAdaptDownPastMinFramerate) {
|
|
|
|
|
// disable frame dropping and make testing easier.
|
|
|
|
|
ResetEncoder("VP8", 1, 2, 1, true);
|
|
|
|
|
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
video_stream_encoder_->SetSource(
|
|
|
|
|
&video_source_, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
|
|
|
|
|
video_source_.set_adaptation_enabled(true);
|
|
|
|
@ -2834,7 +2883,8 @@ TEST_F(VideoStreamEncoderTest,
|
|
|
|
|
const int kHeight = 720;
|
|
|
|
|
const int64_t kFrameIntervalMs = 150;
|
|
|
|
|
int64_t timestamp_ms = kFrameIntervalMs;
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
// Enable BALANCED preference, no initial limitation.
|
|
|
|
|
AdaptingFrameForwarder source;
|
|
|
|
@ -3014,7 +3064,8 @@ TEST_F(VideoStreamEncoderTest, AdaptWithTwoReasonsAndDifferentOrder_Framerate) {
|
|
|
|
|
const int kHeight = 720;
|
|
|
|
|
const int64_t kFrameIntervalMs = 150;
|
|
|
|
|
int64_t timestamp_ms = kFrameIntervalMs;
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
// Enable BALANCED preference, no initial limitation.
|
|
|
|
|
AdaptingFrameForwarder source;
|
|
|
|
@ -3127,7 +3178,8 @@ TEST_F(VideoStreamEncoderTest,
|
|
|
|
|
const int kFpsLimit = 15;
|
|
|
|
|
const int64_t kFrameIntervalMs = 150;
|
|
|
|
|
int64_t timestamp_ms = kFrameIntervalMs;
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
// Enable BALANCED preference, no initial limitation.
|
|
|
|
|
AdaptingFrameForwarder source;
|
|
|
|
@ -3245,7 +3297,8 @@ TEST_F(VideoStreamEncoderTest, AcceptsFullHdAdaptedDownSimulcastFrames) {
|
|
|
|
|
const int kAdaptedFrameHeight = 808;
|
|
|
|
|
const int kFramerate = 24;
|
|
|
|
|
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
// Trigger reconfigure encoder (without resetting the entire instance).
|
|
|
|
|
VideoEncoderConfig video_encoder_config;
|
|
|
|
|
video_encoder_config.codec_type = kVideoCodecVP8;
|
|
|
|
@ -3278,7 +3331,8 @@ TEST_F(VideoStreamEncoderTest, PeriodicallyUpdatesChannelParameters) {
|
|
|
|
|
const int kLowFps = 2;
|
|
|
|
|
const int kHighFps = 30;
|
|
|
|
|
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
int64_t timestamp_ms = fake_clock_.TimeNanos() / rtc::kNumNanosecsPerMillisec;
|
|
|
|
|
max_framerate_ = kLowFps;
|
|
|
|
@ -3292,7 +3346,8 @@ TEST_F(VideoStreamEncoderTest, PeriodicallyUpdatesChannelParameters) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Make sure encoder is updated with new target.
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
video_source_.IncomingCapturedFrame(
|
|
|
|
|
CreateFrame(timestamp_ms, kFrameWidth, kFrameHeight));
|
|
|
|
|
WaitForEncodedFrame(timestamp_ms);
|
|
|
|
@ -3330,7 +3385,8 @@ TEST_F(VideoStreamEncoderTest, DoesNotUpdateBitrateAllocationWhenSuspended) {
|
|
|
|
|
|
|
|
|
|
MockBitrateObserver bitrate_observer;
|
|
|
|
|
video_stream_encoder_->SetBitrateAllocationObserver(&bitrate_observer);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
video_stream_encoder_->WaitUntilTaskQueueIsIdle();
|
|
|
|
|
|
|
|
|
|
// Insert a first video frame, causes another bitrate update.
|
|
|
|
@ -3341,7 +3397,8 @@ TEST_F(VideoStreamEncoderTest, DoesNotUpdateBitrateAllocationWhenSuspended) {
|
|
|
|
|
WaitForEncodedFrame(timestamp_ms);
|
|
|
|
|
|
|
|
|
|
// Next, simulate video suspension due to pacer queue overrun.
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(0, 0, 1);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(0), DataRate::Zero(), 0,
|
|
|
|
|
1);
|
|
|
|
|
|
|
|
|
|
// Skip ahead until a new periodic parameter update should have occured.
|
|
|
|
|
timestamp_ms += vcm::VCMProcessTimer::kDefaultProcessIntervalMs;
|
|
|
|
@ -3363,7 +3420,8 @@ TEST_F(VideoStreamEncoderTest,
|
|
|
|
|
const int kFrameWidth = 1280;
|
|
|
|
|
const int kFrameHeight = 720;
|
|
|
|
|
const CpuOveruseOptions default_options;
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
video_source_.IncomingCapturedFrame(
|
|
|
|
|
CreateFrame(1, kFrameWidth, kFrameHeight));
|
|
|
|
|
WaitForEncodedFrame(1);
|
|
|
|
@ -3385,7 +3443,8 @@ TEST_F(VideoStreamEncoderTest,
|
|
|
|
|
hardware_options.high_encode_usage_threshold_percent = 200;
|
|
|
|
|
fake_encoder_.SetIsHardwareAccelerated(true);
|
|
|
|
|
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
video_source_.IncomingCapturedFrame(
|
|
|
|
|
CreateFrame(1, kFrameWidth, kFrameHeight));
|
|
|
|
|
WaitForEncodedFrame(1);
|
|
|
|
@ -3405,7 +3464,8 @@ TEST_F(VideoStreamEncoderTest, DropsFramesWhenEncoderOvershoots) {
|
|
|
|
|
const int kTargetBitrateBps = 120000;
|
|
|
|
|
const int kNumFramesInRun = kFps * 5; // Runs of five seconds.
|
|
|
|
|
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
int64_t timestamp_ms = fake_clock_.TimeNanos() / rtc::kNumNanosecsPerMillisec;
|
|
|
|
|
max_framerate_ = kFps;
|
|
|
|
@ -3439,7 +3499,8 @@ TEST_F(VideoStreamEncoderTest, DropsFramesWhenEncoderOvershoots) {
|
|
|
|
|
overshoot_factor *= 2;
|
|
|
|
|
}
|
|
|
|
|
fake_encoder_.SimulateOvershoot(overshoot_factor);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps + 1000, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(
|
|
|
|
|
DataRate::bps(kTargetBitrateBps + 1000), DataRate::Zero(), 0, 0);
|
|
|
|
|
num_dropped = 0;
|
|
|
|
|
for (int i = 0; i < kNumFramesInRun; ++i) {
|
|
|
|
|
video_source_.IncomingCapturedFrame(
|
|
|
|
@ -3451,7 +3512,8 @@ TEST_F(VideoStreamEncoderTest, DropsFramesWhenEncoderOvershoots) {
|
|
|
|
|
timestamp_ms += 1000 / kFps;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
// Target framerate should be still be near the expected target, despite
|
|
|
|
|
// the frame drops.
|
|
|
|
@ -3473,7 +3535,8 @@ TEST_F(VideoStreamEncoderTest, ConfiguresCorrectFrameRate) {
|
|
|
|
|
|
|
|
|
|
int64_t timestamp_ms = fake_clock_.TimeNanos() / rtc::kNumNanosecsPerMillisec;
|
|
|
|
|
max_framerate_ = kActualInputFps;
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
// Insert 3 seconds of video, with an input fps lower than configured max.
|
|
|
|
|
for (int i = 0; i < kActualInputFps * 3; ++i) {
|
|
|
|
@ -3491,7 +3554,8 @@ TEST_F(VideoStreamEncoderTest, ConfiguresCorrectFrameRate) {
|
|
|
|
|
|
|
|
|
|
TEST_F(VideoStreamEncoderTest, AccumulatesUpdateRectOnDroppedFrames) {
|
|
|
|
|
VideoFrame::UpdateRect rect;
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
fake_encoder_.BlockNextEncode();
|
|
|
|
|
video_source_.IncomingCapturedFrame(
|
|
|
|
@ -3534,7 +3598,8 @@ TEST_F(VideoStreamEncoderTest, AccumulatesUpdateRectOnDroppedFrames) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(VideoStreamEncoderTest, SetsFrameTypes) {
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
// First frame is always keyframe.
|
|
|
|
|
video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr));
|
|
|
|
@ -3561,7 +3626,8 @@ TEST_F(VideoStreamEncoderTest, SetsFrameTypes) {
|
|
|
|
|
TEST_F(VideoStreamEncoderTest, SetsFrameTypesSimulcast) {
|
|
|
|
|
// Setup simulcast with three streams.
|
|
|
|
|
ResetEncoder("VP8", 3, 1, 1, false);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kSimulcastTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(
|
|
|
|
|
DataRate::bps(kSimulcastTargetBitrateBps), DataRate::Zero(), 0, 0);
|
|
|
|
|
// Wait for all three layers before triggering event.
|
|
|
|
|
sink_.SetNumExpectedLayers(3);
|
|
|
|
|
|
|
|
|
@ -3595,7 +3661,8 @@ TEST_F(VideoStreamEncoderTest, RequestKeyframeInternalSource) {
|
|
|
|
|
// Configure internal source factory and setup test again.
|
|
|
|
|
encoder_factory_.SetHasInternalSource(true);
|
|
|
|
|
ResetEncoder("VP8", 1, 1, 1, false);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
// Call encoder directly, simulating internal source where encoded frame
|
|
|
|
|
// callback in VideoStreamEncoder is called despite no OnFrame().
|
|
|
|
@ -3627,7 +3694,8 @@ TEST_F(VideoStreamEncoderTest, AdjustsTimestampInternalSource) {
|
|
|
|
|
// Configure internal source factory and setup test again.
|
|
|
|
|
encoder_factory_.SetHasInternalSource(true);
|
|
|
|
|
ResetEncoder("VP8", 1, 1, 1, false);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
|
|
|
|
|
video_stream_encoder_->OnBitrateUpdated(DataRate::bps(kTargetBitrateBps),
|
|
|
|
|
DataRate::Zero(), 0, 0);
|
|
|
|
|
|
|
|
|
|
int64_t timestamp = 1;
|
|
|
|
|
EncodedImage image;
|
|
|
|
|