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

Unified Diff: webkit/media/crypto/ppapi/clear_key_cdm.cc

Issue 11147032: Fake video decoder in clearkey CDM. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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: webkit/media/crypto/ppapi/clear_key_cdm.cc
diff --git a/webkit/media/crypto/ppapi/clear_key_cdm.cc b/webkit/media/crypto/ppapi/clear_key_cdm.cc
index 406a93497b4e40edafd9e934a55bef622ce22a13..6e6c96c476071d7da1185f7bf770b1fbb7a54eaf 100644
--- a/webkit/media/crypto/ppapi/clear_key_cdm.cc
+++ b/webkit/media/crypto/ppapi/clear_key_cdm.cc
@@ -236,8 +236,13 @@ cdm::Status ClearKeyCdm::Decrypt(
cdm::Status ClearKeyCdm::InitializeVideoDecoder(
const cdm::VideoDecoderConfig& video_decoder_config) {
+#if !defined(CLEAR_KEY_CDM_USE_FAKE_DECODER)
+ NOTIMPLEMENTED();
+ return cdm::kSessionError;
+#else
video_size_ = video_decoder_config.coded_size;
return cdm::kSuccess;
+#endif
}
void ClearKeyCdm::ResetDecoder(cdm::StreamType) {
@@ -271,25 +276,37 @@ cdm::Status ClearKeyCdm::DecryptAndDecodeFrame(
if (status == media::Decryptor::kNoKey)
return cdm::kNoKey;
+#if !defined(CLEAR_KEY_CDM_USE_FAKE_DECODER)
+ NOTIMPLEMENTED();
+ return cdm::kDecodeError;
+#else
GenerateFakeVideoFrame(decoder_buffer->GetTimestamp(), video_frame);
return cdm::kSuccess;
+#endif
}
+#if defined(CLEAR_KEY_CDM_USE_FAKE_DECODER)
void ClearKeyCdm::GenerateFakeVideoFrame(base::TimeDelta timestamp,
cdm::VideoFrame* video_frame) {
+ // Choose non-zero alignment and padding on purpose for testing.
+ const int kAlignment = 8;
+ const int kPadding = 16;
+ const int kPlanePadding = 128;
+
int width = video_size_.width;
int height = video_size_.height;
- int alignment = 8;
- int padding = 16;
- int y_stride = (width + alignment - 1) / alignment * alignment + padding;
- int uv_stride = (width / 2 + alignment - 1) / alignment * alignment + padding;
+ DCHECK(width % 2 == 0);
+ DCHECK(height % 2 == 0);
+
+ int y_stride = (width + kAlignment - 1) / kAlignment * kAlignment + kPadding;
+ int uv_stride =
+ (width / 2 + kAlignment - 1) / kAlignment * kAlignment + kPadding;
int y_rows = height;
int uv_rows = height / 2;
- int plane_padding = 128;
int y_offset = 0;
- int v_offset = y_stride * y_rows + plane_padding;
- int u_offset = v_offset + uv_stride * uv_rows + plane_padding;
- int frame_size = u_offset + uv_stride * uv_rows + plane_padding;
+ int v_offset = y_stride * y_rows + kPlanePadding;
+ int u_offset = v_offset + uv_stride * uv_rows + kPlanePadding;
+ int frame_size = u_offset + uv_stride * uv_rows + kPlanePadding;
video_frame->set_format(cdm::kYv12);
video_frame->set_size(video_size_);
@@ -308,5 +325,6 @@ void ClearKeyCdm::GenerateFakeVideoFrame(base::TimeDelta timestamp,
memset(reinterpret_cast<void*>(video_frame->frame_buffer()->data()),
color, frame_size);
}
+#endif // CLEAR_KEY_CDM_USE_FAKE_DECODER
} // namespace webkit_media
« webkit/media/crypto/ppapi/clear_key_cdm.h ('K') | « webkit/media/crypto/ppapi/clear_key_cdm.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698