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

Side by Side Diff: media/base/android/media_source_player_unittest.cc

Issue 323563002: support adaptive playback in MSE (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 6 years, 6 months 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 | Annotate | Revision Log
« no previous file with comments | « media/base/android/media_decoder_job.cc ('k') | media/base/android/video_decoder_job.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 <string> 5 #include <string>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 demuxer_->num_browser_seek_requests()); 595 demuxer_->num_browser_seek_requests());
596 EXPECT_EQ(expected_num_data_requests, demuxer_->num_data_requests()); 596 EXPECT_EQ(expected_num_data_requests, demuxer_->num_data_requests());
597 } 597 }
598 598
599 // Creates a new media codec bridge and feeds it data ending with a 599 // Creates a new media codec bridge and feeds it data ending with a
600 // |kConfigChanged| access unit. If |config_unit_in_prefetch| is true, sends 600 // |kConfigChanged| access unit. If |config_unit_in_prefetch| is true, sends
601 // feeds the config change AU in response to the job's first read request 601 // feeds the config change AU in response to the job's first read request
602 // (prefetch). If false, regular data is fed and decoded prior to feeding the 602 // (prefetch). If false, regular data is fed and decoded prior to feeding the
603 // config change AU in response to the second data request (after prefetch 603 // config change AU in response to the second data request (after prefetch
604 // completed). |config_unit_index| controls which access unit is 604 // completed). |config_unit_index| controls which access unit is
605 // |kConfigChanged|. 605 // |kConfigChanged|. If |enable_adaptive_playback| is true, config change will
606 // not cause the decoder to recreate the media codec bridge. Otherwise, the
607 // decoder has to drain all its data before recreating the new codec.
606 void SendConfigChangeToDecoder(bool is_audio, 608 void SendConfigChangeToDecoder(bool is_audio,
607 bool config_unit_in_prefetch, 609 bool config_unit_in_prefetch,
608 int config_unit_index) { 610 int config_unit_index,
611 bool enable_adaptive_playback) {
609 EXPECT_FALSE(GetMediaCodecBridge(is_audio)); 612 EXPECT_FALSE(GetMediaCodecBridge(is_audio));
610 if (is_audio) { 613 if (is_audio) {
611 StartAudioDecoderJob(); 614 StartAudioDecoderJob();
612 } else { 615 } else {
613 CreateNextTextureAndSetVideoSurface(); 616 CreateNextTextureAndSetVideoSurface();
614 StartVideoDecoderJob(); 617 StartVideoDecoderJob();
615 } 618 }
616 619
617 int expected_num_data_requests = demuxer_->num_data_requests(); 620 int expected_num_data_requests = demuxer_->num_data_requests();
618 // Feed and decode a standalone access unit so the player exits prefetch. 621 // Feed and decode a standalone access unit so the player exits prefetch.
619 if (!config_unit_in_prefetch) { 622 if (!config_unit_in_prefetch) {
620 if (is_audio) 623 if (is_audio) {
621 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0)); 624 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0));
622 else 625 } else {
623 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo()); 626 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo());
627 EnableAdaptiveVideoPlayback(enable_adaptive_playback);
628 }
624 629
625 WaitForDecodeDone(is_audio, !is_audio); 630 WaitForDecodeDone(is_audio, !is_audio);
626 631
627 // We should have completed the prefetch phase at this point. 632 // We should have completed the prefetch phase at this point.
628 expected_num_data_requests++; 633 expected_num_data_requests++;
629 EXPECT_EQ(expected_num_data_requests, demuxer_->num_data_requests()); 634 EXPECT_EQ(expected_num_data_requests, demuxer_->num_data_requests());
630 } 635 }
631 636
632 DemuxerConfigs configs = is_audio ? 637 DemuxerConfigs configs = is_audio ?
633 CreateAudioDemuxerConfigs(kCodecAAC, false) : 638 CreateAudioDemuxerConfigs(kCodecAAC, false) :
634 CreateVideoDemuxerConfigs(true); 639 CreateVideoDemuxerConfigs(true);
635 // Feed and decode access units with data for any units prior to 640 // Feed and decode access units with data for any units prior to
636 // |config_unit_index|, and a |kConfigChanged| unit at that index. 641 // |config_unit_index|, and a |kConfigChanged| unit at that index.
637 // Player should prepare to reconfigure the decoder job, and should request 642 // Player should prepare to reconfigure the decoder job, and should request
638 // new demuxer configs. 643 // new demuxer configs.
639 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckWithConfigChanged( 644 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckWithConfigChanged(
640 is_audio, config_unit_index, configs)); 645 is_audio, config_unit_index, configs));
641 646
642 expected_num_data_requests++; 647 expected_num_data_requests++;
643 EXPECT_EQ(expected_num_data_requests, demuxer_->num_data_requests()); 648 EXPECT_EQ(expected_num_data_requests, demuxer_->num_data_requests());
644 if (is_audio) 649 if (is_audio)
645 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0)); 650 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0));
646 else 651 else
647 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo()); 652 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo());
653
654 // If the adaptive playback setting was not passed to the MediaCodecBridge
655 // earlier, do it here.
656 if (config_unit_in_prefetch && !is_audio)
657 EnableAdaptiveVideoPlayback(enable_adaptive_playback);
648 } 658 }
649 659
650 // Send a config change to the decoder job and drain the decoder so that the 660 // Send a config change to the decoder job and drain the decoder so that the
651 // config change is processed. 661 // config change is processed.
652 void StartConfigChange(bool is_audio, 662 void StartConfigChange(bool is_audio,
653 bool config_unit_in_prefetch, 663 bool config_unit_in_prefetch,
654 int config_unit_index) { 664 int config_unit_index,
665 bool enable_adaptive_playback) {
655 SendConfigChangeToDecoder(is_audio, config_unit_in_prefetch, 666 SendConfigChangeToDecoder(is_audio, config_unit_in_prefetch,
656 config_unit_index); 667 config_unit_index, enable_adaptive_playback);
657 EXPECT_EQ(!config_unit_in_prefetch && config_unit_index == 0, 668
658 IsDrainingDecoder(is_audio)); 669 EXPECT_EQ(!config_unit_in_prefetch && !enable_adaptive_playback &&
670 config_unit_index == 0, IsDrainingDecoder(is_audio));
659 int expected_num_data_requests = demuxer_->num_data_requests(); 671 int expected_num_data_requests = demuxer_->num_data_requests();
660 // Run until decoder starts to request new data. 672 // Run until decoder starts to request new data.
661 while (demuxer_->num_data_requests() == expected_num_data_requests) 673 while (demuxer_->num_data_requests() == expected_num_data_requests)
662 message_loop_.RunUntilIdle(); 674 message_loop_.RunUntilIdle();
663 EXPECT_FALSE(IsDrainingDecoder(is_audio)); 675 EXPECT_FALSE(IsDrainingDecoder(is_audio));
664 } 676 }
665 677
678 void EnableAdaptiveVideoPlayback(bool enable) {
679 EXPECT_TRUE(GetMediaCodecBridge(false));
680 static_cast<VideoCodecBridge*>(GetMediaCodecBridge(false))->
681 set_adaptive_playback_supported_for_testing(
682 enable ? 1 : 0);
683 }
684
666 void CreateNextTextureAndSetVideoSurface() { 685 void CreateNextTextureAndSetVideoSurface() {
667 gfx::SurfaceTexture* surface_texture; 686 gfx::SurfaceTexture* surface_texture;
668 if (surface_texture_a_is_next_) { 687 if (surface_texture_a_is_next_) {
669 surface_texture_a_ = gfx::SurfaceTexture::Create(next_texture_id_++); 688 surface_texture_a_ = gfx::SurfaceTexture::Create(next_texture_id_++);
670 surface_texture = surface_texture_a_.get(); 689 surface_texture = surface_texture_a_.get();
671 } else { 690 } else {
672 surface_texture_b_ = gfx::SurfaceTexture::Create(next_texture_id_++); 691 surface_texture_b_ = gfx::SurfaceTexture::Create(next_texture_id_++);
673 surface_texture = surface_texture_b_.get(); 692 surface_texture = surface_texture_b_.get();
674 } 693 }
675 694
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after
1638 1657
1639 // Test that the player allows simultaneous audio and video config change, 1658 // Test that the player allows simultaneous audio and video config change,
1640 // such as might occur during OnPrefetchDone() if next access unit for both 1659 // such as might occur during OnPrefetchDone() if next access unit for both
1641 // audio and video jobs is |kConfigChanged|. 1660 // audio and video jobs is |kConfigChanged|.
1642 CreateNextTextureAndSetVideoSurface(); 1661 CreateNextTextureAndSetVideoSurface();
1643 Start(CreateAudioVideoDemuxerConfigs()); 1662 Start(CreateAudioVideoDemuxerConfigs());
1644 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0)); 1663 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0));
1645 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo()); 1664 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo());
1646 EXPECT_TRUE(GetMediaCodecBridge(true)); 1665 EXPECT_TRUE(GetMediaCodecBridge(true));
1647 EXPECT_TRUE(GetMediaCodecBridge(false)); 1666 EXPECT_TRUE(GetMediaCodecBridge(false));
1667 EnableAdaptiveVideoPlayback(false);
1648 WaitForAudioVideoDecodeDone(); 1668 WaitForAudioVideoDecodeDone();
1649 1669
1650 // Simulate audio |kConfigChanged| prefetched as standalone access unit. 1670 // Simulate audio |kConfigChanged| prefetched as standalone access unit.
1651 DemuxerConfigs audio_configs = CreateAudioDemuxerConfigs(kCodecVorbis, true); 1671 DemuxerConfigs audio_configs = CreateAudioDemuxerConfigs(kCodecVorbis, true);
1652 player_.OnDemuxerDataAvailable( 1672 player_.OnDemuxerDataAvailable(
1653 CreateReadFromDemuxerAckWithConfigChanged(true, 0, audio_configs)); 1673 CreateReadFromDemuxerAckWithConfigChanged(true, 0, audio_configs));
1654 1674
1655 // Simulate video |kConfigChanged| prefetched as standalone access unit. 1675 // Simulate video |kConfigChanged| prefetched as standalone access unit.
1656 player_.OnDemuxerDataAvailable( 1676 player_.OnDemuxerDataAvailable(
1657 CreateReadFromDemuxerAckWithConfigChanged( 1677 CreateReadFromDemuxerAckWithConfigChanged(
1658 false, 0, CreateVideoDemuxerConfigs(true))); 1678 false, 0, CreateVideoDemuxerConfigs(true)));
1659 EXPECT_EQ(6, demuxer_->num_data_requests()); 1679 EXPECT_EQ(6, demuxer_->num_data_requests());
1660 EXPECT_TRUE(IsDrainingDecoder(true)); 1680 EXPECT_TRUE(IsDrainingDecoder(true));
1661 EXPECT_TRUE(IsDrainingDecoder(false)); 1681 EXPECT_TRUE(IsDrainingDecoder(false));
1662 1682
1663 // Waiting for decoder to finish draining. 1683 // Waiting for decoder to finish draining.
1664 while (IsDrainingDecoder(true) || IsDrainingDecoder(false)) 1684 while (IsDrainingDecoder(true) || IsDrainingDecoder(false))
1665 message_loop_.RunUntilIdle(); 1685 message_loop_.RunUntilIdle();
1666 } 1686 }
1667 1687
1688 TEST_F(MediaSourcePlayerTest,
1689 SimultaneousAudioVideoConfigChangeWithAdaptivePlayback) {
1690 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1691
1692 // Test that the player allows simultaneous audio and video config change with
1693 // adaptive video playback enabled.
1694 CreateNextTextureAndSetVideoSurface();
1695 Start(CreateAudioVideoDemuxerConfigs());
1696 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0));
1697 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo());
1698 EXPECT_TRUE(GetMediaCodecBridge(true));
1699 EXPECT_TRUE(GetMediaCodecBridge(false));
1700 EnableAdaptiveVideoPlayback(true);
1701 WaitForAudioVideoDecodeDone();
1702
1703 // Simulate audio |kConfigChanged| prefetched as standalone access unit.
1704 DemuxerConfigs audio_configs = CreateAudioDemuxerConfigs(kCodecVorbis, true);
1705 player_.OnDemuxerDataAvailable(
1706 CreateReadFromDemuxerAckWithConfigChanged(true, 0, audio_configs));
1707
1708 // Simulate video |kConfigChanged| prefetched as standalone access unit.
1709 player_.OnDemuxerDataAvailable(
1710 CreateReadFromDemuxerAckWithConfigChanged(
1711 false, 0, CreateVideoDemuxerConfigs(true)));
1712 EXPECT_EQ(6, demuxer_->num_data_requests());
1713 EXPECT_TRUE(IsDrainingDecoder(true));
1714 EXPECT_FALSE(IsDrainingDecoder(false));
1715
1716 // Waiting for audio decoder to finish draining.
1717 while (IsDrainingDecoder(true))
1718 message_loop_.RunUntilIdle();
1719 }
1720
1668 TEST_F(MediaSourcePlayerTest, DemuxerConfigRequestedIfInPrefetchUnit0) { 1721 TEST_F(MediaSourcePlayerTest, DemuxerConfigRequestedIfInPrefetchUnit0) {
1669 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1722 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1670 1723
1671 // Test that the player detects need for and requests demuxer configs if 1724 // Test that the player detects need for and requests demuxer configs if
1672 // the |kConfigChanged| unit is the very first unit in the set of units 1725 // the |kConfigChanged| unit is the very first unit in the set of units
1673 // received in OnDemuxerDataAvailable() ostensibly while 1726 // received in OnDemuxerDataAvailable() ostensibly while
1674 // |PREFETCH_DONE_EVENT_PENDING|. 1727 // |PREFETCH_DONE_EVENT_PENDING|.
1675 StartConfigChange(true, true, 0); 1728 StartConfigChange(true, true, 0, false);
1676 } 1729 }
1677 1730
1678 TEST_F(MediaSourcePlayerTest, DemuxerConfigRequestedIfInPrefetchUnit1) { 1731 TEST_F(MediaSourcePlayerTest, DemuxerConfigRequestedIfInPrefetchUnit1) {
1679 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1732 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1680 1733
1681 // Test that the player detects need for and requests demuxer configs if 1734 // Test that the player detects need for and requests demuxer configs if
1682 // the |kConfigChanged| unit is not the first unit in the set of units 1735 // the |kConfigChanged| unit is not the first unit in the set of units
1683 // received in OnDemuxerDataAvailable() ostensibly while 1736 // received in OnDemuxerDataAvailable() ostensibly while
1684 // |PREFETCH_DONE_EVENT_PENDING|. 1737 // |PREFETCH_DONE_EVENT_PENDING|.
1685 StartConfigChange(true, true, 1); 1738 StartConfigChange(true, true, 1, false);
1686 } 1739 }
1687 1740
1688 TEST_F(MediaSourcePlayerTest, DemuxerConfigRequestedIfInUnit0AfterPrefetch) { 1741 TEST_F(MediaSourcePlayerTest, DemuxerConfigRequestedIfInUnit0AfterPrefetch) {
1689 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1742 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1690 1743
1691 // Test that the player detects need for and requests demuxer configs if 1744 // Test that the player detects need for and requests demuxer configs if
1692 // the |kConfigChanged| unit is the very first unit in the set of units 1745 // the |kConfigChanged| unit is the very first unit in the set of units
1693 // received in OnDemuxerDataAvailable() from data requested ostensibly while 1746 // received in OnDemuxerDataAvailable() from data requested ostensibly while
1694 // not prefetching. 1747 // not prefetching.
1695 StartConfigChange(true, false, 0); 1748 StartConfigChange(true, false, 0, false);
1696 } 1749 }
1697 1750
1698 TEST_F(MediaSourcePlayerTest, DemuxerConfigRequestedIfInUnit1AfterPrefetch) { 1751 TEST_F(MediaSourcePlayerTest, DemuxerConfigRequestedIfInUnit1AfterPrefetch) {
1699 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1752 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1700 1753
1701 // Test that the player detects need for and requests demuxer configs if 1754 // Test that the player detects need for and requests demuxer configs if
1702 // the |kConfigChanged| unit is not the first unit in the set of units 1755 // the |kConfigChanged| unit is not the first unit in the set of units
1703 // received in OnDemuxerDataAvailable() from data requested ostensibly while 1756 // received in OnDemuxerDataAvailable() from data requested ostensibly while
1704 // not prefetching. 1757 // not prefetching.
1705 StartConfigChange(true, false, 1); 1758 StartConfigChange(true, false, 1, false);
1706 } 1759 }
1707 1760
1708 TEST_F(MediaSourcePlayerTest, BrowserSeek_PrerollAfterBrowserSeek) { 1761 TEST_F(MediaSourcePlayerTest, BrowserSeek_PrerollAfterBrowserSeek) {
1709 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1762 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1710 1763
1711 // Test decoder job will preroll the media to the actual seek position 1764 // Test decoder job will preroll the media to the actual seek position
1712 // resulting from a browser seek. 1765 // resulting from a browser seek.
1713 BrowserSeekPlayer(false); 1766 BrowserSeekPlayer(false);
1714 1767
1715 // Simulate browser seek is done, but to a later time than was requested. 1768 // Simulate browser seek is done, but to a later time than was requested.
1716 EXPECT_LT(player_.GetCurrentTime().InMillisecondsF(), 100); 1769 EXPECT_LT(player_.GetCurrentTime().InMillisecondsF(), 100);
1717 player_.OnDemuxerSeekDone(base::TimeDelta::FromMilliseconds(100)); 1770 player_.OnDemuxerSeekDone(base::TimeDelta::FromMilliseconds(100));
1718 // Because next AU is not I-frame, MediaCodecBridge will not be recreated. 1771 // Because next AU is not I-frame, MediaCodecBridge will not be recreated.
1719 EXPECT_FALSE(GetMediaCodecBridge(false)); 1772 EXPECT_FALSE(GetMediaCodecBridge(false));
1720 EXPECT_EQ(100.0, player_.GetCurrentTime().InMillisecondsF()); 1773 EXPECT_EQ(100.0, player_.GetCurrentTime().InMillisecondsF());
1721 EXPECT_EQ(100.0, GetPrerollTimestamp().InMillisecondsF()); 1774 EXPECT_EQ(100.0, GetPrerollTimestamp().InMillisecondsF());
1722 EXPECT_EQ(3, demuxer_->num_data_requests()); 1775 EXPECT_EQ(3, demuxer_->num_data_requests());
1723 1776
1724 PrerollDecoderToTime( 1777 PrerollDecoderToTime(
1725 false, base::TimeDelta(), base::TimeDelta::FromMilliseconds(100)); 1778 false, base::TimeDelta(), base::TimeDelta::FromMilliseconds(100));
1726 } 1779 }
1727 1780
1728 TEST_F(MediaSourcePlayerTest, VideoDemuxerConfigChange) { 1781 TEST_F(MediaSourcePlayerTest, VideoDemuxerConfigChange) {
1729 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1782 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1730 1783
1731 // Test that video config change notification results in creating a new 1784 // Test that video config change notification results in creating a new
1732 // video codec without any browser seek. 1785 // video codec without any browser seek.
1733 StartConfigChange(false, true, 1); 1786 StartConfigChange(false, true, 1, false);
1734 1787
1735 // New video codec should have been created and configured, without any 1788 // New video codec should have been created and configured, without any
1736 // browser seek. 1789 // browser seek.
1737 EXPECT_TRUE(GetMediaCodecBridge(false)); 1790 EXPECT_TRUE(GetMediaCodecBridge(false));
1738 EXPECT_EQ(3, demuxer_->num_data_requests()); 1791 EXPECT_EQ(3, demuxer_->num_data_requests());
1739 EXPECT_EQ(0, demuxer_->num_seek_requests()); 1792 EXPECT_EQ(0, demuxer_->num_seek_requests());
1793
1794 // 2 codecs should have been created, one before the config change, and one
1795 // after it.
1796 EXPECT_EQ(2, manager_.num_resources_requested());
1797 EXPECT_EQ(1, manager_.num_resources_released());
1798 }
1799
1800 TEST_F(MediaSourcePlayerTest, VideoDemuxerConfigChangeWithAdaptivePlayback) {
1801 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1802
1803 // Test that if codec supports adaptive playback, no new codec should be
1804 // created beyond the one used to decode the prefetch media data prior to
1805 // the kConfigChanged.
1806 StartConfigChange(false, true, 1, true);
1807
1808 // No browser seek should be needed.
1809 EXPECT_TRUE(GetMediaCodecBridge(false));
1810 EXPECT_EQ(3, demuxer_->num_data_requests());
1811 EXPECT_EQ(0, demuxer_->num_seek_requests());
1812
1813 // Only 1 codec should have been created so far.
1814 EXPECT_EQ(1, manager_.num_resources_requested());
1740 } 1815 }
1741 1816
1742 TEST_F(MediaSourcePlayerTest, DecoderDrainInterruptedBySeek) { 1817 TEST_F(MediaSourcePlayerTest, DecoderDrainInterruptedBySeek) {
1743 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1818 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1744 1819
1745 // Test if a decoder is being drained while receiving a seek request, draining 1820 // Test if a decoder is being drained while receiving a seek request, draining
1746 // is canceled. 1821 // is canceled.
1747 SendConfigChangeToDecoder(true, false, 0); 1822 SendConfigChangeToDecoder(true, false, 0, false);
1748 EXPECT_TRUE(IsDrainingDecoder(true)); 1823 EXPECT_TRUE(IsDrainingDecoder(true));
1749 1824
1750 player_.SeekTo(base::TimeDelta::FromMilliseconds(100)); 1825 player_.SeekTo(base::TimeDelta::FromMilliseconds(100));
1751 WaitForAudioDecodeDone(); 1826 WaitForAudioDecodeDone();
1752 EXPECT_FALSE(IsDrainingDecoder(true)); 1827 EXPECT_FALSE(IsDrainingDecoder(true));
1753 player_.OnDemuxerSeekDone(kNoTimestamp()); 1828 player_.OnDemuxerSeekDone(kNoTimestamp());
1754 1829
1755 EXPECT_EQ(1, demuxer_->num_seek_requests()); 1830 EXPECT_EQ(1, demuxer_->num_seek_requests());
1756 EXPECT_EQ(4, demuxer_->num_data_requests()); 1831 EXPECT_EQ(4, demuxer_->num_data_requests());
1757 } 1832 }
1758 1833
1759 TEST_F(MediaSourcePlayerTest, DecoderDrainInterruptedByRelease) { 1834 TEST_F(MediaSourcePlayerTest, DecoderDrainInterruptedByRelease) {
1760 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1835 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1761 1836
1762 // Test if a decoder is being drained while receiving a release request, 1837 // Test if a decoder is being drained while receiving a release request,
1763 // draining is canceled. 1838 // draining is canceled.
1764 SendConfigChangeToDecoder(true, false, 0); 1839 SendConfigChangeToDecoder(true, false, 0, false);
1765 EXPECT_TRUE(IsDrainingDecoder(true)); 1840 EXPECT_TRUE(IsDrainingDecoder(true));
1766 1841
1767 ReleasePlayer(); 1842 ReleasePlayer();
1768 WaitForAudioDecodeDone(); 1843 WaitForAudioDecodeDone();
1769 EXPECT_EQ(3, demuxer_->num_data_requests()); 1844 EXPECT_EQ(3, demuxer_->num_data_requests());
1770 EXPECT_FALSE(IsDrainingDecoder(true)); 1845 EXPECT_FALSE(IsDrainingDecoder(true));
1771 1846
1772 EXPECT_FALSE(GetMediaCodecBridge(true)); 1847 EXPECT_FALSE(GetMediaCodecBridge(true));
1773 EXPECT_FALSE(player_.IsPlaying()); 1848 EXPECT_FALSE(player_.IsPlaying());
1774 1849
1775 player_.Start(); 1850 player_.Start();
1776 EXPECT_TRUE(player_.IsPlaying()); 1851 EXPECT_TRUE(player_.IsPlaying());
1777 EXPECT_EQ(3, demuxer_->num_data_requests()); 1852 EXPECT_EQ(3, demuxer_->num_data_requests());
1778 } 1853 }
1779 1854
1780 TEST_F(MediaSourcePlayerTest, DecoderDrainInterruptedBySurfaceChange) { 1855 TEST_F(MediaSourcePlayerTest, DecoderDrainInterruptedBySurfaceChange) {
1781 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1856 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1782 1857
1783 // Test if a video decoder is being drained while surface changes, draining 1858 // Test if a video decoder is being drained while surface changes, draining
1784 // is canceled. 1859 // is canceled.
1785 SendConfigChangeToDecoder(false, false, 0); 1860 SendConfigChangeToDecoder(false, false, 0, false);
1786 EXPECT_TRUE(IsDrainingDecoder(false)); 1861 EXPECT_TRUE(IsDrainingDecoder(false));
1787 1862
1788 CreateNextTextureAndSetVideoSurface(); 1863 CreateNextTextureAndSetVideoSurface();
1789 WaitForVideoDecodeDone(); 1864 WaitForVideoDecodeDone();
1790 1865
1791 EXPECT_FALSE(IsDrainingDecoder(false)); 1866 EXPECT_FALSE(IsDrainingDecoder(false));
1792 EXPECT_FALSE(GetMediaCodecBridge(false)); 1867 EXPECT_FALSE(GetMediaCodecBridge(false));
1793 EXPECT_TRUE(player_.IsPlaying()); 1868 EXPECT_TRUE(player_.IsPlaying());
1794 EXPECT_EQ(3, demuxer_->num_data_requests()); 1869 EXPECT_EQ(3, demuxer_->num_data_requests());
1795 1870
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1981 // No further seek should have been requested since before Release(), above. 2056 // No further seek should have been requested since before Release(), above.
1982 EXPECT_EQ(1, demuxer_->num_seek_requests()); 2057 EXPECT_EQ(1, demuxer_->num_seek_requests());
1983 } 2058 }
1984 2059
1985 TEST_F(MediaSourcePlayerTest, ConfigChangedThenReleaseThenStart) { 2060 TEST_F(MediaSourcePlayerTest, ConfigChangedThenReleaseThenStart) {
1986 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 2061 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1987 2062
1988 // Test if Release() occurs after |kConfigChanged| is processed, new data 2063 // Test if Release() occurs after |kConfigChanged| is processed, new data
1989 // requested of demuxer, and the requested data arrive before the next 2064 // requested of demuxer, and the requested data arrive before the next
1990 // Start(), then the player starts to decode the new data without any seek. 2065 // Start(), then the player starts to decode the new data without any seek.
1991 StartConfigChange(true, true, 0); 2066 StartConfigChange(true, true, 0, false);
1992 ReleasePlayer(); 2067 ReleasePlayer();
1993 2068
1994 EXPECT_TRUE(GetMediaCodecBridge(true)); 2069 EXPECT_TRUE(GetMediaCodecBridge(true));
1995 EXPECT_FALSE(player_.IsPlaying()); 2070 EXPECT_FALSE(player_.IsPlaying());
1996 EXPECT_EQ(3, demuxer_->num_data_requests()); 2071 EXPECT_EQ(3, demuxer_->num_data_requests());
1997 player_.OnDemuxerDataAvailable( 2072 player_.OnDemuxerDataAvailable(
1998 CreateReadFromDemuxerAckWithConfigChanged( 2073 CreateReadFromDemuxerAckWithConfigChanged(
1999 true, 4, CreateAudioDemuxerConfigs(kCodecVorbis, false))); 2074 true, 4, CreateAudioDemuxerConfigs(kCodecVorbis, false)));
2000 WaitForAudioDecodeDone(); 2075 WaitForAudioDecodeDone();
2001 EXPECT_FALSE(GetMediaCodecBridge(true)); 2076 EXPECT_FALSE(GetMediaCodecBridge(true));
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
2115 2190
2116 DemuxerConfigs configs = CreateAudioDemuxerConfigs(kCodecVorbis, true); 2191 DemuxerConfigs configs = CreateAudioDemuxerConfigs(kCodecVorbis, true);
2117 DemuxerData data = CreateReadFromDemuxerAckWithConfigChanged( 2192 DemuxerData data = CreateReadFromDemuxerAckWithConfigChanged(
2118 true, 0, configs); 2193 true, 0, configs);
2119 player_.OnDemuxerDataAvailable(data); 2194 player_.OnDemuxerDataAvailable(data);
2120 WaitForAudioDecodeDone(); 2195 WaitForAudioDecodeDone();
2121 DecodeAudioDataUntilOutputBecomesAvailable(); 2196 DecodeAudioDataUntilOutputBecomesAvailable();
2122 } 2197 }
2123 2198
2124 } // namespace media 2199 } // namespace media
OLDNEW
« no previous file with comments | « media/base/android/media_decoder_job.cc ('k') | media/base/android/video_decoder_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698