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

Side by Side Diff: webrtc/video/vie_encoder_unittest.cc

Issue 2457203002: Revert of Reland Change ViEEncoder to not reconfigure the encoder until the video resolution is known. (Closed)
Patch Set: Created 4 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
« no previous file with comments | « webrtc/video/vie_encoder.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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());
290 289
291 // Capture a frame and wait for it to synchronize with the encoder thread. 290 // Capture a frame and wait for it to synchronize with the encoder thread.
292 video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr)); 291 video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr));
293 sink_.WaitForEncodedFrame(1); 292 sink_.WaitForEncodedFrame(1);
294 // The encoder will have been configured once when the first frame is 293 // The encoder will have been configured twice. First time before the first
295 // received. 294 // frame has been received. Then a second time when the resolution is known.
296 EXPECT_EQ(1, sink_.number_of_reconfigurations()); 295 EXPECT_EQ(2, sink_.number_of_reconfigurations());
297 296
298 VideoEncoderConfig video_encoder_config; 297 VideoEncoderConfig video_encoder_config;
299 test::FillEncoderConfiguration(1, &video_encoder_config); 298 test::FillEncoderConfiguration(1, &video_encoder_config);
300 video_encoder_config.min_transmit_bitrate_bps = 9999; 299 video_encoder_config.min_transmit_bitrate_bps = 9999;
301 vie_encoder_->ConfigureEncoder(std::move(video_encoder_config), 1440); 300 vie_encoder_->ConfigureEncoder(std::move(video_encoder_config), 1440);
302 301
303 // Capture a frame and wait for it to synchronize with the encoder thread. 302 // Capture a frame and wait for it to synchronize with the encoder thread.
304 video_source_.IncomingCapturedFrame(CreateFrame(2, nullptr)); 303 video_source_.IncomingCapturedFrame(CreateFrame(2, nullptr));
305 sink_.WaitForEncodedFrame(2); 304 sink_.WaitForEncodedFrame(2);
306 EXPECT_EQ(2, sink_.number_of_reconfigurations()); 305 EXPECT_EQ(3, sink_.number_of_reconfigurations());
307 EXPECT_EQ(9999, sink_.last_min_transmit_bitrate()); 306 EXPECT_EQ(9999, sink_.last_min_transmit_bitrate());
308 307
309 vie_encoder_->Stop(); 308 vie_encoder_->Stop();
310 } 309 }
311 310
312 TEST_F(ViEEncoderTest, FrameResolutionChangeReconfigureEncoder) { 311 TEST_F(ViEEncoderTest, FrameResolutionChangeReconfigureEncoder) {
313 const int kTargetBitrateBps = 100000; 312 const int kTargetBitrateBps = 100000;
314 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); 313 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
315 314
316 // Capture a frame and wait for it to synchronize with the encoder thread. 315 // Capture a frame and wait for it to synchronize with the encoder thread.
317 video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr)); 316 video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr));
318 sink_.WaitForEncodedFrame(1); 317 sink_.WaitForEncodedFrame(1);
319 // The encoder will have been configured once. 318 // The encoder will have been configured twice. First time before the first
320 EXPECT_EQ(1, sink_.number_of_reconfigurations()); 319 // frame has been received. Then a second time when the resolution is known.
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(2, sink_.number_of_reconfigurations()); 332 EXPECT_EQ(3, sink_.number_of_reconfigurations());
333 333
334 vie_encoder_->Stop(); 334 vie_encoder_->Stop();
335 } 335 }
336 336
337 } // namespace webrtc 337 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/vie_encoder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698