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

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

Issue 638233002: Preroll decoders when video starts playing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « media/base/android/media_source_player.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string> 5 #include <string>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 for (int i = 0; i < 10; ++i) { 348 for (int i = 0; i < 10; ++i) {
349 manager_.ResetTimestampUpdated(); 349 manager_.ResetTimestampUpdated();
350 player_.OnDemuxerDataAvailable( 350 player_.OnDemuxerDataAvailable(
351 CreateReadFromDemuxerAckForAudio(i > 3 ? 3 : i)); 351 CreateReadFromDemuxerAckForAudio(i > 3 ? 3 : i));
352 WaitForAudioDecodeDone(); 352 WaitForAudioDecodeDone();
353 base::TimeDelta new_current_time = player_.GetCurrentTime(); 353 base::TimeDelta new_current_time = player_.GetCurrentTime();
354 EXPECT_LE(current_time.InMilliseconds(), 354 EXPECT_LE(current_time.InMilliseconds(),
355 new_current_time.InMilliseconds()); 355 new_current_time.InMilliseconds());
356 current_time = new_current_time; 356 current_time = new_current_time;
357 if (manager_.timestamp_updated()) { 357 if (manager_.timestamp_updated()) {
358 EXPECT_LT(start_timestamp.InMillisecondsF(), 358 // TODO(qinmin): the current time is from the decoder thread and it does
359 // not take the delay from posting the task into consideration.
360 // http://crbug.com/421616.
361 EXPECT_LE(start_timestamp.InMillisecondsF(),
359 new_current_time.InMillisecondsF()); 362 new_current_time.InMillisecondsF());
360 return; 363 return;
361 } 364 }
362 } 365 }
363 EXPECT_TRUE(false); 366 EXPECT_TRUE(false);
364 } 367 }
365 368
366 AccessUnit CreateAccessUnitWithData(bool is_audio, int audio_packet_id) { 369 AccessUnit CreateAccessUnitWithData(bool is_audio, int audio_packet_id) {
367 AccessUnit unit; 370 AccessUnit unit;
368 371
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 } 1174 }
1172 1175
1173 TEST_F(MediaSourcePlayerTest, StartTimeTicksResetAfterDecoderUnderruns) { 1176 TEST_F(MediaSourcePlayerTest, StartTimeTicksResetAfterDecoderUnderruns) {
1174 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1177 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1175 1178
1176 // Test start time ticks will reset after decoder job underruns. 1179 // Test start time ticks will reset after decoder job underruns.
1177 StartAudioDecoderJob(); 1180 StartAudioDecoderJob();
1178 1181
1179 DecodeAudioDataUntilOutputBecomesAvailable(); 1182 DecodeAudioDataUntilOutputBecomesAvailable();
1180 1183
1181 // The decoder job should finish and a new request will be sent. 1184 // The decoder job should finish prerolling and start prefetching.
1185 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(3));
1182 base::TimeTicks previous = StartTimeTicks(); 1186 base::TimeTicks previous = StartTimeTicks();
1183 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(3));
1184 1187
1185 // Let the decoder starve. 1188 // Let the decoder starve.
1186 TriggerPlayerStarvation(); 1189 TriggerPlayerStarvation();
1187 WaitForAudioDecodeDone(); 1190 WaitForAudioDecodeDone();
1188 EXPECT_TRUE(StartTimeTicks() == previous); 1191 EXPECT_TRUE(StartTimeTicks() == previous);
1189 1192
1190 // Send new data to the decoder so it can finish prefetching. This should 1193 // Send new data to the decoder so it can finish prefetching. This should
1191 // reset the start time ticks. 1194 // reset the start time ticks.
1192 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(3)); 1195 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(3));
1193 EXPECT_TRUE(StartTimeTicks() != previous); 1196 EXPECT_TRUE(StartTimeTicks() != previous);
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
1731 // audio and video jobs is |kConfigChanged|. 1734 // audio and video jobs is |kConfigChanged|.
1732 CreateNextTextureAndSetVideoSurface(); 1735 CreateNextTextureAndSetVideoSurface();
1733 Start(CreateAudioVideoDemuxerConfigs()); 1736 Start(CreateAudioVideoDemuxerConfigs());
1734 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0)); 1737 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0));
1735 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo()); 1738 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo());
1736 EXPECT_TRUE(GetMediaCodecBridge(true)); 1739 EXPECT_TRUE(GetMediaCodecBridge(true));
1737 EXPECT_TRUE(GetMediaCodecBridge(false)); 1740 EXPECT_TRUE(GetMediaCodecBridge(false));
1738 EnableAdaptiveVideoPlayback(false); 1741 EnableAdaptiveVideoPlayback(false);
1739 WaitForAudioVideoDecodeDone(); 1742 WaitForAudioVideoDecodeDone();
1740 1743
1744 EXPECT_TRUE(IsPrerolling(true));
1745 EXPECT_TRUE(IsPrerolling(false));
1746 PrerollDecoderToTime(true, base::TimeDelta(), base::TimeDelta(), true);
1747 PrerollDecoderToTime(false, base::TimeDelta(), base::TimeDelta(), false);
1748 int expected_num_data_requests = demuxer_->num_data_requests();
1749
1741 // Simulate audio |kConfigChanged| prefetched as standalone access unit. 1750 // Simulate audio |kConfigChanged| prefetched as standalone access unit.
1742 DemuxerConfigs audio_configs = CreateAudioDemuxerConfigs(kCodecVorbis, true); 1751 DemuxerConfigs audio_configs = CreateAudioDemuxerConfigs(kCodecVorbis, true);
1743 player_.OnDemuxerDataAvailable( 1752 player_.OnDemuxerDataAvailable(
1744 CreateReadFromDemuxerAckWithConfigChanged(true, 0, audio_configs)); 1753 CreateReadFromDemuxerAckWithConfigChanged(true, 0, audio_configs));
1745 1754
1746 // Simulate video |kConfigChanged| prefetched as standalone access unit. 1755 // Simulate video |kConfigChanged| prefetched as standalone access unit.
1747 player_.OnDemuxerDataAvailable( 1756 player_.OnDemuxerDataAvailable(
1748 CreateReadFromDemuxerAckWithConfigChanged( 1757 CreateReadFromDemuxerAckWithConfigChanged(
1749 false, 0, CreateVideoDemuxerConfigs(true))); 1758 false, 0, CreateVideoDemuxerConfigs(true)));
1750 EXPECT_EQ(6, demuxer_->num_data_requests()); 1759 EXPECT_EQ(expected_num_data_requests + 2, demuxer_->num_data_requests());
1751 EXPECT_TRUE(IsDrainingDecoder(true)); 1760 EXPECT_TRUE(IsDrainingDecoder(true));
1752 EXPECT_TRUE(IsDrainingDecoder(false)); 1761 EXPECT_TRUE(IsDrainingDecoder(false));
1753 1762
1754 // Waiting for decoder to finish draining. 1763 // Waiting for decoder to finish draining.
1755 while (IsDrainingDecoder(true) || IsDrainingDecoder(false)) 1764 while (IsDrainingDecoder(true) || IsDrainingDecoder(false))
1756 message_loop_.RunUntilIdle(); 1765 message_loop_.RunUntilIdle();
1757 } 1766 }
1758 1767
1759 TEST_F(MediaSourcePlayerTest, 1768 TEST_F(MediaSourcePlayerTest,
1760 SimultaneousAudioVideoConfigChangeWithAdaptivePlayback) { 1769 SimultaneousAudioVideoConfigChangeWithAdaptivePlayback) {
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
2260 2269
2261 DemuxerConfigs configs = CreateAudioDemuxerConfigs(kCodecVorbis, true); 2270 DemuxerConfigs configs = CreateAudioDemuxerConfigs(kCodecVorbis, true);
2262 DemuxerData data = CreateReadFromDemuxerAckWithConfigChanged( 2271 DemuxerData data = CreateReadFromDemuxerAckWithConfigChanged(
2263 true, 0, configs); 2272 true, 0, configs);
2264 player_.OnDemuxerDataAvailable(data); 2273 player_.OnDemuxerDataAvailable(data);
2265 WaitForAudioDecodeDone(); 2274 WaitForAudioDecodeDone();
2266 DecodeAudioDataUntilOutputBecomesAvailable(); 2275 DecodeAudioDataUntilOutputBecomesAvailable();
2267 } 2276 }
2268 2277
2269 } // namespace media 2278 } // namespace media
OLDNEW
« no previous file with comments | « media/base/android/media_source_player.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698