summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorxhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-23 02:20:56 +0000
committerxhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-23 02:20:56 +0000
commit2b61b68be1db53957ebd4c6890de91f81060c74b (patch)
tree33287cf32fc9ae15be79c32037d1275577c6f363 /media
parent5c61cc960bac8471d3f002e434ac1796b43c129f (diff)
downloadchromium_src-2b61b68be1db53957ebd4c6890de91f81060c74b.zip
chromium_src-2b61b68be1db53957ebd4c6890de91f81060c74b.tar.gz
chromium_src-2b61b68be1db53957ebd4c6890de91f81060c74b.tar.bz2
Add a media pipeline status error code for decryption error.
Also fix a bug in FFmpegVideoDecoderTest.DecodeEncryptedFrame_NoKey test that the frame isn't marked as decrypted. BUG=121177 TEST=media_unittests Review URL: http://codereview.chromium.org/10165010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133397 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/base/media_log.cc2
-rw-r--r--media/base/pipeline_status.h1
-rw-r--r--media/filters/ffmpeg_video_decoder.cc3
-rw-r--r--media/filters/ffmpeg_video_decoder_unittest.cc32
4 files changed, 18 insertions, 20 deletions
diff --git a/media/base/media_log.cc b/media/base/media_log.cc
index 0920fb4..d1ac7de 100644
--- a/media/base/media_log.cc
+++ b/media/base/media_log.cc
@@ -110,6 +110,8 @@ const char* MediaLog::PipelineStatusToString(PipelineStatus status) {
return "pipeline: network error";
case PIPELINE_ERROR_DECODE:
return "pipeline: decode error";
+ case PIPELINE_ERROR_DECRYPT:
+ return "pipeline: decrypt error";
case PIPELINE_ERROR_ABORT:
return "pipeline: abort";
case PIPELINE_ERROR_INITIALIZATION_FAILED:
diff --git a/media/base/pipeline_status.h b/media/base/pipeline_status.h
index f78bc2a..c863fa6 100644
--- a/media/base/pipeline_status.h
+++ b/media/base/pipeline_status.h
@@ -15,6 +15,7 @@ enum PipelineStatus {
PIPELINE_ERROR_URL_NOT_FOUND,
PIPELINE_ERROR_NETWORK,
PIPELINE_ERROR_DECODE,
+ PIPELINE_ERROR_DECRYPT,
PIPELINE_ERROR_ABORT,
PIPELINE_ERROR_INITIALIZATION_FAILED,
PIPELINE_ERROR_REQUIRED_FILTER_MISSING,
diff --git a/media/filters/ffmpeg_video_decoder.cc b/media/filters/ffmpeg_video_decoder.cc
index cd63830..93dfbfb 100644
--- a/media/filters/ffmpeg_video_decoder.cc
+++ b/media/filters/ffmpeg_video_decoder.cc
@@ -286,11 +286,10 @@ void FFmpegVideoDecoder::DoDecodeBuffer(const scoped_refptr<Buffer>& buffer) {
scoped_refptr<Buffer> unencrypted_buffer = buffer;
if (buffer->GetDecryptConfig() && buffer->GetDataSize()) {
unencrypted_buffer = decryptor_.Decrypt(buffer);
- // TODO(xhwang): Add a decryption error code, see http://crbug.com/121177
if (!unencrypted_buffer || !unencrypted_buffer->GetDataSize()) {
state_ = kDecodeFinished;
DeliverFrame(VideoFrame::CreateEmptyFrame());
- host()->SetError(PIPELINE_ERROR_DECODE);
+ host()->SetError(PIPELINE_ERROR_DECRYPT);
return;
}
}
diff --git a/media/filters/ffmpeg_video_decoder_unittest.cc b/media/filters/ffmpeg_video_decoder_unittest.cc
index 9b12699..b111ac3 100644
--- a/media/filters/ffmpeg_video_decoder_unittest.cc
+++ b/media/filters/ffmpeg_video_decoder_unittest.cc
@@ -378,20 +378,17 @@ TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_Normal) {
EXPECT_FALSE(video_frame->IsEndOfStream());
}
-// No key was provided with the encrypted frame. The decoder will mistakenly
-// assume the frame is not encrypted. The behavior should be the same as
-// decoding a corrupted frame.
+// No key is provided to the decryptor and we expect to see a decrypt error.
TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_NoKey) {
Initialize();
+ // Simulate decoding a single encrypted frame.
+ encrypted_i_frame_buffer_->SetDecryptConfig(scoped_ptr<DecryptConfig>(
+ new DecryptConfig(kKeyId, arraysize(kKeyId) - 1)));
+
EXPECT_CALL(*demuxer_, Read(_))
.WillRepeatedly(ReturnBuffer(encrypted_i_frame_buffer_));
-
- // The error is only raised on the second decode attempt, so we expect at
- // least one successful decode but we don't expect FrameReady() to be
- // executed as an error is raised instead.
- EXPECT_CALL(statistics_cb_, OnStatistics(_));
- EXPECT_CALL(host_, SetError(PIPELINE_ERROR_DECODE));
+ EXPECT_CALL(host_, SetError(PIPELINE_ERROR_DECRYPT));
// Our read should still get satisfied with end of stream frame during an
// error.
@@ -409,21 +406,20 @@ TEST_F(FFmpegVideoDecoderTest, DecodeEncryptedFrame_WrongKey) {
decoder_->decryptor()->AddKey(kKeyId, arraysize(kKeyId) - 1,
kWrongKey, arraysize(kWrongKey) - 1);
-#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.
- //
- // TODO(xhwang): Add a decryption error code, see http://crbug.com/121177
- EXPECT_CALL(statistics_cb_, OnStatistics(_));
-#endif
-
encrypted_i_frame_buffer_->SetDecryptConfig(scoped_ptr<DecryptConfig>(
new DecryptConfig(kKeyId, arraysize(kKeyId) - 1)));
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(_));
EXPECT_CALL(host_, SetError(PIPELINE_ERROR_DECODE));
+#else
+ EXPECT_CALL(host_, SetError(PIPELINE_ERROR_DECRYPT));
+#endif
// Our read should still get satisfied with end of stream frame during an
// error.