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