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/logging.h" | 8 #include "base/logging.h" |
9 #include "media/base/decrypt_config.h" | 9 #include "media/base/decrypt_config.h" |
10 #include "media/webm/cluster_builder.h" | 10 #include "media/webm/cluster_builder.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 176 |
177 const scoped_refptr<StreamParserBuffer> buffer = *buffer_iter++; | 177 const scoped_refptr<StreamParserBuffer> buffer = *buffer_iter++; |
178 EXPECT_EQ(buffer->timestamp().InMilliseconds(), block_info.timestamp); | 178 EXPECT_EQ(buffer->timestamp().InMilliseconds(), block_info.timestamp); |
179 EXPECT_EQ(buffer->duration().InMilliseconds(), block_info.duration); | 179 EXPECT_EQ(buffer->duration().InMilliseconds(), block_info.duration); |
180 } | 180 } |
181 | 181 |
182 EXPECT_TRUE(buffer_iter == buffer_end); | 182 EXPECT_TRUE(buffer_iter == buffer_end); |
183 return true; | 183 return true; |
184 } | 184 } |
185 | 185 |
186 static bool VerifyEncryptedBuffer( | 186 static void VerifyEncryptedBuffer( |
187 scoped_refptr<StreamParserBuffer> buffer) { | 187 scoped_refptr<StreamParserBuffer> buffer) { |
188 EXPECT_TRUE(buffer->decrypt_config()); | 188 EXPECT_TRUE(buffer->decrypt_config()); |
189 EXPECT_EQ(static_cast<unsigned long>(DecryptConfig::kDecryptionKeySize), | 189 EXPECT_EQ(static_cast<unsigned long>(DecryptConfig::kDecryptionKeySize), |
190 buffer->decrypt_config()->iv().length()); | 190 buffer->decrypt_config()->iv().length()); |
191 const uint8* data = buffer->data(); | |
192 return data[0] & kWebMFlagEncryptedFrame; | |
193 } | 191 } |
194 | 192 |
195 static void AppendToEnd(const WebMClusterParser::BufferQueue& src, | 193 static void AppendToEnd(const WebMClusterParser::BufferQueue& src, |
196 WebMClusterParser::BufferQueue* dest) { | 194 WebMClusterParser::BufferQueue* dest) { |
197 for (WebMClusterParser::BufferQueue::const_iterator itr = src.begin(); | 195 for (WebMClusterParser::BufferQueue::const_iterator itr = src.begin(); |
198 itr != src.end(); ++itr) { | 196 itr != src.end(); ++itr) { |
199 dest->push_back(*itr); | 197 dest->push_back(*itr); |
200 } | 198 } |
201 } | 199 } |
202 | 200 |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 kVideoTrackNum, | 499 kVideoTrackNum, |
502 WebMTracksParser::TextTracks(), | 500 WebMTracksParser::TextTracks(), |
503 std::set<int64>(), | 501 std::set<int64>(), |
504 std::string(), | 502 std::string(), |
505 "video_key_id", | 503 "video_key_id", |
506 LogCB())); | 504 LogCB())); |
507 int result = parser_->Parse(cluster->data(), cluster->size()); | 505 int result = parser_->Parse(cluster->data(), cluster->size()); |
508 EXPECT_EQ(cluster->size(), result); | 506 EXPECT_EQ(cluster->size(), result); |
509 ASSERT_EQ(1UL, parser_->video_buffers().size()); | 507 ASSERT_EQ(1UL, parser_->video_buffers().size()); |
510 scoped_refptr<StreamParserBuffer> buffer = parser_->video_buffers()[0]; | 508 scoped_refptr<StreamParserBuffer> buffer = parser_->video_buffers()[0]; |
511 EXPECT_TRUE(VerifyEncryptedBuffer(buffer)); | 509 VerifyEncryptedBuffer(buffer); |
512 } | 510 } |
513 | 511 |
514 TEST_F(WebMClusterParserTest, ParseBadEncryptedBlock) { | 512 TEST_F(WebMClusterParserTest, ParseBadEncryptedBlock) { |
515 scoped_ptr<Cluster> cluster( | 513 scoped_ptr<Cluster> cluster( |
516 CreateEncryptedCluster(sizeof(kEncryptedFrame) - 1)); | 514 CreateEncryptedCluster(sizeof(kEncryptedFrame) - 1)); |
517 | 515 |
518 parser_.reset(new WebMClusterParser(kTimecodeScale, | 516 parser_.reset(new WebMClusterParser(kTimecodeScale, |
519 kAudioTrackNum, | 517 kAudioTrackNum, |
520 kVideoTrackNum, | 518 kVideoTrackNum, |
521 WebMTracksParser::TextTracks(), | 519 WebMTracksParser::TextTracks(), |
522 std::set<int64>(), | 520 std::set<int64>(), |
523 std::string(), | 521 std::string(), |
524 "video_key_id", | 522 "video_key_id", |
525 LogCB())); | 523 LogCB())); |
526 int result = parser_->Parse(cluster->data(), cluster->size()); | 524 int result = parser_->Parse(cluster->data(), cluster->size()); |
527 EXPECT_EQ(-1, result); | 525 EXPECT_EQ(-1, result); |
528 } | 526 } |
529 | 527 |
530 } // namespace media | 528 } // namespace media |
OLD | NEW |