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

Unified Diff: ppapi/cpp/video_decoder.cc

Issue 703753002: Pepper: Expose visible_rect to PPB_VideoDecoder.GetPicture. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments. Created 6 years, 1 month 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: ppapi/cpp/video_decoder.cc
diff --git a/ppapi/cpp/video_decoder.cc b/ppapi/cpp/video_decoder.cc
index 85654c1edefe18157e9faf7cb7c521b2eb477086..8312417c6ea39eaec4b4547eddfd707e1bfe9d13 100644
--- a/ppapi/cpp/video_decoder.cc
+++ b/ppapi/cpp/video_decoder.cc
@@ -25,6 +25,40 @@ const char* interface_name<PPB_VideoDecoder_0_2>() {
return PPB_VIDEODECODER_INTERFACE_0_2;
}
+template <>
+const char* interface_name<PPB_VideoDecoder_1_0>() {
+ return PPB_VIDEODECODER_INTERFACE_1_0;
+}
+
+struct CallbackData_0_1 {
dmichael (off chromium) 2014/11/05 23:06:04 An overarching comment about the strategy here mig
bbudge 2014/11/06 00:26:36 Done.
+ CallbackData_0_1(const CompletionCallbackWithOutput<PP_VideoPicture>& cc)
dmichael (off chromium) 2014/11/05 23:06:04 super nitty nit: explicit
bbudge 2014/11/06 00:26:36 Done.
+ : original_picture(cc.output()),
dmichael (off chromium) 2014/11/05 23:06:04 nit: May be good to also add: picture(), ...to get
bbudge 2014/11/06 00:26:36 It's a micro-optimization. It is an 'out' paramete
+ original_callback(cc.pp_completion_callback()) {}
+ PP_VideoPicture_0_1 picture;
+ PP_VideoPicture* original_picture;
+ PP_CompletionCallback original_callback;
+};
+
+// static
+void CallbackConverter(void* user_data, int32_t result) {
+ CallbackData_0_1* data = static_cast<CallbackData_0_1*>(user_data);
+ if (result == PP_OK) {
+ PP_VideoPicture_0_1* picture = &data->picture;
+ PP_VideoPicture* original_picture = data->original_picture;
+ original_picture->decode_id = picture->decode_id;
+ original_picture->texture_id = picture->texture_id;
+ original_picture->texture_target = picture->texture_target;
+ original_picture->texture_size = picture->texture_size;
+ // Return an empty rect, since we have no knowledge of texture size.
dmichael (off chromium) 2014/11/05 23:06:04 You mean a full-size rect? I.e., the same size as
bbudge 2014/11/06 00:26:36 Gah, comment is stale. Done.
+ original_picture->visible_rect = PP_MakeRectFromXYWH(
+ 0, 0, picture->texture_size.width, picture->texture_size.height);
+ }
+
+ // Now execute the original callback.
+ PP_RunCompletionCallback(&data->original_callback, result);
+ delete data;
+}
+
} // namespace
VideoDecoder::VideoDecoder() {
@@ -44,12 +78,14 @@ int32_t VideoDecoder::Initialize(const Graphics3D& context,
PP_VideoProfile profile,
PP_HardwareAcceleration acceleration,
const CompletionCallback& cc) {
+ if (has_interface<PPB_VideoDecoder_1_0>()) {
+ return get_interface<PPB_VideoDecoder_1_0>()->Initialize(
+ pp_resource(), context.pp_resource(), profile, acceleration,
+ cc.pp_completion_callback());
+ }
if (has_interface<PPB_VideoDecoder_0_2>()) {
return get_interface<PPB_VideoDecoder_0_2>()->Initialize(
- pp_resource(),
- context.pp_resource(),
- profile,
- acceleration,
+ pp_resource(), context.pp_resource(), profile, acceleration,
cc.pp_completion_callback());
}
if (has_interface<PPB_VideoDecoder_0_1>()) {
@@ -71,6 +107,10 @@ int32_t VideoDecoder::Decode(uint32_t decode_id,
uint32_t size,
const void* buffer,
const CompletionCallback& cc) {
+ if (has_interface<PPB_VideoDecoder_1_0>()) {
+ return get_interface<PPB_VideoDecoder_1_0>()->Decode(
+ pp_resource(), decode_id, size, buffer, cc.pp_completion_callback());
+ }
if (has_interface<PPB_VideoDecoder_0_2>()) {
return get_interface<PPB_VideoDecoder_0_2>()->Decode(
pp_resource(), decode_id, size, buffer, cc.pp_completion_callback());
@@ -84,19 +124,32 @@ int32_t VideoDecoder::Decode(uint32_t decode_id,
int32_t VideoDecoder::GetPicture(
const CompletionCallbackWithOutput<PP_VideoPicture>& cc) {
+ if (has_interface<PPB_VideoDecoder_1_0>()) {
+ return get_interface<PPB_VideoDecoder_1_0>()->GetPicture(
+ pp_resource(), cc.output(), cc.pp_completion_callback());
+ }
if (has_interface<PPB_VideoDecoder_0_2>()) {
+ // Data for our callback wrapper. The callback handler will delete it.
+ CallbackData_0_1* data = new CallbackData_0_1(cc);
return get_interface<PPB_VideoDecoder_0_2>()->GetPicture(
- pp_resource(), cc.output(), cc.pp_completion_callback());
+ pp_resource(), &data->picture,
+ PP_MakeCompletionCallback(&CallbackConverter, data));
}
if (has_interface<PPB_VideoDecoder_0_1>()) {
+ // Data for our callback wrapper. The callback handler will delete it.
+ CallbackData_0_1* data = new CallbackData_0_1(cc);
return get_interface<PPB_VideoDecoder_0_1>()->GetPicture(
- pp_resource(), cc.output(), cc.pp_completion_callback());
+ pp_resource(), &data->picture,
+ PP_MakeCompletionCallback(&CallbackConverter, data));
}
return cc.MayForce(PP_ERROR_NOINTERFACE);
}
void VideoDecoder::RecyclePicture(const PP_VideoPicture& picture) {
- if (has_interface<PPB_VideoDecoder_0_2>()) {
+ if (has_interface<PPB_VideoDecoder_1_0>()) {
+ get_interface<PPB_VideoDecoder_1_0>()->RecyclePicture(pp_resource(),
+ &picture);
+ } else if (has_interface<PPB_VideoDecoder_0_2>()) {
get_interface<PPB_VideoDecoder_0_2>()->RecyclePicture(pp_resource(),
&picture);
} else if (has_interface<PPB_VideoDecoder_0_1>()) {
@@ -106,6 +159,10 @@ void VideoDecoder::RecyclePicture(const PP_VideoPicture& picture) {
}
int32_t VideoDecoder::Flush(const CompletionCallback& cc) {
+ if (has_interface<PPB_VideoDecoder_1_0>()) {
+ return get_interface<PPB_VideoDecoder_1_0>()->Flush(
+ pp_resource(), cc.pp_completion_callback());
+ }
if (has_interface<PPB_VideoDecoder_0_2>()) {
return get_interface<PPB_VideoDecoder_0_2>()->Flush(
pp_resource(), cc.pp_completion_callback());
@@ -118,6 +175,10 @@ int32_t VideoDecoder::Flush(const CompletionCallback& cc) {
}
int32_t VideoDecoder::Reset(const CompletionCallback& cc) {
+ if (has_interface<PPB_VideoDecoder_1_0>()) {
+ return get_interface<PPB_VideoDecoder_1_0>()->Reset(
+ pp_resource(), cc.pp_completion_callback());
+ }
if (has_interface<PPB_VideoDecoder_0_2>()) {
return get_interface<PPB_VideoDecoder_0_2>()->Reset(
pp_resource(), cc.pp_completion_callback());

Powered by Google App Engine
This is Rietveld 408576698