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/logging.h" | 5 #include "base/logging.h" |
6 #include "media/webm/cluster_builder.h" | 6 #include "media/webm/cluster_builder.h" |
7 #include "media/webm/webm_cluster_parser.h" | 7 #include "media/webm/webm_cluster_parser.h" |
8 #include "media/webm/webm_constants.h" | 8 #include "media/webm/webm_constants.h" |
9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 } | 31 } |
32 | 32 |
33 struct BlockInfo { | 33 struct BlockInfo { |
34 int track_num; | 34 int track_num; |
35 int timestamp; | 35 int timestamp; |
36 int duration; | 36 int duration; |
37 bool use_simple_block; | 37 bool use_simple_block; |
38 }; | 38 }; |
39 | 39 |
40 const BlockInfo kDefaultBlockInfo[] = { | 40 const BlockInfo kDefaultBlockInfo[] = { |
41 { kAudioTrackNum, 0, -1, true }, | 41 { kAudioTrackNum, 0, 23, true }, |
42 { kAudioTrackNum, 23, -1, true }, | 42 { kAudioTrackNum, 23, 23, true }, |
43 { kVideoTrackNum, kVideoDefaultDurationInMs, kVideoDefaultDurationInMs, | 43 { kVideoTrackNum, kVideoDefaultDurationInMs, kVideoDefaultDurationInMs, |
44 true }, | 44 true }, |
45 { kAudioTrackNum, 46, -1, true }, | 45 { kAudioTrackNum, 46, 23, false }, |
46 { kVideoTrackNum, 2 * kVideoDefaultDurationInMs, kVideoDefaultDurationInMs, | 46 { kVideoTrackNum, 2 * kVideoDefaultDurationInMs, kVideoDefaultDurationInMs, |
47 true }, | 47 true }, |
48 }; | 48 }; |
49 | 49 |
50 static scoped_ptr<Cluster> CreateCluster(int timecode, | 50 static scoped_ptr<Cluster> CreateCluster(int timecode, |
51 const BlockInfo* block_info, | 51 const BlockInfo* block_info, |
52 int block_count) { | 52 int block_count) { |
53 ClusterBuilder cb; | 53 ClusterBuilder cb; |
54 cb.SetClusterTimecode(0); | 54 cb.SetClusterTimecode(0); |
55 | 55 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 }; | 235 }; |
236 const int kClusterSize = sizeof(kClusterData); | 236 const int kClusterSize = sizeof(kClusterData); |
237 | 237 |
238 int result = parser_->Parse(kClusterData, kClusterSize); | 238 int result = parser_->Parse(kClusterData, kClusterSize); |
239 EXPECT_EQ(result, kClusterSize); | 239 EXPECT_EQ(result, kClusterSize); |
240 ASSERT_TRUE(VerifyBuffers(parser_, kBlockInfo, block_count)); | 240 ASSERT_TRUE(VerifyBuffers(parser_, kBlockInfo, block_count)); |
241 } | 241 } |
242 | 242 |
243 TEST_F(WebMClusterParserTest, ParseSimpleBlockAndBlockGroupMixture) { | 243 TEST_F(WebMClusterParserTest, ParseSimpleBlockAndBlockGroupMixture) { |
244 const BlockInfo kBlockInfo[] = { | 244 const BlockInfo kBlockInfo[] = { |
245 { kAudioTrackNum, 0, -1, true }, | 245 { kAudioTrackNum, 0, 23, true }, |
246 { kAudioTrackNum, 23, 23, false }, | 246 { kAudioTrackNum, 23, 23, false }, |
247 { kVideoTrackNum, kVideoDefaultDurationInMs, kVideoDefaultDurationInMs, | 247 { kVideoTrackNum, kVideoDefaultDurationInMs, kVideoDefaultDurationInMs, |
248 true }, | 248 true }, |
249 { kAudioTrackNum, 46, 23, false }, | 249 { kAudioTrackNum, 46, 23, false }, |
250 { kVideoTrackNum, 2 * kVideoDefaultDurationInMs, 34, | 250 { kVideoTrackNum, 2 * kVideoDefaultDurationInMs, 34, |
251 false }, | 251 false }, |
252 }; | 252 }; |
253 int block_count = arraysize(kBlockInfo); | 253 int block_count = arraysize(kBlockInfo); |
254 scoped_ptr<Cluster> cluster(CreateCluster(0, kBlockInfo, block_count)); | 254 scoped_ptr<Cluster> cluster(CreateCluster(0, kBlockInfo, block_count)); |
255 | 255 |
256 int result = parser_->Parse(cluster->data(), cluster->size()); | 256 int result = parser_->Parse(cluster->data(), cluster->size()); |
257 EXPECT_EQ(cluster->size(), result); | 257 EXPECT_EQ(cluster->size(), result); |
258 ASSERT_TRUE(VerifyBuffers(parser_, kBlockInfo, block_count)); | 258 ASSERT_TRUE(VerifyBuffers(parser_, kBlockInfo, block_count)); |
259 } | 259 } |
260 | 260 |
261 } // namespace media | 261 } // namespace media |
OLD | NEW |