| 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 6367ab248b73b4ac3aec8dd2750809f2a2c806b3..fc13994b04cc20c0b401090a146b560d30c3485d 100644
|
| --- a/media/filters/ffmpeg_video_decoder_unittest.cc
|
| +++ b/media/filters/ffmpeg_video_decoder_unittest.cc
|
| @@ -16,6 +16,7 @@
|
| #include "media/base/test_data_util.h"
|
| #include "media/base/video_decoder.h"
|
| #include "media/base/video_frame.h"
|
| +#include "media/crypto/aes_decryptor.h"
|
| #include "media/ffmpeg/ffmpeg_common.h"
|
| #include "media/filters/ffmpeg_decoder_unittest.h"
|
| #include "media/filters/ffmpeg_glue.h"
|
| @@ -37,9 +38,14 @@ static const gfx::Rect kVisibleRect(320, 240);
|
| static const gfx::Size kNaturalSize(522, 288);
|
| static const AVRational kFrameRate = { 100, 1 };
|
| static const AVRational kAspectRatio = { 1, 1 };
|
| -static const unsigned char kRawKey[] = "A wonderful key!";
|
| +static const unsigned char kRawKey[] =
|
| + "\x5b\x4e\xe8\xb6\xd0\x7e\x4e\x58\xea\x24\x4c\x40\x13\xfd\xb5\x2d";
|
| static const unsigned char kWrongKey[] = "I'm a wrong key.";
|
| static const unsigned char kKeyId[] = "A normal key ID.";
|
| +static const uint64 kIv = 0;
|
| +static const int kHmacSize = 12;
|
| +static const unsigned char kHmac[] =
|
| + "\xeb\x1c\xa5\x2e\x51\x27\xd0\x83\xa2\xad\x38\x80";
|
|
|
| ACTION_P(ReturnBuffer, buffer) {
|
| arg0.Run(buffer);
|
| @@ -48,7 +54,7 @@ ACTION_P(ReturnBuffer, buffer) {
|
| class FFmpegVideoDecoderTest : public testing::Test {
|
| public:
|
| FFmpegVideoDecoderTest()
|
| - : decryptor_(new AesDecryptor()),
|
| + : decryptor_(new HmacAesDecryptor()),
|
| decoder_(new FFmpegVideoDecoder(base::Bind(&Identity<MessageLoop*>,
|
| &message_loop_))),
|
| demuxer_(new StrictMock<MockDemuxerStream>()),
|
| @@ -197,7 +203,7 @@ class FFmpegVideoDecoderTest : public testing::Test {
|
| scoped_refptr<VideoFrame>));
|
|
|
| MessageLoop message_loop_;
|
| - scoped_ptr<AesDecryptor> decryptor_;
|
| + scoped_ptr<HmacAesDecryptor> decryptor_;
|
| scoped_refptr<FFmpegVideoDecoder> decoder_;
|
| scoped_refptr<StrictMock<MockDemuxerStream> > demuxer_;
|
| MockStatisticsCB statistics_cb_;
|
| @@ -380,7 +386,11 @@ TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_Normal) {
|
|
|
| // Simulate decoding a single encrypted frame.
|
| encrypted_i_frame_buffer_->SetDecryptConfig(scoped_ptr<DecryptConfig>(
|
| - new DecryptConfig(kKeyId, arraysize(kKeyId) - 1)));
|
| + new DecryptConfig(kHmac, kHmacSize,
|
| + reinterpret_cast<const uint8*>(&kIv), sizeof(kIv),
|
| + kKeyId, arraysize(kKeyId) - 1,
|
| + sizeof(kIv))));
|
| +
|
| VideoDecoder::DecoderStatus status;
|
| scoped_refptr<VideoFrame> video_frame;
|
| DecodeSingleFrame(encrypted_i_frame_buffer_, &status, &video_frame);
|
| @@ -396,7 +406,10 @@ TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_NoKey) {
|
|
|
| // Simulate decoding a single encrypted frame.
|
| encrypted_i_frame_buffer_->SetDecryptConfig(scoped_ptr<DecryptConfig>(
|
| - new DecryptConfig(kKeyId, arraysize(kKeyId) - 1)));
|
| + new DecryptConfig(kHmac, kHmacSize,
|
| + reinterpret_cast<const uint8*>(&kIv), sizeof(kIv),
|
| + kKeyId, arraysize(kKeyId) - 1,
|
| + sizeof(kIv))));
|
|
|
| EXPECT_CALL(*demuxer_, Read(_))
|
| .WillRepeatedly(ReturnBuffer(encrypted_i_frame_buffer_));
|
| @@ -419,27 +432,19 @@ TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_WrongKey) {
|
| kWrongKey, arraysize(kWrongKey) - 1);
|
|
|
| encrypted_i_frame_buffer_->SetDecryptConfig(scoped_ptr<DecryptConfig>(
|
| - new DecryptConfig(kKeyId, arraysize(kKeyId) - 1)));
|
| + new DecryptConfig(kHmac, kHmacSize,
|
| + reinterpret_cast<const uint8*>(&kIv), sizeof(kIv),
|
| + kKeyId, arraysize(kKeyId) - 1,
|
| + sizeof(kIv))));
|
| EXPECT_CALL(*demuxer_, Read(_))
|
| .WillRepeatedly(ReturnBuffer(encrypted_i_frame_buffer_));
|
|
|
| -#if defined(OS_LINUX)
|
| - // Using the wrong key on linux doesn't cause an decryption error but actually
|
| - // attempts to decode the content, however we're unable to distinguish between
|
| - // the two (see http://crbug.com/124434).
|
| - EXPECT_CALL(statistics_cb_, OnStatistics(_));
|
| -#endif
|
| -
|
| // Our read should still get satisfied with end of stream frame during an
|
| // error.
|
| VideoDecoder::DecoderStatus status;
|
| scoped_refptr<VideoFrame> video_frame;
|
| Read(&status, &video_frame);
|
| -#if defined(OS_LINUX)
|
| - EXPECT_EQ(VideoDecoder::kDecodeError, status);
|
| -#else
|
| EXPECT_EQ(VideoDecoder::kDecryptError, status);
|
| -#endif
|
| EXPECT_FALSE(video_frame);
|
|
|
| message_loop_.RunAllPending();
|
|
|