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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
| (...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 752 // tests require init segment received before duration set. | 752 // tests require init segment received before duration set. |
| 753 EXPECT_CALL(*this, InitSegmentReceived()); | 753 EXPECT_CALL(*this, InitSegmentReceived()); |
| 754 demuxer_->Initialize( | 754 demuxer_->Initialize( |
| 755 &host_, CreateInitDoneCB(base::TimeDelta::FromMilliseconds(2744), | 755 &host_, CreateInitDoneCB(base::TimeDelta::FromMilliseconds(2744), |
| 756 PIPELINE_OK), true); | 756 PIPELINE_OK), true); |
| 757 | 757 |
| 758 if (AddId(kSourceId, HAS_AUDIO | HAS_VIDEO) != ChunkDemuxer::kOk) | 758 if (AddId(kSourceId, HAS_AUDIO | HAS_VIDEO) != ChunkDemuxer::kOk) |
| 759 return false; | 759 return false; |
| 760 | 760 |
| 761 // Append the whole bear1 file. | 761 // Append the whole bear1 file. |
| 762 // TODO(wolenetz/acolwell): Remove this extra SetDuration expectation once | 762 // Expect duration adjustment since actual duration differs slightly from |
| 763 // the files are fixed to have the correct duration in their init segments, | 763 // duration in the init segment. |
|
wolenetz
2015/09/14 23:02:20
this change is good and aligns with the current "W
| |
| 764 // and the CreateInitDoneCB() call, above, is fixed to used that duration. | |
| 765 // See http://crbug.com/354284. | |
| 766 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2746))); | 764 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2746))); |
| 767 AppendData(bear1->data(), bear1->data_size()); | 765 AppendData(bear1->data(), bear1->data_size()); |
| 768 // Last audio frame has timestamp 2721 and duration 24 (estimated from max | 766 // Last audio frame has timestamp 2721 and duration 24 (estimated from max |
| 769 // seen so far for audio track). | 767 // seen so far for audio track). |
| 770 // Last video frame has timestamp 2703 and duration 33 (from TrackEntry | 768 // Last video frame has timestamp 2703 and duration 33 (from TrackEntry |
| 771 // DefaultDuration for video track). | 769 // DefaultDuration for video track). |
| 772 CheckExpectedRanges(kSourceId, "{ [0,2736) }"); | 770 CheckExpectedRanges(kSourceId, "{ [0,2736) }"); |
| 773 | 771 |
| 774 // Append initialization segment for bear2. | 772 // Append initialization segment for bear2. |
| 775 // Note: Offsets here and below are derived from | 773 // Note: Offsets here and below are derived from |
| (...skipping 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1979 TEST_F(ChunkDemuxerTest, WebMFile_AudioAndVideo) { | 1977 TEST_F(ChunkDemuxerTest, WebMFile_AudioAndVideo) { |
| 1980 struct BufferTimestamps buffer_timestamps[] = { | 1978 struct BufferTimestamps buffer_timestamps[] = { |
| 1981 {0, 0}, | 1979 {0, 0}, |
| 1982 {33, 3}, | 1980 {33, 3}, |
| 1983 {67, 6}, | 1981 {67, 6}, |
| 1984 {100, 9}, | 1982 {100, 9}, |
| 1985 {133, 12}, | 1983 {133, 12}, |
| 1986 {kSkip, kSkip}, | 1984 {kSkip, kSkip}, |
| 1987 }; | 1985 }; |
| 1988 | 1986 |
| 1989 // TODO(wolenetz/acolwell): Remove this SetDuration expectation and update the | 1987 // Expect duration adjustment since actual duration differs slightly from |
| 1990 // ParseWebMFile() call's expected duration, below, once the file is fixed to | 1988 // duration in the init segment. |
| 1991 // have the correct duration in the init segment. See http://crbug.com/354284. | |
| 1992 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2746))); | 1989 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2746))); |
| 1993 | 1990 |
| 1994 ASSERT_TRUE(ParseWebMFile("bear-320x240.webm", buffer_timestamps, | 1991 ASSERT_TRUE(ParseWebMFile("bear-320x240.webm", buffer_timestamps, |
| 1995 base::TimeDelta::FromMilliseconds(2744))); | 1992 base::TimeDelta::FromMilliseconds(2744))); |
| 1996 } | 1993 } |
| 1997 | 1994 |
| 1998 TEST_F(ChunkDemuxerTest, WebMFile_LiveAudioAndVideo) { | 1995 TEST_F(ChunkDemuxerTest, WebMFile_LiveAudioAndVideo) { |
| 1999 struct BufferTimestamps buffer_timestamps[] = { | 1996 struct BufferTimestamps buffer_timestamps[] = { |
| 2000 {0, 0}, | 1997 {0, 0}, |
| 2001 {33, 3}, | 1998 {33, 3}, |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 2017 TEST_F(ChunkDemuxerTest, WebMFile_AudioOnly) { | 2014 TEST_F(ChunkDemuxerTest, WebMFile_AudioOnly) { |
| 2018 struct BufferTimestamps buffer_timestamps[] = { | 2015 struct BufferTimestamps buffer_timestamps[] = { |
| 2019 {kSkip, 0}, | 2016 {kSkip, 0}, |
| 2020 {kSkip, 3}, | 2017 {kSkip, 3}, |
| 2021 {kSkip, 6}, | 2018 {kSkip, 6}, |
| 2022 {kSkip, 9}, | 2019 {kSkip, 9}, |
| 2023 {kSkip, 12}, | 2020 {kSkip, 12}, |
| 2024 {kSkip, kSkip}, | 2021 {kSkip, kSkip}, |
| 2025 }; | 2022 }; |
| 2026 | 2023 |
| 2027 // TODO(wolenetz/acolwell): Remove this SetDuration expectation and update the | 2024 // Expect duration adjustment since actual duration differs slightly from |
| 2028 // ParseWebMFile() call's expected duration, below, once the file is fixed to | 2025 // duration in the init segment. |
| 2029 // have the correct duration in the init segment. See http://crbug.com/354284. | |
| 2030 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2746))); | 2026 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2746))); |
| 2031 | 2027 |
| 2032 ASSERT_TRUE(ParseWebMFile("bear-320x240-audio-only.webm", buffer_timestamps, | 2028 ASSERT_TRUE(ParseWebMFile("bear-320x240-audio-only.webm", buffer_timestamps, |
| 2033 base::TimeDelta::FromMilliseconds(2744), | 2029 base::TimeDelta::FromMilliseconds(2744), |
| 2034 HAS_AUDIO)); | 2030 HAS_AUDIO)); |
| 2035 } | 2031 } |
| 2036 | 2032 |
| 2037 TEST_F(ChunkDemuxerTest, WebMFile_VideoOnly) { | 2033 TEST_F(ChunkDemuxerTest, WebMFile_VideoOnly) { |
| 2038 struct BufferTimestamps buffer_timestamps[] = { | 2034 struct BufferTimestamps buffer_timestamps[] = { |
| 2039 {0, kSkip}, | 2035 {0, kSkip}, |
| 2040 {33, kSkip}, | 2036 {33, kSkip}, |
| 2041 {67, kSkip}, | 2037 {67, kSkip}, |
| 2042 {100, kSkip}, | 2038 {100, kSkip}, |
| 2043 {133, kSkip}, | 2039 {133, kSkip}, |
| 2044 {kSkip, kSkip}, | 2040 {kSkip, kSkip}, |
| 2045 }; | 2041 }; |
| 2046 | 2042 |
| 2047 // TODO(wolenetz/acolwell): Remove this SetDuration expectation and update the | 2043 // Expect duration adjustment since actual duration differs slightly from |
| 2048 // ParseWebMFile() call's expected duration, below, once the file is fixed to | 2044 // duration in the init segment. |
| 2049 // have the correct duration in the init segment. See http://crbug.com/354284. | |
| 2050 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2736))); | 2045 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2736))); |
| 2051 | 2046 |
| 2052 ASSERT_TRUE(ParseWebMFile("bear-320x240-video-only.webm", buffer_timestamps, | 2047 ASSERT_TRUE(ParseWebMFile("bear-320x240-video-only.webm", buffer_timestamps, |
| 2053 base::TimeDelta::FromMilliseconds(2703), | 2048 base::TimeDelta::FromMilliseconds(2703), |
| 2054 HAS_VIDEO)); | 2049 HAS_VIDEO)); |
| 2055 } | 2050 } |
| 2056 | 2051 |
| 2057 TEST_F(ChunkDemuxerTest, WebMFile_AltRefFrames) { | 2052 TEST_F(ChunkDemuxerTest, WebMFile_AltRefFrames) { |
| 2058 struct BufferTimestamps buffer_timestamps[] = { | 2053 struct BufferTimestamps buffer_timestamps[] = { |
| 2059 {0, 0}, | 2054 {0, 0}, |
| (...skipping 1495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3555 TEST_F(ChunkDemuxerTest, AppendWindow_AudioConfigUpdateRemovesPreroll) { | 3550 TEST_F(ChunkDemuxerTest, AppendWindow_AudioConfigUpdateRemovesPreroll) { |
| 3556 EXPECT_CALL(*this, DemuxerOpened()); | 3551 EXPECT_CALL(*this, DemuxerOpened()); |
| 3557 demuxer_->Initialize( | 3552 demuxer_->Initialize( |
| 3558 &host_, | 3553 &host_, |
| 3559 CreateInitDoneCB(base::TimeDelta::FromMilliseconds(2744), PIPELINE_OK), | 3554 CreateInitDoneCB(base::TimeDelta::FromMilliseconds(2744), PIPELINE_OK), |
| 3560 true); | 3555 true); |
| 3561 ASSERT_EQ(ChunkDemuxer::kOk, AddId(kSourceId, HAS_AUDIO)); | 3556 ASSERT_EQ(ChunkDemuxer::kOk, AddId(kSourceId, HAS_AUDIO)); |
| 3562 | 3557 |
| 3563 // Set the append window such that the first file is completely before the | 3558 // Set the append window such that the first file is completely before the |
| 3564 // append window. | 3559 // append window. |
| 3565 // TODO(wolenetz/acolwell): Update this duration once the files are fixed to | 3560 // Expect duration adjustment since actual duration differs slightly from |
| 3566 // have the correct duration in their init segments, and the | 3561 // duration in the init segment. |
| 3567 // CreateInitDoneCB() call, above, is fixed to used that duration. See | |
| 3568 // http://crbug.com/354284. | |
| 3569 const base::TimeDelta duration_1 = base::TimeDelta::FromMilliseconds(2746); | 3562 const base::TimeDelta duration_1 = base::TimeDelta::FromMilliseconds(2746); |
| 3570 append_window_start_for_next_append_ = duration_1; | 3563 append_window_start_for_next_append_ = duration_1; |
| 3571 | 3564 |
| 3572 // Read a WebM file into memory and append the data. | 3565 // Read a WebM file into memory and append the data. |
| 3573 scoped_refptr<DecoderBuffer> buffer = | 3566 scoped_refptr<DecoderBuffer> buffer = |
| 3574 ReadTestDataFile("bear-320x240-audio-only.webm"); | 3567 ReadTestDataFile("bear-320x240-audio-only.webm"); |
| 3575 EXPECT_CALL(*this, InitSegmentReceived()); | 3568 EXPECT_CALL(*this, InitSegmentReceived()); |
| 3576 AppendDataInPieces(buffer->data(), buffer->data_size(), 512); | 3569 AppendDataInPieces(buffer->data(), buffer->data_size(), 512); |
| 3577 CheckExpectedRanges(kSourceId, "{ }"); | 3570 CheckExpectedRanges(kSourceId, "{ }"); |
| 3578 | 3571 |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3848 // audio size is 80 bytes, new data is 28 bytes, we need to remove just one 10 | 3841 // audio size is 80 bytes, new data is 28 bytes, we need to remove just one 10 |
| 3849 // byte block to stay under 100 bytes memory limit after append | 3842 // byte block to stay under 100 bytes memory limit after append |
| 3850 // 80 - 10 + 28 = 98). | 3843 // 80 - 10 + 28 = 98). |
| 3851 // For video stream 150 + 52 = 202. Video limit is 150 bytes. We need to | 3844 // For video stream 150 + 52 = 202. Video limit is 150 bytes. We need to |
| 3852 // remove at least 6 blocks to stay under limit. | 3845 // remove at least 6 blocks to stay under limit. |
| 3853 CheckExpectedBuffers(audio_stream, "40K 80K 120K 160K 200K 240K 280K"); | 3846 CheckExpectedBuffers(audio_stream, "40K 80K 120K 160K 200K 240K 280K"); |
| 3854 CheckExpectedBuffers(video_stream, "60K 70 80K 90 100K 110 120K 130 140K"); | 3847 CheckExpectedBuffers(video_stream, "60K 70 80K 90 100K 110 120K 130 140K"); |
| 3855 } | 3848 } |
| 3856 | 3849 |
| 3857 } // namespace media | 3850 } // namespace media |
| OLD | NEW |