Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(950)

Unified Diff: media/filters/ffmpeg_video_decoder_unittest.cc

Issue 10800057: Clean up decryption tests in FFmpegVideoDecoderTest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Leave the binary file to make CQ happy. Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/ffmpeg_video_decoder_unittest.cc
diff --git a/media/filters/ffmpeg_video_decoder_unittest.cc b/media/filters/ffmpeg_video_decoder_unittest.cc
index a21c3c84a6d63a92302e6f7b43be7c1f3073a01e..fb1b0c551d8a7ebc8619e323d3306ba1458f86ae 100644
--- a/media/filters/ffmpeg_video_decoder_unittest.cc
+++ b/media/filters/ffmpeg_video_decoder_unittest.cc
@@ -37,18 +37,22 @@ static const gfx::Size kCodedSize(320, 240);
static const gfx::Rect kVisibleRect(320, 240);
static const AVRational kFrameRate = { 100, 1 };
static const AVRational kAspectRatio = { 1, 1 };
-
-static const uint8 kKeyId[] = { 0x4b, 0x65, 0x79, 0x20, 0x49, 0x44 };
-static const uint8 kSecretKey[] = {
- 0xfb, 0x67, 0x8a, 0x91, 0x19, 0x12, 0x7b, 0x6b,
- 0x0b, 0x63, 0x11, 0xf8, 0x6f, 0xe1, 0xc4, 0x2d
-};
-
-static const uint64 kIv = 3735928559ULL;
-static const uint8 kHmac[] = {
- 0x16, 0xc0, 0x65, 0x1f, 0xf8, 0x0b, 0x36, 0x16,
- 0xb8, 0x32, 0x35, 0x56
-};
+static const uint8 kFakeKeyId[] = { 0x4b, 0x65, 0x79, 0x20, 0x49, 0x44 };
+static const uint8 kFakeIv[DecryptConfig::kDecryptionKeySize] = { 0 };
+static const uint8 kFakeCheckSum[] = { 0, 0 };
+
+// Create a fake non-empty encrypted buffer.
+static scoped_refptr<DecoderBuffer> CreateFakeEncryptedBuffer() {
+ const int buffer_size = 16; // Need a non-empty buffer;
+ const int encrypted_frame_offset = 1; // This should be non-zero.
+ scoped_refptr<DecoderBuffer> buffer(new DecoderBuffer(buffer_size));
+ buffer->SetDecryptConfig(scoped_ptr<DecryptConfig>(new DecryptConfig(
+ kFakeKeyId, arraysize(kFakeKeyId),
+ kFakeIv, DecryptConfig::kDecryptionKeySize,
+ kFakeCheckSum, arraysize(kFakeCheckSum),
+ encrypted_frame_offset)));
+ return buffer;
+}
ACTION_P(ReturnBuffer, buffer) {
arg0.Run(buffer ? DemuxerStream::kOk : DemuxerStream::kAborted, buffer);
@@ -76,13 +80,7 @@ class FFmpegVideoDecoderTest : public testing::Test {
end_of_stream_buffer_ = DecoderBuffer::CreateEOSBuffer();
i_frame_buffer_ = ReadTestDataFile("vp8-I-frame-320x240");
corrupt_i_frame_buffer_ = ReadTestDataFile("vp8-corrupt-I-frame");
- {
- scoped_refptr<DecoderBuffer> temp_buffer = ReadTestDataFile(
- "vp8-encrypted-I-frame-320x240");
- encrypted_i_frame_buffer_ = DecoderBuffer::CopyFrom(
- temp_buffer->GetData() + arraysize(kHmac),
- temp_buffer->GetDataSize() - arraysize(kHmac));
- }
+ encrypted_i_frame_buffer_ = CreateFakeEncryptedBuffer();
config_.Initialize(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN,
kVideoFormat, kCodedSize, kVisibleRect,
@@ -211,24 +209,6 @@ class FFmpegVideoDecoderTest : public testing::Test {
message_loop_.RunAllPending();
}
- // Generates a 16 byte CTR counter block. The CTR counter block format is a
- // CTR IV appended with a CTR block counter. |iv| is an 8 byte CTR IV.
- static scoped_array<uint8> GenerateCounterBlock(uint64 iv) {
- scoped_array<uint8> counter_block_data(
- new uint8[DecryptConfig::kDecryptionKeySize]);
-
- // Set the IV.
- memcpy(counter_block_data.get(), &iv, sizeof(iv));
-
- // Set block counter to all 0's.
- memset(counter_block_data.get() + sizeof(iv),
- 0,
- DecryptConfig::kDecryptionKeySize - sizeof(iv));
-
- return counter_block_data.Pass();
- }
-
-
MOCK_METHOD2(FrameReady, void(VideoDecoder::DecoderStatus,
const scoped_refptr<VideoFrame>&));
@@ -409,20 +389,10 @@ TEST_F(FFmpegVideoDecoderTest, DecodeFrame_SmallerHeight) {
DecodeIFrameThenTestFile("vp8-I-frame-320x120", 320, 120);
}
-// TODO(fgalligan): Enable test when encrypted test data is updated and new
-// decryption code is landed. http://crbug.com/132801
-TEST_F(FFmpegVideoDecoderTest, DISABLED_DecodeEncryptedFrame_Normal) {
+TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_Normal) {
Initialize();
// Simulate decoding a single encrypted frame.
- scoped_array<uint8> counter_block(GenerateCounterBlock(kIv));
- encrypted_i_frame_buffer_->SetDecryptConfig(scoped_ptr<DecryptConfig>(
- new DecryptConfig(
- kKeyId, arraysize(kKeyId),
- counter_block.get(), DecryptConfig::kDecryptionKeySize,
- kHmac, arraysize(kHmac),
- sizeof(kIv))));
-
EXPECT_CALL(*decryptor_, Decrypt(encrypted_i_frame_buffer_, _))
.WillRepeatedly(RunDecryptCB(Decryptor::kSuccess, i_frame_buffer_));
@@ -440,14 +410,6 @@ TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_DecryptError) {
Initialize();
// Simulate decoding a single encrypted frame.
- scoped_array<uint8> counter_block(GenerateCounterBlock(kIv));
- encrypted_i_frame_buffer_->SetDecryptConfig(scoped_ptr<DecryptConfig>(
- new DecryptConfig(
- kKeyId, arraysize(kKeyId),
- counter_block.get(), DecryptConfig::kDecryptionKeySize,
- kHmac, arraysize(kHmac),
- sizeof(kIv))));
-
EXPECT_CALL(*demuxer_, Read(_))
.WillRepeatedly(ReturnBuffer(encrypted_i_frame_buffer_));
EXPECT_CALL(*decryptor_, Decrypt(encrypted_i_frame_buffer_, _))
@@ -471,14 +433,6 @@ TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_CorruptedBufferReturned) {
Initialize();
// Simulate decoding a single encrypted frame.
- scoped_array<uint8> counter_block(GenerateCounterBlock(kIv));
- encrypted_i_frame_buffer_->SetDecryptConfig(scoped_ptr<DecryptConfig>(
- new DecryptConfig(
- kKeyId, arraysize(kKeyId),
- counter_block.get(), DecryptConfig::kDecryptionKeySize,
- kHmac, arraysize(kHmac),
- sizeof(kIv))));
-
EXPECT_CALL(*demuxer_, Read(_))
.WillRepeatedly(ReturnBuffer(encrypted_i_frame_buffer_));
EXPECT_CALL(*decryptor_, Decrypt(encrypted_i_frame_buffer_, _))
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698