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