OLD | NEW |
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 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 EXPECT_EQ(1, demuxer_->num_seek_requests()); | 724 EXPECT_EQ(1, demuxer_->num_seek_requests()); |
725 | 725 |
726 player_.OnDemuxerSeekDone(kNoTimestamp()); | 726 player_.OnDemuxerSeekDone(kNoTimestamp()); |
727 EXPECT_FALSE(manager_.playback_completed()); | 727 EXPECT_FALSE(manager_.playback_completed()); |
728 } | 728 } |
729 | 729 |
730 base::TimeTicks StartTimeTicks() { | 730 base::TimeTicks StartTimeTicks() { |
731 return player_.start_time_ticks_; | 731 return player_.start_time_ticks_; |
732 } | 732 } |
733 | 733 |
| 734 AudioTimestampHelper* GetAudioTimestampHelper() { |
| 735 return player_.audio_timestamp_helper_.get(); |
| 736 } |
| 737 |
734 base::MessageLoop message_loop_; | 738 base::MessageLoop message_loop_; |
735 MockMediaPlayerManager manager_; | 739 MockMediaPlayerManager manager_; |
736 MockDemuxerAndroid* demuxer_; // Owned by |player_|. | 740 MockDemuxerAndroid* demuxer_; // Owned by |player_|. |
737 MediaSourcePlayer player_; | 741 MediaSourcePlayer player_; |
738 | 742 |
739 // Track whether a possibly async decoder callback test hook has run. | 743 // Track whether a possibly async decoder callback test hook has run. |
740 bool decoder_callback_hook_executed_; | 744 bool decoder_callback_hook_executed_; |
741 | 745 |
742 // We need to keep the surface texture while the decoder is actively decoding. | 746 // We need to keep the surface texture while the decoder is actively decoding. |
743 // Otherwise, it may trigger unexpected crashes on some devices. To switch | 747 // Otherwise, it may trigger unexpected crashes on some devices. To switch |
(...skipping 1313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2057 // player has not yet received media crypto. | 2061 // player has not yet received media crypto. |
2058 DemuxerConfigs configs = CreateVideoDemuxerConfigs(); | 2062 DemuxerConfigs configs = CreateVideoDemuxerConfigs(); |
2059 configs.is_video_encrypted = true; | 2063 configs.is_video_encrypted = true; |
2060 | 2064 |
2061 player_.OnDemuxerConfigsAvailable(configs); | 2065 player_.OnDemuxerConfigsAvailable(configs); |
2062 CreateNextTextureAndSetVideoSurface(); | 2066 CreateNextTextureAndSetVideoSurface(); |
2063 EXPECT_FALSE(IsPendingSurfaceChange()); | 2067 EXPECT_FALSE(IsPendingSurfaceChange()); |
2064 EXPECT_FALSE(GetMediaDecoderJob(false)); | 2068 EXPECT_FALSE(GetMediaDecoderJob(false)); |
2065 } | 2069 } |
2066 | 2070 |
| 2071 TEST_F(MediaSourcePlayerTest, CurrentTimeUpdatedWhileDecoderStarved) { |
| 2072 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
| 2073 |
| 2074 // Test that current time is updated while decoder is starved. |
| 2075 StartAudioDecoderJob(true); |
| 2076 for (int i = 0; i < 3; ++i) { |
| 2077 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(i)); |
| 2078 WaitForAudioDecodeDone(); |
| 2079 } |
| 2080 base::TimeDelta current_time = player_.GetCurrentTime(); |
| 2081 |
| 2082 // Trigger starvation while the decoder is decoding. |
| 2083 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(3)); |
| 2084 TriggerPlayerStarvation(); |
| 2085 WaitForAudioDecodeDone(); |
| 2086 |
| 2087 // Current time should be updated. |
| 2088 EXPECT_LT(current_time.InMillisecondsF(), |
| 2089 player_.GetCurrentTime().InMillisecondsF()); |
| 2090 } |
| 2091 |
| 2092 TEST_F(MediaSourcePlayerTest, |
| 2093 AudioTimestampHelperNotRecreatedIfOnlyVideoConfigChanges) { |
| 2094 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
| 2095 |
| 2096 // Test that AudioTimestampHelper is not recreated if only video config |
| 2097 // changes. |
| 2098 CreateNextTextureAndSetVideoSurface(); |
| 2099 Start(CreateAudioVideoDemuxerConfigs(), true); |
| 2100 AudioTimestampHelper* helper = GetAudioTimestampHelper(); |
| 2101 for (int i = 0; i < 3; ++i) { |
| 2102 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(i)); |
| 2103 WaitForAudioDecodeDone(); |
| 2104 } |
| 2105 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(3)); |
| 2106 player_.OnDemuxerDataAvailable( |
| 2107 CreateReadFromDemuxerAckWithConfigChanged(false, 0)); |
| 2108 WaitForDecodeDone(true, true); |
| 2109 EXPECT_EQ(1, demuxer_->num_config_requests()); |
| 2110 player_.OnDemuxerConfigsAvailable(CreateAudioVideoDemuxerConfigs()); |
| 2111 |
| 2112 // TODO(qinmin): Pointer comparison is not guaranteed to be correct for |
| 2113 // checking whether an object is recreated. Need to fix all the usages in this |
| 2114 // file. See http://crbug.com/360094. |
| 2115 EXPECT_EQ(helper, GetAudioTimestampHelper()); |
| 2116 } |
| 2117 |
2067 } // namespace media | 2118 } // namespace media |
OLD | NEW |