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 2180c342ac099e12bc0fc6134dcf82196e34f894..fee6b9efaf538614a9d27de253c7f8115781faa7 100644 |
--- a/webkit/media/crypto/ppapi/cdm_wrapper.cc |
+++ b/webkit/media/crypto/ppapi/cdm_wrapper.cc |
@@ -476,6 +476,10 @@ class CdmWrapper : public pp::Instance, |
const cdm::Status& status, |
const LinkedVideoFrame& video_frame, |
const PP_DecryptTrackingInfo& tracking_info); |
+ void DeliverSamples(int32_t result, |
+ const cdm::Status& status, |
+ const LinkedDecryptedBlock& audio_frames, |
ddorwin
2012/10/22 17:47:11
Type should be Samples/AudioFrames?
It sounds like
xhwang
2012/10/23 01:53:12
Added AudioFrame class. But we need a ppapi change
|
+ const PP_DecryptTrackingInfo& tracking_info); |
// Helper for SetTimer(). |
void TimerExpired(int32 result); |
@@ -678,8 +682,6 @@ void CdmWrapper::DecryptAndDecode( |
PP_DecryptorStreamType decoder_type, |
pp::Buffer_Dev encrypted_buffer, |
const PP_EncryptedBlockInfo& encrypted_block_info) { |
- // TODO(tomfinegan): Remove this check when audio decoding is added. |
- PP_DCHECK(decoder_type == PP_DECRYPTORSTREAMTYPE_VIDEO); |
PP_DCHECK(cdm_); |
cdm::InputBuffer input_buffer; |
@@ -691,14 +693,25 @@ void CdmWrapper::DecryptAndDecode( |
&input_buffer); |
} |
- LinkedVideoFrame video_frame(new VideoFrameImpl()); |
- cdm::Status status = cdm_->DecryptAndDecodeFrame(input_buffer, |
- video_frame.get()); |
- CallOnMain(callback_factory_.NewCallback( |
- &CdmWrapper::DeliverFrame, |
- status, |
- video_frame, |
- encrypted_block_info.tracking_info)); |
+ if (decoder_type == PP_DECRYPTORSTREAMTYPE_AUDIO) { |
ddorwin
2012/10/22 17:47:11
We should check for an invalid value somewhere. I
xhwang
2012/10/23 01:53:12
Done.
|
+ LinkedDecryptedBlock audio_frames(new DecryptedBlockImpl()); |
+ cdm::Status status = cdm_->DecryptAndDecodeSamples(input_buffer, |
+ audio_frames.get()); |
+ CallOnMain(callback_factory_.NewCallback( |
+ &CdmWrapper::DeliverSamples, |
+ status, |
+ audio_frames, |
+ encrypted_block_info.tracking_info)); |
+ } else { // decoder_type == PP_DECRYPTORSTREAMTYPE_VIDEO |
+ LinkedVideoFrame video_frame(new VideoFrameImpl()); |
+ cdm::Status status = cdm_->DecryptAndDecodeFrame(input_buffer, |
+ video_frame.get()); |
+ CallOnMain(callback_factory_.NewCallback( |
+ &CdmWrapper::DeliverFrame, |
+ status, |
+ video_frame, |
+ encrypted_block_info.tracking_info)); |
+ } |
} |
void CdmWrapper::SetTimer(int64 delay_ms) { |
@@ -875,6 +888,42 @@ void CdmWrapper::DeliverFrame( |
pp::ContentDecryptor_Private::DeliverFrame(buffer, decrypted_frame_info); |
} |
+void CdmWrapper::DeliverSamples(int32_t result, |
+ const cdm::Status& status, |
+ const LinkedDecryptedBlock& audio_frames, |
+ const PP_DecryptTrackingInfo& tracking_info) { |
+ PP_DCHECK(result == PP_OK); |
+ PP_DecryptedBlockInfo decrypted_block_info; |
+ decrypted_block_info.tracking_info = tracking_info; |
+ decrypted_block_info.tracking_info.timestamp = audio_frames->timestamp(); |
ddorwin
2012/10/22 17:47:11
What is this timestamp? Do we need it? We should p
xhwang
2012/10/23 01:53:12
Done.
|
+ |
+ switch (status) { |
+ case cdm::kSuccess: |
+ decrypted_block_info.result = PP_DECRYPTRESULT_SUCCESS; |
+ PP_DCHECK(audio_frames.get() && audio_frames->buffer()); |
+ break; |
+ case cdm::kNeedMoreData: |
+ decrypted_block_info.result = PP_DECRYPTRESULT_SUCCESS; |
+ break; |
+ case cdm::kNoKey: |
+ decrypted_block_info.result = PP_DECRYPTRESULT_DECRYPT_NOKEY; |
+ break; |
+ case cdm::kDecryptError: |
+ decrypted_block_info.result = PP_DECRYPTRESULT_DECRYPT_ERROR; |
+ break; |
+ default: |
+ PP_DCHECK(false); |
+ decrypted_block_info.result = PP_DECRYPTRESULT_DECRYPT_ERROR; |
+ } |
+ |
+ const pp::Buffer_Dev& buffer = |
+ audio_frames.get() && audio_frames->buffer() ? |
+ static_cast<PpbBuffer*>(audio_frames->buffer())->buffer_dev() : |
+ pp::Buffer_Dev(); |
+ |
+ pp::ContentDecryptor_Private::DeliverSamples(buffer, decrypted_block_info); |
+} |
+ |
// This object is the global object representing this plugin library as long |
// as it is loaded. |