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

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

Issue 11316045: Add a libvpx video decoder to ClearKeyCdm and move the fake video decoder to its own class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 8 years 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 3c3ce77e7f2072e89455e5b3eb839dc769a54046..d96db4c0610d6f9dc7e8cbe225276f482e669f2b 100644
--- a/webkit/media/crypto/ppapi/clear_key_cdm.cc
+++ b/webkit/media/crypto/ppapi/clear_key_cdm.cc
@@ -355,21 +355,14 @@ cdm::Status ClearKeyCdm::InitializeAudioDecoder(
cdm::Status ClearKeyCdm::InitializeVideoDecoder(
const cdm::VideoDecoderConfig& video_decoder_config) {
-#if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER)
- if (!video_decoder_)
- video_decoder_.reset(new webkit_media::FFmpegCdmVideoDecoder(allocator_));
+ if (video_decoder_ && video_decoder_->is_initialized())
ddorwin 2012/12/04 22:38:15 I'm not familiar with this logic. xhwang, is this
xhwang 2012/12/04 23:07:46 Hmm, shouldn't we DCHECK(!video_decoder_->is_initi
Tom Finegan 2012/12/04 23:17:39 Done.
+ return cdm::kSessionError;
- if (!video_decoder_->Initialize(video_decoder_config))
+ video_decoder_ = CreateVideoDecoder(allocator_, video_decoder_config);
ddorwin 2012/12/04 22:38:15 // Any uninitialized decoder will be replaced.
Tom Finegan 2012/12/04 23:17:39 Done.
+ if (!video_decoder_)
return cdm::kSessionError;
return cdm::kSuccess;
-#elif defined(CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER)
- video_size_ = video_decoder_config.coded_size;
- return cdm::kSuccess;
-#else
- NOTIMPLEMENTED();
- return cdm::kSessionError;
-#endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER
}
void ClearKeyCdm::ResetDecoder(cdm::StreamType decoder_type) {
@@ -395,23 +388,21 @@ void ClearKeyCdm::ResetDecoder(cdm::StreamType decoder_type) {
void ClearKeyCdm::DeinitializeDecoder(cdm::StreamType decoder_type) {
DVLOG(1) << "DeinitializeDecoder()";
-#if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER)
switch (decoder_type) {
case cdm::kStreamTypeVideo:
video_decoder_->Deinitialize();
break;
case cdm::kStreamTypeAudio:
+#if !defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER)
audio_decoder_->Deinitialize();
+#else
+ output_timestamp_base_in_microseconds_ = kNoTimestamp;
+ total_samples_generated_ = 0;
+#endif
break;
default:
NOTREACHED() << "DeinitializeDecoder(): invalid cdm::StreamType";
}
-#elif defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER)
- if (decoder_type == cdm::kStreamTypeAudio) {
- output_timestamp_base_in_microseconds_ = kNoTimestamp;
- total_samples_generated_ = 0;
- }
-#endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER
}
cdm::Status ClearKeyCdm::DecryptAndDecodeFrame(
@@ -426,25 +417,12 @@ cdm::Status ClearKeyCdm::DecryptAndDecodeFrame(
if (status != cdm::kSuccess)
return status;
-#if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER)
DCHECK(status == cdm::kSuccess);
DCHECK(buffer);
return video_decoder_->DecodeFrame(buffer.get()->GetData(),
buffer->GetDataSize(),
encrypted_buffer.timestamp,
decoded_frame);
-#elif defined(CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER)
- // The fake decoder does not buffer any frames internally. So if the input is
- // empty (EOS), just return kNeedMoreData.
- if (buffer->IsEndOfStream())
- return cdm::kNeedMoreData;
-
- GenerateFakeVideoFrame(buffer->GetTimestamp(), decoded_frame);
- return cdm::kSuccess;
-#else
- NOTIMPLEMENTED();
- return cdm::kDecodeError;
-#endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER
}
cdm::Status ClearKeyCdm::DecryptAndDecodeSamples(
@@ -563,46 +541,4 @@ cdm::Status ClearKeyCdm::GenerateFakeAudioFrames(
}
#endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER
-#if defined(CLEAR_KEY_CDM_USE_FAKE_VIDEO_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;
- DCHECK_EQ(width % 2, 0);
- DCHECK_EQ(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 y_offset = 0;
- 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_);
- video_frame->set_frame_buffer(allocator_->Allocate(frame_size));
- video_frame->set_plane_offset(cdm::VideoFrame::kYPlane, y_offset);
- video_frame->set_plane_offset(cdm::VideoFrame::kVPlane, v_offset);
- video_frame->set_plane_offset(cdm::VideoFrame::kUPlane, u_offset);
- video_frame->set_stride(cdm::VideoFrame::kYPlane, y_stride);
- video_frame->set_stride(cdm::VideoFrame::kVPlane, uv_stride);
- video_frame->set_stride(cdm::VideoFrame::kUPlane, uv_stride);
- video_frame->set_timestamp(timestamp.InMicroseconds());
-
- static unsigned char color = 0;
- color += 10;
-
- memset(reinterpret_cast<void*>(video_frame->frame_buffer()->data()),
- color, frame_size);
-}
-#endif // CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER
-
} // namespace webkit_media

Powered by Google App Engine
This is Rietveld 408576698