OLD | NEW |
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 Loading... |
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 EXPECT_EQ(0, encoder_factory.GetNumCreatedEncoders()); | 347 ASSERT_TRUE(encoder_factory.WaitForCreatedVideoEncoders(1)); |
| 348 ASSERT_EQ(1u, encoder_factory.encoders().size()); |
348 EXPECT_TRUE(channel->SetSend(true)); | 349 EXPECT_TRUE(channel->SetSend(true)); |
| 350 |
349 cricket::FakeVideoCapturer capturer; | 351 cricket::FakeVideoCapturer capturer; |
350 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, nullptr, &capturer)); | 352 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, nullptr, &capturer)); |
351 EXPECT_EQ(cricket::CS_RUNNING, | 353 EXPECT_EQ(cricket::CS_RUNNING, |
352 capturer.Start(capturer.GetSupportedFormats()->front())); | 354 capturer.Start(capturer.GetSupportedFormats()->front())); |
353 EXPECT_TRUE(capturer.CaptureFrame()); | 355 EXPECT_TRUE(capturer.CaptureFrame()); |
354 // Sending one frame will have allocate the encoder. | 356 // Sending one frame will have reallocated the encoder since input size |
355 ASSERT_TRUE(encoder_factory.WaitForCreatedVideoEncoders(1)); | 357 // changes from a small default to the actual frame width/height. Wait for |
| 358 // that to happen then for the frame to be sent. |
| 359 ASSERT_TRUE(encoder_factory.WaitForCreatedVideoEncoders(2)); |
356 EXPECT_TRUE_WAIT(encoder_factory.encoders()[0]->GetNumEncodedFrames() > 0, | 360 EXPECT_TRUE_WAIT(encoder_factory.encoders()[0]->GetNumEncodedFrames() > 0, |
357 kTimeout); | 361 kTimeout); |
358 | 362 |
359 int num_created_encoders = encoder_factory.GetNumCreatedEncoders(); | 363 int num_created_encoders = encoder_factory.GetNumCreatedEncoders(); |
360 EXPECT_EQ(num_created_encoders, 1); | 364 EXPECT_EQ(num_created_encoders, 2); |
361 | 365 |
362 // Setting codecs of the same type should not reallocate any encoders | 366 // Setting codecs of the same type should not reallocate any encoders |
363 // (expecting a no-op). | 367 // (expecting a no-op). |
364 EXPECT_TRUE(channel->SetSendParameters(parameters)); | 368 EXPECT_TRUE(channel->SetSendParameters(parameters)); |
365 EXPECT_EQ(num_created_encoders, encoder_factory.GetNumCreatedEncoders()); | 369 EXPECT_EQ(num_created_encoders, encoder_factory.GetNumCreatedEncoders()); |
366 | 370 |
367 // Remove stream previously added to free the external encoder instance. | 371 // Remove stream previously added to free the external encoder instance. |
368 EXPECT_TRUE(channel->RemoveSendStream(kSsrc)); | 372 EXPECT_TRUE(channel->RemoveSendStream(kSsrc)); |
369 EXPECT_EQ(0u, encoder_factory.encoders().size()); | 373 EXPECT_EQ(0u, encoder_factory.encoders().size()); |
370 } | 374 } |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 | 662 |
659 std::vector<cricket::VideoCodec> codecs; | 663 std::vector<cricket::VideoCodec> codecs; |
660 codecs.push_back(kH264Codec); | 664 codecs.push_back(kH264Codec); |
661 | 665 |
662 std::unique_ptr<VideoMediaChannel> channel( | 666 std::unique_ptr<VideoMediaChannel> channel( |
663 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); | 667 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); |
664 | 668 |
665 EXPECT_TRUE( | 669 EXPECT_TRUE( |
666 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); | 670 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); |
667 ASSERT_EQ(1u, encoder_factory.encoders().size()); | 671 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()); | |
676 ASSERT_TRUE(encoder_factory.encoders()[0]->WaitForInitEncode()); | 672 ASSERT_TRUE(encoder_factory.encoders()[0]->WaitForInitEncode()); |
677 EXPECT_EQ(webrtc::kVideoCodecH264, | 673 EXPECT_EQ(webrtc::kVideoCodecH264, |
678 encoder_factory.encoders()[0]->GetCodecSettings().codecType); | 674 encoder_factory.encoders()[0]->GetCodecSettings().codecType); |
679 | 675 |
680 channel.reset(); | 676 channel.reset(); |
681 // Make sure DestroyVideoEncoder was called on the factory. | 677 // Make sure DestroyVideoEncoder was called on the factory. |
682 ASSERT_EQ(0u, encoder_factory.encoders().size()); | 678 ASSERT_EQ(0u, encoder_factory.encoders().size()); |
683 } | 679 } |
684 | 680 |
685 TEST_F(WebRtcVideoEngine2Test, SimulcastDisabledForH264) { | 681 TEST_F(WebRtcVideoEngine2Test, SimulcastDisabledForH264) { |
(...skipping 3154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3840 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith3SimulcastStreams) { | 3836 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith3SimulcastStreams) { |
3841 VerifySimulcastSettings(kVp8Codec, 1280, 720, 3, 3); | 3837 VerifySimulcastSettings(kVp8Codec, 1280, 720, 3, 3); |
3842 } | 3838 } |
3843 | 3839 |
3844 // Test that we normalize send codec format size in simulcast. | 3840 // Test that we normalize send codec format size in simulcast. |
3845 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { | 3841 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { |
3846 cricket::VideoCodec codec(kVp8Codec); | 3842 cricket::VideoCodec codec(kVp8Codec); |
3847 VerifySimulcastSettings(codec, 541, 271, 2, 2); | 3843 VerifySimulcastSettings(codec, 541, 271, 2, 2); |
3848 } | 3844 } |
3849 } // namespace cricket | 3845 } // namespace cricket |
OLD | NEW |