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..27f4277a520b1d2fd4083e1ac0509f0f5af790c0 100644 |
--- a/webkit/media/crypto/ppapi/clear_key_cdm.cc |
+++ b/webkit/media/crypto/ppapi/clear_key_cdm.cc |
@@ -355,21 +355,13 @@ 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_->Initialize(video_decoder_config)) |
- return cdm::kSessionError; |
+ if (!video_decoder_) { |
+ 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) { |
@@ -395,23 +387,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 +416,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 +540,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 |