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

Side by Side Diff: webrtc/media/engine/webrtcvideoengine2_unittest.cc

Issue 2455063002: Change ViEEncoder to not reconfigure the encoder until the video resolution is known. (Closed)
Patch Set: Fix test UseExternalFactoryForVp8WhenSupported. 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 | « no previous file | webrtc/video/video_send_stream_tests.cc » ('j') | 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) 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2004 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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 337 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
338 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); 338 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8");
339 cricket::VideoSendParameters parameters; 339 cricket::VideoSendParameters parameters;
340 parameters.codecs.push_back(kVp8Codec); 340 parameters.codecs.push_back(kVp8Codec);
341 341
342 std::unique_ptr<VideoMediaChannel> channel( 342 std::unique_ptr<VideoMediaChannel> channel(
343 SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs)); 343 SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs));
344 344
345 EXPECT_TRUE( 345 EXPECT_TRUE(
346 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); 346 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc)));
347 ASSERT_TRUE(encoder_factory.WaitForCreatedVideoEncoders(1)); 347 EXPECT_EQ(0, encoder_factory.GetNumCreatedEncoders());
348 ASSERT_EQ(1u, encoder_factory.encoders().size());
349 EXPECT_TRUE(channel->SetSend(true)); 348 EXPECT_TRUE(channel->SetSend(true));
350
351 cricket::FakeVideoCapturer capturer; 349 cricket::FakeVideoCapturer capturer;
352 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, nullptr, &capturer)); 350 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, nullptr, &capturer));
353 EXPECT_EQ(cricket::CS_RUNNING, 351 EXPECT_EQ(cricket::CS_RUNNING,
354 capturer.Start(capturer.GetSupportedFormats()->front())); 352 capturer.Start(capturer.GetSupportedFormats()->front()));
355 EXPECT_TRUE(capturer.CaptureFrame()); 353 EXPECT_TRUE(capturer.CaptureFrame());
356 // Sending one frame will have reallocated the encoder since input size 354 // Sending one frame will have allocate the encoder.
357 // changes from a small default to the actual frame width/height. Wait for 355 ASSERT_TRUE(encoder_factory.WaitForCreatedVideoEncoders(1));
358 // that to happen then for the frame to be sent.
359 ASSERT_TRUE(encoder_factory.WaitForCreatedVideoEncoders(2));
360 EXPECT_TRUE_WAIT(encoder_factory.encoders()[0]->GetNumEncodedFrames() > 0, 356 EXPECT_TRUE_WAIT(encoder_factory.encoders()[0]->GetNumEncodedFrames() > 0,
361 kTimeout); 357 kTimeout);
362 358
363 int num_created_encoders = encoder_factory.GetNumCreatedEncoders(); 359 int num_created_encoders = encoder_factory.GetNumCreatedEncoders();
364 EXPECT_EQ(num_created_encoders, 2); 360 EXPECT_EQ(num_created_encoders, 1);
365 361
366 // Setting codecs of the same type should not reallocate any encoders 362 // Setting codecs of the same type should not reallocate any encoders
367 // (expecting a no-op). 363 // (expecting a no-op).
368 EXPECT_TRUE(channel->SetSendParameters(parameters)); 364 EXPECT_TRUE(channel->SetSendParameters(parameters));
369 EXPECT_EQ(num_created_encoders, encoder_factory.GetNumCreatedEncoders()); 365 EXPECT_EQ(num_created_encoders, encoder_factory.GetNumCreatedEncoders());
370 366
371 // Remove stream previously added to free the external encoder instance. 367 // Remove stream previously added to free the external encoder instance.
372 EXPECT_TRUE(channel->RemoveSendStream(kSsrc)); 368 EXPECT_TRUE(channel->RemoveSendStream(kSsrc));
373 EXPECT_EQ(0u, encoder_factory.encoders().size()); 369 EXPECT_EQ(0u, encoder_factory.encoders().size());
374 } 370 }
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 658
663 std::vector<cricket::VideoCodec> codecs; 659 std::vector<cricket::VideoCodec> codecs;
664 codecs.push_back(kH264Codec); 660 codecs.push_back(kH264Codec);
665 661
666 std::unique_ptr<VideoMediaChannel> channel( 662 std::unique_ptr<VideoMediaChannel> channel(
667 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); 663 SetUpForExternalEncoderFactory(&encoder_factory, codecs));
668 664
669 EXPECT_TRUE( 665 EXPECT_TRUE(
670 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); 666 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc)));
671 ASSERT_EQ(1u, encoder_factory.encoders().size()); 667 ASSERT_EQ(1u, encoder_factory.encoders().size());
668
669 // Send a frame of 720p. This should trigger a "real" encoder initialization.
670 cricket::VideoFormat format(
671 1280, 720, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420);
672 cricket::FakeVideoCapturer capturer;
673 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, nullptr, &capturer));
674 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(format));
675 EXPECT_TRUE(capturer.CaptureFrame());
672 ASSERT_TRUE(encoder_factory.encoders()[0]->WaitForInitEncode()); 676 ASSERT_TRUE(encoder_factory.encoders()[0]->WaitForInitEncode());
673 EXPECT_EQ(webrtc::kVideoCodecH264, 677 EXPECT_EQ(webrtc::kVideoCodecH264,
674 encoder_factory.encoders()[0]->GetCodecSettings().codecType); 678 encoder_factory.encoders()[0]->GetCodecSettings().codecType);
675 679
676 channel.reset(); 680 channel.reset();
677 // Make sure DestroyVideoEncoder was called on the factory. 681 // Make sure DestroyVideoEncoder was called on the factory.
678 ASSERT_EQ(0u, encoder_factory.encoders().size()); 682 ASSERT_EQ(0u, encoder_factory.encoders().size());
679 } 683 }
680 684
681 TEST_F(WebRtcVideoEngine2Test, SimulcastDisabledForH264) { 685 TEST_F(WebRtcVideoEngine2Test, SimulcastDisabledForH264) {
(...skipping 3154 matching lines...) Expand 10 before | Expand all | Expand 10 after
3836 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith3SimulcastStreams) { 3840 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith3SimulcastStreams) {
3837 VerifySimulcastSettings(kVp8Codec, 1280, 720, 3, 3); 3841 VerifySimulcastSettings(kVp8Codec, 1280, 720, 3, 3);
3838 } 3842 }
3839 3843
3840 // Test that we normalize send codec format size in simulcast. 3844 // Test that we normalize send codec format size in simulcast.
3841 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { 3845 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) {
3842 cricket::VideoCodec codec(kVp8Codec); 3846 cricket::VideoCodec codec(kVp8Codec);
3843 VerifySimulcastSettings(codec, 541, 271, 2, 2); 3847 VerifySimulcastSettings(codec, 541, 271, 2, 2);
3844 } 3848 }
3845 } // namespace cricket 3849 } // namespace cricket
OLDNEW
« no previous file with comments | « no previous file | webrtc/video/video_send_stream_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698