OLD | NEW |
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" | 5 #include "media/base/android/media_codec_player.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <memory> |
8 #include <utility> | 9 #include <utility> |
9 | 10 |
10 #include "base/bind.h" | 11 #include "base/bind.h" |
11 #include "base/logging.h" | 12 #include "base/logging.h" |
12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ptr_util.h" |
13 #include "base/timer/timer.h" | 15 #include "base/timer/timer.h" |
14 #include "media/base/android/demuxer_android.h" | 16 #include "media/base/android/demuxer_android.h" |
15 #include "media/base/android/media_codec_util.h" | 17 #include "media/base/android/media_codec_util.h" |
16 #include "media/base/android/media_player_manager.h" | 18 #include "media/base/android/media_player_manager.h" |
17 #include "media/base/android/media_task_runner.h" | 19 #include "media/base/android/media_task_runner.h" |
18 #include "media/base/android/sdk_media_codec_bridge.h" | 20 #include "media/base/android/sdk_media_codec_bridge.h" |
19 #include "media/base/android/test_data_factory.h" | 21 #include "media/base/android/test_data_factory.h" |
20 #include "media/base/android/test_statistics.h" | 22 #include "media/base/android/test_statistics.h" |
21 #include "media/base/timestamp_constants.h" | 23 #include "media/base/timestamp_constants.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 | 343 |
342 // Helper methods that enable using a weak pointer when posting to the player. | 344 // Helper methods that enable using a weak pointer when posting to the player. |
343 void OnDemuxerDataAvailable(const DemuxerData& chunk); | 345 void OnDemuxerDataAvailable(const DemuxerData& chunk); |
344 void OnDemuxerSeekDone(base::TimeDelta reported_seek_time); | 346 void OnDemuxerSeekDone(base::TimeDelta reported_seek_time); |
345 | 347 |
346 // Sets the callback that is fired when demuxer is deleted (deletion | 348 // Sets the callback that is fired when demuxer is deleted (deletion |
347 // happens on the Media thread). | 349 // happens on the Media thread). |
348 void SetDemuxerDeletedCallback(base::Closure cb) { demuxer_deleted_cb_ = cb; } | 350 void SetDemuxerDeletedCallback(base::Closure cb) { demuxer_deleted_cb_ = cb; } |
349 | 351 |
350 // Sets the audio data factory. | 352 // Sets the audio data factory. |
351 void SetAudioFactory(scoped_ptr<AudioFactory> factory) { | 353 void SetAudioFactory(std::unique_ptr<AudioFactory> factory) { |
352 audio_factory_ = std::move(factory); | 354 audio_factory_ = std::move(factory); |
353 } | 355 } |
354 | 356 |
355 // Sets the video data factory. | 357 // Sets the video data factory. |
356 void SetVideoFactory(scoped_ptr<VideoFactory> factory) { | 358 void SetVideoFactory(std::unique_ptr<VideoFactory> factory) { |
357 video_factory_ = std::move(factory); | 359 video_factory_ = std::move(factory); |
358 } | 360 } |
359 | 361 |
360 // Accessors for data factories. | 362 // Accessors for data factories. |
361 AudioFactory* audio_factory() const { return audio_factory_.get(); } | 363 AudioFactory* audio_factory() const { return audio_factory_.get(); } |
362 VideoFactory* video_factory() const { return video_factory_.get(); } | 364 VideoFactory* video_factory() const { return video_factory_.get(); } |
363 | 365 |
364 // Set the preroll interval after seek for audio stream. | 366 // Set the preroll interval after seek for audio stream. |
365 void SetAudioPrerollInterval(base::TimeDelta value) { | 367 void SetAudioPrerollInterval(base::TimeDelta value) { |
366 audio_preroll_interval_ = value; | 368 audio_preroll_interval_ = value; |
(...skipping 16 matching lines...) Expand all Loading... |
383 // Conditions to wait for. | 385 // Conditions to wait for. |
384 bool IsInitialized() const { return client_; } | 386 bool IsInitialized() const { return client_; } |
385 bool HasPendingConfigs() const { return !!pending_configs_; } | 387 bool HasPendingConfigs() const { return !!pending_configs_; } |
386 bool ReceivedSeekRequest() const { return num_seeks_ > 0; } | 388 bool ReceivedSeekRequest() const { return num_seeks_ > 0; } |
387 bool ReceivedBrowserSeekRequest() const { return num_browser_seeks_ > 0; } | 389 bool ReceivedBrowserSeekRequest() const { return num_browser_seeks_ > 0; } |
388 | 390 |
389 private: | 391 private: |
390 base::MessageLoop* ui_message_loop_; | 392 base::MessageLoop* ui_message_loop_; |
391 DemuxerAndroidClient* client_; | 393 DemuxerAndroidClient* client_; |
392 | 394 |
393 scoped_ptr<DemuxerConfigs> pending_configs_; | 395 std::unique_ptr<DemuxerConfigs> pending_configs_; |
394 scoped_ptr<AudioFactory> audio_factory_; | 396 std::unique_ptr<AudioFactory> audio_factory_; |
395 scoped_ptr<VideoFactory> video_factory_; | 397 std::unique_ptr<VideoFactory> video_factory_; |
396 | 398 |
397 base::TimeDelta audio_preroll_interval_; | 399 base::TimeDelta audio_preroll_interval_; |
398 base::TimeDelta video_preroll_interval_; | 400 base::TimeDelta video_preroll_interval_; |
399 base::TimeDelta seek_done_delay_; | 401 base::TimeDelta seek_done_delay_; |
400 | 402 |
401 int num_seeks_; | 403 int num_seeks_; |
402 int num_browser_seeks_; | 404 int num_browser_seeks_; |
403 | 405 |
404 base::Closure demuxer_deleted_cb_; | 406 base::Closure demuxer_deleted_cb_; |
405 | 407 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 void MockDemuxerAndroid::PostConfigs(const DemuxerConfigs& configs) { | 508 void MockDemuxerAndroid::PostConfigs(const DemuxerConfigs& configs) { |
507 RUN_ON_MEDIA_THREAD(MockDemuxerAndroid, PostConfigs, configs); | 509 RUN_ON_MEDIA_THREAD(MockDemuxerAndroid, PostConfigs, configs); |
508 | 510 |
509 DVLOG(1) << "MockDemuxerAndroid::" << __FUNCTION__; | 511 DVLOG(1) << "MockDemuxerAndroid::" << __FUNCTION__; |
510 | 512 |
511 DCHECK(GetMediaTaskRunner()->BelongsToCurrentThread()); | 513 DCHECK(GetMediaTaskRunner()->BelongsToCurrentThread()); |
512 | 514 |
513 if (client_) | 515 if (client_) |
514 client_->OnDemuxerConfigsAvailable(configs); | 516 client_->OnDemuxerConfigsAvailable(configs); |
515 else | 517 else |
516 pending_configs_ = scoped_ptr<DemuxerConfigs>(new DemuxerConfigs(configs)); | 518 pending_configs_ = base::WrapUnique(new DemuxerConfigs(configs)); |
517 } | 519 } |
518 | 520 |
519 void MockDemuxerAndroid::PostInternalConfigs() { | 521 void MockDemuxerAndroid::PostInternalConfigs() { |
520 ASSERT_TRUE(audio_factory_ || video_factory_); | 522 ASSERT_TRUE(audio_factory_ || video_factory_); |
521 | 523 |
522 if (audio_factory_ && video_factory_) { | 524 if (audio_factory_ && video_factory_) { |
523 PostConfigs( | 525 PostConfigs( |
524 CreateAudioVideoConfigs(audio_factory_.get(), video_factory_.get())); | 526 CreateAudioVideoConfigs(audio_factory_.get(), video_factory_.get())); |
525 } else if (audio_factory_) { | 527 } else if (audio_factory_) { |
526 PostConfigs(audio_factory_->GetConfigs()); | 528 PostConfigs(audio_factory_->GetConfigs()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 // playback has passed the given position. | 565 // playback has passed the given position. |
564 bool WaitForPlaybackBeyondPosition( | 566 bool WaitForPlaybackBeyondPosition( |
565 const base::TimeDelta& pts, | 567 const base::TimeDelta& pts, |
566 const base::TimeDelta& timeout = kDefaultTimeout); | 568 const base::TimeDelta& timeout = kDefaultTimeout); |
567 | 569 |
568 // Helper method that starts video only stream. Waits till it actually | 570 // Helper method that starts video only stream. Waits till it actually |
569 // started. | 571 // started. |
570 bool StartVideoPlayback(base::TimeDelta duration, const char* test_name); | 572 bool StartVideoPlayback(base::TimeDelta duration, const char* test_name); |
571 | 573 |
572 // Helper method that starts audio and video streams. | 574 // Helper method that starts audio and video streams. |
573 bool StartAVPlayback(scoped_ptr<AudioFactory> audio_factory, | 575 bool StartAVPlayback(std::unique_ptr<AudioFactory> audio_factory, |
574 scoped_ptr<VideoFactory> video_factory, | 576 std::unique_ptr<VideoFactory> video_factory, |
575 uint32_t flags, | 577 uint32_t flags, |
576 const char* test_name); | 578 const char* test_name); |
577 | 579 |
578 // Helper method that starts audio and video streams with preroll. | 580 // Helper method that starts audio and video streams with preroll. |
579 // The preroll is achieved by setting significant video preroll interval | 581 // The preroll is achieved by setting significant video preroll interval |
580 // so video will have to catch up with audio. To make room for this interval | 582 // so video will have to catch up with audio. To make room for this interval |
581 // the Start() command is preceded by SeekTo(). | 583 // the Start() command is preceded by SeekTo(). |
582 bool StartAVSeekAndPreroll(scoped_ptr<AudioFactory> audio_factory, | 584 bool StartAVSeekAndPreroll(std::unique_ptr<AudioFactory> audio_factory, |
583 scoped_ptr<VideoFactory> video_factory, | 585 std::unique_ptr<VideoFactory> video_factory, |
584 base::TimeDelta seek_position, | 586 base::TimeDelta seek_position, |
585 uint32_t flags, | 587 uint32_t flags, |
586 const char* test_name); | 588 const char* test_name); |
587 | 589 |
588 // Callback sent when demuxer is being deleted. | 590 // Callback sent when demuxer is being deleted. |
589 void OnDemuxerDeleted() { demuxer_ = nullptr; } | 591 void OnDemuxerDeleted() { demuxer_ = nullptr; } |
590 | 592 |
591 bool IsDemuxerDeleted() const { return !demuxer_; } | 593 bool IsDemuxerDeleted() const { return !demuxer_; } |
592 | 594 |
593 base::MessageLoop message_loop_; | 595 base::MessageLoop message_loop_; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 } | 639 } |
638 } | 640 } |
639 | 641 |
640 void MediaCodecPlayerTest::CreatePlayer() { | 642 void MediaCodecPlayerTest::CreatePlayer() { |
641 DCHECK(demuxer_); | 643 DCHECK(demuxer_); |
642 player_ = new MediaCodecPlayer( | 644 player_ = new MediaCodecPlayer( |
643 0, // player_id | 645 0, // player_id |
644 manager_.GetWeakPtr(), | 646 manager_.GetWeakPtr(), |
645 base::Bind(&MockMediaPlayerManager::OnMediaResourcesRequested, | 647 base::Bind(&MockMediaPlayerManager::OnMediaResourcesRequested, |
646 base::Unretained(&manager_)), | 648 base::Unretained(&manager_)), |
647 scoped_ptr<MockDemuxerAndroid>(demuxer_), GURL(), kDefaultMediaSessionId); | 649 base::WrapUnique(demuxer_), GURL(), kDefaultMediaSessionId); |
648 | 650 |
649 DCHECK(player_); | 651 DCHECK(player_); |
650 } | 652 } |
651 | 653 |
652 void MediaCodecPlayerTest::SetVideoSurface() { | 654 void MediaCodecPlayerTest::SetVideoSurface() { |
653 surface_texture_a_ = gfx::SurfaceTexture::Create(0); | 655 surface_texture_a_ = gfx::SurfaceTexture::Create(0); |
654 gfx::ScopedJavaSurface surface(surface_texture_a_.get()); | 656 gfx::ScopedJavaSurface surface(surface_texture_a_.get()); |
655 | 657 |
656 ASSERT_NE(nullptr, player_); | 658 ASSERT_NE(nullptr, player_); |
657 player_->SetVideoSurface(std::move(surface)); | 659 player_->SetVideoSurface(std::move(surface)); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 return WaitForCondition( | 706 return WaitForCondition( |
705 base::Bind(&MockMediaPlayerManager::IsPlaybackBeyondPosition, | 707 base::Bind(&MockMediaPlayerManager::IsPlaybackBeyondPosition, |
706 base::Unretained(&manager_), pts), | 708 base::Unretained(&manager_), pts), |
707 timeout); | 709 timeout); |
708 } | 710 } |
709 | 711 |
710 bool MediaCodecPlayerTest::StartVideoPlayback(base::TimeDelta duration, | 712 bool MediaCodecPlayerTest::StartVideoPlayback(base::TimeDelta duration, |
711 const char* test_name) { | 713 const char* test_name) { |
712 const base::TimeDelta start_timeout = base::TimeDelta::FromMilliseconds(800); | 714 const base::TimeDelta start_timeout = base::TimeDelta::FromMilliseconds(800); |
713 | 715 |
714 demuxer_->SetVideoFactory( | 716 demuxer_->SetVideoFactory(base::WrapUnique(new VideoFactory(duration))); |
715 scoped_ptr<VideoFactory>(new VideoFactory(duration))); | |
716 | 717 |
717 CreatePlayer(); | 718 CreatePlayer(); |
718 | 719 |
719 // Wait till the player is initialized on media thread. | 720 // Wait till the player is initialized on media thread. |
720 EXPECT_TRUE(WaitForCondition(base::Bind(&MockDemuxerAndroid::IsInitialized, | 721 EXPECT_TRUE(WaitForCondition(base::Bind(&MockDemuxerAndroid::IsInitialized, |
721 base::Unretained(demuxer_)))); | 722 base::Unretained(demuxer_)))); |
722 | 723 |
723 if (!demuxer_->IsInitialized()) { | 724 if (!demuxer_->IsInitialized()) { |
724 DVLOG(0) << test_name << ": demuxer is not initialized"; | 725 DVLOG(0) << test_name << ": demuxer is not initialized"; |
725 return false; | 726 return false; |
(...skipping 16 matching lines...) Expand all Loading... |
742 | 743 |
743 if (!manager_.IsPlaybackStarted()) { | 744 if (!manager_.IsPlaybackStarted()) { |
744 DVLOG(0) << test_name << ": playback did not start"; | 745 DVLOG(0) << test_name << ": playback did not start"; |
745 return false; | 746 return false; |
746 } | 747 } |
747 | 748 |
748 return true; | 749 return true; |
749 } | 750 } |
750 | 751 |
751 bool MediaCodecPlayerTest::StartAVPlayback( | 752 bool MediaCodecPlayerTest::StartAVPlayback( |
752 scoped_ptr<AudioFactory> audio_factory, | 753 std::unique_ptr<AudioFactory> audio_factory, |
753 scoped_ptr<VideoFactory> video_factory, | 754 std::unique_ptr<VideoFactory> video_factory, |
754 uint32_t flags, | 755 uint32_t flags, |
755 const char* test_name) { | 756 const char* test_name) { |
756 demuxer_->SetAudioFactory(std::move(audio_factory)); | 757 demuxer_->SetAudioFactory(std::move(audio_factory)); |
757 demuxer_->SetVideoFactory(std::move(video_factory)); | 758 demuxer_->SetVideoFactory(std::move(video_factory)); |
758 | 759 |
759 CreatePlayer(); | 760 CreatePlayer(); |
760 SetVideoSurface(); | 761 SetVideoSurface(); |
761 | 762 |
762 // Wait till the player is initialized on media thread. | 763 // Wait till the player is initialized on media thread. |
763 EXPECT_TRUE(WaitForCondition(base::Bind(&MockDemuxerAndroid::IsInitialized, | 764 EXPECT_TRUE(WaitForCondition(base::Bind(&MockDemuxerAndroid::IsInitialized, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 | 801 |
801 if (!manager_.IsPlaybackStarted()) { | 802 if (!manager_.IsPlaybackStarted()) { |
802 DVLOG(0) << test_name << ": playback did not start"; | 803 DVLOG(0) << test_name << ": playback did not start"; |
803 return false; | 804 return false; |
804 } | 805 } |
805 | 806 |
806 return true; | 807 return true; |
807 } | 808 } |
808 | 809 |
809 bool MediaCodecPlayerTest::StartAVSeekAndPreroll( | 810 bool MediaCodecPlayerTest::StartAVSeekAndPreroll( |
810 scoped_ptr<AudioFactory> audio_factory, | 811 std::unique_ptr<AudioFactory> audio_factory, |
811 scoped_ptr<VideoFactory> video_factory, | 812 std::unique_ptr<VideoFactory> video_factory, |
812 base::TimeDelta seek_position, | 813 base::TimeDelta seek_position, |
813 uint32_t flags, | 814 uint32_t flags, |
814 const char* test_name) { | 815 const char* test_name) { |
815 // Initialize A/V playback | 816 // Initialize A/V playback |
816 | 817 |
817 demuxer_->SetAudioFactory(std::move(audio_factory)); | 818 demuxer_->SetAudioFactory(std::move(audio_factory)); |
818 demuxer_->SetVideoFactory(std::move(video_factory)); | 819 demuxer_->SetVideoFactory(std::move(video_factory)); |
819 | 820 |
820 CreatePlayer(); | 821 CreatePlayer(); |
821 SetVideoSurface(); | 822 SetVideoSurface(); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
937 EXPECT_EQ(320, manager_.media_metadata_.width); | 938 EXPECT_EQ(320, manager_.media_metadata_.width); |
938 EXPECT_EQ(240, manager_.media_metadata_.height); | 939 EXPECT_EQ(240, manager_.media_metadata_.height); |
939 } | 940 } |
940 | 941 |
941 TEST_F(MediaCodecPlayerTest, DISABLED_AudioPlayTillCompletion) { | 942 TEST_F(MediaCodecPlayerTest, DISABLED_AudioPlayTillCompletion) { |
942 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 943 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
943 | 944 |
944 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(1000); | 945 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(1000); |
945 base::TimeDelta timeout = base::TimeDelta::FromMilliseconds(2000); | 946 base::TimeDelta timeout = base::TimeDelta::FromMilliseconds(2000); |
946 | 947 |
947 demuxer_->SetAudioFactory( | 948 demuxer_->SetAudioFactory(base::WrapUnique(new AudioFactory(duration))); |
948 scoped_ptr<AudioFactory>(new AudioFactory(duration))); | |
949 | 949 |
950 CreatePlayer(); | 950 CreatePlayer(); |
951 | 951 |
952 // Wait till the player is initialized on media thread. | 952 // Wait till the player is initialized on media thread. |
953 EXPECT_TRUE(WaitForCondition(base::Bind(&MockDemuxerAndroid::IsInitialized, | 953 EXPECT_TRUE(WaitForCondition(base::Bind(&MockDemuxerAndroid::IsInitialized, |
954 base::Unretained(demuxer_)))); | 954 base::Unretained(demuxer_)))); |
955 | 955 |
956 // Post configuration after the player has been initialized. | 956 // Post configuration after the player has been initialized. |
957 demuxer_->PostInternalConfigs(); | 957 demuxer_->PostInternalConfigs(); |
958 | 958 |
(...skipping 13 matching lines...) Expand all Loading... |
972 } | 972 } |
973 | 973 |
974 TEST_F(MediaCodecPlayerTest, AudioNoPermission) { | 974 TEST_F(MediaCodecPlayerTest, AudioNoPermission) { |
975 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 975 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
976 | 976 |
977 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(1000); | 977 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(1000); |
978 base::TimeDelta start_timeout = base::TimeDelta::FromMilliseconds(800); | 978 base::TimeDelta start_timeout = base::TimeDelta::FromMilliseconds(800); |
979 | 979 |
980 manager_.SetPlaybackAllowed(false); | 980 manager_.SetPlaybackAllowed(false); |
981 | 981 |
982 demuxer_->SetAudioFactory( | 982 demuxer_->SetAudioFactory(base::WrapUnique(new AudioFactory(duration))); |
983 scoped_ptr<AudioFactory>(new AudioFactory(duration))); | |
984 | 983 |
985 CreatePlayer(); | 984 CreatePlayer(); |
986 | 985 |
987 // Wait till the player is initialized on media thread. | 986 // Wait till the player is initialized on media thread. |
988 EXPECT_TRUE(WaitForCondition(base::Bind(&MockDemuxerAndroid::IsInitialized, | 987 EXPECT_TRUE(WaitForCondition(base::Bind(&MockDemuxerAndroid::IsInitialized, |
989 base::Unretained(demuxer_)))); | 988 base::Unretained(demuxer_)))); |
990 | 989 |
991 // Post configuration after the player has been initialized. | 990 // Post configuration after the player has been initialized. |
992 demuxer_->PostInternalConfigs(); | 991 demuxer_->PostInternalConfigs(); |
993 | 992 |
(...skipping 26 matching lines...) Expand all Loading... |
1020 } | 1019 } |
1021 | 1020 |
1022 TEST_F(MediaCodecPlayerTest, VideoNoPermission) { | 1021 TEST_F(MediaCodecPlayerTest, VideoNoPermission) { |
1023 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1022 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
1024 | 1023 |
1025 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); | 1024 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); |
1026 const base::TimeDelta start_timeout = base::TimeDelta::FromMilliseconds(800); | 1025 const base::TimeDelta start_timeout = base::TimeDelta::FromMilliseconds(800); |
1027 | 1026 |
1028 manager_.SetPlaybackAllowed(false); | 1027 manager_.SetPlaybackAllowed(false); |
1029 | 1028 |
1030 demuxer_->SetVideoFactory( | 1029 demuxer_->SetVideoFactory(base::WrapUnique(new VideoFactory(duration))); |
1031 scoped_ptr<VideoFactory>(new VideoFactory(duration))); | |
1032 | 1030 |
1033 CreatePlayer(); | 1031 CreatePlayer(); |
1034 | 1032 |
1035 // Wait till the player is initialized on media thread. | 1033 // Wait till the player is initialized on media thread. |
1036 EXPECT_TRUE(WaitForCondition(base::Bind(&MockDemuxerAndroid::IsInitialized, | 1034 EXPECT_TRUE(WaitForCondition(base::Bind(&MockDemuxerAndroid::IsInitialized, |
1037 base::Unretained(demuxer_)))); | 1035 base::Unretained(demuxer_)))); |
1038 | 1036 |
1039 SetVideoSurface(); | 1037 SetVideoSurface(); |
1040 | 1038 |
1041 // Post configuration after the player has been initialized. | 1039 // Post configuration after the player has been initialized. |
(...skipping 12 matching lines...) Expand all Loading... |
1054 | 1052 |
1055 // http://crbug.com/518900 | 1053 // http://crbug.com/518900 |
1056 TEST_F(MediaCodecPlayerTest, DISABLED_AudioSeekAfterStop) { | 1054 TEST_F(MediaCodecPlayerTest, DISABLED_AudioSeekAfterStop) { |
1057 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1055 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
1058 | 1056 |
1059 // Play for 300 ms, then Pause, then Seek to beginning. The playback should | 1057 // Play for 300 ms, then Pause, then Seek to beginning. The playback should |
1060 // start from the beginning. | 1058 // start from the beginning. |
1061 | 1059 |
1062 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(2000); | 1060 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(2000); |
1063 | 1061 |
1064 demuxer_->SetAudioFactory( | 1062 demuxer_->SetAudioFactory(base::WrapUnique(new AudioFactory(duration))); |
1065 scoped_ptr<AudioFactory>(new AudioFactory(duration))); | |
1066 | 1063 |
1067 CreatePlayer(); | 1064 CreatePlayer(); |
1068 | 1065 |
1069 // Post configuration. | 1066 // Post configuration. |
1070 demuxer_->PostInternalConfigs(); | 1067 demuxer_->PostInternalConfigs(); |
1071 | 1068 |
1072 // Start the player. | 1069 // Start the player. |
1073 player_->Start(); | 1070 player_->Start(); |
1074 | 1071 |
1075 // Wait for playback to start. | 1072 // Wait for playback to start. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1114 | 1111 |
1115 TEST_F(MediaCodecPlayerTest, DISABLED_AudioSeekThenPlay) { | 1112 TEST_F(MediaCodecPlayerTest, DISABLED_AudioSeekThenPlay) { |
1116 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1113 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
1117 | 1114 |
1118 // Issue Seek command immediately followed by Start. The playback should | 1115 // Issue Seek command immediately followed by Start. The playback should |
1119 // start at the seek position. | 1116 // start at the seek position. |
1120 | 1117 |
1121 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(2000); | 1118 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(2000); |
1122 base::TimeDelta seek_position = base::TimeDelta::FromMilliseconds(500); | 1119 base::TimeDelta seek_position = base::TimeDelta::FromMilliseconds(500); |
1123 | 1120 |
1124 demuxer_->SetAudioFactory( | 1121 demuxer_->SetAudioFactory(base::WrapUnique(new AudioFactory(duration))); |
1125 scoped_ptr<AudioFactory>(new AudioFactory(duration))); | |
1126 | 1122 |
1127 CreatePlayer(); | 1123 CreatePlayer(); |
1128 | 1124 |
1129 // Post configuration. | 1125 // Post configuration. |
1130 demuxer_->PostInternalConfigs(); | 1126 demuxer_->PostInternalConfigs(); |
1131 | 1127 |
1132 // Seek and immediately start. | 1128 // Seek and immediately start. |
1133 player_->SeekTo(seek_position); | 1129 player_->SeekTo(seek_position); |
1134 player_->Start(); | 1130 player_->Start(); |
1135 | 1131 |
(...skipping 13 matching lines...) Expand all Loading... |
1149 TEST_F(MediaCodecPlayerTest, DISABLED_AudioSeekThenPlayThenConfig) { | 1145 TEST_F(MediaCodecPlayerTest, DISABLED_AudioSeekThenPlayThenConfig) { |
1150 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1146 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
1151 | 1147 |
1152 // Issue Seek command immediately followed by Start but without prior demuxer | 1148 // Issue Seek command immediately followed by Start but without prior demuxer |
1153 // configuration. Start should wait for configuration. After it has been | 1149 // configuration. Start should wait for configuration. After it has been |
1154 // posted the playback should start at the seek position. | 1150 // posted the playback should start at the seek position. |
1155 | 1151 |
1156 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(2000); | 1152 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(2000); |
1157 base::TimeDelta seek_position = base::TimeDelta::FromMilliseconds(500); | 1153 base::TimeDelta seek_position = base::TimeDelta::FromMilliseconds(500); |
1158 | 1154 |
1159 demuxer_->SetAudioFactory( | 1155 demuxer_->SetAudioFactory(base::WrapUnique(new AudioFactory(duration))); |
1160 scoped_ptr<AudioFactory>(new AudioFactory(duration))); | |
1161 | 1156 |
1162 CreatePlayer(); | 1157 CreatePlayer(); |
1163 | 1158 |
1164 // Seek and immediately start. | 1159 // Seek and immediately start. |
1165 player_->SeekTo(seek_position); | 1160 player_->SeekTo(seek_position); |
1166 player_->Start(); | 1161 player_->Start(); |
1167 | 1162 |
1168 // Make sure the player is waiting. | 1163 // Make sure the player is waiting. |
1169 WaitForDelay(base::TimeDelta::FromMilliseconds(200)); | 1164 WaitForDelay(base::TimeDelta::FromMilliseconds(200)); |
1170 EXPECT_FALSE(player_->IsPlaying()); | 1165 EXPECT_FALSE(player_->IsPlaying()); |
(...skipping 20 matching lines...) Expand all Loading... |
1191 | 1186 |
1192 // Play for 300 ms, then issue several Seek commands in the row. | 1187 // Play for 300 ms, then issue several Seek commands in the row. |
1193 // The playback should continue at the last seek position. | 1188 // The playback should continue at the last seek position. |
1194 | 1189 |
1195 // To test this condition without analyzing the reported time details | 1190 // To test this condition without analyzing the reported time details |
1196 // and without introducing dependency on implementation I make a long (10s) | 1191 // and without introducing dependency on implementation I make a long (10s) |
1197 // duration and test that the playback resumes after big time jump (5s) in a | 1192 // duration and test that the playback resumes after big time jump (5s) in a |
1198 // short period of time (200 ms). | 1193 // short period of time (200 ms). |
1199 base::TimeDelta duration = base::TimeDelta::FromSeconds(10); | 1194 base::TimeDelta duration = base::TimeDelta::FromSeconds(10); |
1200 | 1195 |
1201 demuxer_->SetAudioFactory( | 1196 demuxer_->SetAudioFactory(base::WrapUnique(new AudioFactory(duration))); |
1202 scoped_ptr<AudioFactory>(new AudioFactory(duration))); | |
1203 | 1197 |
1204 CreatePlayer(); | 1198 CreatePlayer(); |
1205 | 1199 |
1206 // Post configuration. | 1200 // Post configuration. |
1207 demuxer_->PostInternalConfigs(); | 1201 demuxer_->PostInternalConfigs(); |
1208 | 1202 |
1209 // Start the player. | 1203 // Start the player. |
1210 player_->Start(); | 1204 player_->Start(); |
1211 | 1205 |
1212 // Wait for playback to start. | 1206 // Wait for playback to start. |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1479 // they should not be rendered. We deduce which frame is rendered by looking | 1473 // they should not be rendered. We deduce which frame is rendered by looking |
1480 // at the reported time progress. | 1474 // at the reported time progress. |
1481 | 1475 |
1482 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(600); | 1476 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(600); |
1483 base::TimeDelta seek_position = base::TimeDelta::FromMilliseconds(500); | 1477 base::TimeDelta seek_position = base::TimeDelta::FromMilliseconds(500); |
1484 base::TimeDelta start_timeout = base::TimeDelta::FromMilliseconds(800); | 1478 base::TimeDelta start_timeout = base::TimeDelta::FromMilliseconds(800); |
1485 | 1479 |
1486 // Tell demuxer to make the first frame 100ms earlier than the seek request. | 1480 // Tell demuxer to make the first frame 100ms earlier than the seek request. |
1487 demuxer_->SetVideoPrerollInterval(base::TimeDelta::FromMilliseconds(100)); | 1481 demuxer_->SetVideoPrerollInterval(base::TimeDelta::FromMilliseconds(100)); |
1488 | 1482 |
1489 demuxer_->SetVideoFactory( | 1483 demuxer_->SetVideoFactory(base::WrapUnique(new VideoFactory(duration))); |
1490 scoped_ptr<VideoFactory>(new VideoFactory(duration))); | |
1491 | 1484 |
1492 CreatePlayer(); | 1485 CreatePlayer(); |
1493 SetVideoSurface(); | 1486 SetVideoSurface(); |
1494 | 1487 |
1495 // Wait till the player is initialized on media thread. | 1488 // Wait till the player is initialized on media thread. |
1496 EXPECT_TRUE(WaitForCondition(base::Bind(&MockDemuxerAndroid::IsInitialized, | 1489 EXPECT_TRUE(WaitForCondition(base::Bind(&MockDemuxerAndroid::IsInitialized, |
1497 base::Unretained(demuxer_)))); | 1490 base::Unretained(demuxer_)))); |
1498 if (!demuxer_->IsInitialized()) { | 1491 if (!demuxer_->IsInitialized()) { |
1499 DVLOG(0) << "VideoPrerollAfterSeek: demuxer is not initialized"; | 1492 DVLOG(0) << "VideoPrerollAfterSeek: demuxer is not initialized"; |
1500 return; | 1493 return; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1537 // with a decoder PTS that is delivered by a test-only callback. | 1530 // with a decoder PTS that is delivered by a test-only callback. |
1538 | 1531 |
1539 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(2000); | 1532 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(2000); |
1540 | 1533 |
1541 // Set significant preroll interval. 500 ms means 25 frames, at 10 ms | 1534 // Set significant preroll interval. 500 ms means 25 frames, at 10 ms |
1542 // per frame it would take 250 ms to preroll. | 1535 // per frame it would take 250 ms to preroll. |
1543 base::TimeDelta seek_position = base::TimeDelta::FromMilliseconds(1000); | 1536 base::TimeDelta seek_position = base::TimeDelta::FromMilliseconds(1000); |
1544 base::TimeDelta preroll_intvl = base::TimeDelta::FromMilliseconds(500); | 1537 base::TimeDelta preroll_intvl = base::TimeDelta::FromMilliseconds(500); |
1545 base::TimeDelta preroll_timeout = base::TimeDelta::FromMilliseconds(1000); | 1538 base::TimeDelta preroll_timeout = base::TimeDelta::FromMilliseconds(1000); |
1546 | 1539 |
1547 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(duration)); | 1540 std::unique_ptr<AudioFactory> audio_factory(new AudioFactory(duration)); |
1548 scoped_ptr<VideoFactory> video_factory(new VideoFactory(duration)); | 1541 std::unique_ptr<VideoFactory> video_factory(new VideoFactory(duration)); |
1549 | 1542 |
1550 demuxer_->SetVideoPrerollInterval(preroll_intvl); | 1543 demuxer_->SetVideoPrerollInterval(preroll_intvl); |
1551 | 1544 |
1552 ASSERT_TRUE(StartAVSeekAndPreroll(std::move(audio_factory), | 1545 ASSERT_TRUE(StartAVSeekAndPreroll(std::move(audio_factory), |
1553 std::move(video_factory), seek_position, 0, | 1546 std::move(video_factory), seek_position, 0, |
1554 "AVPrerollAudioWaitsForVideo")); | 1547 "AVPrerollAudioWaitsForVideo")); |
1555 | 1548 |
1556 // Wait till preroll finishes and the real playback starts. | 1549 // Wait till preroll finishes and the real playback starts. |
1557 EXPECT_TRUE( | 1550 EXPECT_TRUE( |
1558 WaitForCondition(base::Bind(&MockMediaPlayerManager::IsPlaybackStarted, | 1551 WaitForCondition(base::Bind(&MockMediaPlayerManager::IsPlaybackStarted, |
(...skipping 27 matching lines...) Expand all Loading... |
1586 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(2000); | 1579 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(2000); |
1587 | 1580 |
1588 // Set significant preroll interval. 500 ms means 25 frames, at 10 ms | 1581 // Set significant preroll interval. 500 ms means 25 frames, at 10 ms |
1589 // per frame it would take 250 ms to preroll. | 1582 // per frame it would take 250 ms to preroll. |
1590 base::TimeDelta seek_position = base::TimeDelta::FromMilliseconds(1000); | 1583 base::TimeDelta seek_position = base::TimeDelta::FromMilliseconds(1000); |
1591 base::TimeDelta preroll_intvl = base::TimeDelta::FromMilliseconds(500); | 1584 base::TimeDelta preroll_intvl = base::TimeDelta::FromMilliseconds(500); |
1592 | 1585 |
1593 base::TimeDelta start_timeout = base::TimeDelta::FromMilliseconds(800); | 1586 base::TimeDelta start_timeout = base::TimeDelta::FromMilliseconds(800); |
1594 base::TimeDelta preroll_timeout = base::TimeDelta::FromMilliseconds(1000); | 1587 base::TimeDelta preroll_timeout = base::TimeDelta::FromMilliseconds(1000); |
1595 | 1588 |
1596 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(duration)); | 1589 std::unique_ptr<AudioFactory> audio_factory(new AudioFactory(duration)); |
1597 scoped_ptr<VideoFactory> video_factory(new VideoFactory(duration)); | 1590 std::unique_ptr<VideoFactory> video_factory(new VideoFactory(duration)); |
1598 | 1591 |
1599 demuxer_->SetVideoPrerollInterval(preroll_intvl); | 1592 demuxer_->SetVideoPrerollInterval(preroll_intvl); |
1600 | 1593 |
1601 ASSERT_TRUE(StartAVSeekAndPreroll(std::move(audio_factory), | 1594 ASSERT_TRUE(StartAVSeekAndPreroll(std::move(audio_factory), |
1602 std::move(video_factory), seek_position, 0, | 1595 std::move(video_factory), seek_position, 0, |
1603 "AVPrerollReleaseAndRestart")); | 1596 "AVPrerollReleaseAndRestart")); |
1604 | 1597 |
1605 // Issue Release(). | 1598 // Issue Release(). |
1606 player_->Release(); | 1599 player_->Release(); |
1607 | 1600 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1660 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(1200); | 1653 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(1200); |
1661 | 1654 |
1662 // Set significant preroll interval. 500 ms means 25 frames, at 10 ms | 1655 // Set significant preroll interval. 500 ms means 25 frames, at 10 ms |
1663 // per frame it would take 250 ms to preroll. | 1656 // per frame it would take 250 ms to preroll. |
1664 base::TimeDelta seek_position = base::TimeDelta::FromMilliseconds(1000); | 1657 base::TimeDelta seek_position = base::TimeDelta::FromMilliseconds(1000); |
1665 base::TimeDelta preroll_intvl = base::TimeDelta::FromMilliseconds(500); | 1658 base::TimeDelta preroll_intvl = base::TimeDelta::FromMilliseconds(500); |
1666 | 1659 |
1667 base::TimeDelta start_timeout = base::TimeDelta::FromMilliseconds(800); | 1660 base::TimeDelta start_timeout = base::TimeDelta::FromMilliseconds(800); |
1668 base::TimeDelta preroll_timeout = base::TimeDelta::FromMilliseconds(1000); | 1661 base::TimeDelta preroll_timeout = base::TimeDelta::FromMilliseconds(1000); |
1669 | 1662 |
1670 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(duration)); | 1663 std::unique_ptr<AudioFactory> audio_factory(new AudioFactory(duration)); |
1671 scoped_ptr<VideoFactory> video_factory(new VideoFactory(duration)); | 1664 std::unique_ptr<VideoFactory> video_factory(new VideoFactory(duration)); |
1672 | 1665 |
1673 demuxer_->SetVideoPrerollInterval(preroll_intvl); | 1666 demuxer_->SetVideoPrerollInterval(preroll_intvl); |
1674 | 1667 |
1675 ASSERT_TRUE(StartAVSeekAndPreroll(std::move(audio_factory), | 1668 ASSERT_TRUE(StartAVSeekAndPreroll(std::move(audio_factory), |
1676 std::move(video_factory), seek_position, 0, | 1669 std::move(video_factory), seek_position, 0, |
1677 "AVPrerollStopAndRestart")); | 1670 "AVPrerollStopAndRestart")); |
1678 | 1671 |
1679 // Video stream should be prerolling. Request to stop. | 1672 // Video stream should be prerolling. Request to stop. |
1680 EXPECT_FALSE(IsPaused()); | 1673 EXPECT_FALSE(IsPaused()); |
1681 player_->Pause(true); | 1674 player_->Pause(true); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1756 base::TimeDelta audio_duration = base::TimeDelta::FromMilliseconds(1100); | 1749 base::TimeDelta audio_duration = base::TimeDelta::FromMilliseconds(1100); |
1757 base::TimeDelta video_duration = base::TimeDelta::FromMilliseconds(900); | 1750 base::TimeDelta video_duration = base::TimeDelta::FromMilliseconds(900); |
1758 base::TimeDelta seek_position = base::TimeDelta::FromMilliseconds(1000); | 1751 base::TimeDelta seek_position = base::TimeDelta::FromMilliseconds(1000); |
1759 base::TimeDelta video_preroll_intvl = base::TimeDelta::FromMilliseconds(200); | 1752 base::TimeDelta video_preroll_intvl = base::TimeDelta::FromMilliseconds(200); |
1760 | 1753 |
1761 base::TimeDelta start_timeout = base::TimeDelta::FromMilliseconds(800); | 1754 base::TimeDelta start_timeout = base::TimeDelta::FromMilliseconds(800); |
1762 base::TimeDelta preroll_timeout = base::TimeDelta::FromMilliseconds(400); | 1755 base::TimeDelta preroll_timeout = base::TimeDelta::FromMilliseconds(400); |
1763 | 1756 |
1764 demuxer_->SetVideoPrerollInterval(video_preroll_intvl); | 1757 demuxer_->SetVideoPrerollInterval(video_preroll_intvl); |
1765 | 1758 |
1766 demuxer_->SetAudioFactory( | 1759 demuxer_->SetAudioFactory(base::WrapUnique(new AudioFactory(audio_duration))); |
1767 scoped_ptr<AudioFactory>(new AudioFactory(audio_duration))); | 1760 demuxer_->SetVideoFactory(base::WrapUnique(new VideoFactory(video_duration))); |
1768 demuxer_->SetVideoFactory( | |
1769 scoped_ptr<VideoFactory>(new VideoFactory(video_duration))); | |
1770 | 1761 |
1771 CreatePlayer(); | 1762 CreatePlayer(); |
1772 SetVideoSurface(); | 1763 SetVideoSurface(); |
1773 | 1764 |
1774 // Set special testing callback to receive PTS from decoders. | 1765 // Set special testing callback to receive PTS from decoders. |
1775 player_->SetDecodersTimeCallbackForTests( | 1766 player_->SetDecodersTimeCallbackForTests( |
1776 base::Bind(&MockMediaPlayerManager::OnDecodersTimeUpdate, | 1767 base::Bind(&MockMediaPlayerManager::OnDecodersTimeUpdate, |
1777 base::Unretained(&manager_))); | 1768 base::Unretained(&manager_))); |
1778 | 1769 |
1779 // Wait till the player is initialized on media thread. | 1770 // Wait till the player is initialized on media thread. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1834 // Test that video only playback continues after video config change. | 1825 // Test that video only playback continues after video config change. |
1835 | 1826 |
1836 // Initialize video playback | 1827 // Initialize video playback |
1837 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(1200); | 1828 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(1200); |
1838 base::TimeDelta config_change_position = | 1829 base::TimeDelta config_change_position = |
1839 base::TimeDelta::FromMilliseconds(1000); | 1830 base::TimeDelta::FromMilliseconds(1000); |
1840 | 1831 |
1841 base::TimeDelta start_timeout = base::TimeDelta::FromMilliseconds(2000); | 1832 base::TimeDelta start_timeout = base::TimeDelta::FromMilliseconds(2000); |
1842 base::TimeDelta completion_timeout = base::TimeDelta::FromMilliseconds(3000); | 1833 base::TimeDelta completion_timeout = base::TimeDelta::FromMilliseconds(3000); |
1843 | 1834 |
1844 demuxer_->SetVideoFactory( | 1835 demuxer_->SetVideoFactory(base::WrapUnique(new VideoFactory(duration))); |
1845 scoped_ptr<VideoFactory>(new VideoFactory(duration))); | |
1846 | 1836 |
1847 demuxer_->video_factory()->RequestConfigChange(config_change_position); | 1837 demuxer_->video_factory()->RequestConfigChange(config_change_position); |
1848 | 1838 |
1849 CreatePlayer(); | 1839 CreatePlayer(); |
1850 SetVideoSurface(); | 1840 SetVideoSurface(); |
1851 | 1841 |
1852 // Wait till the player is initialized on media thread. | 1842 // Wait till the player is initialized on media thread. |
1853 EXPECT_TRUE(WaitForCondition(base::Bind(&MockDemuxerAndroid::IsInitialized, | 1843 EXPECT_TRUE(WaitForCondition(base::Bind(&MockDemuxerAndroid::IsInitialized, |
1854 base::Unretained(demuxer_)))); | 1844 base::Unretained(demuxer_)))); |
1855 | 1845 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1904 | 1894 |
1905 // Test that A/V playback continues after video config change. | 1895 // Test that A/V playback continues after video config change. |
1906 | 1896 |
1907 // Initialize A/V playback | 1897 // Initialize A/V playback |
1908 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(1200); | 1898 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(1200); |
1909 base::TimeDelta config_change_position = | 1899 base::TimeDelta config_change_position = |
1910 base::TimeDelta::FromMilliseconds(1000); | 1900 base::TimeDelta::FromMilliseconds(1000); |
1911 | 1901 |
1912 base::TimeDelta completion_timeout = base::TimeDelta::FromMilliseconds(3000); | 1902 base::TimeDelta completion_timeout = base::TimeDelta::FromMilliseconds(3000); |
1913 | 1903 |
1914 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(duration)); | 1904 std::unique_ptr<AudioFactory> audio_factory(new AudioFactory(duration)); |
1915 scoped_ptr<VideoFactory> video_factory(new VideoFactory(duration)); | 1905 std::unique_ptr<VideoFactory> video_factory(new VideoFactory(duration)); |
1916 | 1906 |
1917 video_factory->RequestConfigChange(config_change_position); | 1907 video_factory->RequestConfigChange(config_change_position); |
1918 | 1908 |
1919 ASSERT_TRUE(StartAVPlayback(std::move(audio_factory), | 1909 ASSERT_TRUE(StartAVPlayback(std::move(audio_factory), |
1920 std::move(video_factory), kAlwaysReconfigVideo, | 1910 std::move(video_factory), kAlwaysReconfigVideo, |
1921 "AVVideoConfigChangeWhilePlaying")); | 1911 "AVVideoConfigChangeWhilePlaying")); |
1922 | 1912 |
1923 // Wait till completion | 1913 // Wait till completion |
1924 EXPECT_TRUE( | 1914 EXPECT_TRUE( |
1925 WaitForCondition(base::Bind(&MockMediaPlayerManager::IsPlaybackCompleted, | 1915 WaitForCondition(base::Bind(&MockMediaPlayerManager::IsPlaybackCompleted, |
(...skipping 24 matching lines...) Expand all Loading... |
1950 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1940 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
1951 | 1941 |
1952 // Test that A/V playback continues after audio config change. | 1942 // Test that A/V playback continues after audio config change. |
1953 | 1943 |
1954 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(1200); | 1944 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(1200); |
1955 base::TimeDelta config_change_position = | 1945 base::TimeDelta config_change_position = |
1956 base::TimeDelta::FromMilliseconds(1000); | 1946 base::TimeDelta::FromMilliseconds(1000); |
1957 | 1947 |
1958 base::TimeDelta completion_timeout = base::TimeDelta::FromMilliseconds(3000); | 1948 base::TimeDelta completion_timeout = base::TimeDelta::FromMilliseconds(3000); |
1959 | 1949 |
1960 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(duration)); | 1950 std::unique_ptr<AudioFactory> audio_factory(new AudioFactory(duration)); |
1961 scoped_ptr<VideoFactory> video_factory(new VideoFactory(duration)); | 1951 std::unique_ptr<VideoFactory> video_factory(new VideoFactory(duration)); |
1962 | 1952 |
1963 audio_factory->RequestConfigChange(config_change_position); | 1953 audio_factory->RequestConfigChange(config_change_position); |
1964 | 1954 |
1965 ASSERT_TRUE(StartAVPlayback(std::move(audio_factory), | 1955 ASSERT_TRUE(StartAVPlayback(std::move(audio_factory), |
1966 std::move(video_factory), kAlwaysReconfigAudio, | 1956 std::move(video_factory), kAlwaysReconfigAudio, |
1967 "AVAudioConfigChangeWhilePlaying")); | 1957 "AVAudioConfigChangeWhilePlaying")); |
1968 | 1958 |
1969 // Wait till completion | 1959 // Wait till completion |
1970 EXPECT_TRUE( | 1960 EXPECT_TRUE( |
1971 WaitForCondition(base::Bind(&MockMediaPlayerManager::IsPlaybackCompleted, | 1961 WaitForCondition(base::Bind(&MockMediaPlayerManager::IsPlaybackCompleted, |
(...skipping 23 matching lines...) Expand all Loading... |
1995 | 1985 |
1996 // Test that the playback continues if audio and video config changes happen | 1986 // Test that the playback continues if audio and video config changes happen |
1997 // at the same time. | 1987 // at the same time. |
1998 | 1988 |
1999 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(1200); | 1989 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(1200); |
2000 base::TimeDelta config_change_audio = base::TimeDelta::FromMilliseconds(1000); | 1990 base::TimeDelta config_change_audio = base::TimeDelta::FromMilliseconds(1000); |
2001 base::TimeDelta config_change_video = base::TimeDelta::FromMilliseconds(1000); | 1991 base::TimeDelta config_change_video = base::TimeDelta::FromMilliseconds(1000); |
2002 | 1992 |
2003 base::TimeDelta completion_timeout = base::TimeDelta::FromMilliseconds(3000); | 1993 base::TimeDelta completion_timeout = base::TimeDelta::FromMilliseconds(3000); |
2004 | 1994 |
2005 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(duration)); | 1995 std::unique_ptr<AudioFactory> audio_factory(new AudioFactory(duration)); |
2006 scoped_ptr<VideoFactory> video_factory(new VideoFactory(duration)); | 1996 std::unique_ptr<VideoFactory> video_factory(new VideoFactory(duration)); |
2007 | 1997 |
2008 audio_factory->RequestConfigChange(config_change_audio); | 1998 audio_factory->RequestConfigChange(config_change_audio); |
2009 video_factory->RequestConfigChange(config_change_video); | 1999 video_factory->RequestConfigChange(config_change_video); |
2010 | 2000 |
2011 ASSERT_TRUE(StartAVPlayback(std::move(audio_factory), | 2001 ASSERT_TRUE(StartAVPlayback(std::move(audio_factory), |
2012 std::move(video_factory), | 2002 std::move(video_factory), |
2013 kAlwaysReconfigAudio | kAlwaysReconfigVideo, | 2003 kAlwaysReconfigAudio | kAlwaysReconfigVideo, |
2014 "AVSimultaneousConfigChange_1")); | 2004 "AVSimultaneousConfigChange_1")); |
2015 | 2005 |
2016 // Wait till completion | 2006 // Wait till completion |
(...skipping 26 matching lines...) Expand all Loading... |
2043 // Test that the playback continues if audio and video config changes happen | 2033 // Test that the playback continues if audio and video config changes happen |
2044 // at the same time. Move audio change moment slightly to make it drained | 2034 // at the same time. Move audio change moment slightly to make it drained |
2045 // after video. | 2035 // after video. |
2046 | 2036 |
2047 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(1200); | 2037 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(1200); |
2048 base::TimeDelta config_change_audio = base::TimeDelta::FromMilliseconds(1020); | 2038 base::TimeDelta config_change_audio = base::TimeDelta::FromMilliseconds(1020); |
2049 base::TimeDelta config_change_video = base::TimeDelta::FromMilliseconds(1000); | 2039 base::TimeDelta config_change_video = base::TimeDelta::FromMilliseconds(1000); |
2050 | 2040 |
2051 base::TimeDelta completion_timeout = base::TimeDelta::FromMilliseconds(3000); | 2041 base::TimeDelta completion_timeout = base::TimeDelta::FromMilliseconds(3000); |
2052 | 2042 |
2053 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(duration)); | 2043 std::unique_ptr<AudioFactory> audio_factory(new AudioFactory(duration)); |
2054 scoped_ptr<VideoFactory> video_factory(new VideoFactory(duration)); | 2044 std::unique_ptr<VideoFactory> video_factory(new VideoFactory(duration)); |
2055 | 2045 |
2056 audio_factory->RequestConfigChange(config_change_audio); | 2046 audio_factory->RequestConfigChange(config_change_audio); |
2057 video_factory->RequestConfigChange(config_change_video); | 2047 video_factory->RequestConfigChange(config_change_video); |
2058 | 2048 |
2059 ASSERT_TRUE(StartAVPlayback(std::move(audio_factory), | 2049 ASSERT_TRUE(StartAVPlayback(std::move(audio_factory), |
2060 std::move(video_factory), | 2050 std::move(video_factory), |
2061 kAlwaysReconfigAudio | kAlwaysReconfigVideo, | 2051 kAlwaysReconfigAudio | kAlwaysReconfigVideo, |
2062 "AVSimultaneousConfigChange_2")); | 2052 "AVSimultaneousConfigChange_2")); |
2063 | 2053 |
2064 // Wait till completion | 2054 // Wait till completion |
(...skipping 24 matching lines...) Expand all Loading... |
2089 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 2079 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
2090 | 2080 |
2091 // Test that audio can end while video config change processing. | 2081 // Test that audio can end while video config change processing. |
2092 | 2082 |
2093 base::TimeDelta audio_duration = base::TimeDelta::FromMilliseconds(1000); | 2083 base::TimeDelta audio_duration = base::TimeDelta::FromMilliseconds(1000); |
2094 base::TimeDelta video_duration = base::TimeDelta::FromMilliseconds(1200); | 2084 base::TimeDelta video_duration = base::TimeDelta::FromMilliseconds(1200); |
2095 base::TimeDelta config_change_video = base::TimeDelta::FromMilliseconds(1000); | 2085 base::TimeDelta config_change_video = base::TimeDelta::FromMilliseconds(1000); |
2096 | 2086 |
2097 base::TimeDelta completion_timeout = base::TimeDelta::FromMilliseconds(3000); | 2087 base::TimeDelta completion_timeout = base::TimeDelta::FromMilliseconds(3000); |
2098 | 2088 |
2099 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(audio_duration)); | 2089 std::unique_ptr<AudioFactory> audio_factory(new AudioFactory(audio_duration)); |
2100 scoped_ptr<VideoFactory> video_factory(new VideoFactory(video_duration)); | 2090 std::unique_ptr<VideoFactory> video_factory(new VideoFactory(video_duration)); |
2101 | 2091 |
2102 video_factory->RequestConfigChange(config_change_video); | 2092 video_factory->RequestConfigChange(config_change_video); |
2103 | 2093 |
2104 ASSERT_TRUE(StartAVPlayback(std::move(audio_factory), | 2094 ASSERT_TRUE(StartAVPlayback(std::move(audio_factory), |
2105 std::move(video_factory), kAlwaysReconfigVideo, | 2095 std::move(video_factory), kAlwaysReconfigVideo, |
2106 "AVAudioEndsAcrossVideoConfigChange")); | 2096 "AVAudioEndsAcrossVideoConfigChange")); |
2107 | 2097 |
2108 // Wait till completion | 2098 // Wait till completion |
2109 EXPECT_TRUE( | 2099 EXPECT_TRUE( |
2110 WaitForCondition(base::Bind(&MockMediaPlayerManager::IsPlaybackCompleted, | 2100 WaitForCondition(base::Bind(&MockMediaPlayerManager::IsPlaybackCompleted, |
(...skipping 28 matching lines...) Expand all Loading... |
2139 TEST_F(MediaCodecPlayerTest, DISABLED_AVVideoEndsAcrossAudioConfigChange) { | 2129 TEST_F(MediaCodecPlayerTest, DISABLED_AVVideoEndsAcrossAudioConfigChange) { |
2140 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 2130 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
2141 | 2131 |
2142 // Test that video can end while audio config change processing. | 2132 // Test that video can end while audio config change processing. |
2143 base::TimeDelta audio_duration = base::TimeDelta::FromMilliseconds(1200); | 2133 base::TimeDelta audio_duration = base::TimeDelta::FromMilliseconds(1200); |
2144 base::TimeDelta video_duration = base::TimeDelta::FromMilliseconds(1000); | 2134 base::TimeDelta video_duration = base::TimeDelta::FromMilliseconds(1000); |
2145 base::TimeDelta config_change_audio = base::TimeDelta::FromMilliseconds(1000); | 2135 base::TimeDelta config_change_audio = base::TimeDelta::FromMilliseconds(1000); |
2146 | 2136 |
2147 base::TimeDelta completion_timeout = base::TimeDelta::FromMilliseconds(3000); | 2137 base::TimeDelta completion_timeout = base::TimeDelta::FromMilliseconds(3000); |
2148 | 2138 |
2149 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(audio_duration)); | 2139 std::unique_ptr<AudioFactory> audio_factory(new AudioFactory(audio_duration)); |
2150 scoped_ptr<VideoFactory> video_factory(new VideoFactory(video_duration)); | 2140 std::unique_ptr<VideoFactory> video_factory(new VideoFactory(video_duration)); |
2151 | 2141 |
2152 audio_factory->RequestConfigChange(config_change_audio); | 2142 audio_factory->RequestConfigChange(config_change_audio); |
2153 | 2143 |
2154 ASSERT_TRUE(StartAVPlayback(std::move(audio_factory), | 2144 ASSERT_TRUE(StartAVPlayback(std::move(audio_factory), |
2155 std::move(video_factory), kAlwaysReconfigAudio, | 2145 std::move(video_factory), kAlwaysReconfigAudio, |
2156 "AVVideoEndsAcrossAudioConfigChange")); | 2146 "AVVideoEndsAcrossAudioConfigChange")); |
2157 | 2147 |
2158 // Wait till completion | 2148 // Wait till completion |
2159 EXPECT_TRUE( | 2149 EXPECT_TRUE( |
2160 WaitForCondition(base::Bind(&MockMediaPlayerManager::IsPlaybackCompleted, | 2150 WaitForCondition(base::Bind(&MockMediaPlayerManager::IsPlaybackCompleted, |
(...skipping 21 matching lines...) Expand all Loading... |
2182 | 2172 |
2183 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(1200); | 2173 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(1200); |
2184 base::TimeDelta seek_position = base::TimeDelta::FromMilliseconds(1000); | 2174 base::TimeDelta seek_position = base::TimeDelta::FromMilliseconds(1000); |
2185 base::TimeDelta config_change_position = | 2175 base::TimeDelta config_change_position = |
2186 base::TimeDelta::FromMilliseconds(800); | 2176 base::TimeDelta::FromMilliseconds(800); |
2187 base::TimeDelta video_preroll_intvl = base::TimeDelta::FromMilliseconds(500); | 2177 base::TimeDelta video_preroll_intvl = base::TimeDelta::FromMilliseconds(500); |
2188 base::TimeDelta preroll_timeout = base::TimeDelta::FromMilliseconds(3000); | 2178 base::TimeDelta preroll_timeout = base::TimeDelta::FromMilliseconds(3000); |
2189 | 2179 |
2190 demuxer_->SetVideoPrerollInterval(video_preroll_intvl); | 2180 demuxer_->SetVideoPrerollInterval(video_preroll_intvl); |
2191 | 2181 |
2192 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(duration)); | 2182 std::unique_ptr<AudioFactory> audio_factory(new AudioFactory(duration)); |
2193 | 2183 |
2194 scoped_ptr<VideoFactory> video_factory(new VideoFactory(duration)); | 2184 std::unique_ptr<VideoFactory> video_factory(new VideoFactory(duration)); |
2195 video_factory->RequestConfigChange(config_change_position); | 2185 video_factory->RequestConfigChange(config_change_position); |
2196 | 2186 |
2197 ASSERT_TRUE(StartAVSeekAndPreroll( | 2187 ASSERT_TRUE(StartAVSeekAndPreroll( |
2198 std::move(audio_factory), std::move(video_factory), seek_position, | 2188 std::move(audio_factory), std::move(video_factory), seek_position, |
2199 kAlwaysReconfigVideo, "AVPrerollAcrossVideoConfigChange")); | 2189 kAlwaysReconfigVideo, "AVPrerollAcrossVideoConfigChange")); |
2200 | 2190 |
2201 // Wait till preroll finishes and the real playback starts. | 2191 // Wait till preroll finishes and the real playback starts. |
2202 EXPECT_TRUE( | 2192 EXPECT_TRUE( |
2203 WaitForCondition(base::Bind(&MockMediaPlayerManager::IsPlaybackStarted, | 2193 WaitForCondition(base::Bind(&MockMediaPlayerManager::IsPlaybackStarted, |
2204 base::Unretained(&manager_)), | 2194 base::Unretained(&manager_)), |
(...skipping 26 matching lines...) Expand all Loading... |
2231 | 2221 |
2232 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(1200); | 2222 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(1200); |
2233 base::TimeDelta seek_position = base::TimeDelta::FromMilliseconds(1000); | 2223 base::TimeDelta seek_position = base::TimeDelta::FromMilliseconds(1000); |
2234 base::TimeDelta config_change_position = | 2224 base::TimeDelta config_change_position = |
2235 base::TimeDelta::FromMilliseconds(800); | 2225 base::TimeDelta::FromMilliseconds(800); |
2236 base::TimeDelta audio_preroll_intvl = base::TimeDelta::FromMilliseconds(400); | 2226 base::TimeDelta audio_preroll_intvl = base::TimeDelta::FromMilliseconds(400); |
2237 base::TimeDelta preroll_timeout = base::TimeDelta::FromMilliseconds(3000); | 2227 base::TimeDelta preroll_timeout = base::TimeDelta::FromMilliseconds(3000); |
2238 | 2228 |
2239 demuxer_->SetAudioPrerollInterval(audio_preroll_intvl); | 2229 demuxer_->SetAudioPrerollInterval(audio_preroll_intvl); |
2240 | 2230 |
2241 scoped_ptr<AudioFactory> audio_factory(new AudioFactory(duration)); | 2231 std::unique_ptr<AudioFactory> audio_factory(new AudioFactory(duration)); |
2242 audio_factory->RequestConfigChange(config_change_position); | 2232 audio_factory->RequestConfigChange(config_change_position); |
2243 | 2233 |
2244 scoped_ptr<VideoFactory> video_factory(new VideoFactory(duration)); | 2234 std::unique_ptr<VideoFactory> video_factory(new VideoFactory(duration)); |
2245 | 2235 |
2246 ASSERT_TRUE(StartAVSeekAndPreroll( | 2236 ASSERT_TRUE(StartAVSeekAndPreroll( |
2247 std::move(audio_factory), std::move(video_factory), seek_position, | 2237 std::move(audio_factory), std::move(video_factory), seek_position, |
2248 kAlwaysReconfigAudio, "AVPrerollAcrossAudioConfigChange")); | 2238 kAlwaysReconfigAudio, "AVPrerollAcrossAudioConfigChange")); |
2249 | 2239 |
2250 // Wait till preroll finishes and the real playback starts. | 2240 // Wait till preroll finishes and the real playback starts. |
2251 EXPECT_TRUE( | 2241 EXPECT_TRUE( |
2252 WaitForCondition(base::Bind(&MockMediaPlayerManager::IsPlaybackStarted, | 2242 WaitForCondition(base::Bind(&MockMediaPlayerManager::IsPlaybackStarted, |
2253 base::Unretained(&manager_)), | 2243 base::Unretained(&manager_)), |
2254 preroll_timeout)); | 2244 preroll_timeout)); |
(...skipping 20 matching lines...) Expand all Loading... |
2275 // TODO(timav): maybe we should not call the testing callback for | 2265 // TODO(timav): maybe we should not call the testing callback for |
2276 // kRenderAfterPreroll for video (for audio we already do not call). | 2266 // kRenderAfterPreroll for video (for audio we already do not call). |
2277 // EXPECT_TRUE(AlmostEqual(manager_.FirstFrameTime(DemuxerStream::AUDIO), | 2267 // EXPECT_TRUE(AlmostEqual(manager_.FirstFrameTime(DemuxerStream::AUDIO), |
2278 // manager_.FirstFrameTime(DemuxerStream::VIDEO), 50)); | 2268 // manager_.FirstFrameTime(DemuxerStream::VIDEO), 50)); |
2279 | 2269 |
2280 // The playback should start at |seek_position| | 2270 // The playback should start at |seek_position| |
2281 EXPECT_TRUE(AlmostEqual(seek_position, manager_.pts_stat_.min(), 25)); | 2271 EXPECT_TRUE(AlmostEqual(seek_position, manager_.pts_stat_.min(), 25)); |
2282 } | 2272 } |
2283 | 2273 |
2284 } // namespace media | 2274 } // namespace media |
OLD | NEW |