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

Unified Diff: webkit/plugins/ppapi/ppapi_plugin_instance.cc

Issue 11013052: Add PPAPI CDM video decoder initialization. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Decoder init, first pass. 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/plugins/ppapi/ppapi_plugin_instance.cc
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index e6d0eeeef7bc34e270c52e5f11db130db19aee18..1fcd7d46388743b47196b61de0a15afe11deacb2 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -16,6 +16,8 @@
#include "base/utf_string_conversions.h"
#include "media/base/decoder_buffer.h"
#include "media/base/decryptor_client.h"
+#include "media/base/video_decoder_config.h"
+#include "media/base/video_frame.h"
#include "ppapi/c/dev/ppb_find_dev.h"
#include "ppapi/c/dev/ppb_zoom_dev.h"
#include "ppapi/c/dev/ppp_find_dev.h"
@@ -381,6 +383,67 @@ bool MakeEncryptedBlockInfo(
return true;
}
+PP_VideoCodec MediaVideoCodecToPpVideoCodec(media::VideoCodec codec) {
+ switch (codec) {
+ case media::kCodecVP8:
+ return PP_VIDEOCODEC_VP8;
+
+ case media::kCodecH264:
+ case media::kCodecVC1:
+ case media::kCodecMPEG2:
+ case media::kCodecMPEG4:
+ case media::kCodecTheora:
xhwang 2012/10/08 17:16:13 Why do we need to list them all? Is it because if
Tom Finegan 2012/10/08 23:23:27 Done.
+ default:
+ NOTREACHED();
xhwang 2012/10/08 17:16:13 By having NOTREACHED() here, we are assuming that
Tom Finegan 2012/10/08 23:23:27 Removed the NOTREACHED (here and in other conversi
+ }
+ return PP_VIDEOCODEC_UNKNOWN;
+}
+
+PP_VideoCodecProfile MediaVideoCodecProfileToPpVideoCodecProfile(
+ media::VideoCodecProfile profile) {
+ switch (profile) {
+ case media::VP8PROFILE_MAIN:
+ return PP_VIDEOCODECPROFILE_VP8_MAIN;
+
+ case media::VIDEO_CODEC_PROFILE_UNKNOWN:
+ case media::H264PROFILE_BASELINE:
+ case media::H264PROFILE_MAIN:
+ case media::H264PROFILE_EXTENDED:
+ case media::H264PROFILE_HIGH:
+ case media::H264PROFILE_HIGH10PROFILE:
+ case media::H264PROFILE_HIGH422PROFILE:
+ case media::H264PROFILE_HIGH444PREDICTIVEPROFILE:
+ case media::H264PROFILE_SCALABLEBASELINE:
+ case media::H264PROFILE_SCALABLEHIGH:
+ case media::H264PROFILE_STEREOHIGH:
+ case media::H264PROFILE_MULTIVIEWHIGH:
xhwang 2012/10/08 17:16:13 ditto
Tom Finegan 2012/10/08 23:23:27 Done.
+ default:
+ NOTREACHED();
+ }
+ return PP_VIDEOCODECPROFILE_UNKNOWN;
+}
+
+PP_DecryptedFrameFormat MediaVideoFormatToPpDecryptedFrameFormat(
+ media::VideoFrame::Format format) {
+ switch (format) {
+ case media::VideoFrame::YV12:
+ return PP_DECRYPTEDFRAMEFORMAT_YV12;
+
+ case media::VideoFrame::I420:
+ return PP_DECRYPTEDFRAMEFORMAT_I420;
+
+ case media::VideoFrame::INVALID:
+ case media::VideoFrame::RGB32:
+ case media::VideoFrame::YV16:
+ case media::VideoFrame::EMPTY:
+ case media::VideoFrame::NATIVE_TEXTURE:
xhwang 2012/10/08 17:16:13 ditto
Tom Finegan 2012/10/08 23:23:27 Done.
xhwang 2012/10/09 00:49:08 This is not done?
Tom Finegan 2012/10/09 01:12:42 Sorry. Missed it, done now.
+ default:
+ NOTREACHED();
+ }
+ return PP_DECRYPTEDFRAMEFORMAT_UNKNOWN;
+}
+
+
} // namespace
// static
@@ -1546,7 +1609,36 @@ bool PluginInstance::Decrypt(
return true;
}
-// Note: this method can be used with an unencrypted frame.
+bool PluginInstance::InitializeVideoDecoder(
+ const media::VideoDecoderConfig& decoder_config,
+ const media::Decryptor::DecryptCB& decrypt_cb) {
+ PP_VideoDecoderConfig pp_decoder_config;
+ pp_decoder_config.codec =
+ MediaVideoCodecToPpVideoCodec(decoder_config.codec());
xhwang 2012/10/08 17:16:13 So here if the codec is invalid (unknown), we are
Tom Finegan 2012/10/08 23:23:27 Done.
+ pp_decoder_config.profile =
+ MediaVideoCodecProfileToPpVideoCodecProfile(decoder_config.profile());
+ pp_decoder_config.format =
+ MediaVideoFormatToPpDecryptedFrameFormat(decoder_config.format());
+ pp_decoder_config.width = decoder_config.coded_size().width();
+ pp_decoder_config.height = decoder_config.coded_size().height();
+ pp_decoder_config.request_id = next_decryption_request_id_++;
+
+ DCHECK(!ContainsKey(pending_decryption_cbs_, pp_decoder_config.request_id));
xhwang 2012/10/08 17:16:13 We'll have at most two pending decoder initializat
Tom Finegan 2012/10/08 23:23:27 Added TODO(xhwang).
xhwang 2012/10/09 00:49:08 Thanks!
+ pending_decryption_cbs_.insert(std::make_pair(pp_decoder_config.request_id,
+ decrypt_cb));
+
+ ScopedPPResource extra_data_resource(
+ ScopedPPResource::PassRef(),
+ MakeBufferResource(pp_instance(),
+ decoder_config.extra_data(),
+ decoder_config.extra_data_size()));
+
+ plugin_decryption_interface_->InitializeVideoDecoder(pp_instance(),
+ &pp_decoder_config,
+ extra_data_resource);
+ return false;
xhwang 2012/10/08 17:16:13 always return false?
Tom Finegan 2012/10/08 23:23:27 Oops! Done.
+}
+
bool PluginInstance::DecryptAndDecodeFrame(
const scoped_refptr<media::DecoderBuffer>& encrypted_frame,
const media::Decryptor::DecryptCB& decrypt_cb) {
@@ -2279,6 +2371,21 @@ void PluginInstance::KeyError(PP_Instance instance,
system_code);
}
+void PluginInstance::DecoderInitializeStatus(PP_Instance instance,
+ PP_Bool success,
+ uint32_t request_id) {
+ DecryptionCBMap::iterator found = pending_decryption_cbs_.find(request_id);
xhwang 2012/10/08 17:16:13 ditto, we'll not use map here and use individual v
Tom Finegan 2012/10/08 23:23:27 Added TODO(xhwang).
+ if (found == pending_decryption_cbs_.end())
+ return;
+ media::Decryptor::DecryptCB decrypt_cb = found->second;
+ pending_decryption_cbs_.erase(found);
+
+ media::Decryptor::Status status =
+ success == PP_TRUE ? media::Decryptor::kSuccess :
+ media::Decryptor::kError;
+ decrypt_cb.Run(status, NULL);
+}
+
void PluginInstance::DeliverBlock(PP_Instance instance,
PP_Resource decrypted_block,
const PP_DecryptedBlockInfo* block_info) {
« webkit/plugins/ppapi/ppapi_plugin_instance.h ('K') | « webkit/plugins/ppapi/ppapi_plugin_instance.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698