diff options
-rw-r--r-- | media/base/media_log.cc | 2 | ||||
-rw-r--r-- | media/base/pipeline_status.h | 1 | ||||
-rw-r--r-- | media/filters/ffmpeg_video_decoder.cc | 3 | ||||
-rw-r--r-- | media/filters/ffmpeg_video_decoder_unittest.cc | 32 | ||||
-rw-r--r-- | webkit/media/webmediaplayer_impl.cc | 7 |
5 files changed, 25 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. diff --git a/webkit/media/webmediaplayer_impl.cc b/webkit/media/webmediaplayer_impl.cc index a604f3a7..1c236fb8 100644 --- a/webkit/media/webmediaplayer_impl.cc +++ b/webkit/media/webmediaplayer_impl.cc @@ -886,6 +886,13 @@ void WebMediaPlayerImpl::OnPipelineError(PipelineStatus error) { // Decode error. SetNetworkState(WebMediaPlayer::NetworkStateDecodeError); break; + + case media::PIPELINE_ERROR_DECRYPT: + // Decrypt error. + // TODO(xhwang): Change to use NetworkStateDecryptError once it's added in + // Webkit (see http://crbug.com/124486). + SetNetworkState(WebMediaPlayer::NetworkStateDecodeError); + break; } // Repaint to trigger UI update. |