Chromium Code Reviews| 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..47308dade453668be2b7d760d73812db7a922eb1 100644 |
| --- a/webkit/media/crypto/ppapi/cdm_wrapper.cc |
| +++ b/webkit/media/crypto/ppapi/cdm_wrapper.cc |
| @@ -378,6 +378,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 +400,9 @@ class CdmWrapper : public pp::Instance, |
| const cdm::Status& status, |
| const LinkedDecryptedBlock& decrypted_block, |
| const PP_DecryptTrackingInfo& tracking_info); |
| + void DecoderInitializeStatus(int32_t result, |
| + bool success, |
| + uint32_t request_id); |
| void DeliverFrame(int32_t result, |
| const cdm::Status& status, |
| const LinkedVideoFrame& video_frame, |
| @@ -530,6 +536,74 @@ void CdmWrapper::Decrypt(pp::Buffer_Dev encrypted_buffer, |
| encrypted_block_info.tracking_info)); |
| } |
| +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/08 18:35:16
why default if you're handling all enum values?
(h
Tom Finegan
2012/10/08 23:23:27
Removed defaults.
Tom Finegan
2012/10/09 04:34:11
Defaults replaced, because MSVC:
d:\src\chromium\s
|
| + PP_DCHECK(false); |
|
xhwang
2012/10/08 17:16:13
We need to make clear assumptions about what codec
Tom Finegan
2012/10/08 23:23:27
I've removed DCHECKs (and moved these up with the
|
| + } |
| + 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: |
| + PP_DCHECK(false); |
|
xhwang
2012/10/08 17:16:13
ditto
Tom Finegan
2012/10/08 23:23:27
Done.
|
| + } |
| + 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: |
| + case PP_DECRYPTEDFRAMEFORMAT_EMPTY: |
| + default: |
| + PP_DCHECK(false); |
|
xhwang
2012/10/08 17:16:13
ditto
Tom Finegan
2012/10/08 23:23:27
Done.
|
| + } |
| + return cdm::kUnknownVideoFormat; |
| +} |
| + |
| +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::DecoderInitializeStatus, |
| + status == cdm::kSuccess, |
| + decoder_config.request_id)); |
| + |
| +} |
| + |
| void CdmWrapper::DecryptAndDecodeFrame( |
| pp::Buffer_Dev encrypted_frame, |
| const PP_EncryptedVideoFrameInfo& encrypted_video_frame_info) { |
| @@ -607,6 +681,12 @@ void CdmWrapper::DeliverBlock(int32_t result, |
| pp::ContentDecryptor_Private::DeliverBlock(buffer, decrypted_block_info); |
| } |
| +void CdmWrapper::DecoderInitializeStatus(int32_t result, |
|
Ami GONE FROM CHROMIUM
2012/10/08 18:35:16
I'm confused about this being "result" and not "in
Tom Finegan
2012/10/08 23:23:27
The pp::CompletionCallback templates all require a
|
| + bool success, |
| + uint32_t request_id) { |
| + pp::ContentDecryptor_Private::DecoderInitializeStatus(success, request_id); |
| +} |
| + |
| void CdmWrapper::DeliverFrame( |
| int32_t result, |
| const cdm::Status& status, |