OLD | NEW |
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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 new_bitrate_kbps * 1000, settings_.maxFramerate); | 309 new_bitrate_kbps * 1000, settings_.maxFramerate); |
310 EXPECT_CALL(encoder_, | 310 EXPECT_CALL(encoder_, |
311 SetRateAllocation(new_rate_allocation, settings_.maxFramerate)) | 311 SetRateAllocation(new_rate_allocation, settings_.maxFramerate)) |
312 .Times(1) | 312 .Times(1) |
313 .WillOnce(Return(0)); | 313 .WillOnce(Return(0)); |
314 sender_->SetChannelParameters(new_bitrate_kbps * 1000, 0, 200, | 314 sender_->SetChannelParameters(new_bitrate_kbps * 1000, 0, 200, |
315 rate_allocator_.get(), nullptr); | 315 rate_allocator_.get(), nullptr); |
316 AddFrame(); | 316 AddFrame(); |
317 clock_.AdvanceTimeMilliseconds(kFrameIntervalMs); | 317 clock_.AdvanceTimeMilliseconds(kFrameIntervalMs); |
318 | 318 |
319 // Add enough frames so that input frame rate will be updated. | |
320 const int kFramesToSend = | |
321 (VCMProcessTimer::kDefaultProcessIntervalMs / kFrameIntervalMs) + 1; | |
322 for (int i = 0; i < kFramesToSend; ++i) { | |
323 AddFrame(); | |
324 clock_.AdvanceTimeMilliseconds(kFrameIntervalMs); | |
325 } | |
326 | |
327 EXPECT_CALL(encoder_, | |
328 SetRateAllocation(new_rate_allocation, kActualFrameRate)) | |
329 .Times(1) | |
330 .WillOnce(Return(0)); | |
331 | |
332 sender_->Process(); | |
333 AddFrame(); | |
334 | |
335 // Expect no call to encoder_.SetRates if the new bitrate is zero. | 319 // Expect no call to encoder_.SetRates if the new bitrate is zero. |
336 EXPECT_CALL(encoder_, SetRateAllocation(_, _)).Times(0); | 320 EXPECT_CALL(encoder_, SetRateAllocation(_, _)).Times(0); |
337 sender_->SetChannelParameters(0, 0, 200, rate_allocator_.get(), nullptr); | 321 sender_->SetChannelParameters(0, 0, 200, rate_allocator_.get(), nullptr); |
338 AddFrame(); | 322 AddFrame(); |
339 } | 323 } |
340 | 324 |
341 TEST_F(TestVideoSenderWithMockEncoder, TestIntraRequestsInternalCapture) { | 325 TEST_F(TestVideoSenderWithMockEncoder, TestIntraRequestsInternalCapture) { |
342 // De-register current external encoder. | 326 // De-register current external encoder. |
343 sender_->RegisterExternalEncoder(nullptr, kUnusedPayloadType, false); | 327 sender_->RegisterExternalEncoder(nullptr, kUnusedPayloadType, false); |
344 // Register encoder with internal capture. | 328 // Register encoder with internal capture. |
(...skipping 23 matching lines...) Expand all Loading... |
368 const uint32_t new_bitrate_kbps = settings_.startBitrate + 300; | 352 const uint32_t new_bitrate_kbps = settings_.startBitrate + 300; |
369 BitrateAllocation new_rate_allocation = rate_allocator_->GetAllocation( | 353 BitrateAllocation new_rate_allocation = rate_allocator_->GetAllocation( |
370 new_bitrate_kbps * 1000, settings_.maxFramerate); | 354 new_bitrate_kbps * 1000, settings_.maxFramerate); |
371 EXPECT_CALL(encoder_, SetRateAllocation(new_rate_allocation, _)) | 355 EXPECT_CALL(encoder_, SetRateAllocation(new_rate_allocation, _)) |
372 .Times(1) | 356 .Times(1) |
373 .WillOnce(Return(0)); | 357 .WillOnce(Return(0)); |
374 sender_->SetChannelParameters(new_bitrate_kbps * 1000, 0, 200, | 358 sender_->SetChannelParameters(new_bitrate_kbps * 1000, 0, 200, |
375 rate_allocator_.get(), nullptr); | 359 rate_allocator_.get(), nullptr); |
376 } | 360 } |
377 | 361 |
378 TEST_F(TestVideoSenderWithMockEncoder, EncoderFramerateUpdatedViaProcess) { | |
379 sender_->SetChannelParameters(settings_.startBitrate * 1000, 0, 200, | |
380 rate_allocator_.get(), nullptr); | |
381 const int64_t kRateStatsWindowMs = 2000; | |
382 const uint32_t kInputFps = 20; | |
383 int64_t start_time = clock_.TimeInMilliseconds(); | |
384 while (clock_.TimeInMilliseconds() < start_time + kRateStatsWindowMs) { | |
385 AddFrame(); | |
386 clock_.AdvanceTimeMilliseconds(1000 / kInputFps); | |
387 } | |
388 EXPECT_CALL(encoder_, SetRateAllocation(_, kInputFps)) | |
389 .Times(1) | |
390 .WillOnce(Return(0)); | |
391 sender_->Process(); | |
392 AddFrame(); | |
393 } | |
394 | |
395 TEST_F(TestVideoSenderWithMockEncoder, | 362 TEST_F(TestVideoSenderWithMockEncoder, |
396 NoRedundantSetChannelParameterOrSetRatesCalls) { | 363 NoRedundantSetChannelParameterOrSetRatesCalls) { |
397 const uint8_t kLossRate = 4; | 364 const uint8_t kLossRate = 4; |
398 const uint8_t kRtt = 200; | 365 const uint8_t kRtt = 200; |
399 const int64_t kRateStatsWindowMs = 2000; | 366 const int64_t kRateStatsWindowMs = 2000; |
400 const uint32_t kInputFps = 20; | 367 const uint32_t kInputFps = 20; |
401 int64_t start_time = clock_.TimeInMilliseconds(); | 368 int64_t start_time = clock_.TimeInMilliseconds(); |
402 // Expect initial call to SetChannelParameters. Rates are initialized through | 369 // Expect initial call to SetChannelParameters. Rates are initialized through |
403 // InitEncode and expects no additional call before the framerate (or bitrate) | 370 // InitEncode and expects no additional call before the framerate (or bitrate) |
404 // updates. | 371 // updates. |
405 EXPECT_CALL(encoder_, SetChannelParameters(kLossRate, kRtt)) | 372 EXPECT_CALL(encoder_, SetChannelParameters(kLossRate, kRtt)) |
406 .Times(1) | 373 .Times(1) |
407 .WillOnce(Return(0)); | 374 .WillOnce(Return(0)); |
408 sender_->SetChannelParameters(settings_.startBitrate * 1000, kLossRate, kRtt, | 375 sender_->SetChannelParameters(settings_.startBitrate * 1000, kLossRate, kRtt, |
409 rate_allocator_.get(), nullptr); | 376 rate_allocator_.get(), nullptr); |
410 while (clock_.TimeInMilliseconds() < start_time + kRateStatsWindowMs) { | 377 while (clock_.TimeInMilliseconds() < start_time + kRateStatsWindowMs) { |
411 AddFrame(); | 378 AddFrame(); |
412 clock_.AdvanceTimeMilliseconds(1000 / kInputFps); | 379 clock_.AdvanceTimeMilliseconds(1000 / kInputFps); |
413 } | 380 } |
414 // After process, input framerate should be updated but not ChannelParameters | 381 |
415 // as they are the same as before. | |
416 EXPECT_CALL(encoder_, SetRateAllocation(_, kInputFps)) | |
417 .Times(1) | |
418 .WillOnce(Return(0)); | |
419 sender_->Process(); | |
420 AddFrame(); | |
421 // Call to SetChannelParameters with changed bitrate should call encoder | 382 // Call to SetChannelParameters with changed bitrate should call encoder |
422 // SetRates but not encoder SetChannelParameters (that are unchanged). | 383 // SetRates but not encoder SetChannelParameters (that are unchanged). |
423 uint32_t new_bitrate_bps = 2 * settings_.startBitrate * 1000; | 384 uint32_t new_bitrate_bps = 2 * settings_.startBitrate * 1000; |
424 BitrateAllocation new_rate_allocation = | 385 BitrateAllocation new_rate_allocation = |
425 rate_allocator_->GetAllocation(new_bitrate_bps, kInputFps); | 386 rate_allocator_->GetAllocation(new_bitrate_bps, kInputFps); |
426 EXPECT_CALL(encoder_, SetRateAllocation(new_rate_allocation, kInputFps)) | 387 EXPECT_CALL(encoder_, SetRateAllocation(new_rate_allocation, kInputFps)) |
427 .Times(1) | 388 .Times(1) |
428 .WillOnce(Return(0)); | 389 .WillOnce(Return(0)); |
429 sender_->SetChannelParameters(new_bitrate_bps, kLossRate, kRtt, | 390 sender_->SetChannelParameters(new_bitrate_bps, kLossRate, kRtt, |
430 rate_allocator_.get(), nullptr); | 391 rate_allocator_.get(), nullptr); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 } | 528 } |
568 { | 529 { |
569 // TODO(andresp): Find out why this fails with framerate = 7.5 | 530 // TODO(andresp): Find out why this fails with framerate = 7.5 |
570 Vp8StreamInfo expected = {{7.0, 7.0, 7.0}, {high_b, high_b, high_b}}; | 531 Vp8StreamInfo expected = {{7.0, 7.0, 7.0}, {high_b, high_b, high_b}}; |
571 EXPECT_THAT(SimulateWithFramerate(7.0), MatchesVp8StreamInfo(expected)); | 532 EXPECT_THAT(SimulateWithFramerate(7.0), MatchesVp8StreamInfo(expected)); |
572 } | 533 } |
573 } | 534 } |
574 } // namespace | 535 } // namespace |
575 } // namespace vcm | 536 } // namespace vcm |
576 } // namespace webrtc | 537 } // namespace webrtc |
OLD | NEW |