OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 video_source_.IncomingCapturedFrame(CreateFrame(3, nullptr)); | 279 video_source_.IncomingCapturedFrame(CreateFrame(3, nullptr)); |
280 fake_encoder_.ContinueEncode(); | 280 fake_encoder_.ContinueEncode(); |
281 sink_.WaitForEncodedFrame(3); | 281 sink_.WaitForEncodedFrame(3); |
282 | 282 |
283 vie_encoder_->Stop(); | 283 vie_encoder_->Stop(); |
284 } | 284 } |
285 | 285 |
286 TEST_F(ViEEncoderTest, ConfigureEncoderTriggersOnEncoderConfigurationChanged) { | 286 TEST_F(ViEEncoderTest, ConfigureEncoderTriggersOnEncoderConfigurationChanged) { |
287 const int kTargetBitrateBps = 100000; | 287 const int kTargetBitrateBps = 100000; |
288 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); | 288 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
| 289 EXPECT_EQ(0, sink_.number_of_reconfigurations()); |
289 | 290 |
290 // Capture a frame and wait for it to synchronize with the encoder thread. | 291 // Capture a frame and wait for it to synchronize with the encoder thread. |
291 video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr)); | 292 video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr)); |
292 sink_.WaitForEncodedFrame(1); | 293 sink_.WaitForEncodedFrame(1); |
293 // The encoder will have been configured twice. First time before the first | 294 // The encoder will have been configured once when the first frame is |
294 // frame has been received. Then a second time when the resolution is known. | 295 // received. |
295 EXPECT_EQ(2, sink_.number_of_reconfigurations()); | 296 EXPECT_EQ(1, sink_.number_of_reconfigurations()); |
296 | 297 |
297 VideoEncoderConfig video_encoder_config; | 298 VideoEncoderConfig video_encoder_config; |
298 test::FillEncoderConfiguration(1, &video_encoder_config); | 299 test::FillEncoderConfiguration(1, &video_encoder_config); |
299 video_encoder_config.min_transmit_bitrate_bps = 9999; | 300 video_encoder_config.min_transmit_bitrate_bps = 9999; |
300 vie_encoder_->ConfigureEncoder(std::move(video_encoder_config), 1440); | 301 vie_encoder_->ConfigureEncoder(std::move(video_encoder_config), 1440); |
301 | 302 |
302 // Capture a frame and wait for it to synchronize with the encoder thread. | 303 // Capture a frame and wait for it to synchronize with the encoder thread. |
303 video_source_.IncomingCapturedFrame(CreateFrame(2, nullptr)); | 304 video_source_.IncomingCapturedFrame(CreateFrame(2, nullptr)); |
304 sink_.WaitForEncodedFrame(2); | 305 sink_.WaitForEncodedFrame(2); |
305 EXPECT_EQ(3, sink_.number_of_reconfigurations()); | 306 EXPECT_EQ(2, sink_.number_of_reconfigurations()); |
306 EXPECT_EQ(9999, sink_.last_min_transmit_bitrate()); | 307 EXPECT_EQ(9999, sink_.last_min_transmit_bitrate()); |
307 | 308 |
308 vie_encoder_->Stop(); | 309 vie_encoder_->Stop(); |
309 } | 310 } |
310 | 311 |
311 TEST_F(ViEEncoderTest, FrameResolutionChangeReconfigureEncoder) { | 312 TEST_F(ViEEncoderTest, FrameResolutionChangeReconfigureEncoder) { |
312 const int kTargetBitrateBps = 100000; | 313 const int kTargetBitrateBps = 100000; |
313 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); | 314 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
314 | 315 |
315 // Capture a frame and wait for it to synchronize with the encoder thread. | 316 // Capture a frame and wait for it to synchronize with the encoder thread. |
316 video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr)); | 317 video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr)); |
317 sink_.WaitForEncodedFrame(1); | 318 sink_.WaitForEncodedFrame(1); |
318 // The encoder will have been configured twice. First time before the first | 319 // The encoder will have been configured once. |
319 // frame has been received. Then a second time when the resolution is known. | 320 EXPECT_EQ(1, sink_.number_of_reconfigurations()); |
320 EXPECT_EQ(2, sink_.number_of_reconfigurations()); | |
321 EXPECT_EQ(codec_width_, fake_encoder_.codec_config().width); | 321 EXPECT_EQ(codec_width_, fake_encoder_.codec_config().width); |
322 EXPECT_EQ(codec_height_, fake_encoder_.codec_config().height); | 322 EXPECT_EQ(codec_height_, fake_encoder_.codec_config().height); |
323 | 323 |
324 codec_width_ *= 2; | 324 codec_width_ *= 2; |
325 codec_height_ *= 2; | 325 codec_height_ *= 2; |
326 // Capture a frame with a higher resolution and wait for it to synchronize | 326 // Capture a frame with a higher resolution and wait for it to synchronize |
327 // with the encoder thread. | 327 // with the encoder thread. |
328 video_source_.IncomingCapturedFrame(CreateFrame(2, nullptr)); | 328 video_source_.IncomingCapturedFrame(CreateFrame(2, nullptr)); |
329 sink_.WaitForEncodedFrame(2); | 329 sink_.WaitForEncodedFrame(2); |
330 EXPECT_EQ(codec_width_, fake_encoder_.codec_config().width); | 330 EXPECT_EQ(codec_width_, fake_encoder_.codec_config().width); |
331 EXPECT_EQ(codec_height_, fake_encoder_.codec_config().height); | 331 EXPECT_EQ(codec_height_, fake_encoder_.codec_config().height); |
332 EXPECT_EQ(3, sink_.number_of_reconfigurations()); | 332 EXPECT_EQ(2, sink_.number_of_reconfigurations()); |
333 | 333 |
334 vie_encoder_->Stop(); | 334 vie_encoder_->Stop(); |
335 } | 335 } |
336 | 336 |
337 } // namespace webrtc | 337 } // namespace webrtc |
OLD | NEW |