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

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: Rebase, fix incorrect DCHECK and fix include order. 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
« no previous file with comments | « webkit/media/crypto/ppapi/clear_key_cdm.h ('k') | webkit/media/crypto/ppapi/fake_cdm_video_decoder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 fdc757e3a4ce3bedc0be6d982328b8a2b758803c..2f0453aa8556105d0f4af5b7fbf7869d6f0f0193 100644
--- a/webkit/media/crypto/ppapi/clear_key_cdm.cc
+++ b/webkit/media/crypto/ppapi/clear_key_cdm.cc
@@ -359,21 +359,17 @@ 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()) {
+ DCHECK(!video_decoder_->is_initialized());
+ return cdm::kSessionError;
+ }
- if (!video_decoder_->Initialize(video_decoder_config))
+ // Any uninitialized decoder will be replaced.
+ video_decoder_ = CreateVideoDecoder(allocator_, video_decoder_config);
+ 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) {
@@ -399,23 +395,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(
@@ -430,25 +424,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(
@@ -567,46 +548,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
« no previous file with comments | « webkit/media/crypto/ppapi/clear_key_cdm.h ('k') | webkit/media/crypto/ppapi/fake_cdm_video_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698