Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(288)

Unified Diff: webrtc/modules/video_coding/video_sender_unittest.cc

Issue 2513383002: Initial rate allocation should not use fps = 0 (Closed)
Patch Set: nit Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/modules/video_coding/video_sender.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/video_coding/video_sender_unittest.cc
diff --git a/webrtc/modules/video_coding/video_sender_unittest.cc b/webrtc/modules/video_coding/video_sender_unittest.cc
index bda45521f62e15dd6bdd448a859d18cbb3ae076f..e24bbd758cc4bd823f6ac9fe3e1ab71deee2a24d 100644
--- a/webrtc/modules/video_coding/video_sender_unittest.cc
+++ b/webrtc/modules/video_coding/video_sender_unittest.cc
@@ -129,7 +129,7 @@ class EncodedImageCallbackImpl : public EncodedImageCallback {
private:
struct FrameData {
- FrameData() {}
+ FrameData() : payload_size(0) {}
FrameData(size_t payload_size, const CodecSpecificInfo& codec_specific_info)
: payload_size(payload_size),
@@ -299,15 +299,38 @@ TEST_F(TestVideoSenderWithMockEncoder, TestIntraRequests) {
}
TEST_F(TestVideoSenderWithMockEncoder, TestSetRate) {
+ // Let actual fps be half of max, so it can be distinguished from default.
+ const uint32_t kActualFrameRate = settings_.maxFramerate / 2;
+ const int64_t kFrameIntervalMs = 1000 / kActualFrameRate;
const uint32_t new_bitrate_kbps = settings_.startBitrate + 300;
+
+ // Initial frame rate is taken from config, as we have no data yet.
BitrateAllocation new_rate_allocation = rate_allocator_->GetAllocation(
new_bitrate_kbps * 1000, settings_.maxFramerate);
- EXPECT_CALL(encoder_, SetRateAllocation(new_rate_allocation, _))
+ EXPECT_CALL(encoder_,
+ SetRateAllocation(new_rate_allocation, settings_.maxFramerate))
.Times(1)
.WillOnce(Return(0));
sender_->SetChannelParameters(new_bitrate_kbps * 1000, 0, 200,
rate_allocator_.get());
AddFrame();
+ clock_.AdvanceTimeMilliseconds(kFrameIntervalMs);
+
+ // Add enough frames so that input frame rate will be updated.
+ const int kFramesToSend =
+ (VCMProcessTimer::kDefaultProcessIntervalMs / kFrameIntervalMs) + 1;
+ for (int i = 0; i < kFramesToSend; ++i) {
+ AddFrame();
+ clock_.AdvanceTimeMilliseconds(kFrameIntervalMs);
+ }
+
+ EXPECT_CALL(encoder_,
+ SetRateAllocation(new_rate_allocation, kActualFrameRate))
+ .Times(1)
+ .WillOnce(Return(0));
+
+ sender_->Process();
+ AddFrame();
// Expect no call to encoder_.SetRates if the new bitrate is zero.
EXPECT_CALL(encoder_, SetRateAllocation(_, _)).Times(0);
« no previous file with comments | « webrtc/modules/video_coding/video_sender.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698