OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 codec_.startBitrate = 3000; | 515 codec_.startBitrate = 3000; |
516 EXPECT_EQ(0, adapter_->InitEncode(&codec_, 1, 1200)); | 516 EXPECT_EQ(0, adapter_->InitEncode(&codec_, 1, 1200)); |
517 adapter_->RegisterEncodeCompleteCallback(this); | 517 adapter_->RegisterEncodeCompleteCallback(this); |
518 ASSERT_EQ(3u, helper_->factory()->encoders().size()); | 518 ASSERT_EQ(3u, helper_->factory()->encoders().size()); |
519 for (MockVideoEncoder* encoder : helper_->factory()->encoders()) | 519 for (MockVideoEncoder* encoder : helper_->factory()->encoders()) |
520 encoder->set_supports_native_handle(true); | 520 encoder->set_supports_native_handle(true); |
521 EXPECT_TRUE(adapter_->SupportsNativeHandle()); | 521 EXPECT_TRUE(adapter_->SupportsNativeHandle()); |
522 | 522 |
523 rtc::scoped_refptr<VideoFrameBuffer> buffer( | 523 rtc::scoped_refptr<VideoFrameBuffer> buffer( |
524 new rtc::RefCountedObject<FakeNativeHandleBuffer>(this, 1280, 720)); | 524 new rtc::RefCountedObject<FakeNativeHandleBuffer>(this, 1280, 720)); |
525 VideoFrame input_frame(buffer, 100, 1000, kVideoRotation_180); | 525 VideoFrame input_frame(buffer, 100, 1000, kVideoRotation_180, |
| 526 webrtc::VideoContentType::kDefault); |
526 // Expect calls with the given video frame verbatim, since it's a texture | 527 // Expect calls with the given video frame verbatim, since it's a texture |
527 // frame and can't otherwise be modified/resized. | 528 // frame and can't otherwise be modified/resized. |
528 for (MockVideoEncoder* encoder : helper_->factory()->encoders()) | 529 for (MockVideoEncoder* encoder : helper_->factory()->encoders()) |
529 EXPECT_CALL(*encoder, Encode(::testing::Ref(input_frame), _, _)).Times(1); | 530 EXPECT_CALL(*encoder, Encode(::testing::Ref(input_frame), _, _)).Times(1); |
530 std::vector<FrameType> frame_types(3, kVideoFrameKey); | 531 std::vector<FrameType> frame_types(3, kVideoFrameKey); |
531 EXPECT_EQ(0, adapter_->Encode(input_frame, NULL, &frame_types)); | 532 EXPECT_EQ(0, adapter_->Encode(input_frame, NULL, &frame_types)); |
532 } | 533 } |
533 | 534 |
534 TEST_F(TestSimulcastEncoderAdapterFake, TestFailureReturnCodesFromEncodeCalls) { | 535 TEST_F(TestSimulcastEncoderAdapterFake, TestFailureReturnCodesFromEncodeCalls) { |
535 TestVp8Simulcast::DefaultSettings( | 536 TestVp8Simulcast::DefaultSettings( |
536 &codec_, static_cast<const int*>(kTestTemporalLayerProfile)); | 537 &codec_, static_cast<const int*>(kTestTemporalLayerProfile)); |
537 codec_.VP8()->tl_factory = &tl_factory_; | 538 codec_.VP8()->tl_factory = &tl_factory_; |
538 codec_.numberOfSimulcastStreams = 3; | 539 codec_.numberOfSimulcastStreams = 3; |
539 EXPECT_EQ(0, adapter_->InitEncode(&codec_, 1, 1200)); | 540 EXPECT_EQ(0, adapter_->InitEncode(&codec_, 1, 1200)); |
540 adapter_->RegisterEncodeCompleteCallback(this); | 541 adapter_->RegisterEncodeCompleteCallback(this); |
541 ASSERT_EQ(3u, helper_->factory()->encoders().size()); | 542 ASSERT_EQ(3u, helper_->factory()->encoders().size()); |
542 // Tell the 2nd encoder to request software fallback. | 543 // Tell the 2nd encoder to request software fallback. |
543 EXPECT_CALL(*helper_->factory()->encoders()[1], Encode(_, _, _)) | 544 EXPECT_CALL(*helper_->factory()->encoders()[1], Encode(_, _, _)) |
544 .WillOnce(Return(WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE)); | 545 .WillOnce(Return(WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE)); |
545 | 546 |
546 // Send a fake frame and assert the return is software fallback. | 547 // Send a fake frame and assert the return is software fallback. |
547 int half_width = (kDefaultWidth + 1) / 2; | 548 int half_width = (kDefaultWidth + 1) / 2; |
548 rtc::scoped_refptr<I420Buffer> input_buffer = I420Buffer::Create( | 549 rtc::scoped_refptr<I420Buffer> input_buffer = I420Buffer::Create( |
549 kDefaultWidth, kDefaultHeight, kDefaultWidth, half_width, half_width); | 550 kDefaultWidth, kDefaultHeight, kDefaultWidth, half_width, half_width); |
550 input_buffer->InitializeData(); | 551 input_buffer->InitializeData(); |
551 VideoFrame input_frame(input_buffer, 0, 0, webrtc::kVideoRotation_0); | 552 VideoFrame input_frame(input_buffer, 0, 0, webrtc::kVideoRotation_0, |
| 553 webrtc::VideoContentType::kDefault); |
552 std::vector<FrameType> frame_types(3, kVideoFrameKey); | 554 std::vector<FrameType> frame_types(3, kVideoFrameKey); |
553 EXPECT_EQ(WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE, | 555 EXPECT_EQ(WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE, |
554 adapter_->Encode(input_frame, nullptr, &frame_types)); | 556 adapter_->Encode(input_frame, nullptr, &frame_types)); |
555 } | 557 } |
556 | 558 |
557 TEST_F(TestSimulcastEncoderAdapterFake, TestInitFailureCleansUpEncoders) { | 559 TEST_F(TestSimulcastEncoderAdapterFake, TestInitFailureCleansUpEncoders) { |
558 TestVp8Simulcast::DefaultSettings( | 560 TestVp8Simulcast::DefaultSettings( |
559 &codec_, static_cast<const int*>(kTestTemporalLayerProfile)); | 561 &codec_, static_cast<const int*>(kTestTemporalLayerProfile)); |
560 codec_.VP8()->tl_factory = &tl_factory_; | 562 codec_.VP8()->tl_factory = &tl_factory_; |
561 codec_.numberOfSimulcastStreams = 3; | 563 codec_.numberOfSimulcastStreams = 3; |
562 helper_->factory()->set_init_encode_return_value( | 564 helper_->factory()->set_init_encode_return_value( |
563 WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE); | 565 WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE); |
564 EXPECT_EQ(WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE, | 566 EXPECT_EQ(WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE, |
565 adapter_->InitEncode(&codec_, 1, 1200)); | 567 adapter_->InitEncode(&codec_, 1, 1200)); |
566 EXPECT_TRUE(helper_->factory()->encoders().empty()); | 568 EXPECT_TRUE(helper_->factory()->encoders().empty()); |
567 } | 569 } |
568 | 570 |
569 } // namespace testing | 571 } // namespace testing |
570 } // namespace webrtc | 572 } // namespace webrtc |
OLD | NEW |