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 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1036 message_loop_.RunUntilIdle(); | 1036 message_loop_.RunUntilIdle(); |
1037 | 1037 |
1038 // No further seek or data requests should have been received since the | 1038 // No further seek or data requests should have been received since the |
1039 // surface is empty. | 1039 // surface is empty. |
1040 EXPECT_EQ(0, demuxer_->num_browser_seek_requests()); | 1040 EXPECT_EQ(0, demuxer_->num_browser_seek_requests()); |
1041 EXPECT_EQ(2, demuxer_->num_data_requests()); | 1041 EXPECT_EQ(2, demuxer_->num_data_requests()); |
1042 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo(false)); | 1042 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo(false)); |
1043 | 1043 |
1044 // Playback resumes once a non-empty surface is passed. | 1044 // Playback resumes once a non-empty surface is passed. |
1045 CreateNextTextureAndSetVideoSurface(); | 1045 CreateNextTextureAndSetVideoSurface(); |
1046 EXPECT_EQ(1, demuxer_->num_browser_seek_requests()); | 1046 EXPECT_EQ(0, demuxer_->num_browser_seek_requests()); |
1047 while(demuxer_->num_browser_seek_requests() != 1) | |
1048 message_loop_.RunUntilIdle(); | |
1047 WaitForVideoDecodeDone(); | 1049 WaitForVideoDecodeDone(); |
1048 } | 1050 } |
1049 | 1051 |
1050 TEST_F(MediaSourcePlayerTest, ReleaseVideoDecoderResourcesWhileDecoding) { | 1052 TEST_F(MediaSourcePlayerTest, ReleaseVideoDecoderResourcesWhileDecoding) { |
1051 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1053 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
1052 | 1054 |
1053 // Test that if video decoder is released while decoding, the resources will | 1055 // Test that if video decoder is released while decoding, the resources will |
1054 // not be immediately released. | 1056 // not be immediately released. |
1055 CreateNextTextureAndSetVideoSurface(); | 1057 CreateNextTextureAndSetVideoSurface(); |
1056 StartVideoDecoderJob(); | 1058 StartVideoDecoderJob(); |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1527 // Test that one browser seek is requested if player Release() + Start(), with | 1529 // Test that one browser seek is requested if player Release() + Start(), with |
1528 // video data received between Release() and Start(). | 1530 // video data received between Release() and Start(). |
1529 BrowserSeekPlayer(true); | 1531 BrowserSeekPlayer(true); |
1530 | 1532 |
1531 // Simulate browser seek is done and confirm player requests more data. | 1533 // Simulate browser seek is done and confirm player requests more data. |
1532 player_.OnDemuxerSeekDone(base::TimeDelta()); | 1534 player_.OnDemuxerSeekDone(base::TimeDelta()); |
1533 EXPECT_EQ(3, demuxer_->num_data_requests()); | 1535 EXPECT_EQ(3, demuxer_->num_data_requests()); |
1534 EXPECT_EQ(1, demuxer_->num_seek_requests()); | 1536 EXPECT_EQ(1, demuxer_->num_seek_requests()); |
1535 } | 1537 } |
1536 | 1538 |
1539 TEST_F(MediaSourcePlayerTest, NoBrowserSeekWithKeyFrameInCache) { | |
1540 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | |
1541 | |
1542 // Test that browser seek is not needed if a key frame is found in data | |
1543 // cache. | |
1544 CreateNextTextureAndSetVideoSurface(); | |
1545 StartVideoDecoderJob(); | |
1546 DemuxerData data = CreateReadFromDemuxerAckForVideo(false); | |
1547 data.access_units[0].is_key_frame = true; | |
1548 | |
1549 // Simulate demuxer's response to the video data request. | |
1550 player_.OnDemuxerDataAvailable(data); | |
1551 | |
1552 // Trigger decoder recreation later by changing surfaces. | |
1553 CreateNextTextureAndSetVideoSurface(); | |
1554 | |
1555 // Wait for the media codec bridge to finish decoding and be reset. | |
1556 WaitForVideoDecodeDone(); | |
wolenetz
2015/02/04 21:07:23
nit: after waiting here, confirm explicitly that t
qinmin
2015/02/04 23:11:23
Done.
| |
1557 | |
1558 // Send a non key frame to decoder so that decoder can continue. This will | |
1559 // not trigger any browser seeks as the previous key frame is still in the | |
1560 // buffer. | |
1561 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo(false)); | |
1562 WaitForVideoDecodeDone(); | |
1563 EXPECT_EQ(0, demuxer_->num_browser_seek_requests()); | |
1564 } | |
1565 | |
1537 TEST_F(MediaSourcePlayerTest, PrerollAudioAfterSeek) { | 1566 TEST_F(MediaSourcePlayerTest, PrerollAudioAfterSeek) { |
1538 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1567 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
1539 | 1568 |
1540 // Test decoder job will preroll the media to the seek position. | 1569 // Test decoder job will preroll the media to the seek position. |
1541 StartAudioDecoderJob(); | 1570 StartAudioDecoderJob(); |
1542 | 1571 |
1543 SeekPlayerWithAbort(true, base::TimeDelta::FromMilliseconds(100)); | 1572 SeekPlayerWithAbort(true, base::TimeDelta::FromMilliseconds(100)); |
1544 EXPECT_TRUE(IsPrerolling(true)); | 1573 EXPECT_TRUE(IsPrerolling(true)); |
1545 PrerollDecoderToTime( | 1574 PrerollDecoderToTime( |
1546 true, base::TimeDelta(), base::TimeDelta::FromMilliseconds(100), true); | 1575 true, base::TimeDelta(), base::TimeDelta::FromMilliseconds(100), true); |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2322 // Wait for the metadata change. | 2351 // Wait for the metadata change. |
2323 while(manager_.num_metadata_changes() == 1) { | 2352 while(manager_.num_metadata_changes() == 1) { |
2324 player_.OnDemuxerDataAvailable(data); | 2353 player_.OnDemuxerDataAvailable(data); |
2325 WaitForVideoDecodeDone(); | 2354 WaitForVideoDecodeDone(); |
2326 } | 2355 } |
2327 EXPECT_EQ(2, manager_.num_metadata_changes()); | 2356 EXPECT_EQ(2, manager_.num_metadata_changes()); |
2328 WaitForVideoDecodeDone(); | 2357 WaitForVideoDecodeDone(); |
2329 } | 2358 } |
2330 | 2359 |
2331 } // namespace media | 2360 } // namespace media |
OLD | NEW |