| 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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 EXPECT_EQ(0, sender_->IntraFrameRequest(0)); | 307 EXPECT_EQ(0, sender_->IntraFrameRequest(0)); |
| 308 ExpectIntraRequest(1); | 308 ExpectIntraRequest(1); |
| 309 EXPECT_EQ(0, sender_->IntraFrameRequest(1)); | 309 EXPECT_EQ(0, sender_->IntraFrameRequest(1)); |
| 310 ExpectIntraRequest(2); | 310 ExpectIntraRequest(2); |
| 311 EXPECT_EQ(0, sender_->IntraFrameRequest(2)); | 311 EXPECT_EQ(0, sender_->IntraFrameRequest(2)); |
| 312 // No requests expected since these indices are out of bounds. | 312 // No requests expected since these indices are out of bounds. |
| 313 EXPECT_EQ(-1, sender_->IntraFrameRequest(3)); | 313 EXPECT_EQ(-1, sender_->IntraFrameRequest(3)); |
| 314 EXPECT_EQ(-1, sender_->IntraFrameRequest(-1)); | 314 EXPECT_EQ(-1, sender_->IntraFrameRequest(-1)); |
| 315 } | 315 } |
| 316 | 316 |
| 317 TEST_F(TestVideoSenderWithMockEncoder, EncoderFramerateUpdatedViaProcess) { |
| 318 sender_->SetChannelParameters(settings_.startBitrate, 0, 200); |
| 319 const int64_t kRateStatsWindowMs = 2000; |
| 320 const uint32_t kInputFps = 20; |
| 321 int64_t start_time = clock_.TimeInMilliseconds(); |
| 322 while (clock_.TimeInMilliseconds() < start_time + kRateStatsWindowMs) { |
| 323 AddFrame(); |
| 324 clock_.AdvanceTimeMilliseconds(1000 / kInputFps); |
| 325 } |
| 326 EXPECT_CALL(encoder_, SetRates(_, kInputFps)).Times(1).WillOnce(Return(0)); |
| 327 sender_->Process(); |
| 328 AddFrame(); |
| 329 } |
| 330 |
| 317 class TestVideoSenderWithVp8 : public TestVideoSender { | 331 class TestVideoSenderWithVp8 : public TestVideoSender { |
| 318 public: | 332 public: |
| 319 TestVideoSenderWithVp8() | 333 TestVideoSenderWithVp8() |
| 320 : codec_bitrate_kbps_(300), available_bitrate_kbps_(1000) {} | 334 : codec_bitrate_kbps_(300), available_bitrate_kbps_(1000) {} |
| 321 | 335 |
| 322 void SetUp() override { | 336 void SetUp() override { |
| 323 TestVideoSender::SetUp(); | 337 TestVideoSender::SetUp(); |
| 324 | 338 |
| 325 const char* input_video = "foreman_cif"; | 339 const char* input_video = "foreman_cif"; |
| 326 const int width = 352; | 340 const int width = 352; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 347 codec.codecSpecific.VP8.numberOfTemporalLayers = temporal_layers; | 361 codec.codecSpecific.VP8.numberOfTemporalLayers = temporal_layers; |
| 348 return codec; | 362 return codec; |
| 349 } | 363 } |
| 350 | 364 |
| 351 void InsertFrames(float framerate, float seconds) { | 365 void InsertFrames(float framerate, float seconds) { |
| 352 for (int i = 0; i < seconds * framerate; ++i) { | 366 for (int i = 0; i < seconds * framerate; ++i) { |
| 353 clock_.AdvanceTimeMilliseconds(1000.0f / framerate); | 367 clock_.AdvanceTimeMilliseconds(1000.0f / framerate); |
| 354 EXPECT_CALL(post_encode_callback_, Encoded(_, NULL, NULL)) | 368 EXPECT_CALL(post_encode_callback_, Encoded(_, NULL, NULL)) |
| 355 .WillOnce(Return(0)); | 369 .WillOnce(Return(0)); |
| 356 AddFrame(); | 370 AddFrame(); |
| 357 | |
| 358 // SetChannelParameters needs to be called frequently to propagate | 371 // SetChannelParameters needs to be called frequently to propagate |
| 359 // framerate from the media optimization into the encoder. | 372 // framerate from the media optimization into the encoder. |
| 360 // Note: SetChannelParameters fails if less than 2 frames are in the | 373 // Note: SetChannelParameters fails if less than 2 frames are in the |
| 361 // buffer since it will fail to calculate the framerate. | 374 // buffer since it will fail to calculate the framerate. |
| 362 if (i != 0) { | 375 if (i != 0) { |
| 363 EXPECT_EQ(VCM_OK, | 376 EXPECT_EQ(VCM_OK, sender_->SetChannelParameters( |
| 364 sender_->SetChannelParameters( | 377 available_bitrate_kbps_ * 1000, 0, 200)); |
| 365 available_bitrate_kbps_ * 1000, 0, 200)); | |
| 366 } | 378 } |
| 367 } | 379 } |
| 368 } | 380 } |
| 369 | 381 |
| 370 Vp8StreamInfo SimulateWithFramerate(float framerate) { | 382 Vp8StreamInfo SimulateWithFramerate(float framerate) { |
| 371 const float short_simulation_interval = 5.0; | 383 const float short_simulation_interval = 5.0; |
| 372 const float long_simulation_interval = 10.0; | 384 const float long_simulation_interval = 10.0; |
| 373 // It appears that this 5 seconds simulation is needed to allow | 385 // It appears that this 5 seconds simulation is needed to allow |
| 374 // bitrate and framerate to stabilize. | 386 // bitrate and framerate to stabilize. |
| 375 InsertFrames(framerate, short_simulation_interval); | 387 InsertFrames(framerate, short_simulation_interval); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 } | 446 } |
| 435 { | 447 { |
| 436 // TODO(andresp): Find out why this fails with framerate = 7.5 | 448 // TODO(andresp): Find out why this fails with framerate = 7.5 |
| 437 Vp8StreamInfo expected = {{7.0, 7.0, 7.0}, {high_b, high_b, high_b}}; | 449 Vp8StreamInfo expected = {{7.0, 7.0, 7.0}, {high_b, high_b, high_b}}; |
| 438 EXPECT_THAT(SimulateWithFramerate(7.0), MatchesVp8StreamInfo(expected)); | 450 EXPECT_THAT(SimulateWithFramerate(7.0), MatchesVp8StreamInfo(expected)); |
| 439 } | 451 } |
| 440 } | 452 } |
| 441 } // namespace | 453 } // namespace |
| 442 } // namespace vcm | 454 } // namespace vcm |
| 443 } // namespace webrtc | 455 } // namespace webrtc |
| OLD | NEW |