| 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 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 video->Read(NewReadCB(FROM_HERE, 631, 66482, false)); | 587 video->Read(NewReadCB(FROM_HERE, 631, 66482, false)); |
| 588 message_loop_.Run(); | 588 message_loop_.Run(); |
| 589 | 589 |
| 590 // Seek back to the beginning and repeat the test. | 590 // Seek back to the beginning and repeat the test. |
| 591 WaitableMessageLoopEvent event; | 591 WaitableMessageLoopEvent event; |
| 592 demuxer_->Seek(base::TimeDelta(), event.GetPipelineStatusCB()); | 592 demuxer_->Seek(base::TimeDelta(), event.GetPipelineStatusCB()); |
| 593 event.RunAndWaitForStatus(PIPELINE_OK); | 593 event.RunAndWaitForStatus(PIPELINE_OK); |
| 594 } | 594 } |
| 595 } | 595 } |
| 596 | 596 |
| 597 // Similar to the test above, but using an opus clip with a large amount of |
| 598 // pre-skip, which ffmpeg encodes as negative timestamps. |
| 599 TEST_F(FFmpegDemuxerTest, Read_AudioNegativeStartTimeAndOpusDiscard_Sync) { |
| 600 CreateDemuxer("opus-trimming-video-test.webm"); |
| 601 InitializeDemuxer(); |
| 602 |
| 603 // Attempt a read from the video stream and run the message loop until done. |
| 604 DemuxerStream* video = demuxer_->GetStream(DemuxerStream::VIDEO); |
| 605 DemuxerStream* audio = demuxer_->GetStream(DemuxerStream::AUDIO); |
| 606 EXPECT_EQ(audio->audio_decoder_config().codec_delay(), 65535); |
| 607 |
| 608 // Packet size to timestamp (in microseconds) mapping for the first N packets |
| 609 // which should be fully discarded. |
| 610 static const int kTestExpectations[][2] = { |
| 611 {635, 0}, {594, 120000}, {597, 240000}, {591, 360000}, |
| 612 {582, 480000}, {583, 600000}, {592, 720000}, {567, 840000}, |
| 613 {579, 960000}, {572, 1080000}, {583, 1200000}}; |
| 614 |
| 615 // Run the test twice with a seek in between. |
| 616 for (int i = 0; i < 2; ++i) { |
| 617 for (size_t j = 0; j < arraysize(kTestExpectations); ++j) { |
| 618 audio->Read(NewReadCB(FROM_HERE, kTestExpectations[j][0], |
| 619 kTestExpectations[j][1], true)); |
| 620 message_loop_.Run(); |
| 621 } |
| 622 |
| 623 // Though the internal start time may be below zero, the exposed media time |
| 624 // must always be greater than zero. |
| 625 EXPECT_EQ(base::TimeDelta(), demuxer_->GetStartTime()); |
| 626 |
| 627 video->Read(NewReadCB(FROM_HERE, 16009, 0, true)); |
| 628 message_loop_.Run(); |
| 629 |
| 630 video->Read(NewReadCB(FROM_HERE, 2715, 1000, false)); |
| 631 message_loop_.Run(); |
| 632 |
| 633 video->Read(NewReadCB(FROM_HERE, 427, 33000, false)); |
| 634 message_loop_.Run(); |
| 635 |
| 636 // Seek back to the beginning and repeat the test. |
| 637 WaitableMessageLoopEvent event; |
| 638 demuxer_->Seek(base::TimeDelta(), event.GetPipelineStatusCB()); |
| 639 event.RunAndWaitForStatus(PIPELINE_OK); |
| 640 } |
| 641 } |
| 642 |
| 643 // Similar to the test above, but using sfx-opus.ogg, which has a much smaller |
| 644 // amount of discard padding and no |start_time| set on the AVStream. |
| 645 TEST_F(FFmpegDemuxerTest, Read_AudioNegativeStartTimeAndOpusSfxDiscard_Sync) { |
| 646 CreateDemuxer("sfx-opus.ogg"); |
| 647 InitializeDemuxer(); |
| 648 |
| 649 // Attempt a read from the video stream and run the message loop until done. |
| 650 DemuxerStream* audio = demuxer_->GetStream(DemuxerStream::AUDIO); |
| 651 EXPECT_EQ(audio->audio_decoder_config().codec_delay(), 312); |
| 652 |
| 653 // Run the test twice with a seek in between. |
| 654 for (int i = 0; i < 2; ++i) { |
| 655 audio->Read(NewReadCB(FROM_HERE, 314, 0, true)); |
| 656 message_loop_.Run(); |
| 657 |
| 658 audio->Read(NewReadCB(FROM_HERE, 244, 20000, true)); |
| 659 message_loop_.Run(); |
| 660 |
| 661 // Though the internal start time may be below zero, the exposed media time |
| 662 // must always be greater than zero. |
| 663 EXPECT_EQ(base::TimeDelta(), demuxer_->GetStartTime()); |
| 664 |
| 665 // Seek back to the beginning and repeat the test. |
| 666 WaitableMessageLoopEvent event; |
| 667 demuxer_->Seek(base::TimeDelta(), event.GetPipelineStatusCB()); |
| 668 event.RunAndWaitForStatus(PIPELINE_OK); |
| 669 } |
| 670 } |
| 671 |
| 597 TEST_F(FFmpegDemuxerTest, Read_EndOfStream) { | 672 TEST_F(FFmpegDemuxerTest, Read_EndOfStream) { |
| 598 // Verify that end of stream buffers are created. | 673 // Verify that end of stream buffers are created. |
| 599 CreateDemuxer("bear-320x240.webm"); | 674 CreateDemuxer("bear-320x240.webm"); |
| 600 InitializeDemuxer(); | 675 InitializeDemuxer(); |
| 601 ReadUntilEndOfStream(demuxer_->GetStream(DemuxerStream::AUDIO)); | 676 ReadUntilEndOfStream(demuxer_->GetStream(DemuxerStream::AUDIO)); |
| 602 } | 677 } |
| 603 | 678 |
| 604 TEST_F(FFmpegDemuxerTest, Read_EndOfStreamText) { | 679 TEST_F(FFmpegDemuxerTest, Read_EndOfStreamText) { |
| 605 // Verify that end of stream buffers are created. | 680 // Verify that end of stream buffers are created. |
| 606 CreateDemuxer("bear-vp8-webvtt.webm"); | 681 CreateDemuxer("bear-vp8-webvtt.webm"); |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::VIDEO); | 1065 DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::VIDEO); |
| 991 ASSERT_TRUE(stream); | 1066 ASSERT_TRUE(stream); |
| 992 | 1067 |
| 993 const VideoDecoderConfig& video_config = stream->video_decoder_config(); | 1068 const VideoDecoderConfig& video_config = stream->video_decoder_config(); |
| 994 EXPECT_EQ(gfx::Size(638, 360), video_config.natural_size()); | 1069 EXPECT_EQ(gfx::Size(638, 360), video_config.natural_size()); |
| 995 } | 1070 } |
| 996 | 1071 |
| 997 #endif | 1072 #endif |
| 998 | 1073 |
| 999 } // namespace media | 1074 } // namespace media |
| OLD | NEW |