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

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: Comments addressed with the exceptions being some questions and TODOs. 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
« no previous file with comments | « ppapi/thunk/ppb_instance_api.h ('k') | webkit/plugins/ppapi/ppapi_plugin_instance.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..6324205eb94a50cb436097f81dba70753faa0efc 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:
@@ -96,11 +96,44 @@ PP_DecryptedFrameFormat VideoFormatToPpDecryptedFrameFormat(
case cdm::kI420:
return PP_DECRYPTEDFRAMEFORMAT_I420;
case cdm::kUnknownVideoFormat:
- default:
return PP_DECRYPTEDFRAMEFORMAT_UNKNOWN;
}
}
+cdm::VideoDecoderConfig::VideoCodec PpVideoCodecToCdmVideoCodec(
+ PP_VideoCodec codec) {
+ switch (codec) {
+ case PP_VIDEOCODEC_VP8:
+ return cdm::VideoDecoderConfig::kCodecVP8;
+ case PP_VIDEOCODEC_UNKNOWN:
+ return cdm::VideoDecoderConfig::kUnknownVideoCodec;
+ }
+}
+
+cdm::VideoDecoderConfig::VideoCodecProfile
+ PpVideoCodecProfileToCdmVideoCodecProfile(PP_VideoCodecProfile profile) {
xhwang 2012/10/09 00:49:08 I am not sure about if this indentation is correct
Tom Finegan 2012/10/09 01:12:42 Yeah, me neither... incredibly long function name.
Ami GONE FROM CHROMIUM 2012/10/09 07:21:12 <MatrixEvade> rename method to PpVCProfileToCdmVCP
Tom Finegan 2012/10/09 19:49:08 Done.
+ switch (profile) {
+ case PP_VIDEOCODECPROFILE_VP8_MAIN:
+ return cdm::VideoDecoderConfig::kVp8ProfileMain;
+ case PP_VIDEOCODECPROFILE_UNKNOWN:
+ 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:
+ return cdm::kEmptyVideoFrame;
+ }
+}
+
} // namespace
namespace webkit_media {
@@ -378,6 +411,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 +433,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 +569,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);
xhwang 2012/10/09 00:49:08 This is okay. We can also set the status to kError
Tom Finegan 2012/10/09 01:12:42 My thinking was to allow the CDMs to decide which
xhwang 2012/10/09 15:50:49 ok
+ 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 +671,12 @@ void CdmWrapper::DeliverBlock(int32_t result,
pp::ContentDecryptor_Private::DeliverBlock(buffer, decrypted_block_info);
}
+void CdmWrapper::DecoderInitialized(int32_t result,
+ bool success,
xhwang 2012/10/09 00:49:08 indentation is off
Tom Finegan 2012/10/09 01:12:42 Done.
+ uint32_t request_id) {
+ pp::ContentDecryptor_Private::DecoderInitialized(success, request_id);
+}
+
void CdmWrapper::DeliverFrame(
int32_t result,
const cdm::Status& status,
@@ -622,7 +692,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] =
« no previous file with comments | « ppapi/thunk/ppb_instance_api.h ('k') | webkit/plugins/ppapi/ppapi_plugin_instance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698