| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <deque> | 9 #include <deque> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 }; | 284 }; |
| 285 | 285 |
| 286 TEST_F(FFmpegDemuxerTest, Initialize_OpenFails) { | 286 TEST_F(FFmpegDemuxerTest, Initialize_OpenFails) { |
| 287 // Simulate avformat_open_input() failing. | 287 // Simulate avformat_open_input() failing. |
| 288 CreateDemuxer("ten_byte_file"); | 288 CreateDemuxer("ten_byte_file"); |
| 289 WaitableMessageLoopEvent event; | 289 WaitableMessageLoopEvent event; |
| 290 demuxer_->Initialize(&host_, event.GetPipelineStatusCB(), true); | 290 demuxer_->Initialize(&host_, event.GetPipelineStatusCB(), true); |
| 291 event.RunAndWaitForStatus(DEMUXER_ERROR_COULD_NOT_OPEN); | 291 event.RunAndWaitForStatus(DEMUXER_ERROR_COULD_NOT_OPEN); |
| 292 } | 292 } |
| 293 | 293 |
| 294 // TODO(acolwell): Uncomment this test when we discover a file that passes | |
| 295 // avformat_open_input(), but has avformat_find_stream_info() fail. | |
| 296 // | |
| 297 //TEST_F(FFmpegDemuxerTest, Initialize_ParseFails) { | |
| 298 // ("find_stream_info_fail.webm"); | |
| 299 // demuxer_->Initialize( | |
| 300 // &host_, NewExpectedStatusCB(DEMUXER_ERROR_COULD_NOT_PARSE)); | |
| 301 // base::RunLoop().RunUntilIdle(); | |
| 302 //} | |
| 303 | |
| 304 TEST_F(FFmpegDemuxerTest, Initialize_NoStreams) { | 294 TEST_F(FFmpegDemuxerTest, Initialize_NoStreams) { |
| 305 // Open a file with no streams whatsoever. | 295 // Open a file with no streams whatsoever. |
| 306 CreateDemuxer("no_streams.webm"); | 296 CreateDemuxer("no_streams.webm"); |
| 307 WaitableMessageLoopEvent event; | 297 WaitableMessageLoopEvent event; |
| 308 demuxer_->Initialize(&host_, event.GetPipelineStatusCB(), true); | 298 demuxer_->Initialize(&host_, event.GetPipelineStatusCB(), true); |
| 309 event.RunAndWaitForStatus(DEMUXER_ERROR_NO_SUPPORTED_STREAMS); | 299 event.RunAndWaitForStatus(DEMUXER_ERROR_NO_SUPPORTED_STREAMS); |
| 310 } | 300 } |
| 311 | 301 |
| 312 TEST_F(FFmpegDemuxerTest, Initialize_NoAudioVideo) { | 302 TEST_F(FFmpegDemuxerTest, Initialize_NoAudioVideo) { |
| 313 // Open a file containing streams but none of which are audio/video streams. | 303 // Open a file containing streams but none of which are audio/video streams. |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 base::RunLoop().Run(); | 614 base::RunLoop().Run(); |
| 625 EXPECT_EQ(base::TimeDelta(), demuxer_->start_time()); | 615 EXPECT_EQ(base::TimeDelta(), demuxer_->start_time()); |
| 626 | 616 |
| 627 // Seek back to the beginning and repeat the test. | 617 // Seek back to the beginning and repeat the test. |
| 628 WaitableMessageLoopEvent event; | 618 WaitableMessageLoopEvent event; |
| 629 demuxer_->Seek(base::TimeDelta(), event.GetPipelineStatusCB()); | 619 demuxer_->Seek(base::TimeDelta(), event.GetPipelineStatusCB()); |
| 630 event.RunAndWaitForStatus(PIPELINE_OK); | 620 event.RunAndWaitForStatus(PIPELINE_OK); |
| 631 } | 621 } |
| 632 } | 622 } |
| 633 | 623 |
| 624 TEST_F(FFmpegDemuxerTest, Read_InvalidNegativeTimestamp) { |
| 625 CreateDemuxer("negative_ts.flac"); |
| 626 InitializeDemuxer(); |
| 627 EXPECT_CALL(host_, OnDemuxerError(DEMUXER_ERROR_COULD_NOT_PARSE)); |
| 628 ReadUntilEndOfStream(GetStream(DemuxerStream::AUDIO)); |
| 629 } |
| 630 |
| 634 // TODO(dalecurtis): Test is disabled since FFmpeg does not currently guarantee | 631 // TODO(dalecurtis): Test is disabled since FFmpeg does not currently guarantee |
| 635 // the order of demuxed packets in OGG containers. Re-enable and fix key frame | 632 // the order of demuxed packets in OGG containers. Re-enable and fix key frame |
| 636 // expectations once we decide to either workaround it or attempt a fix | 633 // expectations once we decide to either workaround it or attempt a fix |
| 637 // upstream. See http://crbug.com/387996. | 634 // upstream. See http://crbug.com/387996. |
| 638 TEST_F(FFmpegDemuxerTest, | 635 TEST_F(FFmpegDemuxerTest, |
| 639 DISABLED_Read_AudioNegativeStartTimeAndOggDiscard_Bear) { | 636 DISABLED_Read_AudioNegativeStartTimeAndOggDiscard_Bear) { |
| 640 // Many ogg files have negative starting timestamps, so ensure demuxing and | 637 // Many ogg files have negative starting timestamps, so ensure demuxing and |
| 641 // seeking work correctly with a negative start time. | 638 // seeking work correctly with a negative start time. |
| 642 CreateDemuxer("bear.ogv"); | 639 CreateDemuxer("bear.ogv"); |
| 643 InitializeDemuxer(); | 640 InitializeDemuxer(); |
| (...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1514 EXPECT_EQ(astream, preferred_seeking_stream(base::TimeDelta())); | 1511 EXPECT_EQ(astream, preferred_seeking_stream(base::TimeDelta())); |
| 1515 | 1512 |
| 1516 // Now pretend that audio stream got disabled. | 1513 // Now pretend that audio stream got disabled. |
| 1517 astream->set_enabled(false, base::TimeDelta()); | 1514 astream->set_enabled(false, base::TimeDelta()); |
| 1518 // Since there's no other enabled streams, the preferred seeking stream should | 1515 // Since there's no other enabled streams, the preferred seeking stream should |
| 1519 // still be the audio stream. | 1516 // still be the audio stream. |
| 1520 EXPECT_EQ(astream, preferred_seeking_stream(base::TimeDelta())); | 1517 EXPECT_EQ(astream, preferred_seeking_stream(base::TimeDelta())); |
| 1521 } | 1518 } |
| 1522 | 1519 |
| 1523 } // namespace media | 1520 } // namespace media |
| OLD | NEW |