summaryrefslogtreecommitdiffstats
path: root/media/webm
diff options
context:
space:
mode:
authoracolwell@chromium.org <acolwell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-21 17:56:59 +0000
committeracolwell@chromium.org <acolwell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-21 17:56:59 +0000
commitc8d979926f125e9d409528f0d89043f72536f3f4 (patch)
tree664a5fc0f9ee46354782447332cdcb12151deff5 /media/webm
parentab2abc8dec6e6f236af927b0c671287977cadd27 (diff)
downloadchromium_src-c8d979926f125e9d409528f0d89043f72536f3f4.zip
chromium_src-c8d979926f125e9d409528f0d89043f72536f3f4.tar.gz
chromium_src-c8d979926f125e9d409528f0d89043f72536f3f4.tar.bz2
Revert 115229 - Revert 115214 (caused media_unittests failure in FFmpegGlueTest,
suspiciously immediately after the code modified in this test.) FFmpegGlueTest failure was a flake. Fix ChunkDemuxer seeks that occur during a partially parsed cluster. BUG=104160 TEST=ChunkDemuxerTest.TestSeekWhileParsingCluster, WebMParserTest.TestReset Review URL: http://codereview.chromium.org/9010001 TBR=acolwell@chromium.org Review URL: http://codereview.chromium.org/8989041 TBR=dmazzoni@chromium.org Review URL: http://codereview.chromium.org/9019020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115360 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/webm')
-rw-r--r--media/webm/webm_cluster_parser.cc8
-rw-r--r--media/webm/webm_cluster_parser.h3
-rw-r--r--media/webm/webm_parser_unittest.cc48
3 files changed, 55 insertions, 4 deletions
diff --git a/media/webm/webm_cluster_parser.cc b/media/webm/webm_cluster_parser.cc
index fd716b2..fc64176 100644
--- a/media/webm/webm_cluster_parser.cc
+++ b/media/webm/webm_cluster_parser.cc
@@ -33,6 +33,14 @@ WebMClusterParser::WebMClusterParser(int64 timecode_scale,
WebMClusterParser::~WebMClusterParser() {}
+void WebMClusterParser::Reset() {
+ audio_buffers_.clear();
+ video_buffers_.clear();
+ last_block_timecode_ = -1;
+ cluster_timecode_ = -1;
+ parser_.Reset();
+}
+
int WebMClusterParser::Parse(const uint8* buf, int size) {
audio_buffers_.clear();
video_buffers_.clear();
diff --git a/media/webm/webm_cluster_parser.h b/media/webm/webm_cluster_parser.h
index 7fb1b94..445d207 100644
--- a/media/webm/webm_cluster_parser.h
+++ b/media/webm/webm_cluster_parser.h
@@ -25,6 +25,9 @@ class WebMClusterParser : public WebMParserClient {
base::TimeDelta video_default_duration);
virtual ~WebMClusterParser();
+ // Resets the parser state so it can accept a new cluster.
+ void Reset();
+
// Parses a WebM cluster element in |buf|.
//
// Returns -1 if the parse fails.
diff --git a/media/webm/webm_parser_unittest.cc b/media/webm/webm_parser_unittest.cc
index e377fda..3c8600b 100644
--- a/media/webm/webm_parser_unittest.cc
+++ b/media/webm/webm_parser_unittest.cc
@@ -60,11 +60,13 @@ static Cluster* CreateCluster(int timecode,
static void CreateClusterExpectations(int timecode,
const SimpleBlockInfo* block_info,
int block_count,
+ bool is_complete_cluster,
MockWebMParserClient* client) {
InSequence s;
EXPECT_CALL(*client, OnListStart(kWebMIdCluster)).WillOnce(Return(true));
- EXPECT_CALL(*client, OnUInt(kWebMIdTimecode, 0)).WillOnce(Return(true));
+ EXPECT_CALL(*client, OnUInt(kWebMIdTimecode, timecode))
+ .WillOnce(Return(true));
for (int i = 0; i < block_count; i++) {
EXPECT_CALL(*client, OnSimpleBlock(block_info[i].track_num,
@@ -73,7 +75,8 @@ static void CreateClusterExpectations(int timecode,
.WillOnce(Return(true));
}
- EXPECT_CALL(*client, OnListEnd(kWebMIdCluster)).WillOnce(Return(true));
+ if (is_complete_cluster)
+ EXPECT_CALL(*client, OnListEnd(kWebMIdCluster)).WillOnce(Return(true));
}
TEST_F(WebMParserTest, EmptyCluster) {
@@ -211,7 +214,7 @@ TEST_F(WebMParserTest, ParseListElementWithSingleCall) {
int block_count = arraysize(kBlockInfo);
scoped_ptr<Cluster> cluster(CreateCluster(0, kBlockInfo, block_count));
- CreateClusterExpectations(0, kBlockInfo, block_count, &client_);
+ CreateClusterExpectations(0, kBlockInfo, block_count, true, &client_);
WebMListParser parser(kWebMIdCluster);
int result = parser.Parse(cluster->data(), cluster->size(), &client_);
@@ -230,7 +233,7 @@ TEST_F(WebMParserTest, ParseListElementWithMultipleCalls) {
int block_count = arraysize(kBlockInfo);
scoped_ptr<Cluster> cluster(CreateCluster(0, kBlockInfo, block_count));
- CreateClusterExpectations(0, kBlockInfo, block_count, &client_);
+ CreateClusterExpectations(0, kBlockInfo, block_count, true, &client_);
const uint8* data = cluster->data();
int size = cluster->size();
@@ -261,4 +264,41 @@ TEST_F(WebMParserTest, ParseListElementWithMultipleCalls) {
EXPECT_TRUE(parser.IsParsingComplete());
}
+TEST_F(WebMParserTest, TestReset) {
+ InSequence s;
+
+ const SimpleBlockInfo kBlockInfo[] = {
+ { 0, 1 },
+ { 1, 2 },
+ { 0, 3 },
+ { 0, 4 },
+ { 1, 4 },
+ };
+ int block_count = arraysize(kBlockInfo);
+
+ scoped_ptr<Cluster> cluster(CreateCluster(0, kBlockInfo, block_count));
+
+ // First expect all but the last block.
+ CreateClusterExpectations(0, kBlockInfo, block_count - 1, false, &client_);
+
+ // Now expect all blocks.
+ CreateClusterExpectations(0, kBlockInfo, block_count, true, &client_);
+
+ WebMListParser parser(kWebMIdCluster);
+
+ // Send slightly less than the full cluster so all but the last block is
+ // parsed.
+ int result = parser.Parse(cluster->data(), cluster->size() - 1, &client_);
+ EXPECT_GT(result, 0);
+ EXPECT_LT(result, cluster->size());
+ EXPECT_FALSE(parser.IsParsingComplete());
+
+ parser.Reset();
+
+ // Now parse a whole cluster to verify that all the blocks will get parsed.
+ result = parser.Parse(cluster->data(), cluster->size(), &client_);
+ EXPECT_EQ(result, cluster->size());
+ EXPECT_TRUE(parser.IsParsingComplete());
+}
+
} // namespace media