Chromium Code Reviews| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 const int kAppendTimeMs = kAppendTimeSec * 1000; | 98 const int kAppendTimeMs = kAppendTimeSec * 1000; |
| 99 const int k320WebMFileDurationMs = 2736; | 99 const int k320WebMFileDurationMs = 2736; |
| 100 #if !defined(DISABLE_EME_TESTS) | 100 #if !defined(DISABLE_EME_TESTS) |
| 101 const int k320EncWebMFileDurationMs = 2737; | 101 const int k320EncWebMFileDurationMs = 2737; |
| 102 #endif // !defined(DISABLE_EME_TESTS) | 102 #endif // !defined(DISABLE_EME_TESTS) |
| 103 const int k640WebMFileDurationMs = 2749; | 103 const int k640WebMFileDurationMs = 2749; |
| 104 const int kOpusEndTrimmingWebMFileDurationMs = 2741; | 104 const int kOpusEndTrimmingWebMFileDurationMs = 2741; |
| 105 const int kVP9WebMFileDurationMs = 2736; | 105 const int kVP9WebMFileDurationMs = 2736; |
| 106 const int kVP8AWebMFileDurationMs = 2734; | 106 const int kVP8AWebMFileDurationMs = 2734; |
| 107 | 107 |
| 108 // Hash for a full playthrough of "opus-trimming-test.(webm|ogg)". | |
| 109 static const char kOpusEndTrimmingHash_1[] = | |
| 110 "-4.56,-5.65,-6.51,-6.29,-4.36,-3.59,"; | |
| 111 // The above hash, plus an additional playthrough starting from T=1s. | |
| 112 static const char kOpusEndTrimmingHash_2[] = | |
| 113 "-11.89,-11.09,-8.25,-7.11,-7.84,-9.97,"; | |
| 114 // The above hash, plus an additional playthrough starting from T=6.36s. | |
|
chcunningham
2015/07/31 19:48:45
Which "above" do you mean here? Could make this mo
DaleCurtis
2015/08/03 22:49:53
The one immediately above :) I dislike putting var
| |
| 115 static const char kOpusEndTrimmingHash_3[] = | |
| 116 "-13.28,-14.35,-13.67,-11.68,-10.18,-10.46,"; | |
| 117 | |
| 108 #if defined(USE_PROPRIETARY_CODECS) | 118 #if defined(USE_PROPRIETARY_CODECS) |
| 109 #if !defined(DISABLE_EME_TESTS) | 119 #if !defined(DISABLE_EME_TESTS) |
| 110 const int k640IsoFileDurationMs = 2737; | 120 const int k640IsoFileDurationMs = 2737; |
| 111 const int k640IsoCencFileDurationMs = 2736; | 121 const int k640IsoCencFileDurationMs = 2736; |
| 112 #endif // !defined(DISABLE_EME_TESTS) | 122 #endif // !defined(DISABLE_EME_TESTS) |
| 113 const int k1280IsoFileDurationMs = 2736; | 123 const int k1280IsoFileDurationMs = 2736; |
| 114 const int k1280IsoAVC3FileDurationMs = 2736; | 124 const int k1280IsoAVC3FileDurationMs = 2736; |
| 115 #endif // defined(USE_PROPRIETARY_CODECS) | 125 #endif // defined(USE_PROPRIETARY_CODECS) |
| 116 | 126 |
| 117 // Return a timeline offset for bear-320x240-live.webm. | 127 // Return a timeline offset for bear-320x240-live.webm. |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 480 kSourceId, | 490 kSourceId, |
| 481 base::TimeDelta(), kInfiniteDuration(), &last_timestamp_offset_); | 491 base::TimeDelta(), kInfiniteDuration(), &last_timestamp_offset_); |
| 482 | 492 |
| 483 DCHECK_GE(new_position, 0); | 493 DCHECK_GE(new_position, 0); |
| 484 DCHECK_LT(new_position, file_data_->data_size()); | 494 DCHECK_LT(new_position, file_data_->data_size()); |
| 485 current_position_ = new_position; | 495 current_position_ = new_position; |
| 486 | 496 |
| 487 AppendData(seek_append_size); | 497 AppendData(seek_append_size); |
| 488 } | 498 } |
| 489 | 499 |
| 500 void Seek(base::TimeDelta seek_time) { | |
| 501 chunk_demuxer_->StartWaitingForSeek(seek_time); | |
| 502 chunk_demuxer_->Abort( | |
|
chcunningham
2015/07/31 19:48:45
Noob questions: I expected to see
chunk_demuxer->
DaleCurtis
2015/08/03 22:49:53
I don't know either, I just copied the Seek(a,b,c)
chcunningham
2015/08/04 20:38:09
wolenetz@, do you know more on this?
wolenetz
2015/08/06 22:21:27
Good catch! tl;dr, drop the Abort() from this new
DaleCurtis
2015/08/06 23:45:27
Hmm, didn't work when I tried this originally, but
| |
| 503 kSourceId, | |
| 504 base::TimeDelta(), kInfiniteDuration(), &last_timestamp_offset_); | |
| 505 } | |
| 506 | |
| 490 void AppendData(int size) { | 507 void AppendData(int size) { |
| 491 DCHECK(chunk_demuxer_); | 508 DCHECK(chunk_demuxer_); |
| 492 DCHECK_LT(current_position_, file_data_->data_size()); | 509 DCHECK_LT(current_position_, file_data_->data_size()); |
| 493 DCHECK_LE(current_position_ + size, file_data_->data_size()); | 510 DCHECK_LE(current_position_ + size, file_data_->data_size()); |
| 494 | 511 |
| 495 chunk_demuxer_->AppendData( | 512 chunk_demuxer_->AppendData( |
| 496 kSourceId, file_data_->data() + current_position_, size, | 513 kSourceId, file_data_->data() + current_position_, size, |
| 497 base::TimeDelta(), kInfiniteDuration(), &last_timestamp_offset_, | 514 base::TimeDelta(), kInfiniteDuration(), &last_timestamp_offset_, |
| 498 base::Bind(&MockMediaSource::InitSegmentReceived, | 515 base::Bind(&MockMediaSource::InitSegmentReceived, |
| 499 base::Unretained(this))); | 516 base::Unretained(this))); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 670 base::Unretained(this))); | 687 base::Unretained(this))); |
| 671 message_loop_.Run(); | 688 message_loop_.Run(); |
| 672 EXPECT_EQ(PIPELINE_OK, pipeline_status_); | 689 EXPECT_EQ(PIPELINE_OK, pipeline_status_); |
| 673 } | 690 } |
| 674 | 691 |
| 675 void StartHashedPipelineWithMediaSource(MockMediaSource* source) { | 692 void StartHashedPipelineWithMediaSource(MockMediaSource* source) { |
| 676 hashing_enabled_ = true; | 693 hashing_enabled_ = true; |
| 677 StartPipelineWithMediaSource(source); | 694 StartPipelineWithMediaSource(source); |
| 678 } | 695 } |
| 679 | 696 |
| 697 void StartHashedClocklessPipelineWithMediaSource(MockMediaSource* source) { | |
| 698 hashing_enabled_ = true; | |
| 699 clockless_playback_ = true; | |
| 700 StartPipelineWithMediaSource(source); | |
| 701 } | |
| 702 | |
| 680 void StartPipelineWithEncryptedMedia( | 703 void StartPipelineWithEncryptedMedia( |
| 681 MockMediaSource* source, | 704 MockMediaSource* source, |
| 682 FakeEncryptedMedia* encrypted_media) { | 705 FakeEncryptedMedia* encrypted_media) { |
| 683 EXPECT_CALL(*source, InitSegmentReceived()).Times(AtLeast(1)); | 706 EXPECT_CALL(*source, InitSegmentReceived()).Times(AtLeast(1)); |
| 684 EXPECT_CALL(*this, OnMetadata(_)) | 707 EXPECT_CALL(*this, OnMetadata(_)) |
| 685 .Times(AtMost(1)) | 708 .Times(AtMost(1)) |
| 686 .WillRepeatedly(SaveArg<0>(&metadata_)); | 709 .WillRepeatedly(SaveArg<0>(&metadata_)); |
| 687 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH)) | 710 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH)) |
| 688 .Times(AnyNumber()); | 711 .Times(AnyNumber()); |
| 689 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_NOTHING)) | 712 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_NOTHING)) |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 776 | 799 |
| 777 Play(); | 800 Play(); |
| 778 | 801 |
| 779 ASSERT_TRUE(WaitUntilOnEnded()); | 802 ASSERT_TRUE(WaitUntilOnEnded()); |
| 780 | 803 |
| 781 EXPECT_HASH_EQ("f0be120a90a811506777c99a2cdf7cc1", GetVideoHash()); | 804 EXPECT_HASH_EQ("f0be120a90a811506777c99a2cdf7cc1", GetVideoHash()); |
| 782 EXPECT_HASH_EQ("-3.59,-2.06,-0.43,2.15,0.77,-0.95,", GetAudioHash()); | 805 EXPECT_HASH_EQ("-3.59,-2.06,-0.43,2.15,0.77,-0.95,", GetAudioHash()); |
| 783 EXPECT_TRUE(demuxer_->GetTimelineOffset().is_null()); | 806 EXPECT_TRUE(demuxer_->GetTimelineOffset().is_null()); |
| 784 } | 807 } |
| 785 | 808 |
| 809 TEST_F(PipelineIntegrationTest, BasicPlaybackOpusOggTrimmingHashed) { | |
| 810 ASSERT_EQ(PIPELINE_OK, | |
| 811 Start("opus-trimming-test.webm", kHashed | kClockless)); | |
| 812 | |
| 813 Play(); | |
| 814 | |
| 815 ASSERT_TRUE(WaitUntilOnEnded()); | |
| 816 EXPECT_HASH_EQ(kOpusEndTrimmingHash_1, GetAudioHash()); | |
| 817 | |
| 818 // Seek within the pre-skip section, this should not cause a beep. | |
| 819 ASSERT_TRUE(Seek(base::TimeDelta::FromSeconds(1))); | |
| 820 Play(); | |
| 821 ASSERT_TRUE(WaitUntilOnEnded()); | |
| 822 EXPECT_HASH_EQ(kOpusEndTrimmingHash_2, GetAudioHash()); | |
| 823 | |
| 824 // Seek somewhere outside of the pre-skip / end-trim section, demxuer should | |
| 825 // correctly preroll enough to accurately decode this segment. | |
| 826 ASSERT_TRUE(Seek(base::TimeDelta::FromMilliseconds(6360))); | |
| 827 Play(); | |
| 828 ASSERT_TRUE(WaitUntilOnEnded()); | |
| 829 EXPECT_HASH_EQ(kOpusEndTrimmingHash_3, GetAudioHash()); | |
| 830 } | |
| 831 | |
| 832 TEST_F(PipelineIntegrationTest, BasicPlaybackOpusWebmTrimmingHashed) { | |
| 833 ASSERT_EQ(PIPELINE_OK, | |
| 834 Start("opus-trimming-test.webm", kHashed | kClockless)); | |
| 835 | |
| 836 Play(); | |
| 837 | |
| 838 ASSERT_TRUE(WaitUntilOnEnded()); | |
| 839 EXPECT_HASH_EQ(kOpusEndTrimmingHash_1, GetAudioHash()); | |
| 840 | |
| 841 // Seek within the pre-skip section, this should not cause a beep. | |
| 842 ASSERT_TRUE(Seek(base::TimeDelta::FromSeconds(1))); | |
| 843 Play(); | |
| 844 ASSERT_TRUE(WaitUntilOnEnded()); | |
| 845 EXPECT_HASH_EQ(kOpusEndTrimmingHash_2, GetAudioHash()); | |
| 846 | |
| 847 // Seek somewhere outside of the pre-skip / end-trim section, demxuer should | |
| 848 // correctly preroll enough to accurately decode this segment. | |
| 849 ASSERT_TRUE(Seek(base::TimeDelta::FromMilliseconds(6360))); | |
| 850 Play(); | |
| 851 ASSERT_TRUE(WaitUntilOnEnded()); | |
| 852 EXPECT_HASH_EQ(kOpusEndTrimmingHash_3, GetAudioHash()); | |
| 853 } | |
| 854 | |
| 855 TEST_F(PipelineIntegrationTest, | |
| 856 BasicPlaybackOpusWebmTrimmingHashed_MediaSource) { | |
| 857 MockMediaSource source("opus-trimming-test.webm", kOpusAudioOnlyWebM, | |
| 858 kAppendWholeFile); | |
| 859 StartHashedClocklessPipelineWithMediaSource(&source); | |
| 860 source.EndOfStream(); | |
| 861 | |
| 862 Play(); | |
| 863 | |
| 864 ASSERT_TRUE(WaitUntilOnEnded()); | |
| 865 EXPECT_HASH_EQ(kOpusEndTrimmingHash_1, GetAudioHash()); | |
| 866 | |
| 867 // Seek within the pre-skip section, this should not cause a beep. | |
| 868 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(1); | |
| 869 source.Seek(seek_time); | |
| 870 ASSERT_TRUE(Seek(seek_time)); | |
| 871 Play(); | |
| 872 ASSERT_TRUE(WaitUntilOnEnded()); | |
| 873 EXPECT_HASH_EQ(kOpusEndTrimmingHash_2, GetAudioHash()); | |
| 874 | |
| 875 // Seek somewhere outside of the pre-skip / end-trim section, demxuer should | |
|
wolenetz
2015/08/06 22:21:27
nit: demuxer spellcheck
DaleCurtis
2015/08/06 23:45:27
Done.
| |
| 876 // correctly preroll enough to accurately decode this segment. | |
| 877 seek_time = base::TimeDelta::FromMilliseconds(6360); | |
| 878 source.Seek(seek_time); | |
| 879 ASSERT_TRUE(Seek(seek_time)); | |
| 880 Play(); | |
| 881 ASSERT_TRUE(WaitUntilOnEnded()); | |
| 882 EXPECT_HASH_EQ(kOpusEndTrimmingHash_3, GetAudioHash()); | |
| 883 } | |
| 884 | |
| 885 // TODO(dalecurtis): Add a test file which ffmpeg and chunkdemuxer will both | |
|
chcunningham
2015/07/31 19:48:45
Don't forget to file a bug if you don't handle thi
DaleCurtis
2015/08/03 22:49:53
Attached the bug to this.
| |
| 886 // seek in. FFmpeg just always seeks to zero in bear-opus.webm while MSE | |
| 887 // more correctly seeks to ~1s, resulting in some discrepencies. | |
| 888 | |
| 786 TEST_F(PipelineIntegrationTest, BasicPlaybackLive) { | 889 TEST_F(PipelineIntegrationTest, BasicPlaybackLive) { |
| 787 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240-live.webm", kHashed)); | 890 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240-live.webm", kHashed)); |
| 788 | 891 |
| 789 Play(); | 892 Play(); |
| 790 | 893 |
| 791 ASSERT_TRUE(WaitUntilOnEnded()); | 894 ASSERT_TRUE(WaitUntilOnEnded()); |
| 792 | 895 |
| 793 EXPECT_HASH_EQ("f0be120a90a811506777c99a2cdf7cc1", GetVideoHash()); | 896 EXPECT_HASH_EQ("f0be120a90a811506777c99a2cdf7cc1", GetVideoHash()); |
| 794 EXPECT_HASH_EQ("-3.59,-2.06,-0.43,2.15,0.77,-0.95,", GetAudioHash()); | 897 EXPECT_HASH_EQ("-3.59,-2.06,-0.43,2.15,0.77,-0.95,", GetAudioHash()); |
| 795 | 898 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 908 EXPECT_EQ(kOpusEndTrimmingWebMFileDurationMs, | 1011 EXPECT_EQ(kOpusEndTrimmingWebMFileDurationMs, |
| 909 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1012 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 910 Play(); | 1013 Play(); |
| 911 | 1014 |
| 912 ASSERT_TRUE(WaitUntilOnEnded()); | 1015 ASSERT_TRUE(WaitUntilOnEnded()); |
| 913 source.Abort(); | 1016 source.Abort(); |
| 914 Stop(); | 1017 Stop(); |
| 915 } | 1018 } |
| 916 | 1019 |
| 917 // Flaky. http://crbug.com/304776 | 1020 // Flaky. http://crbug.com/304776 |
| 918 TEST_F(PipelineIntegrationTest, DISABLED_MediaSource_Opus_Seeking_WebM) { | 1021 TEST_F(PipelineIntegrationTest, DISABLED_MediaSource_Opus_Seeking_WebM) { |
|
chcunningham
2015/07/31 19:48:44
Still flaky? Perhaps the hashes are different now?
DaleCurtis
2015/08/03 22:49:53
I haven't checked, will need to build a valgrind b
| |
| 919 MockMediaSource source("bear-opus-end-trimming.webm", kOpusAudioOnlyWebM, | 1022 MockMediaSource source("bear-opus-end-trimming.webm", kOpusAudioOnlyWebM, |
| 920 kAppendWholeFile); | 1023 kAppendWholeFile); |
| 921 StartHashedPipelineWithMediaSource(&source); | 1024 StartHashedPipelineWithMediaSource(&source); |
| 922 | 1025 |
| 923 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1026 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 924 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1027 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 925 EXPECT_EQ(kOpusEndTrimmingWebMFileDurationMs, | 1028 EXPECT_EQ(kOpusEndTrimmingWebMFileDurationMs, |
| 926 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1029 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 927 | 1030 |
| 928 base::TimeDelta start_seek_time = base::TimeDelta::FromMilliseconds(1000); | 1031 base::TimeDelta start_seek_time = base::TimeDelta::FromMilliseconds(1000); |
| (...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1724 | 1827 |
| 1725 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { | 1828 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { |
| 1726 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); | 1829 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); |
| 1727 Play(); | 1830 Play(); |
| 1728 ASSERT_TRUE(WaitUntilOnEnded()); | 1831 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1729 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), | 1832 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), |
| 1730 demuxer_->GetStartTime()); | 1833 demuxer_->GetStartTime()); |
| 1731 } | 1834 } |
| 1732 | 1835 |
| 1733 } // namespace media | 1836 } // namespace media |
| OLD | NEW |