| 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 15459d3cb4fea2f0f820d6508c16ded0f5499722..a21c3c84a6d63a92302e6f7b43be7c1f3073a01e 100644
|
| --- a/media/filters/ffmpeg_video_decoder_unittest.cc
|
| +++ b/media/filters/ffmpeg_video_decoder_unittest.cc
|
| @@ -37,7 +37,18 @@ 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
|
| +};
|
|
|
| ACTION_P(ReturnBuffer, buffer) {
|
| arg0.Run(buffer ? DemuxerStream::kOk : DemuxerStream::kAborted, buffer);
|
| @@ -65,8 +76,13 @@ 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");
|
| - encrypted_i_frame_buffer_ = ReadTestDataFile(
|
| - "vp8-encrypted-I-frame-320x240");
|
| + {
|
| + 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));
|
| + }
|
|
|
| config_.Initialize(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN,
|
| kVideoFormat, kCodedSize, kVisibleRect,
|
| @@ -195,6 +211,24 @@ 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>&));
|
|
|
| @@ -375,12 +409,19 @@ TEST_F(FFmpegVideoDecoderTest, DecodeFrame_SmallerHeight) {
|
| DecodeIFrameThenTestFile("vp8-I-frame-320x120", 320, 120);
|
| }
|
|
|
| -TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_Normal) {
|
| +// 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) {
|
| 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))));
|
| + 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_));
|
| @@ -399,8 +440,13 @@ 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))));
|
| + 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_));
|
| @@ -425,8 +471,13 @@ 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))));
|
| + 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_));
|
|
|