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

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

Issue 11013052: Add PPAPI CDM video decoder initialization. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add missing IPC handler. 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/cdm_wrapper.cc
diff --git a/webkit/media/crypto/ppapi/cdm_wrapper.cc b/webkit/media/crypto/ppapi/cdm_wrapper.cc
index 679abafc7ecbb2a8751313931f7a4f44002cfb4e..b0a4ef2d3a0864067132e9afedc10d55b0702475 100644
--- a/webkit/media/crypto/ppapi/cdm_wrapper.cc
+++ b/webkit/media/crypto/ppapi/cdm_wrapper.cc
@@ -86,7 +86,7 @@ void ConfigureInputBuffer(
input_buffer->timestamp = encrypted_block_info.tracking_info.timestamp;
}
-PP_DecryptedFrameFormat VideoFormatToPpDecryptedFrameFormat(
+PP_DecryptedFrameFormat CdmVideoFormatToPpDecryptedFrameFormat(
cdm::VideoFormat format) {
switch(format) {
case cdm::kEmptyVideoFrame:
@@ -101,6 +101,43 @@ PP_DecryptedFrameFormat VideoFormatToPpDecryptedFrameFormat(
}
}
+cdm::VideoDecoderConfig::VideoCodec PpVideoCodecToCdmVideoCodec(
+ PP_VideoCodec codec) {
+ switch (codec) {
+ case PP_VIDEOCODEC_VP8:
+ return cdm::VideoDecoderConfig::kCodecVP8;
+ case PP_VIDEOCODEC_UNKNOWN:
+ default:
Ami GONE FROM CHROMIUM 2012/10/09 07:21:12 The need for these default: cases when all enum va
Tom Finegan 2012/10/09 19:49:09 MSVC has the correct type. I don't know why it's r
+ return cdm::VideoDecoderConfig::kUnknownVideoCodec;
+ }
+}
+
+cdm::VideoDecoderConfig::VideoCodecProfile
+ PpVideoCodecProfileToCdmVideoCodecProfile(PP_VideoCodecProfile profile) {
+ switch (profile) {
+ case PP_VIDEOCODECPROFILE_VP8_MAIN:
+ return cdm::VideoDecoderConfig::kVp8ProfileMain;
+ case PP_VIDEOCODECPROFILE_UNKNOWN:
+ default:
+ return cdm::VideoDecoderConfig::kUnknownVideoCodecProfile;
+ }
+}
+
+cdm::VideoFormat PpDecryptedFrameFormatToCdmVideoFormat(
+ PP_DecryptedFrameFormat format) {
+ switch (format) {
+ case PP_DECRYPTEDFRAMEFORMAT_YV12:
+ return cdm::kYv12;
+ case PP_DECRYPTEDFRAMEFORMAT_I420:
+ return cdm::kI420;
+ case PP_DECRYPTEDFRAMEFORMAT_UNKNOWN:
+ return cdm::kUnknownVideoFormat;
+ case PP_DECRYPTEDFRAMEFORMAT_EMPTY:
+ default:
+ return cdm::kEmptyVideoFrame;
+ }
+}
+
} // namespace
namespace webkit_media {
@@ -378,6 +415,9 @@ class CdmWrapper : public pp::Instance,
virtual void Decrypt(
pp::Buffer_Dev encrypted_buffer,
const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE;
+ virtual void InitializeVideoDecoder(
+ const PP_VideoDecoderConfig& decoder_config,
+ pp::Buffer_Dev extra_data_buffer) OVERRIDE;
virtual void DecryptAndDecodeFrame(
pp::Buffer_Dev encrypted_frame,
const PP_EncryptedVideoFrameInfo& encrypted_video_frame_info) OVERRIDE;
@@ -397,6 +437,9 @@ class CdmWrapper : public pp::Instance,
const cdm::Status& status,
const LinkedDecryptedBlock& decrypted_block,
const PP_DecryptTrackingInfo& tracking_info);
+ void DecoderInitialized(int32_t result,
+ bool success,
+ uint32_t request_id);
void DeliverFrame(int32_t result,
const cdm::Status& status,
const LinkedVideoFrame& video_frame,
@@ -530,6 +573,31 @@ void CdmWrapper::Decrypt(pp::Buffer_Dev encrypted_buffer,
encrypted_block_info.tracking_info));
}
+void CdmWrapper::InitializeVideoDecoder(
+ const PP_VideoDecoderConfig& decoder_config,
+ pp::Buffer_Dev extra_data_buffer) {
+ PP_DCHECK(cdm_);
+ cdm::VideoDecoderConfig cdm_decoder_config;
+ cdm_decoder_config.codec = PpVideoCodecToCdmVideoCodec(decoder_config.codec);
+ cdm_decoder_config.profile =
+ PpVideoCodecProfileToCdmVideoCodecProfile(decoder_config.profile);
+ cdm_decoder_config.format =
+ PpDecryptedFrameFormatToCdmVideoFormat(decoder_config.format);
+ cdm_decoder_config.coded_size.width = decoder_config.width;
+ cdm_decoder_config.coded_size.height = decoder_config.height;
+ cdm_decoder_config.extra_data =
+ static_cast<uint8_t*>(extra_data_buffer.data());
+ cdm_decoder_config.extra_data_size =
+ static_cast<int32_t>(extra_data_buffer.size());
+ cdm::Status status = cdm_->InitializeVideoDecoder(cdm_decoder_config);
+
+ CallOnMain(callback_factory_.NewCallback(
+ &CdmWrapper::DecoderInitialized,
+ status == cdm::kSuccess,
+ decoder_config.request_id));
+
+}
+
void CdmWrapper::DecryptAndDecodeFrame(
pp::Buffer_Dev encrypted_frame,
const PP_EncryptedVideoFrameInfo& encrypted_video_frame_info) {
@@ -607,6 +675,12 @@ void CdmWrapper::DeliverBlock(int32_t result,
pp::ContentDecryptor_Private::DeliverBlock(buffer, decrypted_block_info);
}
+void CdmWrapper::DecoderInitialized(int32_t result,
+ bool success,
+ uint32_t request_id) {
+ pp::ContentDecryptor_Private::DecoderInitialized(success, request_id);
+}
+
void CdmWrapper::DeliverFrame(
int32_t result,
const cdm::Status& status,
@@ -622,7 +696,7 @@ void CdmWrapper::DeliverFrame(
PP_DCHECK(video_frame.get() && video_frame->frame_buffer());
decrypted_frame_info.result = PP_DECRYPTRESULT_SUCCESS;
decrypted_frame_info.format =
- VideoFormatToPpDecryptedFrameFormat(video_frame->format());
+ CdmVideoFormatToPpDecryptedFrameFormat(video_frame->format());
decrypted_frame_info.plane_offsets[PP_DECRYPTEDFRAMEPLANES_Y] =
video_frame->plane_offset(cdm::VideoFrame::kYPlane);
decrypted_frame_info.plane_offsets[PP_DECRYPTEDFRAMEPLANES_U] =

Powered by Google App Engine
This is Rietveld 408576698