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/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.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 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1222 ASSERT_EQ(PIPELINE_OK, Start("sfx.mp3", kHashed)); | 1222 ASSERT_EQ(PIPELINE_OK, Start("sfx.mp3", kHashed)); |
| 1223 | 1223 |
| 1224 Play(); | 1224 Play(); |
| 1225 | 1225 |
| 1226 ASSERT_TRUE(WaitUntilOnEnded()); | 1226 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1227 | 1227 |
| 1228 // Verify codec delay and preroll are stripped. | 1228 // Verify codec delay and preroll are stripped. |
| 1229 EXPECT_HASH_EQ("1.30,2.72,4.56,5.08,3.74,2.03,", GetAudioHash()); | 1229 EXPECT_HASH_EQ("1.30,2.72,4.56,5.08,3.74,2.03,", GetAudioHash()); |
| 1230 } | 1230 } |
| 1231 | 1231 |
| 1232 class Mp3SeekTestParams { | |
| 1233 public: | |
| 1234 Mp3SeekTestParams(const char* filename, const char* hash) | |
| 1235 : filename(filename), hash(hash) {} | |
| 1236 const char* filename; | |
| 1237 const char* hash; | |
| 1238 }; | |
| 1239 class Mp3SeekPipelineIntegrationTest | |
|
ddorwin
2015/12/03 23:07:54
nit: Why now empty lines around this class?
chcunningham
2015/12/04 02:29:55
Fixed
| |
| 1240 : public PipelineIntegrationTest, | |
| 1241 public testing::WithParamInterface<Mp3SeekTestParams> {}; | |
| 1242 TEST_P(Mp3SeekPipelineIntegrationTest, FastSeekAccuracy_MP3) { | |
|
ddorwin
2015/12/03 23:07:54
Should we have such tests for other types?
chcunningham
2015/12/04 02:29:55
No, this fastseek thing is mp3 specific. See https
| |
| 1243 Mp3SeekTestParams config = GetParam(); | |
| 1244 ASSERT_EQ(PIPELINE_OK, Start(config.filename, kHashed)); | |
|
ddorwin
2015/12/03 23:07:54
None of the ASSERTed items will cause a crash. Gen
chcunningham
2015/12/04 02:29:55
Leaving to match the other tests in this file
| |
| 1245 | |
| 1246 base::TimeDelta duration(pipeline_->GetMediaDuration()); | |
| 1247 | |
| 1248 // NOTE this seek time of (.3 * duration) is deliberately chosen to expose | |
|
ddorwin
2015/12/03 23:07:53
nit: 0.3? Also, below.
chcunningham
2015/12/04 02:29:55
Done.
| |
| 1249 // loss of precision in the MP3 TOC for CBR. Quick TOC design (not pretty!): | |
| 1250 // - All MP3 TOCs are 100 bytes | |
| 1251 // - Each byte is read as a uint8, value between 0 - 255. | |
|
ddorwin
2015/12/03 23:07:54
nit: remove the comma or replace it with something
chcunningham
2015/12/04 02:29:55
Done.
| |
| 1252 // - The index into this array is the numerator in the ratio: index / 100. | |
| 1253 // This fraction represents a playback time as a percentage of duration. | |
| 1254 // - The value at the given index is the numerator in the ratio: value / 256. | |
| 1255 // This fraction represents a byte offset as a percentage of the file size. | |
| 1256 // | |
| 1257 // For CBR files, each frame is the same size, so the offset for time of | |
| 1258 // (.3 * duration) should be around (.3 * file size). This is 78.8 / 256, | |
|
ddorwin
2015/12/03 23:07:54
7_6_.8?
chcunningham
2015/12/04 02:29:55
Done.
| |
| 1259 // but the numerator will be truncated in the TOC as 78, loosing precision. | |
|
ddorwin
2015/12/03 23:07:53
76?
chcunningham
2015/12/04 02:29:55
Done.
| |
| 1260 // | |
| 1261 // TLDR: | |
|
ddorwin
2015/12/03 23:07:53
This comment block should probably be external to
chcunningham
2015/12/04 02:29:55
Reordered and condensed
| |
| 1262 // The TOC is inaccurate. We don't use it for CBR, we tolerate it for VBR (for | |
| 1263 // faster seeking, see Mp3SeekFFmpegDemuxerTest). The chosen seek time | |
|
ddorwin
2015/12/03 23:07:54
nit: semicolon instead of colon? This isn't intend
chcunningham
2015/12/04 02:29:55
Done.
| |
| 1264 // exposes inaccuracy in TOC such that the hash will change if seek logic is | |
| 1265 // regressed. See https://crbug.com/545914. | |
| 1266 base::TimeDelta seek_time(.3 * duration); | |
| 1267 base::TimeDelta end_time = seek_time + base::TimeDelta::FromMilliseconds(500); | |
| 1268 | |
| 1269 ASSERT_TRUE(Seek(seek_time)); | |
| 1270 Play(); | |
| 1271 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(end_time)); | |
|
ddorwin
2015/12/03 23:07:54
Is this call somehow frame-accurate? Otherwise, th
chcunningham
2015/12/04 02:29:55
Great catch! reworked the test to play from near-e
| |
| 1272 | |
| 1273 EXPECT_HASH_EQ(config.hash, GetAudioHash()); | |
| 1274 } | |
| 1275 | |
| 1276 INSTANTIATE_TEST_CASE_P( | |
| 1277 , | |
|
ddorwin
2015/12/03 23:07:54
?
chcunningham
2015/12/04 02:29:55
Wasn't using this, but I broke up the tests now in
| |
| 1278 Mp3SeekPipelineIntegrationTest, | |
| 1279 ::testing::Values(Mp3SeekTestParams("bear-audio-10s-CBR-has-TOC.mp3", | |
| 1280 "0.06,0.10,-0.32,0.08,0.52,0.78,"), | |
| 1281 Mp3SeekTestParams("bear-audio-10s-CBR-no-TOC.mp3", | |
| 1282 "-0.08,0.06,0.34,0.65,1.01,0.57,"), | |
| 1283 Mp3SeekTestParams("bear-audio-10s-VBR-has-TOC.mp3", | |
| 1284 "-0.02,-0.11,0.02,0.49,1.16,0.88,"), | |
| 1285 Mp3SeekTestParams("bear-audio-10s-VBR-no-TOC.mp3", | |
| 1286 "0.40,0.22,0.36,0.40,1.21,0.91,"))); | |
| 1287 | |
| 1232 TEST_F(PipelineIntegrationTest, MediaSource_MP3) { | 1288 TEST_F(PipelineIntegrationTest, MediaSource_MP3) { |
| 1233 MockMediaSource source("sfx.mp3", kMP3, kAppendWholeFile); | 1289 MockMediaSource source("sfx.mp3", kMP3, kAppendWholeFile); |
| 1234 StartHashedPipelineWithMediaSource(&source); | 1290 StartHashedPipelineWithMediaSource(&source); |
| 1235 source.EndOfStream(); | 1291 source.EndOfStream(); |
| 1236 | 1292 |
| 1237 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1293 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 1238 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1294 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 1239 EXPECT_EQ(313, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1295 EXPECT_EQ(313, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 1240 | 1296 |
| 1241 Play(); | 1297 Play(); |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1840 | 1896 |
| 1841 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { | 1897 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { |
| 1842 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); | 1898 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); |
| 1843 Play(); | 1899 Play(); |
| 1844 ASSERT_TRUE(WaitUntilOnEnded()); | 1900 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1845 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), | 1901 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), |
| 1846 demuxer_->GetStartTime()); | 1902 demuxer_->GetStartTime()); |
| 1847 } | 1903 } |
| 1848 | 1904 |
| 1849 } // namespace media | 1905 } // namespace media |
| OLD | NEW |