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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 // Fixture members. | 186 // Fixture members. |
187 scoped_ptr<FileDataSource> data_source_; | 187 scoped_ptr<FileDataSource> data_source_; |
188 scoped_ptr<FFmpegDemuxer> demuxer_; | 188 scoped_ptr<FFmpegDemuxer> demuxer_; |
189 StrictMock<MockDemuxerHost> host_; | 189 StrictMock<MockDemuxerHost> host_; |
190 base::MessageLoop message_loop_; | 190 base::MessageLoop message_loop_; |
191 | 191 |
192 AVFormatContext* format_context() { | 192 AVFormatContext* format_context() { |
193 return demuxer_->glue_->format_context(); | 193 return demuxer_->glue_->format_context(); |
194 } | 194 } |
195 | 195 |
| 196 int preferred_seeking_stream_index() const { |
| 197 return demuxer_->preferred_stream_for_seeking_.first; |
| 198 } |
| 199 |
196 void ReadUntilEndOfStream(DemuxerStream* stream) { | 200 void ReadUntilEndOfStream(DemuxerStream* stream) { |
197 bool got_eos_buffer = false; | 201 bool got_eos_buffer = false; |
198 const int kMaxBuffers = 170; | 202 const int kMaxBuffers = 170; |
199 for (int i = 0; !got_eos_buffer && i < kMaxBuffers; i++) { | 203 for (int i = 0; !got_eos_buffer && i < kMaxBuffers; i++) { |
200 stream->Read(base::Bind(&EosOnReadDone, &got_eos_buffer)); | 204 stream->Read(base::Bind(&EosOnReadDone, &got_eos_buffer)); |
201 message_loop_.Run(); | 205 message_loop_.Run(); |
202 } | 206 } |
203 | 207 |
204 EXPECT_TRUE(got_eos_buffer); | 208 EXPECT_TRUE(got_eos_buffer); |
205 } | 209 } |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 ASSERT_TRUE(text_stream); | 409 ASSERT_TRUE(text_stream); |
406 EXPECT_EQ(DemuxerStream::TEXT, text_stream->type()); | 410 EXPECT_EQ(DemuxerStream::TEXT, text_stream->type()); |
407 | 411 |
408 text_stream->Read(NewReadCB(FROM_HERE, 31, 0)); | 412 text_stream->Read(NewReadCB(FROM_HERE, 31, 0)); |
409 message_loop_.Run(); | 413 message_loop_.Run(); |
410 | 414 |
411 text_stream->Read(NewReadCB(FROM_HERE, 19, 500000)); | 415 text_stream->Read(NewReadCB(FROM_HERE, 19, 500000)); |
412 message_loop_.Run(); | 416 message_loop_.Run(); |
413 } | 417 } |
414 | 418 |
| 419 TEST_F(FFmpegDemuxerTest, SeekInitialized_NoVideoStartTime) { |
| 420 CreateDemuxer("audio-start-time-only.webm"); |
| 421 InitializeDemuxer(); |
| 422 EXPECT_EQ(0, preferred_seeking_stream_index()); |
| 423 } |
| 424 |
415 TEST_F(FFmpegDemuxerTest, Read_VideoPositiveStartTime) { | 425 TEST_F(FFmpegDemuxerTest, Read_VideoPositiveStartTime) { |
416 const int64 kTimelineOffsetMs = 1352550896000LL; | 426 const int64 kTimelineOffsetMs = 1352550896000LL; |
417 | 427 |
418 // Test the start time is the first timestamp of the video and audio stream. | 428 // Test the start time is the first timestamp of the video and audio stream. |
419 CreateDemuxer("nonzero-start-time.webm"); | 429 CreateDemuxer("nonzero-start-time.webm"); |
420 InitializeDemuxerWithTimelineOffset( | 430 InitializeDemuxerWithTimelineOffset( |
421 false, base::Time::FromJsTime(kTimelineOffsetMs)); | 431 false, base::Time::FromJsTime(kTimelineOffsetMs)); |
422 | 432 |
423 // Attempt a read from the video stream and run the message loop until done. | 433 // Attempt a read from the video stream and run the message loop until done. |
424 DemuxerStream* video = demuxer_->GetStream(DemuxerStream::VIDEO); | 434 DemuxerStream* video = demuxer_->GetStream(DemuxerStream::VIDEO); |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 demuxer_->Stop(event.GetClosure()); | 856 demuxer_->Stop(event.GetClosure()); |
847 event.RunAndWait(); | 857 event.RunAndWait(); |
848 demuxer_.reset(); | 858 demuxer_.reset(); |
849 data_source_.reset(); | 859 data_source_.reset(); |
850 } | 860 } |
851 } | 861 } |
852 | 862 |
853 #endif | 863 #endif |
854 | 864 |
855 } // namespace media | 865 } // namespace media |
OLD | NEW |