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

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

Issue 1551103002: Convert Pass()→std::move() in //media (Android Cast edition) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/base/android/media_codec_player.h"
6
5 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility>
6 9
7 #include "base/bind.h" 10 #include "base/bind.h"
8 #include "base/logging.h" 11 #include "base/logging.h"
9 #include "base/macros.h" 12 #include "base/macros.h"
10 #include "base/timer/timer.h" 13 #include "base/timer/timer.h"
11 #include "media/base/android/demuxer_android.h" 14 #include "media/base/android/demuxer_android.h"
12 #include "media/base/android/media_codec_player.h"
13 #include "media/base/android/media_codec_util.h" 15 #include "media/base/android/media_codec_util.h"
14 #include "media/base/android/media_player_manager.h" 16 #include "media/base/android/media_player_manager.h"
15 #include "media/base/android/media_task_runner.h" 17 #include "media/base/android/media_task_runner.h"
16 #include "media/base/android/sdk_media_codec_bridge.h" 18 #include "media/base/android/sdk_media_codec_bridge.h"
17 #include "media/base/android/test_data_factory.h" 19 #include "media/base/android/test_data_factory.h"
18 #include "media/base/android/test_statistics.h" 20 #include "media/base/android/test_statistics.h"
19 #include "media/base/timestamp_constants.h" 21 #include "media/base/timestamp_constants.h"
20 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
21 #include "ui/gl/android/surface_texture.h" 23 #include "ui/gl/android/surface_texture.h"
22 24
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 // Helper methods that enable using a weak pointer when posting to the player. 340 // Helper methods that enable using a weak pointer when posting to the player.
339 void OnDemuxerDataAvailable(const DemuxerData& chunk); 341 void OnDemuxerDataAvailable(const DemuxerData& chunk);
340 void OnDemuxerSeekDone(base::TimeDelta reported_seek_time); 342 void OnDemuxerSeekDone(base::TimeDelta reported_seek_time);
341 343
342 // Sets the callback that is fired when demuxer is deleted (deletion 344 // Sets the callback that is fired when demuxer is deleted (deletion
343 // happens on the Media thread). 345 // happens on the Media thread).
344 void SetDemuxerDeletedCallback(base::Closure cb) { demuxer_deleted_cb_ = cb; } 346 void SetDemuxerDeletedCallback(base::Closure cb) { demuxer_deleted_cb_ = cb; }
345 347
346 // Sets the audio data factory. 348 // Sets the audio data factory.
347 void SetAudioFactory(scoped_ptr<AudioFactory> factory) { 349 void SetAudioFactory(scoped_ptr<AudioFactory> factory) {
348 audio_factory_ = factory.Pass(); 350 audio_factory_ = std::move(factory);
349 } 351 }
350 352
351 // Sets the video data factory. 353 // Sets the video data factory.
352 void SetVideoFactory(scoped_ptr<VideoFactory> factory) { 354 void SetVideoFactory(scoped_ptr<VideoFactory> factory) {
353 video_factory_ = factory.Pass(); 355 video_factory_ = std::move(factory);
354 } 356 }
355 357
356 // Accessors for data factories. 358 // Accessors for data factories.
357 AudioFactory* audio_factory() const { return audio_factory_.get(); } 359 AudioFactory* audio_factory() const { return audio_factory_.get(); }
358 VideoFactory* video_factory() const { return video_factory_.get(); } 360 VideoFactory* video_factory() const { return video_factory_.get(); }
359 361
360 // Set the preroll interval after seek for audio stream. 362 // Set the preroll interval after seek for audio stream.
361 void SetAudioPrerollInterval(base::TimeDelta value) { 363 void SetAudioPrerollInterval(base::TimeDelta value) {
362 audio_preroll_interval_ = value; 364 audio_preroll_interval_ = value;
363 } 365 }
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 scoped_ptr<MockDemuxerAndroid>(demuxer_), GURL()); 645 scoped_ptr<MockDemuxerAndroid>(demuxer_), GURL());
644 646
645 DCHECK(player_); 647 DCHECK(player_);
646 } 648 }
647 649
648 void MediaCodecPlayerTest::SetVideoSurface() { 650 void MediaCodecPlayerTest::SetVideoSurface() {
649 surface_texture_a_ = gfx::SurfaceTexture::Create(0); 651 surface_texture_a_ = gfx::SurfaceTexture::Create(0);
650 gfx::ScopedJavaSurface surface(surface_texture_a_.get()); 652 gfx::ScopedJavaSurface surface(surface_texture_a_.get());
651 653
652 ASSERT_NE(nullptr, player_); 654 ASSERT_NE(nullptr, player_);
653 player_->SetVideoSurface(surface.Pass()); 655 player_->SetVideoSurface(std::move(surface));
654 } 656 }
655 657
656 void MediaCodecPlayerTest::SetVideoSurfaceB() { 658 void MediaCodecPlayerTest::SetVideoSurfaceB() {
657 surface_texture_b_ = gfx::SurfaceTexture::Create(1); 659 surface_texture_b_ = gfx::SurfaceTexture::Create(1);
658 gfx::ScopedJavaSurface surface(surface_texture_b_.get()); 660 gfx::ScopedJavaSurface surface(surface_texture_b_.get());
659 661
660 ASSERT_NE(nullptr, player_); 662 ASSERT_NE(nullptr, player_);
661 player_->SetVideoSurface(surface.Pass()); 663 player_->SetVideoSurface(std::move(surface));
662 } 664 }
663 665
664 void MediaCodecPlayerTest::RemoveVideoSurface() { 666 void MediaCodecPlayerTest::RemoveVideoSurface() {
665 player_->SetVideoSurface(gfx::ScopedJavaSurface()); 667 player_->SetVideoSurface(gfx::ScopedJavaSurface());
666 surface_texture_a_ = NULL; 668 surface_texture_a_ = NULL;
667 } 669 }
668 670
669 bool MediaCodecPlayerTest::WaitForCondition(const Predicate& condition, 671 bool MediaCodecPlayerTest::WaitForCondition(const Predicate& condition,
670 const base::TimeDelta& timeout) { 672 const base::TimeDelta& timeout) {
671 // Let the message_loop_ process events. 673 // Let the message_loop_ process events.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 } 744 }
743 745
744 return true; 746 return true;
745 } 747 }
746 748
747 bool MediaCodecPlayerTest::StartAVPlayback( 749 bool MediaCodecPlayerTest::StartAVPlayback(
748 scoped_ptr<AudioFactory> audio_factory, 750 scoped_ptr<AudioFactory> audio_factory,
749 scoped_ptr<VideoFactory> video_factory, 751 scoped_ptr<VideoFactory> video_factory,
750 uint32_t flags, 752 uint32_t flags,
751 const char* test_name) { 753 const char* test_name) {
752 demuxer_->SetAudioFactory(audio_factory.Pass()); 754 demuxer_->SetAudioFactory(std::move(audio_factory));
753 demuxer_->SetVideoFactory(video_factory.Pass()); 755 demuxer_->SetVideoFactory(std::move(video_factory));
754 756
755 CreatePlayer(); 757 CreatePlayer();
756 SetVideoSurface(); 758 SetVideoSurface();
757 759
758 // Wait till the player is initialized on media thread. 760 // Wait till the player is initialized on media thread.
759 EXPECT_TRUE(WaitForCondition(base::Bind(&MockDemuxerAndroid::IsInitialized, 761 EXPECT_TRUE(WaitForCondition(base::Bind(&MockDemuxerAndroid::IsInitialized,
760 base::Unretained(demuxer_)))); 762 base::Unretained(demuxer_))));
761 763
762 if (!demuxer_->IsInitialized()) { 764 if (!demuxer_->IsInitialized()) {
763 DVLOG(0) << test_name << ": demuxer is not initialized"; 765 DVLOG(0) << test_name << ": demuxer is not initialized";
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 } 805 }
804 806
805 bool MediaCodecPlayerTest::StartAVSeekAndPreroll( 807 bool MediaCodecPlayerTest::StartAVSeekAndPreroll(
806 scoped_ptr<AudioFactory> audio_factory, 808 scoped_ptr<AudioFactory> audio_factory,
807 scoped_ptr<VideoFactory> video_factory, 809 scoped_ptr<VideoFactory> video_factory,
808 base::TimeDelta seek_position, 810 base::TimeDelta seek_position,
809 uint32_t flags, 811 uint32_t flags,
810 const char* test_name) { 812 const char* test_name) {
811 // Initialize A/V playback 813 // Initialize A/V playback
812 814
813 demuxer_->SetAudioFactory(audio_factory.Pass()); 815 demuxer_->SetAudioFactory(std::move(audio_factory));
814 demuxer_->SetVideoFactory(video_factory.Pass()); 816 demuxer_->SetVideoFactory(std::move(video_factory));
815 817
816 CreatePlayer(); 818 CreatePlayer();
817 SetVideoSurface(); 819 SetVideoSurface();
818 820
819 // Wait till the player is initialized on media thread. 821 // Wait till the player is initialized on media thread.
820 EXPECT_TRUE(WaitForCondition(base::Bind(&MockDemuxerAndroid::IsInitialized, 822 EXPECT_TRUE(WaitForCondition(base::Bind(&MockDemuxerAndroid::IsInitialized,
821 base::Unretained(demuxer_)))); 823 base::Unretained(demuxer_))));
822 824
823 if (!demuxer_->IsInitialized()) { 825 if (!demuxer_->IsInitialized()) {
824 DVLOG(0) << test_name << ": demuxer is not initialized"; 826 DVLOG(0) << test_name << ": demuxer is not initialized";
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
1538 // per frame it would take 250 ms to preroll. 1540 // per frame it would take 250 ms to preroll.
1539 base::TimeDelta seek_position = base::TimeDelta::FromMilliseconds(1000); 1541 base::TimeDelta seek_position = base::TimeDelta::FromMilliseconds(1000);
1540 base::TimeDelta preroll_intvl = base::TimeDelta::FromMilliseconds(500); 1542 base::TimeDelta preroll_intvl = base::TimeDelta::FromMilliseconds(500);
1541 base::TimeDelta preroll_timeout = base::TimeDelta::FromMilliseconds(1000); 1543 base::TimeDelta preroll_timeout = base::TimeDelta::FromMilliseconds(1000);
1542 1544
1543 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(duration)); 1545 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(duration));
1544 scoped_ptr<VideoFactory> video_factory(new VideoFactory(duration)); 1546 scoped_ptr<VideoFactory> video_factory(new VideoFactory(duration));
1545 1547
1546 demuxer_->SetVideoPrerollInterval(preroll_intvl); 1548 demuxer_->SetVideoPrerollInterval(preroll_intvl);
1547 1549
1548 ASSERT_TRUE(StartAVSeekAndPreroll(audio_factory.Pass(), video_factory.Pass(), 1550 ASSERT_TRUE(StartAVSeekAndPreroll(std::move(audio_factory),
1549 seek_position, 0, 1551 std::move(video_factory), seek_position, 0,
1550 "AVPrerollAudioWaitsForVideo")); 1552 "AVPrerollAudioWaitsForVideo"));
1551 1553
1552 // Wait till preroll finishes and the real playback starts. 1554 // Wait till preroll finishes and the real playback starts.
1553 EXPECT_TRUE( 1555 EXPECT_TRUE(
1554 WaitForCondition(base::Bind(&MockMediaPlayerManager::IsPlaybackStarted, 1556 WaitForCondition(base::Bind(&MockMediaPlayerManager::IsPlaybackStarted,
1555 base::Unretained(&manager_)), 1557 base::Unretained(&manager_)),
1556 preroll_timeout)); 1558 preroll_timeout));
1557 1559
1558 // Ensure that the first audio and video pts are close to each other and are 1560 // Ensure that the first audio and video pts are close to each other and are
1559 // reported at the close moments in time. 1561 // reported at the close moments in time.
(...skipping 27 matching lines...) Expand all
1587 base::TimeDelta preroll_intvl = base::TimeDelta::FromMilliseconds(500); 1589 base::TimeDelta preroll_intvl = base::TimeDelta::FromMilliseconds(500);
1588 1590
1589 base::TimeDelta start_timeout = base::TimeDelta::FromMilliseconds(800); 1591 base::TimeDelta start_timeout = base::TimeDelta::FromMilliseconds(800);
1590 base::TimeDelta preroll_timeout = base::TimeDelta::FromMilliseconds(1000); 1592 base::TimeDelta preroll_timeout = base::TimeDelta::FromMilliseconds(1000);
1591 1593
1592 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(duration)); 1594 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(duration));
1593 scoped_ptr<VideoFactory> video_factory(new VideoFactory(duration)); 1595 scoped_ptr<VideoFactory> video_factory(new VideoFactory(duration));
1594 1596
1595 demuxer_->SetVideoPrerollInterval(preroll_intvl); 1597 demuxer_->SetVideoPrerollInterval(preroll_intvl);
1596 1598
1597 ASSERT_TRUE(StartAVSeekAndPreroll(audio_factory.Pass(), video_factory.Pass(), 1599 ASSERT_TRUE(StartAVSeekAndPreroll(std::move(audio_factory),
1598 seek_position, 0, 1600 std::move(video_factory), seek_position, 0,
1599 "AVPrerollReleaseAndRestart")); 1601 "AVPrerollReleaseAndRestart"));
1600 1602
1601 // Issue Release(). 1603 // Issue Release().
1602 player_->Release(); 1604 player_->Release();
1603 1605
1604 // Make sure we have not been playing. 1606 // Make sure we have not been playing.
1605 WaitForDelay(base::TimeDelta::FromMilliseconds(400)); 1607 WaitForDelay(base::TimeDelta::FromMilliseconds(400));
1606 1608
1607 EXPECT_FALSE(manager_.HasFirstFrame(DemuxerStream::AUDIO)); 1609 EXPECT_FALSE(manager_.HasFirstFrame(DemuxerStream::AUDIO));
1608 EXPECT_FALSE(manager_.HasFirstFrame(DemuxerStream::VIDEO)); 1610 EXPECT_FALSE(manager_.HasFirstFrame(DemuxerStream::VIDEO));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1661 base::TimeDelta preroll_intvl = base::TimeDelta::FromMilliseconds(500); 1663 base::TimeDelta preroll_intvl = base::TimeDelta::FromMilliseconds(500);
1662 1664
1663 base::TimeDelta start_timeout = base::TimeDelta::FromMilliseconds(800); 1665 base::TimeDelta start_timeout = base::TimeDelta::FromMilliseconds(800);
1664 base::TimeDelta preroll_timeout = base::TimeDelta::FromMilliseconds(1000); 1666 base::TimeDelta preroll_timeout = base::TimeDelta::FromMilliseconds(1000);
1665 1667
1666 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(duration)); 1668 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(duration));
1667 scoped_ptr<VideoFactory> video_factory(new VideoFactory(duration)); 1669 scoped_ptr<VideoFactory> video_factory(new VideoFactory(duration));
1668 1670
1669 demuxer_->SetVideoPrerollInterval(preroll_intvl); 1671 demuxer_->SetVideoPrerollInterval(preroll_intvl);
1670 1672
1671 ASSERT_TRUE(StartAVSeekAndPreroll(audio_factory.Pass(), video_factory.Pass(), 1673 ASSERT_TRUE(StartAVSeekAndPreroll(std::move(audio_factory),
1672 seek_position, 0, 1674 std::move(video_factory), seek_position, 0,
1673 "AVPrerollStopAndRestart")); 1675 "AVPrerollStopAndRestart"));
1674 1676
1675 // Video stream should be prerolling. Request to stop. 1677 // Video stream should be prerolling. Request to stop.
1676 EXPECT_FALSE(IsPaused()); 1678 EXPECT_FALSE(IsPaused());
1677 player_->Pause(true); 1679 player_->Pause(true);
1678 1680
1679 EXPECT_TRUE(WaitForCondition( 1681 EXPECT_TRUE(WaitForCondition(
1680 base::Bind(&MediaCodecPlayerTest::IsPaused, base::Unretained(this)))); 1682 base::Bind(&MediaCodecPlayerTest::IsPaused, base::Unretained(this))));
1681 1683
1682 // Test that we have not been playing. 1684 // Test that we have not been playing.
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1904 base::TimeDelta config_change_position = 1906 base::TimeDelta config_change_position =
1905 base::TimeDelta::FromMilliseconds(1000); 1907 base::TimeDelta::FromMilliseconds(1000);
1906 1908
1907 base::TimeDelta completion_timeout = base::TimeDelta::FromMilliseconds(3000); 1909 base::TimeDelta completion_timeout = base::TimeDelta::FromMilliseconds(3000);
1908 1910
1909 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(duration)); 1911 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(duration));
1910 scoped_ptr<VideoFactory> video_factory(new VideoFactory(duration)); 1912 scoped_ptr<VideoFactory> video_factory(new VideoFactory(duration));
1911 1913
1912 video_factory->RequestConfigChange(config_change_position); 1914 video_factory->RequestConfigChange(config_change_position);
1913 1915
1914 ASSERT_TRUE(StartAVPlayback(audio_factory.Pass(), video_factory.Pass(), 1916 ASSERT_TRUE(StartAVPlayback(std::move(audio_factory),
1915 kAlwaysReconfigVideo, 1917 std::move(video_factory), kAlwaysReconfigVideo,
1916 "AVVideoConfigChangeWhilePlaying")); 1918 "AVVideoConfigChangeWhilePlaying"));
1917 1919
1918 // Wait till completion 1920 // Wait till completion
1919 EXPECT_TRUE( 1921 EXPECT_TRUE(
1920 WaitForCondition(base::Bind(&MockMediaPlayerManager::IsPlaybackCompleted, 1922 WaitForCondition(base::Bind(&MockMediaPlayerManager::IsPlaybackCompleted,
1921 base::Unretained(&manager_)), 1923 base::Unretained(&manager_)),
1922 completion_timeout)); 1924 completion_timeout));
1923 1925
1924 // The audio codec should be kept. 1926 // The audio codec should be kept.
1925 EXPECT_EQ(1, manager_.num_audio_codecs_created()); 1927 EXPECT_EQ(1, manager_.num_audio_codecs_created());
(...skipping 24 matching lines...) Expand all
1950 base::TimeDelta config_change_position = 1952 base::TimeDelta config_change_position =
1951 base::TimeDelta::FromMilliseconds(1000); 1953 base::TimeDelta::FromMilliseconds(1000);
1952 1954
1953 base::TimeDelta completion_timeout = base::TimeDelta::FromMilliseconds(3000); 1955 base::TimeDelta completion_timeout = base::TimeDelta::FromMilliseconds(3000);
1954 1956
1955 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(duration)); 1957 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(duration));
1956 scoped_ptr<VideoFactory> video_factory(new VideoFactory(duration)); 1958 scoped_ptr<VideoFactory> video_factory(new VideoFactory(duration));
1957 1959
1958 audio_factory->RequestConfigChange(config_change_position); 1960 audio_factory->RequestConfigChange(config_change_position);
1959 1961
1960 ASSERT_TRUE(StartAVPlayback(audio_factory.Pass(), video_factory.Pass(), 1962 ASSERT_TRUE(StartAVPlayback(std::move(audio_factory),
1961 kAlwaysReconfigAudio, 1963 std::move(video_factory), kAlwaysReconfigAudio,
1962 "AVAudioConfigChangeWhilePlaying")); 1964 "AVAudioConfigChangeWhilePlaying"));
1963 1965
1964 // Wait till completion 1966 // Wait till completion
1965 EXPECT_TRUE( 1967 EXPECT_TRUE(
1966 WaitForCondition(base::Bind(&MockMediaPlayerManager::IsPlaybackCompleted, 1968 WaitForCondition(base::Bind(&MockMediaPlayerManager::IsPlaybackCompleted,
1967 base::Unretained(&manager_)), 1969 base::Unretained(&manager_)),
1968 completion_timeout)); 1970 completion_timeout));
1969 1971
1970 // The audio codec should be recreated upon config changes. 1972 // The audio codec should be recreated upon config changes.
1971 EXPECT_EQ(2, manager_.num_audio_codecs_created()); 1973 EXPECT_EQ(2, manager_.num_audio_codecs_created());
(...skipping 24 matching lines...) Expand all
1996 base::TimeDelta config_change_video = base::TimeDelta::FromMilliseconds(1000); 1998 base::TimeDelta config_change_video = base::TimeDelta::FromMilliseconds(1000);
1997 1999
1998 base::TimeDelta completion_timeout = base::TimeDelta::FromMilliseconds(3000); 2000 base::TimeDelta completion_timeout = base::TimeDelta::FromMilliseconds(3000);
1999 2001
2000 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(duration)); 2002 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(duration));
2001 scoped_ptr<VideoFactory> video_factory(new VideoFactory(duration)); 2003 scoped_ptr<VideoFactory> video_factory(new VideoFactory(duration));
2002 2004
2003 audio_factory->RequestConfigChange(config_change_audio); 2005 audio_factory->RequestConfigChange(config_change_audio);
2004 video_factory->RequestConfigChange(config_change_video); 2006 video_factory->RequestConfigChange(config_change_video);
2005 2007
2006 ASSERT_TRUE(StartAVPlayback(audio_factory.Pass(), video_factory.Pass(), 2008 ASSERT_TRUE(StartAVPlayback(std::move(audio_factory),
2009 std::move(video_factory),
2007 kAlwaysReconfigAudio | kAlwaysReconfigVideo, 2010 kAlwaysReconfigAudio | kAlwaysReconfigVideo,
2008 "AVSimultaneousConfigChange_1")); 2011 "AVSimultaneousConfigChange_1"));
2009 2012
2010 // Wait till completion 2013 // Wait till completion
2011 EXPECT_TRUE( 2014 EXPECT_TRUE(
2012 WaitForCondition(base::Bind(&MockMediaPlayerManager::IsPlaybackCompleted, 2015 WaitForCondition(base::Bind(&MockMediaPlayerManager::IsPlaybackCompleted,
2013 base::Unretained(&manager_)), 2016 base::Unretained(&manager_)),
2014 completion_timeout)); 2017 completion_timeout));
2015 2018
2016 // The audio codec should be recreated upon config changes. 2019 // The audio codec should be recreated upon config changes.
(...skipping 26 matching lines...) Expand all
2043 base::TimeDelta config_change_video = base::TimeDelta::FromMilliseconds(1000); 2046 base::TimeDelta config_change_video = base::TimeDelta::FromMilliseconds(1000);
2044 2047
2045 base::TimeDelta completion_timeout = base::TimeDelta::FromMilliseconds(3000); 2048 base::TimeDelta completion_timeout = base::TimeDelta::FromMilliseconds(3000);
2046 2049
2047 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(duration)); 2050 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(duration));
2048 scoped_ptr<VideoFactory> video_factory(new VideoFactory(duration)); 2051 scoped_ptr<VideoFactory> video_factory(new VideoFactory(duration));
2049 2052
2050 audio_factory->RequestConfigChange(config_change_audio); 2053 audio_factory->RequestConfigChange(config_change_audio);
2051 video_factory->RequestConfigChange(config_change_video); 2054 video_factory->RequestConfigChange(config_change_video);
2052 2055
2053 ASSERT_TRUE(StartAVPlayback(audio_factory.Pass(), video_factory.Pass(), 2056 ASSERT_TRUE(StartAVPlayback(std::move(audio_factory),
2057 std::move(video_factory),
2054 kAlwaysReconfigAudio | kAlwaysReconfigVideo, 2058 kAlwaysReconfigAudio | kAlwaysReconfigVideo,
2055 "AVSimultaneousConfigChange_2")); 2059 "AVSimultaneousConfigChange_2"));
2056 2060
2057 // Wait till completion 2061 // Wait till completion
2058 EXPECT_TRUE( 2062 EXPECT_TRUE(
2059 WaitForCondition(base::Bind(&MockMediaPlayerManager::IsPlaybackCompleted, 2063 WaitForCondition(base::Bind(&MockMediaPlayerManager::IsPlaybackCompleted,
2060 base::Unretained(&manager_)), 2064 base::Unretained(&manager_)),
2061 completion_timeout)); 2065 completion_timeout));
2062 2066
2063 // The audio codec should be recreated upon config changes. 2067 // The audio codec should be recreated upon config changes.
(...skipping 23 matching lines...) Expand all
2087 base::TimeDelta video_duration = base::TimeDelta::FromMilliseconds(1200); 2091 base::TimeDelta video_duration = base::TimeDelta::FromMilliseconds(1200);
2088 base::TimeDelta config_change_video = base::TimeDelta::FromMilliseconds(1000); 2092 base::TimeDelta config_change_video = base::TimeDelta::FromMilliseconds(1000);
2089 2093
2090 base::TimeDelta completion_timeout = base::TimeDelta::FromMilliseconds(3000); 2094 base::TimeDelta completion_timeout = base::TimeDelta::FromMilliseconds(3000);
2091 2095
2092 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(audio_duration)); 2096 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(audio_duration));
2093 scoped_ptr<VideoFactory> video_factory(new VideoFactory(video_duration)); 2097 scoped_ptr<VideoFactory> video_factory(new VideoFactory(video_duration));
2094 2098
2095 video_factory->RequestConfigChange(config_change_video); 2099 video_factory->RequestConfigChange(config_change_video);
2096 2100
2097 ASSERT_TRUE(StartAVPlayback(audio_factory.Pass(), video_factory.Pass(), 2101 ASSERT_TRUE(StartAVPlayback(std::move(audio_factory),
2098 kAlwaysReconfigVideo, 2102 std::move(video_factory), kAlwaysReconfigVideo,
2099 "AVAudioEndsAcrossVideoConfigChange")); 2103 "AVAudioEndsAcrossVideoConfigChange"));
2100 2104
2101 // Wait till completion 2105 // Wait till completion
2102 EXPECT_TRUE( 2106 EXPECT_TRUE(
2103 WaitForCondition(base::Bind(&MockMediaPlayerManager::IsPlaybackCompleted, 2107 WaitForCondition(base::Bind(&MockMediaPlayerManager::IsPlaybackCompleted,
2104 base::Unretained(&manager_)), 2108 base::Unretained(&manager_)),
2105 completion_timeout)); 2109 completion_timeout));
2106 2110
2107 // The audio codec should not be recreated. 2111 // The audio codec should not be recreated.
2108 EXPECT_EQ(1, manager_.num_audio_codecs_created()); 2112 EXPECT_EQ(1, manager_.num_audio_codecs_created());
(...skipping 27 matching lines...) Expand all
2136 base::TimeDelta video_duration = base::TimeDelta::FromMilliseconds(1000); 2140 base::TimeDelta video_duration = base::TimeDelta::FromMilliseconds(1000);
2137 base::TimeDelta config_change_audio = base::TimeDelta::FromMilliseconds(1000); 2141 base::TimeDelta config_change_audio = base::TimeDelta::FromMilliseconds(1000);
2138 2142
2139 base::TimeDelta completion_timeout = base::TimeDelta::FromMilliseconds(3000); 2143 base::TimeDelta completion_timeout = base::TimeDelta::FromMilliseconds(3000);
2140 2144
2141 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(audio_duration)); 2145 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(audio_duration));
2142 scoped_ptr<VideoFactory> video_factory(new VideoFactory(video_duration)); 2146 scoped_ptr<VideoFactory> video_factory(new VideoFactory(video_duration));
2143 2147
2144 audio_factory->RequestConfigChange(config_change_audio); 2148 audio_factory->RequestConfigChange(config_change_audio);
2145 2149
2146 ASSERT_TRUE(StartAVPlayback(audio_factory.Pass(), video_factory.Pass(), 2150 ASSERT_TRUE(StartAVPlayback(std::move(audio_factory),
2147 kAlwaysReconfigAudio, 2151 std::move(video_factory), kAlwaysReconfigAudio,
2148 "AVVideoEndsAcrossAudioConfigChange")); 2152 "AVVideoEndsAcrossAudioConfigChange"));
2149 2153
2150 // Wait till completion 2154 // Wait till completion
2151 EXPECT_TRUE( 2155 EXPECT_TRUE(
2152 WaitForCondition(base::Bind(&MockMediaPlayerManager::IsPlaybackCompleted, 2156 WaitForCondition(base::Bind(&MockMediaPlayerManager::IsPlaybackCompleted,
2153 base::Unretained(&manager_)), 2157 base::Unretained(&manager_)),
2154 completion_timeout)); 2158 completion_timeout));
2155 2159
2156 // The audio codec should be recreated upon config changes. 2160 // The audio codec should be recreated upon config changes.
2157 EXPECT_EQ(2, manager_.num_audio_codecs_created()); 2161 EXPECT_EQ(2, manager_.num_audio_codecs_created());
(...skipping 21 matching lines...) Expand all
2179 base::TimeDelta video_preroll_intvl = base::TimeDelta::FromMilliseconds(500); 2183 base::TimeDelta video_preroll_intvl = base::TimeDelta::FromMilliseconds(500);
2180 base::TimeDelta preroll_timeout = base::TimeDelta::FromMilliseconds(3000); 2184 base::TimeDelta preroll_timeout = base::TimeDelta::FromMilliseconds(3000);
2181 2185
2182 demuxer_->SetVideoPrerollInterval(video_preroll_intvl); 2186 demuxer_->SetVideoPrerollInterval(video_preroll_intvl);
2183 2187
2184 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(duration)); 2188 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(duration));
2185 2189
2186 scoped_ptr<VideoFactory> video_factory(new VideoFactory(duration)); 2190 scoped_ptr<VideoFactory> video_factory(new VideoFactory(duration));
2187 video_factory->RequestConfigChange(config_change_position); 2191 video_factory->RequestConfigChange(config_change_position);
2188 2192
2189 ASSERT_TRUE(StartAVSeekAndPreroll(audio_factory.Pass(), video_factory.Pass(), 2193 ASSERT_TRUE(StartAVSeekAndPreroll(
2190 seek_position, kAlwaysReconfigVideo, 2194 std::move(audio_factory), std::move(video_factory), seek_position,
2191 "AVPrerollAcrossVideoConfigChange")); 2195 kAlwaysReconfigVideo, "AVPrerollAcrossVideoConfigChange"));
2192 2196
2193 // Wait till preroll finishes and the real playback starts. 2197 // Wait till preroll finishes and the real playback starts.
2194 EXPECT_TRUE( 2198 EXPECT_TRUE(
2195 WaitForCondition(base::Bind(&MockMediaPlayerManager::IsPlaybackStarted, 2199 WaitForCondition(base::Bind(&MockMediaPlayerManager::IsPlaybackStarted,
2196 base::Unretained(&manager_)), 2200 base::Unretained(&manager_)),
2197 preroll_timeout)); 2201 preroll_timeout));
2198 2202
2199 // The presense of config change should not affect preroll behavior: 2203 // The presense of config change should not affect preroll behavior:
2200 2204
2201 // Ensure that the first audio and video pts are close to each other and are 2205 // Ensure that the first audio and video pts are close to each other and are
(...skipping 26 matching lines...) Expand all
2228 base::TimeDelta audio_preroll_intvl = base::TimeDelta::FromMilliseconds(400); 2232 base::TimeDelta audio_preroll_intvl = base::TimeDelta::FromMilliseconds(400);
2229 base::TimeDelta preroll_timeout = base::TimeDelta::FromMilliseconds(3000); 2233 base::TimeDelta preroll_timeout = base::TimeDelta::FromMilliseconds(3000);
2230 2234
2231 demuxer_->SetAudioPrerollInterval(audio_preroll_intvl); 2235 demuxer_->SetAudioPrerollInterval(audio_preroll_intvl);
2232 2236
2233 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(duration)); 2237 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(duration));
2234 audio_factory->RequestConfigChange(config_change_position); 2238 audio_factory->RequestConfigChange(config_change_position);
2235 2239
2236 scoped_ptr<VideoFactory> video_factory(new VideoFactory(duration)); 2240 scoped_ptr<VideoFactory> video_factory(new VideoFactory(duration));
2237 2241
2238 ASSERT_TRUE(StartAVSeekAndPreroll(audio_factory.Pass(), video_factory.Pass(), 2242 ASSERT_TRUE(StartAVSeekAndPreroll(
2239 seek_position, kAlwaysReconfigAudio, 2243 std::move(audio_factory), std::move(video_factory), seek_position,
2240 "AVPrerollAcrossAudioConfigChange")); 2244 kAlwaysReconfigAudio, "AVPrerollAcrossAudioConfigChange"));
2241 2245
2242 // Wait till preroll finishes and the real playback starts. 2246 // Wait till preroll finishes and the real playback starts.
2243 EXPECT_TRUE( 2247 EXPECT_TRUE(
2244 WaitForCondition(base::Bind(&MockMediaPlayerManager::IsPlaybackStarted, 2248 WaitForCondition(base::Bind(&MockMediaPlayerManager::IsPlaybackStarted,
2245 base::Unretained(&manager_)), 2249 base::Unretained(&manager_)),
2246 preroll_timeout)); 2250 preroll_timeout));
2247 2251
2248 // The presense of config change should not affect preroll behavior: 2252 // The presense of config change should not affect preroll behavior:
2249 2253
2250 // Ensure that the first audio and video pts are close to each other and are 2254 // Ensure that the first audio and video pts are close to each other and are
(...skipping 16 matching lines...) Expand all
2267 // TODO(timav): maybe we should not call the testing callback for 2271 // TODO(timav): maybe we should not call the testing callback for
2268 // kRenderAfterPreroll for video (for audio we already do not call). 2272 // kRenderAfterPreroll for video (for audio we already do not call).
2269 // EXPECT_TRUE(AlmostEqual(manager_.FirstFrameTime(DemuxerStream::AUDIO), 2273 // EXPECT_TRUE(AlmostEqual(manager_.FirstFrameTime(DemuxerStream::AUDIO),
2270 // manager_.FirstFrameTime(DemuxerStream::VIDEO), 50)); 2274 // manager_.FirstFrameTime(DemuxerStream::VIDEO), 50));
2271 2275
2272 // The playback should start at |seek_position| 2276 // The playback should start at |seek_position|
2273 EXPECT_TRUE(AlmostEqual(seek_position, manager_.pts_stat_.min(), 25)); 2277 EXPECT_TRUE(AlmostEqual(seek_position, manager_.pts_stat_.min(), 25));
2274 } 2278 }
2275 2279
2276 } // namespace media 2280 } // namespace media
OLDNEW
« no previous file with comments | « media/base/android/media_codec_player.cc ('k') | media/base/android/media_codec_video_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698