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

Side by Side Diff: webrtc/modules/video_coding/main/source/video_sender_unittest.cc

Issue 1426953003: Remove redudant encoder rate calls. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: remove redundant function Created 5 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 ExpectIntraRequest(1); 311 ExpectIntraRequest(1);
312 EXPECT_EQ(0, sender_->IntraFrameRequest(1)); 312 EXPECT_EQ(0, sender_->IntraFrameRequest(1));
313 ExpectIntraRequest(2); 313 ExpectIntraRequest(2);
314 EXPECT_EQ(0, sender_->IntraFrameRequest(2)); 314 EXPECT_EQ(0, sender_->IntraFrameRequest(2));
315 // No requests expected since these indices are out of bounds. 315 // No requests expected since these indices are out of bounds.
316 EXPECT_EQ(-1, sender_->IntraFrameRequest(3)); 316 EXPECT_EQ(-1, sender_->IntraFrameRequest(3));
317 EXPECT_EQ(-1, sender_->IntraFrameRequest(-1)); 317 EXPECT_EQ(-1, sender_->IntraFrameRequest(-1));
318 } 318 }
319 319
320 TEST_F(TestVideoSenderWithMockEncoder, EncoderFramerateUpdatedViaProcess) { 320 TEST_F(TestVideoSenderWithMockEncoder, EncoderFramerateUpdatedViaProcess) {
321 sender_->SetChannelParameters(settings_.startBitrate, 0, 200); 321 sender_->SetChannelParameters(settings_.startBitrate * 1000, 0, 200);
322 const int64_t kRateStatsWindowMs = 2000; 322 const int64_t kRateStatsWindowMs = 2000;
323 const uint32_t kInputFps = 20; 323 const uint32_t kInputFps = 20;
324 int64_t start_time = clock_.TimeInMilliseconds(); 324 int64_t start_time = clock_.TimeInMilliseconds();
325 while (clock_.TimeInMilliseconds() < start_time + kRateStatsWindowMs) { 325 while (clock_.TimeInMilliseconds() < start_time + kRateStatsWindowMs) {
326 AddFrame(); 326 AddFrame();
327 clock_.AdvanceTimeMilliseconds(1000 / kInputFps); 327 clock_.AdvanceTimeMilliseconds(1000 / kInputFps);
328 } 328 }
329 EXPECT_CALL(encoder_, SetRates(_, kInputFps)).Times(1).WillOnce(Return(0)); 329 EXPECT_CALL(encoder_, SetRates(_, kInputFps)).Times(1).WillOnce(Return(0));
330 sender_->Process(); 330 sender_->Process();
331 AddFrame(); 331 AddFrame();
332 } 332 }
333 333
334 TEST_F(TestVideoSenderWithMockEncoder,
335 NoRedundantSetChannelParameterOrSetRatesCalls) {
336 const uint8_t kLossRate = 4;
337 const uint8_t kRtt = 200;
338 const int64_t kRateStatsWindowMs = 2000;
339 const uint32_t kInputFps = 20;
340 int64_t start_time = clock_.TimeInMilliseconds();
341 // Expect initial call to SetChannelParameters. Rates are initialized through
342 // InitEncode and expects no additional call before the framerate (or bitrate)
343 // updates.
344 EXPECT_CALL(encoder_, SetChannelParameters(kLossRate, kRtt))
345 .Times(1)
346 .WillOnce(Return(0));
347 sender_->SetChannelParameters(settings_.startBitrate * 1000, kLossRate, kRtt);
348 while (clock_.TimeInMilliseconds() < start_time + kRateStatsWindowMs) {
349 AddFrame();
350 clock_.AdvanceTimeMilliseconds(1000 / kInputFps);
351 }
352 // After process, input framerate should be updated but not ChannelParameters
353 // as they are the same as before.
354 EXPECT_CALL(encoder_, SetRates(_, kInputFps)).Times(1).WillOnce(Return(0));
355 sender_->Process();
356 AddFrame();
357 // Call to SetChannelParameters with changed bitrate should call encoder
358 // SetRates but not encoder SetChannelParameters (that are unchanged).
359 EXPECT_CALL(encoder_, SetRates(2 * settings_.startBitrate, kInputFps))
360 .Times(1)
361 .WillOnce(Return(0));
362 sender_->SetChannelParameters(2 * settings_.startBitrate * 1000, kLossRate,
363 kRtt);
364 AddFrame();
365 }
366
334 class TestVideoSenderWithVp8 : public TestVideoSender { 367 class TestVideoSenderWithVp8 : public TestVideoSender {
335 public: 368 public:
336 TestVideoSenderWithVp8() 369 TestVideoSenderWithVp8()
337 : codec_bitrate_kbps_(300), available_bitrate_kbps_(1000) {} 370 : codec_bitrate_kbps_(300), available_bitrate_kbps_(1000) {}
338 371
339 void SetUp() override { 372 void SetUp() override {
340 TestVideoSender::SetUp(); 373 TestVideoSender::SetUp();
341 374
342 const char* input_video = "foreman_cif"; 375 const char* input_video = "foreman_cif";
343 const int width = 352; 376 const int width = 352;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 } 485 }
453 { 486 {
454 // TODO(andresp): Find out why this fails with framerate = 7.5 487 // TODO(andresp): Find out why this fails with framerate = 7.5
455 Vp8StreamInfo expected = {{7.0, 7.0, 7.0}, {high_b, high_b, high_b}}; 488 Vp8StreamInfo expected = {{7.0, 7.0, 7.0}, {high_b, high_b, high_b}};
456 EXPECT_THAT(SimulateWithFramerate(7.0), MatchesVp8StreamInfo(expected)); 489 EXPECT_THAT(SimulateWithFramerate(7.0), MatchesVp8StreamInfo(expected));
457 } 490 }
458 } 491 }
459 } // namespace 492 } // namespace
460 } // namespace vcm 493 } // namespace vcm
461 } // namespace webrtc 494 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/main/source/video_sender.cc ('k') | webrtc/test/configurable_frame_size_encoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698