| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/gpu/android_video_decode_accelerator.h" | 5 #include "media/gpu/android_video_decode_accelerator.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 vda_.reset(avda); | 330 vda_.reset(avda); |
| 331 | 331 |
| 332 bool result = vda_->Initialize(config_, &client_); | 332 bool result = vda_->Initialize(config_, &client_); |
| 333 base::RunLoop().RunUntilIdle(); | 333 base::RunLoop().RunUntilIdle(); |
| 334 return result; | 334 return result; |
| 335 } | 335 } |
| 336 | 336 |
| 337 // Initialize |vda_|, providing a new surface for it. You may get the surface | 337 // Initialize |vda_|, providing a new surface for it. You may get the surface |
| 338 // by asking |codec_allocator_|. | 338 // by asking |codec_allocator_|. |
| 339 void InitializeAVDAWithOverlay() { | 339 void InitializeAVDAWithOverlay() { |
| 340 config_.surface_id = 123; | 340 config_.overlay_info.surface_id = 123; |
| 341 ASSERT_TRUE(InitializeAVDA()); | 341 ASSERT_TRUE(InitializeAVDA()); |
| 342 base::RunLoop().RunUntilIdle(); | 342 base::RunLoop().RunUntilIdle(); |
| 343 ASSERT_TRUE(chooser_->factory_); | 343 ASSERT_TRUE(chooser_->factory_); |
| 344 | 344 |
| 345 // Have the factory provide an overlay, and verify that codec creation is | 345 // Have the factory provide an overlay, and verify that codec creation is |
| 346 // provided with that overlay. | 346 // provided with that overlay. |
| 347 std::unique_ptr<MockAndroidOverlay> overlay = | 347 std::unique_ptr<MockAndroidOverlay> overlay = |
| 348 base::MakeUnique<MockAndroidOverlay>(); | 348 base::MakeUnique<MockAndroidOverlay>(); |
| 349 overlay_callbacks_ = overlay->GetCallbacks(); | 349 overlay_callbacks_ = overlay->GetCallbacks(); |
| 350 | 350 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 LowEndDevicesSucceedInitWithoutASurface) { | 480 LowEndDevicesSucceedInitWithoutASurface) { |
| 481 // If AVDA decides that we should defer surface creation, then it should | 481 // If AVDA decides that we should defer surface creation, then it should |
| 482 // signal success before we provide a surface. It should still ask for a | 482 // signal success before we provide a surface. It should still ask for a |
| 483 // surface, though. | 483 // surface, though. |
| 484 SKIP_IF_MEDIACODEC_IS_NOT_AVAILABLE(); | 484 SKIP_IF_MEDIACODEC_IS_NOT_AVAILABLE(); |
| 485 | 485 |
| 486 // It would be nicer if we didn't just force this on, since we might do so | 486 // It would be nicer if we didn't just force this on, since we might do so |
| 487 // in a state that AVDA isn't supposed to handle (e.g., if we give it a | 487 // in a state that AVDA isn't supposed to handle (e.g., if we give it a |
| 488 // surface, then it would never decide to defer surface creation). | 488 // surface, then it would never decide to defer surface creation). |
| 489 platform_config_.force_deferred_surface_creation = true; | 489 platform_config_.force_deferred_surface_creation = true; |
| 490 config_.surface_id = SurfaceManager::kNoSurfaceID; | 490 config_.overlay_info.surface_id = SurfaceManager::kNoSurfaceID; |
| 491 | 491 |
| 492 EXPECT_CALL(*chooser_, MockInitialize()).Times(0); | 492 EXPECT_CALL(*chooser_, MockInitialize()).Times(0); |
| 493 EXPECT_CALL(client_, NotifyInitializationComplete(true)); | 493 EXPECT_CALL(client_, NotifyInitializationComplete(true)); |
| 494 | 494 |
| 495 InitializeAVDA(); | 495 InitializeAVDA(); |
| 496 } | 496 } |
| 497 | 497 |
| 498 TEST_F(AndroidVideoDecodeAcceleratorTest, | 498 TEST_F(AndroidVideoDecodeAcceleratorTest, |
| 499 AsyncInitWithSurfaceTextureAndDelete) { | 499 AsyncInitWithSurfaceTextureAndDelete) { |
| 500 // When configuring with a SurfaceTexture and deferred init, we should be | 500 // When configuring with a SurfaceTexture and deferred init, we should be |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 // If we ask AVDA to change to SurfaceTexture should be ignored on platforms | 637 // If we ask AVDA to change to SurfaceTexture should be ignored on platforms |
| 638 // that don't support SetSurface (pre-M or blacklisted). It should also | 638 // that don't support SetSurface (pre-M or blacklisted). It should also |
| 639 // ignore SurfaceTexture => overlay, but we don't check that. | 639 // ignore SurfaceTexture => overlay, but we don't check that. |
| 640 // | 640 // |
| 641 // Also note that there are other probably reasonable things to do (like | 641 // Also note that there are other probably reasonable things to do (like |
| 642 // signal an error), but we want to be sure that it doesn't try to SetSurface. | 642 // signal an error), but we want to be sure that it doesn't try to SetSurface. |
| 643 // We also want to be sure that, if it doesn't signal an error, that it also | 643 // We also want to be sure that, if it doesn't signal an error, that it also |
| 644 // doesn't get confused about which surface is in use. So, we assume that it | 644 // doesn't get confused about which surface is in use. So, we assume that it |
| 645 // doesn't signal an error, and we check that it releases the right surface | 645 // doesn't signal an error, and we check that it releases the right surface |
| 646 // with the codec. | 646 // with the codec. |
| 647 SKIP_IF_MEDIACODEC_IS_NOT_AVAILABLE(); |
| 647 EXPECT_CALL(client_, NotifyError(_)).Times(0); | 648 EXPECT_CALL(client_, NotifyError(_)).Times(0); |
| 648 | 649 |
| 649 platform_config_.allow_setsurface = false; | 650 platform_config_.allow_setsurface = false; |
| 650 InitializeAVDAWithOverlay(); | 651 InitializeAVDAWithOverlay(); |
| 651 EXPECT_CALL(*codec_allocator_.most_recent_codec(), SetSurface(_)).Times(0); | 652 EXPECT_CALL(*codec_allocator_.most_recent_codec(), SetSurface(_)).Times(0); |
| 652 | 653 |
| 653 // This should not switch to SurfaceTexture. | 654 // This should not switch to SurfaceTexture. |
| 654 chooser_->ProvideSurfaceTexture(); | 655 chooser_->ProvideSurfaceTexture(); |
| 655 LetAVDAUpdateSurface(); | 656 LetAVDAUpdateSurface(); |
| 656 } | 657 } |
| 657 | 658 |
| 658 TEST_F(AndroidVideoDecodeAcceleratorTest, | 659 TEST_F(AndroidVideoDecodeAcceleratorTest, |
| 659 OnSurfaceDestroyedWithoutSetSurfaceFreesTheCodec) { | 660 OnSurfaceDestroyedWithoutSetSurfaceFreesTheCodec) { |
| 660 // If AVDA receives OnSurfaceDestroyed without support for SetSurface, then it | 661 // If AVDA receives OnSurfaceDestroyed without support for SetSurface, then it |
| 661 // should free the codec. | 662 // should free the codec. |
| 663 SKIP_IF_MEDIACODEC_IS_NOT_AVAILABLE(); |
| 662 platform_config_.allow_setsurface = false; | 664 platform_config_.allow_setsurface = false; |
| 663 InitializeAVDAWithOverlay(); | 665 InitializeAVDAWithOverlay(); |
| 664 EXPECT_CALL(*codec_allocator_.most_recent_codec(), SetSurface(_)).Times(0); | 666 EXPECT_CALL(*codec_allocator_.most_recent_codec(), SetSurface(_)).Times(0); |
| 665 | 667 |
| 666 // This should free the codec. | 668 // This should free the codec. |
| 667 EXPECT_CALL( | 669 EXPECT_CALL( |
| 668 codec_allocator_, | 670 codec_allocator_, |
| 669 MockReleaseMediaCodec(codec_allocator_.most_recent_codec(), | 671 MockReleaseMediaCodec(codec_allocator_.most_recent_codec(), |
| 670 codec_allocator_.most_recent_overlay(), nullptr)); | 672 codec_allocator_.most_recent_overlay(), nullptr)); |
| 671 codec_allocator_.codec_destruction_observer()->ExpectDestruction(); | 673 codec_allocator_.codec_destruction_observer()->ExpectDestruction(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 685 | 687 |
| 686 InitializeAVDAWithSurfaceTexture(); | 688 InitializeAVDAWithSurfaceTexture(); |
| 687 | 689 |
| 688 // This should do nothing. | 690 // This should do nothing. |
| 689 EXPECT_CALL(*codec_allocator_.most_recent_codec(), SetSurface(_)).Times(0); | 691 EXPECT_CALL(*codec_allocator_.most_recent_codec(), SetSurface(_)).Times(0); |
| 690 chooser_->ProvideSurfaceTexture(); | 692 chooser_->ProvideSurfaceTexture(); |
| 691 | 693 |
| 692 base::RunLoop().RunUntilIdle(); | 694 base::RunLoop().RunUntilIdle(); |
| 693 } | 695 } |
| 694 | 696 |
| 697 TEST_F(AndroidVideoDecodeAcceleratorTest, |
| 698 OverlayInfoWithDuplicateSurfaceIDDoesntChangeTheFactory) { |
| 699 // Send OverlayInfo with duplicate info, and verify that it doesn't change |
| 700 // the factory. |
| 701 SKIP_IF_MEDIACODEC_IS_NOT_AVAILABLE(); |
| 702 InitializeAVDAWithOverlay(); |
| 703 |
| 704 EXPECT_CALL(*chooser_, MockReplaceOverlayFactory()).Times(0); |
| 705 OverlayInfo overlay_info = config_.overlay_info; |
| 706 avda()->SetOverlayInfo(overlay_info); |
| 707 } |
| 708 |
| 709 TEST_F(AndroidVideoDecodeAcceleratorTest, |
| 710 OverlayInfoWithNewSurfaceIDDoesChangeTheFactory) { |
| 711 // Send OverlayInfo with new surface info, and verify that it does change the |
| 712 // overlay factory. |
| 713 SKIP_IF_MEDIACODEC_IS_NOT_AVAILABLE(); |
| 714 InitializeAVDAWithOverlay(); |
| 715 |
| 716 EXPECT_CALL(*chooser_, MockReplaceOverlayFactory()).Times(1); |
| 717 OverlayInfo overlay_info = config_.overlay_info; |
| 718 overlay_info.surface_id++; |
| 719 avda()->SetOverlayInfo(overlay_info); |
| 720 } |
| 721 |
| 695 } // namespace media | 722 } // namespace media |
| OLD | NEW |