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

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: 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
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 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 demuxer_->num_browser_seek_requests()); 609 demuxer_->num_browser_seek_requests());
610 EXPECT_EQ(expected_num_data_requests, demuxer_->num_data_requests()); 610 EXPECT_EQ(expected_num_data_requests, demuxer_->num_data_requests());
611 } 611 }
612 612
613 // Creates a new media codec bridge and feeds it data ending with a 613 // Creates a new media codec bridge and feeds it data ending with a
614 // |kConfigChanged| access unit. If |config_unit_in_prefetch| is true, sends 614 // |kConfigChanged| access unit. If |config_unit_in_prefetch| is true, sends
615 // feeds the config change AU in response to the job's first read request 615 // feeds the config change AU in response to the job's first read request
616 // (prefetch). If false, regular data is fed and decoded prior to feeding the 616 // (prefetch). If false, regular data is fed and decoded prior to feeding the
617 // config change AU in response to the second data request (after prefetch 617 // config change AU in response to the second data request (after prefetch
618 // completed). |config_unit_index| controls which access unit is 618 // completed). |config_unit_index| controls which access unit is
619 // |kConfigChanged|. 619 // |kConfigChanged|. If |enable_adaptive_playback| is true, config change will
620 // not cause the decoder to recreate the media codec bridge. Otherwise, the
621 // decoder has to drain all its data before recreating the new codec.
620 void SendConfigChangeToDecoder(bool is_audio, 622 void SendConfigChangeToDecoder(bool is_audio,
621 bool config_unit_in_prefetch, 623 bool config_unit_in_prefetch,
622 int config_unit_index) { 624 int config_unit_index,
625 bool enable_adaptive_playback) {
623 EXPECT_FALSE(GetMediaCodecBridge(is_audio)); 626 EXPECT_FALSE(GetMediaCodecBridge(is_audio));
624 if (is_audio) { 627 if (is_audio) {
625 StartAudioDecoderJob(); 628 StartAudioDecoderJob();
626 } else { 629 } else {
627 CreateNextTextureAndSetVideoSurface(); 630 CreateNextTextureAndSetVideoSurface();
628 StartVideoDecoderJob(); 631 StartVideoDecoderJob();
629 } 632 }
630 633
631 int expected_num_data_requests = demuxer_->num_data_requests(); 634 int expected_num_data_requests = demuxer_->num_data_requests();
632 // Feed and decode a standalone access unit so the player exits prefetch. 635 // Feed and decode a standalone access unit so the player exits prefetch.
633 if (!config_unit_in_prefetch) { 636 if (!config_unit_in_prefetch) {
634 if (is_audio) 637 if (is_audio)
635 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0)); 638 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0));
636 else 639 else {
wolenetz 2014/06/06 23:28:07 lint nit: put {} around clause prior to else to ma
qinmin 2014/06/07 01:31:55 Done.
637 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo()); 640 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo());
641 EnableAdaptiveVideoPlayback(enable_adaptive_playback);
642 }
638 643
639 WaitForDecodeDone(is_audio, !is_audio); 644 WaitForDecodeDone(is_audio, !is_audio);
640 645
641 // We should have completed the prefetch phase at this point. 646 // We should have completed the prefetch phase at this point.
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 } 649 }
645 650
646 DemuxerConfigs configs = is_audio ? 651 DemuxerConfigs configs = is_audio ?
647 CreateAudioDemuxerConfigs(kCodecAAC, false) : 652 CreateAudioDemuxerConfigs(kCodecAAC, false) :
648 CreateVideoDemuxerConfigs(true); 653 CreateVideoDemuxerConfigs(true);
649 // Feed and decode access units with data for any units prior to 654 // Feed and decode access units with data for any units prior to
650 // |config_unit_index|, and a |kConfigChanged| unit at that index. 655 // |config_unit_index|, and a |kConfigChanged| unit at that index.
651 // Player should prepare to reconfigure the decoder job, and should request 656 // Player should prepare to reconfigure the decoder job, and should request
652 // new demuxer configs. 657 // new demuxer configs.
653 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckWithConfigChanged( 658 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckWithConfigChanged(
654 is_audio, config_unit_index, configs)); 659 is_audio, config_unit_index, configs));
655 660
656 expected_num_data_requests++; 661 expected_num_data_requests++;
657 EXPECT_EQ(expected_num_data_requests, demuxer_->num_data_requests()); 662 EXPECT_EQ(expected_num_data_requests, demuxer_->num_data_requests());
658 if (is_audio) 663 if (is_audio)
659 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0)); 664 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0));
660 else 665 else
661 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo()); 666 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo());
667
668 // If the adaptive playback setting was not passed to the MediaCodecBridge
669 // earlier, do it here.
670 if (config_unit_in_prefetch && !is_audio)
671 EnableAdaptiveVideoPlayback(enable_adaptive_playback);
662 } 672 }
663 673
664 // Send a config change to the decoder job and drain the decoder so that the 674 // Send a config change to the decoder job and drain the decoder so that the
665 // config change is processed. 675 // config change is processed.
666 void StartConfigChange(bool is_audio, 676 void StartConfigChange(bool is_audio,
667 bool config_unit_in_prefetch, 677 bool config_unit_in_prefetch,
668 int config_unit_index) { 678 int config_unit_index,
679 bool enable_adaptive_playback) {
669 SendConfigChangeToDecoder(is_audio, config_unit_in_prefetch, 680 SendConfigChangeToDecoder(is_audio, config_unit_in_prefetch,
670 config_unit_index); 681 config_unit_index, enable_adaptive_playback);
671 EXPECT_EQ(!config_unit_in_prefetch && config_unit_index == 0, 682
672 IsDrainingDecoder(is_audio)); 683 EXPECT_EQ(!config_unit_in_prefetch && !enable_adaptive_playback &&
684 config_unit_index == 0, IsDrainingDecoder(is_audio));
673 int expected_num_data_requests = demuxer_->num_data_requests(); 685 int expected_num_data_requests = demuxer_->num_data_requests();
674 // Run until decoder starts to request new data. 686 // Run until decoder starts to request new data.
675 while (demuxer_->num_data_requests() == expected_num_data_requests) 687 while (demuxer_->num_data_requests() == expected_num_data_requests)
676 message_loop_.RunUntilIdle(); 688 message_loop_.RunUntilIdle();
677 EXPECT_FALSE(IsDrainingDecoder(is_audio)); 689 EXPECT_FALSE(IsDrainingDecoder(is_audio));
678 } 690 }
679 691
692 void EnableAdaptiveVideoPlayback(bool enable) {
693 EXPECT_TRUE(GetMediaCodecBridge(false));
694 static_cast<VideoCodecBridge*>(GetMediaCodecBridge(false))->
695 set_adaptive_playback_supported_for_testing(
696 enable ? 1 : 0);
697 }
698
680 void CreateNextTextureAndSetVideoSurface() { 699 void CreateNextTextureAndSetVideoSurface() {
681 gfx::SurfaceTexture* surface_texture; 700 gfx::SurfaceTexture* surface_texture;
682 if (surface_texture_a_is_next_) { 701 if (surface_texture_a_is_next_) {
683 surface_texture_a_ = gfx::SurfaceTexture::Create(next_texture_id_++); 702 surface_texture_a_ = gfx::SurfaceTexture::Create(next_texture_id_++);
684 surface_texture = surface_texture_a_.get(); 703 surface_texture = surface_texture_a_.get();
685 } else { 704 } else {
686 surface_texture_b_ = gfx::SurfaceTexture::Create(next_texture_id_++); 705 surface_texture_b_ = gfx::SurfaceTexture::Create(next_texture_id_++);
687 surface_texture = surface_texture_b_.get(); 706 surface_texture = surface_texture_b_.get();
688 } 707 }
689 708
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 1671
1653 // Test that the player allows simultaneous audio and video config change, 1672 // Test that the player allows simultaneous audio and video config change,
1654 // such as might occur during OnPrefetchDone() if next access unit for both 1673 // such as might occur during OnPrefetchDone() if next access unit for both
1655 // audio and video jobs is |kConfigChanged|. 1674 // audio and video jobs is |kConfigChanged|.
1656 CreateNextTextureAndSetVideoSurface(); 1675 CreateNextTextureAndSetVideoSurface();
1657 Start(CreateAudioVideoDemuxerConfigs()); 1676 Start(CreateAudioVideoDemuxerConfigs());
1658 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0)); 1677 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0));
1659 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo()); 1678 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo());
1660 EXPECT_TRUE(GetMediaCodecBridge(true)); 1679 EXPECT_TRUE(GetMediaCodecBridge(true));
1661 EXPECT_TRUE(GetMediaCodecBridge(false)); 1680 EXPECT_TRUE(GetMediaCodecBridge(false));
1681 EnableAdaptiveVideoPlayback(false);
1662 WaitForAudioVideoDecodeDone(); 1682 WaitForAudioVideoDecodeDone();
1663 1683
1664 // Simulate audio |kConfigChanged| prefetched as standalone access unit. 1684 // Simulate audio |kConfigChanged| prefetched as standalone access unit.
1665 DemuxerConfigs audio_configs = CreateAudioDemuxerConfigs(kCodecVorbis, true); 1685 DemuxerConfigs audio_configs = CreateAudioDemuxerConfigs(kCodecVorbis, true);
1666 player_.OnDemuxerDataAvailable( 1686 player_.OnDemuxerDataAvailable(
1667 CreateReadFromDemuxerAckWithConfigChanged(true, 0, audio_configs)); 1687 CreateReadFromDemuxerAckWithConfigChanged(true, 0, audio_configs));
1668 1688
1669 // Simulate video |kConfigChanged| prefetched as standalone access unit. 1689 // Simulate video |kConfigChanged| prefetched as standalone access unit.
1670 player_.OnDemuxerDataAvailable( 1690 player_.OnDemuxerDataAvailable(
1671 CreateReadFromDemuxerAckWithConfigChanged( 1691 CreateReadFromDemuxerAckWithConfigChanged(
1672 false, 0, CreateVideoDemuxerConfigs(true))); 1692 false, 0, CreateVideoDemuxerConfigs(true)));
1673 EXPECT_EQ(6, demuxer_->num_data_requests()); 1693 EXPECT_EQ(6, demuxer_->num_data_requests());
1674 EXPECT_TRUE(IsDrainingDecoder(true)); 1694 EXPECT_TRUE(IsDrainingDecoder(true));
1675 EXPECT_TRUE(IsDrainingDecoder(false)); 1695 EXPECT_TRUE(IsDrainingDecoder(false));
1676 1696
1677 // Waiting for decoder to finish draining. 1697 // Waiting for decoder to finish draining.
1678 while (IsDrainingDecoder(true) || IsDrainingDecoder(false)) 1698 while (IsDrainingDecoder(true) || IsDrainingDecoder(false))
1679 message_loop_.RunUntilIdle(); 1699 message_loop_.RunUntilIdle();
1680 } 1700 }
1681 1701
1702 TEST_F(MediaSourcePlayerTest,
1703 SimultaneousAudioVideoConfigChangeWithAdaptivePlayback) {
1704 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1705
1706 // Test that the player allows simultaneous audio and video config change with
1707 // adaptive video playback enabled.
1708 CreateNextTextureAndSetVideoSurface();
1709 Start(CreateAudioVideoDemuxerConfigs());
1710 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0));
1711 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo());
1712 EXPECT_TRUE(GetMediaCodecBridge(true));
1713 EXPECT_TRUE(GetMediaCodecBridge(false));
1714 EnableAdaptiveVideoPlayback(true);
1715 WaitForAudioVideoDecodeDone();
1716
1717 // Simulate audio |kConfigChanged| prefetched as standalone access unit.
1718 DemuxerConfigs audio_configs = CreateAudioDemuxerConfigs(kCodecVorbis, true);
1719 player_.OnDemuxerDataAvailable(
1720 CreateReadFromDemuxerAckWithConfigChanged(true, 0, audio_configs));
1721
1722 // Simulate video |kConfigChanged| prefetched as standalone access unit.
1723 player_.OnDemuxerDataAvailable(
1724 CreateReadFromDemuxerAckWithConfigChanged(
1725 false, 0, CreateVideoDemuxerConfigs(true)));
1726 EXPECT_EQ(6, demuxer_->num_data_requests());
1727 EXPECT_TRUE(IsDrainingDecoder(true));
1728 EXPECT_FALSE(IsDrainingDecoder(false));
1729
1730 // Waiting for audio decoder to finish draining.
1731 while (IsDrainingDecoder(true))
1732 message_loop_.RunUntilIdle();
1733 }
1734
1682 TEST_F(MediaSourcePlayerTest, DemuxerConfigRequestedIfInPrefetchUnit0) { 1735 TEST_F(MediaSourcePlayerTest, DemuxerConfigRequestedIfInPrefetchUnit0) {
1683 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1736 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1684 1737
1685 // Test that the player detects need for and requests demuxer configs if 1738 // Test that the player detects need for and requests demuxer configs if
1686 // the |kConfigChanged| unit is the very first unit in the set of units 1739 // the |kConfigChanged| unit is the very first unit in the set of units
1687 // received in OnDemuxerDataAvailable() ostensibly while 1740 // received in OnDemuxerDataAvailable() ostensibly while
1688 // |PREFETCH_DONE_EVENT_PENDING|. 1741 // |PREFETCH_DONE_EVENT_PENDING|.
1689 StartConfigChange(true, true, 0); 1742 StartConfigChange(true, true, 0, false);
1690 } 1743 }
1691 1744
1692 TEST_F(MediaSourcePlayerTest, DemuxerConfigRequestedIfInPrefetchUnit1) { 1745 TEST_F(MediaSourcePlayerTest, DemuxerConfigRequestedIfInPrefetchUnit1) {
1693 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1746 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1694 1747
1695 // Test that the player detects need for and requests demuxer configs if 1748 // Test that the player detects need for and requests demuxer configs if
1696 // the |kConfigChanged| unit is not the first unit in the set of units 1749 // the |kConfigChanged| unit is not the first unit in the set of units
1697 // received in OnDemuxerDataAvailable() ostensibly while 1750 // received in OnDemuxerDataAvailable() ostensibly while
1698 // |PREFETCH_DONE_EVENT_PENDING|. 1751 // |PREFETCH_DONE_EVENT_PENDING|.
1699 StartConfigChange(true, true, 1); 1752 StartConfigChange(true, true, 1, false);
1700 } 1753 }
1701 1754
1702 TEST_F(MediaSourcePlayerTest, DemuxerConfigRequestedIfInUnit0AfterPrefetch) { 1755 TEST_F(MediaSourcePlayerTest, DemuxerConfigRequestedIfInUnit0AfterPrefetch) {
1703 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1756 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1704 1757
1705 // Test that the player detects need for and requests demuxer configs if 1758 // Test that the player detects need for and requests demuxer configs if
1706 // the |kConfigChanged| unit is the very first unit in the set of units 1759 // the |kConfigChanged| unit is the very first unit in the set of units
1707 // received in OnDemuxerDataAvailable() from data requested ostensibly while 1760 // received in OnDemuxerDataAvailable() from data requested ostensibly while
1708 // not prefetching. 1761 // not prefetching.
1709 StartConfigChange(true, false, 0); 1762 StartConfigChange(true, false, 0, false);
1710 } 1763 }
1711 1764
1712 TEST_F(MediaSourcePlayerTest, DemuxerConfigRequestedIfInUnit1AfterPrefetch) { 1765 TEST_F(MediaSourcePlayerTest, DemuxerConfigRequestedIfInUnit1AfterPrefetch) {
1713 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1766 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1714 1767
1715 // Test that the player detects need for and requests demuxer configs if 1768 // Test that the player detects need for and requests demuxer configs if
1716 // the |kConfigChanged| unit is not the first unit in the set of units 1769 // the |kConfigChanged| unit is not the first unit in the set of units
1717 // received in OnDemuxerDataAvailable() from data requested ostensibly while 1770 // received in OnDemuxerDataAvailable() from data requested ostensibly while
1718 // not prefetching. 1771 // not prefetching.
1719 StartConfigChange(true, false, 1); 1772 StartConfigChange(true, false, 1, false);
1720 } 1773 }
1721 1774
1722 TEST_F(MediaSourcePlayerTest, BrowserSeek_PrerollAfterBrowserSeek) { 1775 TEST_F(MediaSourcePlayerTest, BrowserSeek_PrerollAfterBrowserSeek) {
1723 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1776 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1724 1777
1725 // Test decoder job will preroll the media to the actual seek position 1778 // Test decoder job will preroll the media to the actual seek position
1726 // resulting from a browser seek. 1779 // resulting from a browser seek.
1727 BrowserSeekPlayer(false); 1780 BrowserSeekPlayer(false);
1728 1781
1729 // Simulate browser seek is done, but to a later time than was requested. 1782 // Simulate browser seek is done, but to a later time than was requested.
1730 EXPECT_LT(player_.GetCurrentTime().InMillisecondsF(), 100); 1783 EXPECT_LT(player_.GetCurrentTime().InMillisecondsF(), 100);
1731 player_.OnDemuxerSeekDone(base::TimeDelta::FromMilliseconds(100)); 1784 player_.OnDemuxerSeekDone(base::TimeDelta::FromMilliseconds(100));
1732 // Because next AU is not I-frame, MediaCodecBridge will not be recreated. 1785 // Because next AU is not I-frame, MediaCodecBridge will not be recreated.
1733 EXPECT_FALSE(GetMediaCodecBridge(false)); 1786 EXPECT_FALSE(GetMediaCodecBridge(false));
1734 EXPECT_EQ(100.0, player_.GetCurrentTime().InMillisecondsF()); 1787 EXPECT_EQ(100.0, player_.GetCurrentTime().InMillisecondsF());
1735 EXPECT_EQ(100.0, GetPrerollTimestamp().InMillisecondsF()); 1788 EXPECT_EQ(100.0, GetPrerollTimestamp().InMillisecondsF());
1736 EXPECT_EQ(3, demuxer_->num_data_requests()); 1789 EXPECT_EQ(3, demuxer_->num_data_requests());
1737 1790
1738 PrerollDecoderToTime( 1791 PrerollDecoderToTime(
1739 false, base::TimeDelta(), base::TimeDelta::FromMilliseconds(100)); 1792 false, base::TimeDelta(), base::TimeDelta::FromMilliseconds(100));
1740 } 1793 }
1741 1794
1742 TEST_F(MediaSourcePlayerTest, VideoDemuxerConfigChange) { 1795 TEST_F(MediaSourcePlayerTest, VideoDemuxerConfigChange) {
1743 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1796 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1744 1797
1745 // Test that video config change notification results in creating a new 1798 // Test that video config change notification results in creating a new
1746 // video codec without any browser seek. 1799 // video codec without any browser seek.
1747 StartConfigChange(false, true, 1); 1800 StartConfigChange(false, true, 1, false);
1748 1801
1749 // New video codec should have been created and configured, without any 1802 // New video codec should have been created and configured, without any
1750 // browser seek. 1803 // browser seek.
1751 EXPECT_TRUE(GetMediaCodecBridge(false)); 1804 EXPECT_TRUE(GetMediaCodecBridge(false));
1752 EXPECT_EQ(3, demuxer_->num_data_requests()); 1805 EXPECT_EQ(3, demuxer_->num_data_requests());
1753 EXPECT_EQ(0, demuxer_->num_seek_requests()); 1806 EXPECT_EQ(0, demuxer_->num_seek_requests());
1754 } 1807 }
1755 1808
1809 TEST_F(MediaSourcePlayerTest, VideoDemuxerConfigChangeWithAdaptivePlayback) {
1810 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1811
1812 // Test that video config change notification results in creating a new
wolenetz 2014/06/06 23:28:07 No new codec should have been created beyond the o
qinmin 2014/06/07 01:31:55 Done.
1813 // video codec without any browser seek.
1814 StartConfigChange(false, true, 1, true);
1815
1816 // No browser seek should be needed.
1817 EXPECT_TRUE(GetMediaCodecBridge(false));
wolenetz 2014/06/06 23:28:07 We need to somehow verify the resulting codec brid
qinmin 2014/06/07 01:31:55 we can use manager_.num_resources_requested(). On
1818 EXPECT_EQ(3, demuxer_->num_data_requests());
1819 EXPECT_EQ(0, demuxer_->num_seek_requests());
1820 }
1821
1756 TEST_F(MediaSourcePlayerTest, DecoderDrainInterruptedBySeek) { 1822 TEST_F(MediaSourcePlayerTest, DecoderDrainInterruptedBySeek) {
1757 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1823 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1758 1824
1759 // Test if a decoder is being drained while receiving a seek request, draining 1825 // Test if a decoder is being drained while receiving a seek request, draining
1760 // is canceled. 1826 // is canceled.
1761 SendConfigChangeToDecoder(true, false, 0); 1827 SendConfigChangeToDecoder(true, false, 0, false);
1762 EXPECT_TRUE(IsDrainingDecoder(true)); 1828 EXPECT_TRUE(IsDrainingDecoder(true));
1763 1829
1764 player_.SeekTo(base::TimeDelta::FromMilliseconds(100)); 1830 player_.SeekTo(base::TimeDelta::FromMilliseconds(100));
1765 WaitForAudioDecodeDone(); 1831 WaitForAudioDecodeDone();
1766 EXPECT_FALSE(IsDrainingDecoder(true)); 1832 EXPECT_FALSE(IsDrainingDecoder(true));
1767 player_.OnDemuxerSeekDone(kNoTimestamp()); 1833 player_.OnDemuxerSeekDone(kNoTimestamp());
1768 1834
1769 EXPECT_EQ(1, demuxer_->num_seek_requests()); 1835 EXPECT_EQ(1, demuxer_->num_seek_requests());
1770 EXPECT_EQ(4, demuxer_->num_data_requests()); 1836 EXPECT_EQ(4, demuxer_->num_data_requests());
1771 } 1837 }
1772 1838
1773 TEST_F(MediaSourcePlayerTest, DecoderDrainInterruptedByRelease) { 1839 TEST_F(MediaSourcePlayerTest, DecoderDrainInterruptedByRelease) {
1774 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1840 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1775 1841
1776 // Test if a decoder is being drained while receiving a release request, 1842 // Test if a decoder is being drained while receiving a release request,
1777 // draining is canceled. 1843 // draining is canceled.
1778 SendConfigChangeToDecoder(true, false, 0); 1844 SendConfigChangeToDecoder(true, false, 0, false);
1779 EXPECT_TRUE(IsDrainingDecoder(true)); 1845 EXPECT_TRUE(IsDrainingDecoder(true));
1780 1846
1781 ReleasePlayer(); 1847 ReleasePlayer();
1782 WaitForAudioDecodeDone(); 1848 WaitForAudioDecodeDone();
1783 EXPECT_EQ(3, demuxer_->num_data_requests()); 1849 EXPECT_EQ(3, demuxer_->num_data_requests());
1784 EXPECT_FALSE(IsDrainingDecoder(true)); 1850 EXPECT_FALSE(IsDrainingDecoder(true));
1785 1851
1786 EXPECT_FALSE(GetMediaCodecBridge(true)); 1852 EXPECT_FALSE(GetMediaCodecBridge(true));
1787 EXPECT_FALSE(player_.IsPlaying()); 1853 EXPECT_FALSE(player_.IsPlaying());
1788 1854
1789 player_.Start(); 1855 player_.Start();
1790 EXPECT_TRUE(player_.IsPlaying()); 1856 EXPECT_TRUE(player_.IsPlaying());
1791 EXPECT_EQ(3, demuxer_->num_data_requests()); 1857 EXPECT_EQ(3, demuxer_->num_data_requests());
1792 } 1858 }
1793 1859
1794 TEST_F(MediaSourcePlayerTest, DecoderDrainInterruptedBySurfaceChange) { 1860 TEST_F(MediaSourcePlayerTest, DecoderDrainInterruptedBySurfaceChange) {
1795 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1861 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1796 1862
1797 // Test if a video decoder is being drained while surface changes, draining 1863 // Test if a video decoder is being drained while surface changes, draining
1798 // is canceled. 1864 // is canceled.
1799 SendConfigChangeToDecoder(false, false, 0); 1865 SendConfigChangeToDecoder(false, false, 0, false);
1800 EXPECT_TRUE(IsDrainingDecoder(false)); 1866 EXPECT_TRUE(IsDrainingDecoder(false));
1801 1867
1802 CreateNextTextureAndSetVideoSurface(); 1868 CreateNextTextureAndSetVideoSurface();
1803 WaitForVideoDecodeDone(); 1869 WaitForVideoDecodeDone();
1804 1870
1805 EXPECT_FALSE(IsDrainingDecoder(false)); 1871 EXPECT_FALSE(IsDrainingDecoder(false));
1806 EXPECT_FALSE(GetMediaCodecBridge(false)); 1872 EXPECT_FALSE(GetMediaCodecBridge(false));
1807 EXPECT_TRUE(player_.IsPlaying()); 1873 EXPECT_TRUE(player_.IsPlaying());
1808 EXPECT_EQ(3, demuxer_->num_data_requests()); 1874 EXPECT_EQ(3, demuxer_->num_data_requests());
1809 1875
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1995 // No further seek should have been requested since before Release(), above. 2061 // No further seek should have been requested since before Release(), above.
1996 EXPECT_EQ(1, demuxer_->num_seek_requests()); 2062 EXPECT_EQ(1, demuxer_->num_seek_requests());
1997 } 2063 }
1998 2064
1999 TEST_F(MediaSourcePlayerTest, ConfigChangedThenReleaseThenStart) { 2065 TEST_F(MediaSourcePlayerTest, ConfigChangedThenReleaseThenStart) {
2000 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 2066 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
2001 2067
2002 // Test if Release() occurs after |kConfigChanged| is processed, new data 2068 // Test if Release() occurs after |kConfigChanged| is processed, new data
2003 // requested of demuxer, and the requested data arrive before the next 2069 // requested of demuxer, and the requested data arrive before the next
2004 // Start(), then the player starts to decode the new data without any seek. 2070 // Start(), then the player starts to decode the new data without any seek.
2005 StartConfigChange(true, true, 0); 2071 StartConfigChange(true, true, 0, false);
2006 ReleasePlayer(); 2072 ReleasePlayer();
2007 2073
2008 EXPECT_TRUE(GetMediaCodecBridge(true)); 2074 EXPECT_TRUE(GetMediaCodecBridge(true));
2009 EXPECT_FALSE(player_.IsPlaying()); 2075 EXPECT_FALSE(player_.IsPlaying());
2010 EXPECT_EQ(3, demuxer_->num_data_requests()); 2076 EXPECT_EQ(3, demuxer_->num_data_requests());
2011 player_.OnDemuxerDataAvailable( 2077 player_.OnDemuxerDataAvailable(
2012 CreateReadFromDemuxerAckWithConfigChanged( 2078 CreateReadFromDemuxerAckWithConfigChanged(
2013 true, 4, CreateAudioDemuxerConfigs(kCodecVorbis, false))); 2079 true, 4, CreateAudioDemuxerConfigs(kCodecVorbis, false)));
2014 WaitForAudioDecodeDone(); 2080 WaitForAudioDecodeDone();
2015 EXPECT_FALSE(GetMediaCodecBridge(true)); 2081 EXPECT_FALSE(GetMediaCodecBridge(true));
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
2129 2195
2130 DemuxerConfigs configs = CreateAudioDemuxerConfigs(kCodecVorbis, true); 2196 DemuxerConfigs configs = CreateAudioDemuxerConfigs(kCodecVorbis, true);
2131 DemuxerData data = CreateReadFromDemuxerAckWithConfigChanged( 2197 DemuxerData data = CreateReadFromDemuxerAckWithConfigChanged(
2132 true, 0, configs); 2198 true, 0, configs);
2133 player_.OnDemuxerDataAvailable(data); 2199 player_.OnDemuxerDataAvailable(data);
2134 WaitForAudioDecodeDone(); 2200 WaitForAudioDecodeDone();
2135 DecodeAudioDataUntilOutputBecomesAvailable(); 2201 DecodeAudioDataUntilOutputBecomesAvailable();
2136 } 2202 }
2137 2203
2138 } // namespace media 2204 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698