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

Unified Diff: media/filters/ffmpeg_video_decoder_unittest.cc

Issue 10535029: Add support for encrypted WebM files as defined in the RFC. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase to master Created 8 years, 6 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
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 a9468879b6f36e4f210d2a24eea3e7f0fb0690e3..640a1b95502b2d28ff3d376379e85ff3c6032035 100644
--- a/media/filters/ffmpeg_video_decoder_unittest.cc
+++ b/media/filters/ffmpeg_video_decoder_unittest.cc
@@ -43,17 +43,23 @@ 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 char kClearKeySystem[] = "org.w3.clearkey";
static const uint8 kInitData[] = { 0x69, 0x6e, 0x69, 0x74 };
-static const uint8 kRightKey[] = {
- 0x41, 0x20, 0x77, 0x6f, 0x6e, 0x64, 0x65, 0x72,
- 0x66, 0x75, 0x6c, 0x20, 0x6b, 0x65, 0x79, 0x21
-};
static const uint8 kWrongKey[] = {
0x49, 0x27, 0x6d, 0x20, 0x61, 0x20, 0x77, 0x72,
0x6f, 0x6e, 0x67, 0x20, 0x6b, 0x65, 0x79, 0x2e
};
static const uint8 kKeyId[] = { 0x4b, 0x65, 0x79, 0x20, 0x49, 0x44 };
+static const uint8 kRawKey[] = {
ddorwin 2012/07/11 01:00:27 kSecret or kSecretKey seems more general. Would ne
fgalligan1 2012/07/11 22:06:33 Done.
+ 0x5b, 0x4e, 0xe8, 0xb6, 0xd0, 0x7e, 0x4e, 0x58, 0xea, 0x24, 0x4c, 0x40,
+ 0x13, 0xfd, 0xb5, 0x2d
+};
+static const uint64 kIv = 0;
ddorwin 2012/07/11 01:00:27 Suggest choosing a more interesting value. 0 seems
fgalligan1 2012/07/11 22:06:33 Done.
+static const int kHmacSize = 12;
ddorwin 2012/07/11 01:00:27 suggest swapping with next. Better yet, maybe use
fgalligan1 2012/07/11 22:06:33 Done.
+static const uint8 kHmac[] = {
+ 0xeb, 0x1c, 0xa5, 0x2e, 0x51, 0x27, 0xd0, 0x83, 0xa2, 0xad, 0x38, 0x80
+};
ACTION_P(ReturnBuffer, buffer) {
arg0.Run(buffer);
@@ -77,8 +83,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() + kHmacSize,
+ temp_buffer->GetDataSize() - kHmacSize);
+ }
config_.Initialize(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN,
kVideoFormat, kCodedSize, kVisibleRect,
@@ -388,7 +399,9 @@ 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();
std::string sessing_id_string;
EXPECT_CALL(decryptor_client_,
@@ -398,12 +411,15 @@ TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_Normal) {
decryptor_->GenerateKeyRequest(kClearKeySystem,
kInitData, arraysize(kInitData));
EXPECT_CALL(decryptor_client_, KeyAdded(kClearKeySystem, sessing_id_string));
- decryptor_->AddKey(kClearKeySystem, kRightKey, arraysize(kRightKey),
+ decryptor_->AddKey(kClearKeySystem, kRawKey, arraysize(kRawKey),
kKeyId, arraysize(kKeyId), sessing_id_string);
// Simulate decoding a single encrypted frame.
encrypted_i_frame_buffer_->SetDecryptConfig(scoped_ptr<DecryptConfig>(
- new DecryptConfig(kKeyId, arraysize(kKeyId))));
+ new DecryptConfig(kHmac, kHmacSize,
+ reinterpret_cast<const uint8*>(&kIv), sizeof(kIv),
+ kKeyId, arraysize(kKeyId),
+ sizeof(kIv))));
VideoDecoder::DecoderStatus status;
scoped_refptr<VideoFrame> video_frame;
DecodeSingleFrame(encrypted_i_frame_buffer_, &status, &video_frame);
@@ -419,7 +435,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))));
+ new DecryptConfig(kHmac, kHmacSize,
+ reinterpret_cast<const uint8*>(&kIv), sizeof(kIv),
+ kKeyId, arraysize(kKeyId),
+ sizeof(kIv))));
EXPECT_CALL(*demuxer_, Read(_))
.WillRepeatedly(ReturnBuffer(encrypted_i_frame_buffer_));
@@ -443,27 +462,19 @@ TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_WrongKey) {
kKeyId, arraysize(kKeyId), "");
encrypted_i_frame_buffer_->SetDecryptConfig(scoped_ptr<DecryptConfig>(
- new DecryptConfig(kKeyId, arraysize(kKeyId))));
+ new DecryptConfig(kHmac, kHmacSize,
+ reinterpret_cast<const uint8*>(&kIv), sizeof(kIv),
+ kKeyId, arraysize(kKeyId),
+ sizeof(kIv))));
EXPECT_CALL(*demuxer_, Read(_))
.WillRepeatedly(ReturnBuffer(encrypted_i_frame_buffer_));
- // Using the wrong key on some platforms 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).
-#if defined(USE_NSS) || defined(OS_WIN) || defined(OS_MACOSX)
- 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(USE_NSS) || defined(OS_WIN) || defined(OS_MACOSX)
- EXPECT_EQ(VideoDecoder::kDecodeError, status);
-#else
EXPECT_EQ(VideoDecoder::kDecryptError, status);
-#endif
EXPECT_FALSE(video_frame);
message_loop_.RunAllPending();

Powered by Google App Engine
This is Rietveld 408576698