| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <deque> | 6 #include <deque> |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 974 FFmpegDemuxerStream* audio = static_cast<FFmpegDemuxerStream*>( | 974 FFmpegDemuxerStream* audio = static_cast<FFmpegDemuxerStream*>( |
| 975 demuxer_->GetStream(DemuxerStream::AUDIO)); | 975 demuxer_->GetStream(DemuxerStream::AUDIO)); |
| 976 ASSERT_TRUE(audio); | 976 ASSERT_TRUE(audio); |
| 977 | 977 |
| 978 // Seek to near the end of the file | 978 // Seek to near the end of the file |
| 979 WaitableMessageLoopEvent event; | 979 WaitableMessageLoopEvent event; |
| 980 demuxer_->Seek(.9 * audio->duration(), event.GetPipelineStatusCB()); | 980 demuxer_->Seek(.9 * audio->duration(), event.GetPipelineStatusCB()); |
| 981 event.RunAndWaitForStatus(PIPELINE_OK); | 981 event.RunAndWaitForStatus(PIPELINE_OK); |
| 982 | 982 |
| 983 // Verify that seeking to the end read only a small portion of the file. | 983 // Verify that seeking to the end read only a small portion of the file. |
| 984 // Slow that read sequentially up to the seek point will fail this check. | 984 // Slow seeks that read sequentially up to the seek point will read too many |
| 985 // bytes and fail this check. |
| 985 int64 file_size = 0; | 986 int64 file_size = 0; |
| 986 ASSERT_TRUE(data_source_->GetSize(&file_size)); | 987 ASSERT_TRUE(data_source_->GetSize(&file_size)); |
| 987 EXPECT_LT(data_source_->bytes_read_for_testing(), (file_size * .25)); | 988 EXPECT_LT(data_source_->bytes_read_for_testing(), (file_size * .25)); |
| 988 } | 989 } |
| 989 | 990 |
| 990 // MP3s should seek quickly without sequentially reading up to the seek point. | 991 // MP3s should seek quickly without sequentially reading up to the seek point. |
| 991 // VBR vs CBR and the presence/absence of TOC influence the seeking algorithm. | 992 // VBR vs CBR and the presence/absence of TOC influence the seeking algorithm. |
| 992 // See http://crbug.com/530043 and FFmpeg flag AVFMT_FLAG_FAST_SEEK. | 993 // See http://crbug.com/530043 and FFmpeg flag AVFMT_FLAG_FAST_SEEK. |
| 993 INSTANTIATE_TEST_CASE_P(, Mp3SeekFFmpegDemuxerTest, | 994 INSTANTIATE_TEST_CASE_P(, Mp3SeekFFmpegDemuxerTest, |
| 994 ::testing::Values("bear-audio-10s-CBR-has-TOC.mp3", | 995 ::testing::Values("bear-audio-10s-CBR-has-TOC.mp3", |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1122 | 1123 |
| 1123 video->Read(NewReadCB(FROM_HERE, 3569, 66733, true)); | 1124 video->Read(NewReadCB(FROM_HERE, 3569, 66733, true)); |
| 1124 message_loop_.Run(); | 1125 message_loop_.Run(); |
| 1125 | 1126 |
| 1126 video->Read(NewReadCB(FROM_HERE, 1042, 200200, false)); | 1127 video->Read(NewReadCB(FROM_HERE, 1042, 200200, false)); |
| 1127 message_loop_.Run(); | 1128 message_loop_.Run(); |
| 1128 } | 1129 } |
| 1129 #endif | 1130 #endif |
| 1130 | 1131 |
| 1131 } // namespace media | 1132 } // namespace media |
| OLD | NEW |