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 "media/filters/pipeline_integration_test_base.h" | 5 #include "media/filters/pipeline_integration_test_base.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 912 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
913 EXPECT_EQ(325, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 913 EXPECT_EQ(325, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
914 | 914 |
915 Play(); | 915 Play(); |
916 | 916 |
917 EXPECT_TRUE(WaitUntilOnEnded()); | 917 EXPECT_TRUE(WaitUntilOnEnded()); |
918 } | 918 } |
919 | 919 |
920 TEST_P(PipelineIntegrationTest, MediaSource_ADTS_TimestampOffset) { | 920 TEST_P(PipelineIntegrationTest, MediaSource_ADTS_TimestampOffset) { |
921 MockMediaSource source("sfx.adts", kADTS, kAppendWholeFile, GetParam()); | 921 MockMediaSource source("sfx.adts", kADTS, kAppendWholeFile, GetParam()); |
922 StartPipelineWithMediaSource(&source); | 922 StartHashedPipelineWithMediaSource(&source); |
923 EXPECT_EQ(325, source.last_timestamp_offset().InMilliseconds()); | 923 EXPECT_EQ(325, source.last_timestamp_offset().InMilliseconds()); |
924 | 924 |
| 925 // Trim off multiple frames off the beginning of the segment which will cause |
| 926 // the first decoded frame to be incorrect if preroll isn't implemented. |
| 927 const base::TimeDelta adts_preroll_duration = |
| 928 base::TimeDelta::FromSecondsD(2.5 * 1024 / 44100); |
| 929 const base::TimeDelta append_time = |
| 930 source.last_timestamp_offset() - adts_preroll_duration; |
| 931 |
925 scoped_refptr<DecoderBuffer> second_file = ReadTestDataFile("sfx.adts"); | 932 scoped_refptr<DecoderBuffer> second_file = ReadTestDataFile("sfx.adts"); |
926 source.AppendAtTime( | 933 source.AppendAtTimeWithWindow(append_time, |
927 source.last_timestamp_offset() - base::TimeDelta::FromMilliseconds(10), | 934 append_time + adts_preroll_duration, |
928 second_file->data(), | 935 kInfiniteDuration(), |
929 second_file->data_size()); | 936 second_file->data(), |
| 937 second_file->data_size()); |
930 source.EndOfStream(); | 938 source.EndOfStream(); |
931 | 939 |
932 EXPECT_EQ(640, source.last_timestamp_offset().InMilliseconds()); | 940 EXPECT_EQ(592, source.last_timestamp_offset().InMilliseconds()); |
933 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 941 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
934 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 942 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
935 EXPECT_EQ(640, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 943 EXPECT_EQ(592, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
936 | 944 |
937 Play(); | 945 Play(); |
938 | 946 |
939 EXPECT_TRUE(WaitUntilOnEnded()); | 947 EXPECT_TRUE(WaitUntilOnEnded()); |
| 948 |
| 949 // Verify preroll is stripped. |
| 950 EXPECT_EQ("-0.06,0.97,-0.90,-0.70,-0.53,-0.34,", GetAudioHash()); |
940 } | 951 } |
941 | 952 |
942 TEST_F(PipelineIntegrationTest, BasicPlaybackHashed_MP3) { | 953 TEST_F(PipelineIntegrationTest, BasicPlaybackHashed_MP3) { |
943 ASSERT_TRUE(Start(GetTestDataFilePath("sfx.mp3"), PIPELINE_OK, kHashed)); | 954 ASSERT_TRUE(Start(GetTestDataFilePath("sfx.mp3"), PIPELINE_OK, kHashed)); |
944 | 955 |
945 Play(); | 956 Play(); |
946 | 957 |
947 ASSERT_TRUE(WaitUntilOnEnded()); | 958 ASSERT_TRUE(WaitUntilOnEnded()); |
948 | 959 |
949 // Verify codec delay and preroll are stripped. | 960 // Verify codec delay and preroll are stripped. |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1444 } | 1455 } |
1445 | 1456 |
1446 // For MediaSource tests, generate two sets of tests: one using FrameProcessor, | 1457 // For MediaSource tests, generate two sets of tests: one using FrameProcessor, |
1447 // and one using LegacyFrameProcessor. | 1458 // and one using LegacyFrameProcessor. |
1448 INSTANTIATE_TEST_CASE_P(NewFrameProcessor, PipelineIntegrationTest, | 1459 INSTANTIATE_TEST_CASE_P(NewFrameProcessor, PipelineIntegrationTest, |
1449 Values(false)); | 1460 Values(false)); |
1450 INSTANTIATE_TEST_CASE_P(LegacyFrameProcessor, PipelineIntegrationTest, | 1461 INSTANTIATE_TEST_CASE_P(LegacyFrameProcessor, PipelineIntegrationTest, |
1451 Values(true)); | 1462 Values(true)); |
1452 | 1463 |
1453 } // namespace media | 1464 } // namespace media |
OLD | NEW |