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 1970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1981 {133, 12}, | 1981 {133, 12}, |
1982 {kSkip, kSkip}, | 1982 {kSkip, kSkip}, |
1983 }; | 1983 }; |
1984 | 1984 |
1985 // Expect duration adjustment since actual duration differs slightly from | 1985 // Expect duration adjustment since actual duration differs slightly from |
1986 // duration in the init segment. | 1986 // duration in the init segment. |
1987 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2746))); | 1987 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2746))); |
1988 | 1988 |
1989 ASSERT_TRUE(ParseWebMFile("bear-320x240.webm", buffer_timestamps, | 1989 ASSERT_TRUE(ParseWebMFile("bear-320x240.webm", buffer_timestamps, |
1990 base::TimeDelta::FromMilliseconds(2744))); | 1990 base::TimeDelta::FromMilliseconds(2744))); |
| 1991 EXPECT_EQ(212949, demuxer_->GetMemoryUsage()); |
1991 } | 1992 } |
1992 | 1993 |
1993 TEST_F(ChunkDemuxerTest, WebMFile_LiveAudioAndVideo) { | 1994 TEST_F(ChunkDemuxerTest, WebMFile_LiveAudioAndVideo) { |
1994 struct BufferTimestamps buffer_timestamps[] = { | 1995 struct BufferTimestamps buffer_timestamps[] = { |
1995 {0, 0}, | 1996 {0, 0}, |
1996 {33, 3}, | 1997 {33, 3}, |
1997 {67, 6}, | 1998 {67, 6}, |
1998 {100, 9}, | 1999 {100, 9}, |
1999 {133, 12}, | 2000 {133, 12}, |
2000 {kSkip, kSkip}, | 2001 {kSkip, kSkip}, |
2001 }; | 2002 }; |
2002 | 2003 |
2003 ASSERT_TRUE(ParseWebMFile("bear-320x240-live.webm", buffer_timestamps, | 2004 ASSERT_TRUE(ParseWebMFile("bear-320x240-live.webm", buffer_timestamps, |
2004 kInfiniteDuration())); | 2005 kInfiniteDuration())); |
2005 | 2006 |
2006 DemuxerStream* audio = demuxer_->GetStream(DemuxerStream::AUDIO); | 2007 DemuxerStream* audio = demuxer_->GetStream(DemuxerStream::AUDIO); |
2007 EXPECT_EQ(DemuxerStream::LIVENESS_LIVE, audio->liveness()); | 2008 EXPECT_EQ(DemuxerStream::LIVENESS_LIVE, audio->liveness()); |
2008 DemuxerStream* video = demuxer_->GetStream(DemuxerStream::VIDEO); | 2009 DemuxerStream* video = demuxer_->GetStream(DemuxerStream::VIDEO); |
2009 EXPECT_EQ(DemuxerStream::LIVENESS_LIVE, video->liveness()); | 2010 EXPECT_EQ(DemuxerStream::LIVENESS_LIVE, video->liveness()); |
| 2011 EXPECT_EQ(212949, demuxer_->GetMemoryUsage()); |
2010 } | 2012 } |
2011 | 2013 |
2012 TEST_F(ChunkDemuxerTest, WebMFile_AudioOnly) { | 2014 TEST_F(ChunkDemuxerTest, WebMFile_AudioOnly) { |
2013 struct BufferTimestamps buffer_timestamps[] = { | 2015 struct BufferTimestamps buffer_timestamps[] = { |
2014 {kSkip, 0}, | 2016 {kSkip, 0}, |
2015 {kSkip, 3}, | 2017 {kSkip, 3}, |
2016 {kSkip, 6}, | 2018 {kSkip, 6}, |
2017 {kSkip, 9}, | 2019 {kSkip, 9}, |
2018 {kSkip, 12}, | 2020 {kSkip, 12}, |
2019 {kSkip, kSkip}, | 2021 {kSkip, kSkip}, |
2020 }; | 2022 }; |
2021 | 2023 |
2022 // Expect duration adjustment since actual duration differs slightly from | 2024 // Expect duration adjustment since actual duration differs slightly from |
2023 // duration in the init segment. | 2025 // duration in the init segment. |
2024 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2746))); | 2026 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2746))); |
2025 | 2027 |
2026 ASSERT_TRUE(ParseWebMFile("bear-320x240-audio-only.webm", buffer_timestamps, | 2028 ASSERT_TRUE(ParseWebMFile("bear-320x240-audio-only.webm", buffer_timestamps, |
2027 base::TimeDelta::FromMilliseconds(2744), | 2029 base::TimeDelta::FromMilliseconds(2744), |
2028 HAS_AUDIO)); | 2030 HAS_AUDIO)); |
| 2031 EXPECT_EQ(18624, demuxer_->GetMemoryUsage()); |
2029 } | 2032 } |
2030 | 2033 |
2031 TEST_F(ChunkDemuxerTest, WebMFile_VideoOnly) { | 2034 TEST_F(ChunkDemuxerTest, WebMFile_VideoOnly) { |
2032 struct BufferTimestamps buffer_timestamps[] = { | 2035 struct BufferTimestamps buffer_timestamps[] = { |
2033 {0, kSkip}, | 2036 {0, kSkip}, |
2034 {33, kSkip}, | 2037 {33, kSkip}, |
2035 {67, kSkip}, | 2038 {67, kSkip}, |
2036 {100, kSkip}, | 2039 {100, kSkip}, |
2037 {133, kSkip}, | 2040 {133, kSkip}, |
2038 {kSkip, kSkip}, | 2041 {kSkip, kSkip}, |
2039 }; | 2042 }; |
2040 | 2043 |
2041 // Expect duration adjustment since actual duration differs slightly from | 2044 // Expect duration adjustment since actual duration differs slightly from |
2042 // duration in the init segment. | 2045 // duration in the init segment. |
2043 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2736))); | 2046 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2736))); |
2044 | 2047 |
2045 ASSERT_TRUE(ParseWebMFile("bear-320x240-video-only.webm", buffer_timestamps, | 2048 ASSERT_TRUE(ParseWebMFile("bear-320x240-video-only.webm", buffer_timestamps, |
2046 base::TimeDelta::FromMilliseconds(2703), | 2049 base::TimeDelta::FromMilliseconds(2703), |
2047 HAS_VIDEO)); | 2050 HAS_VIDEO)); |
| 2051 EXPECT_EQ(194325, demuxer_->GetMemoryUsage()); |
2048 } | 2052 } |
2049 | 2053 |
2050 TEST_F(ChunkDemuxerTest, WebMFile_AltRefFrames) { | 2054 TEST_F(ChunkDemuxerTest, WebMFile_AltRefFrames) { |
2051 struct BufferTimestamps buffer_timestamps[] = { | 2055 struct BufferTimestamps buffer_timestamps[] = { |
2052 {0, 0}, | 2056 {0, 0}, |
2053 {33, 3}, | 2057 {33, 3}, |
2054 {33, 6}, | 2058 {33, 6}, |
2055 {67, 9}, | 2059 {67, 9}, |
2056 {100, 12}, | 2060 {100, 12}, |
2057 {kSkip, kSkip}, | 2061 {kSkip, kSkip}, |
(...skipping 1902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3960 // audio size is 80 bytes, new data is 28 bytes, we need to remove just one 10 | 3964 // audio size is 80 bytes, new data is 28 bytes, we need to remove just one 10 |
3961 // byte block to stay under 100 bytes memory limit after append | 3965 // byte block to stay under 100 bytes memory limit after append |
3962 // 80 - 10 + 28 = 98). | 3966 // 80 - 10 + 28 = 98). |
3963 // For video stream 150 + 52 = 202. Video limit is 150 bytes. We need to | 3967 // For video stream 150 + 52 = 202. Video limit is 150 bytes. We need to |
3964 // remove at least 6 blocks to stay under limit. | 3968 // remove at least 6 blocks to stay under limit. |
3965 CheckExpectedBuffers(audio_stream, "40K 80K 120K 160K 200K 240K 280K"); | 3969 CheckExpectedBuffers(audio_stream, "40K 80K 120K 160K 200K 240K 280K"); |
3966 CheckExpectedBuffers(video_stream, "60K 70 80K 90 100K 110 120K 130 140K"); | 3970 CheckExpectedBuffers(video_stream, "60K 70 80K 90 100K 110 120K 130 140K"); |
3967 } | 3971 } |
3968 | 3972 |
3969 } // namespace media | 3973 } // namespace media |
OLD | NEW |