| 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 2049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2060 // player has not yet received media crypto. | 2060 // player has not yet received media crypto. |
| 2061 DemuxerConfigs configs = CreateVideoDemuxerConfigs(); | 2061 DemuxerConfigs configs = CreateVideoDemuxerConfigs(); |
| 2062 configs.is_video_encrypted = true; | 2062 configs.is_video_encrypted = true; |
| 2063 | 2063 |
| 2064 player_.OnDemuxerConfigsAvailable(configs); | 2064 player_.OnDemuxerConfigsAvailable(configs); |
| 2065 CreateNextTextureAndSetVideoSurface(); | 2065 CreateNextTextureAndSetVideoSurface(); |
| 2066 EXPECT_FALSE(IsPendingSurfaceChange()); | 2066 EXPECT_FALSE(IsPendingSurfaceChange()); |
| 2067 EXPECT_FALSE(GetMediaDecoderJob(false)); | 2067 EXPECT_FALSE(GetMediaDecoderJob(false)); |
| 2068 } | 2068 } |
| 2069 | 2069 |
| 2070 TEST_F(MediaSourcePlayerTest, CurrentTimeUpdatedWhileDecoderStarved) { | |
| 2071 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | |
| 2072 | |
| 2073 // Test that current time is updated while decoder is starved. | |
| 2074 StartAudioDecoderJob(true); | |
| 2075 for (int i = 0; i < 3; ++i) { | |
| 2076 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(i)); | |
| 2077 WaitForAudioDecodeDone(); | |
| 2078 } | |
| 2079 base::TimeDelta current_time = player_.GetCurrentTime(); | |
| 2080 | |
| 2081 // Trigger starvation while the decoder is decoding. | |
| 2082 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(3)); | |
| 2083 TriggerPlayerStarvation(); | |
| 2084 WaitForAudioDecodeDone(); | |
| 2085 | |
| 2086 // Current time should be updated. | |
| 2087 EXPECT_LT(current_time.InMillisecondsF(), | |
| 2088 player_.GetCurrentTime().InMillisecondsF()); | |
| 2089 } | |
| 2090 | |
| 2091 TEST_F(MediaSourcePlayerTest, CurrentTimeKeepsIncreasingAfterConfigChange) { | |
| 2092 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | |
| 2093 | |
| 2094 // Test current time keep on increasing after audio config change. | |
| 2095 // Test that current time is updated while decoder is starved. | |
| 2096 StartAudioDecoderJob(true); | |
| 2097 | |
| 2098 for (int i = 0; i < 4; ++i) { | |
| 2099 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(i)); | |
| 2100 WaitForAudioDecodeDone(); | |
| 2101 } | |
| 2102 base::TimeDelta current_time = player_.GetCurrentTime(); | |
| 2103 EXPECT_LT(0.0, current_time.InMillisecondsF()); | |
| 2104 | |
| 2105 DemuxerData data = CreateReadFromDemuxerAckWithConfigChanged(true, 0); | |
| 2106 player_.OnDemuxerDataAvailable(data); | |
| 2107 WaitForAudioDecodeDone(); | |
| 2108 | |
| 2109 // Simulate arrival of new configs. | |
| 2110 player_.OnDemuxerConfigsAvailable(CreateAudioDemuxerConfigs(kCodecVorbis)); | |
| 2111 for (int i = 0; i < 4; ++i) { | |
| 2112 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(i)); | |
| 2113 WaitForAudioDecodeDone(); | |
| 2114 base::TimeDelta new_current_time = player_.GetCurrentTime(); | |
| 2115 EXPECT_LE(current_time.InMillisecondsF(), | |
| 2116 new_current_time.InMillisecondsF()); | |
| 2117 current_time = new_current_time; | |
| 2118 } | |
| 2119 } | |
| 2120 | |
| 2121 } // namespace media | 2070 } // namespace media |
| OLD | NEW |