diff options
author | Zeno Albisser <zeno.albisser@theqtcompany.com> | 2014-12-05 15:04:29 +0100 |
---|---|---|
committer | Andras Becsi <andras.becsi@theqtcompany.com> | 2014-12-09 10:49:28 +0100 |
commit | af6588f8d723931a298c995fa97259bb7f7deb55 (patch) | |
tree | 060ca707847ba1735f01af2372e0d5e494dc0366 /chromium/ppapi/cpp | |
parent | 2fff84d821cc7b1c785f6404e0f8091333283e74 (diff) | |
download | qtwebengine-chromium-af6588f8d723931a298c995fa97259bb7f7deb55.tar.gz |
BASELINE: Update chromium to 40.0.2214.28 and ninja to 1.5.3.
Change-Id: I759465284fd64d59ad120219cbe257f7402c4181
Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
Diffstat (limited to 'chromium/ppapi/cpp')
-rw-r--r-- | chromium/ppapi/cpp/compositor_layer.cc | 54 | ||||
-rw-r--r-- | chromium/ppapi/cpp/compositor_layer.h | 2 | ||||
-rw-r--r-- | chromium/ppapi/cpp/dev/buffer_dev.cc | 10 | ||||
-rw-r--r-- | chromium/ppapi/cpp/image_data.cc | 9 | ||||
-rw-r--r-- | chromium/ppapi/cpp/instance.cc | 61 | ||||
-rw-r--r-- | chromium/ppapi/cpp/instance.h | 51 | ||||
-rw-r--r-- | chromium/ppapi/cpp/message_handler.h | 57 | ||||
-rw-r--r-- | chromium/ppapi/cpp/private/camera_capabilities_private.h | 83 | ||||
-rw-r--r-- | chromium/ppapi/cpp/private/content_decryptor_private.cc | 125 | ||||
-rw-r--r-- | chromium/ppapi/cpp/private/content_decryptor_private.h | 18 | ||||
-rw-r--r-- | chromium/ppapi/cpp/private/image_capture_config_private.h | 99 | ||||
-rw-r--r-- | chromium/ppapi/cpp/private/image_capture_private.h | 179 | ||||
-rw-r--r-- | chromium/ppapi/cpp/private/internal_module.cc | 21 | ||||
-rw-r--r-- | chromium/ppapi/cpp/private/internal_module.h | 16 | ||||
-rw-r--r-- | chromium/ppapi/cpp/private/video_source_private.h | 3 | ||||
-rw-r--r-- | chromium/ppapi/cpp/video_decoder.cc | 109 | ||||
-rw-r--r-- | chromium/ppapi/cpp/video_decoder.h | 17 |
17 files changed, 870 insertions, 44 deletions
diff --git a/chromium/ppapi/cpp/compositor_layer.cc b/chromium/ppapi/cpp/compositor_layer.cc index cbe823a3ac0..d15a6731ba5 100644 --- a/chromium/ppapi/cpp/compositor_layer.cc +++ b/chromium/ppapi/cpp/compositor_layer.cc @@ -17,6 +17,10 @@ template <> const char* interface_name<PPB_CompositorLayer_0_1>() { return PPB_COMPOSITORLAYER_INTERFACE_0_1; } +template <> const char* interface_name<PPB_CompositorLayer_0_2>() { + return PPB_COMPOSITORLAYER_INTERFACE_0_2; +} + } // namespace CompositorLayer::CompositorLayer() { @@ -43,6 +47,10 @@ int32_t CompositorLayer::SetColor(float red, float blue, float alpha, const Size& size) { + if (has_interface<PPB_CompositorLayer_0_2>()) { + return get_interface<PPB_CompositorLayer_0_2>()->SetColor( + pp_resource(), red, green, blue, alpha, &size.pp_size()); + } if (has_interface<PPB_CompositorLayer_0_1>()) { return get_interface<PPB_CompositorLayer_0_1>()->SetColor( pp_resource(), red, green, blue, alpha, &size.pp_size()); @@ -51,10 +59,18 @@ int32_t CompositorLayer::SetColor(float red, } int32_t CompositorLayer::SetTexture(const Graphics3D& context, + uint32_t target, uint32_t texture, const Size& size, const CompletionCallback& cc) { + if (has_interface<PPB_CompositorLayer_0_2>()) { + return get_interface<PPB_CompositorLayer_0_2>()->SetTexture( + pp_resource(), context.pp_resource(), target, texture, &size.pp_size(), + cc.pp_completion_callback()); + } if (has_interface<PPB_CompositorLayer_0_1>()) { + if (target != 0x0DE1) // 0x0DE1 GL_TEXTURE_2D + return cc.MayForce(PP_ERROR_NOTSUPPORTED); return get_interface<PPB_CompositorLayer_0_1>()->SetTexture( pp_resource(), context.pp_resource(), texture, &size.pp_size(), cc.pp_completion_callback()); @@ -64,6 +80,11 @@ int32_t CompositorLayer::SetTexture(const Graphics3D& context, int32_t CompositorLayer::SetImage(const ImageData& image, const CompletionCallback& cc) { + if (has_interface<PPB_CompositorLayer_0_2>()) { + return get_interface<PPB_CompositorLayer_0_2>()->SetImage( + pp_resource(), image.pp_resource(), NULL, + cc.pp_completion_callback()); + } if (has_interface<PPB_CompositorLayer_0_1>()) { return get_interface<PPB_CompositorLayer_0_1>()->SetImage( pp_resource(), image.pp_resource(), NULL, @@ -75,6 +96,11 @@ int32_t CompositorLayer::SetImage(const ImageData& image, int32_t CompositorLayer::SetImage(const ImageData& image, const Size& size, const CompletionCallback& cc) { + if (has_interface<PPB_CompositorLayer_0_2>()) { + return get_interface<PPB_CompositorLayer_0_2>()->SetImage( + pp_resource(), image.pp_resource(), &size.pp_size(), + cc.pp_completion_callback()); + } if (has_interface<PPB_CompositorLayer_0_1>()) { return get_interface<PPB_CompositorLayer_0_1>()->SetImage( pp_resource(), image.pp_resource(), &size.pp_size(), @@ -84,6 +110,10 @@ int32_t CompositorLayer::SetImage(const ImageData& image, } int32_t CompositorLayer::SetClipRect(const Rect& rect) { + if (has_interface<PPB_CompositorLayer_0_2>()) { + return get_interface<PPB_CompositorLayer_0_2>()->SetClipRect( + pp_resource(), &rect.pp_rect()); + } if (has_interface<PPB_CompositorLayer_0_1>()) { return get_interface<PPB_CompositorLayer_0_1>()->SetClipRect( pp_resource(), &rect.pp_rect()); @@ -92,6 +122,10 @@ int32_t CompositorLayer::SetClipRect(const Rect& rect) { } int32_t CompositorLayer::SetTransform(const float matrix[16]) { + if (has_interface<PPB_CompositorLayer_0_2>()) { + return get_interface<PPB_CompositorLayer_0_2>()->SetTransform( + pp_resource(), matrix); + } if (has_interface<PPB_CompositorLayer_0_1>()) { return get_interface<PPB_CompositorLayer_0_1>()->SetTransform( pp_resource(), matrix); @@ -100,6 +134,10 @@ int32_t CompositorLayer::SetTransform(const float matrix[16]) { } int32_t CompositorLayer::SetOpacity(float opacity) { + if (has_interface<PPB_CompositorLayer_0_2>()) { + return get_interface<PPB_CompositorLayer_0_2>()->SetOpacity( + pp_resource(), opacity); + } if (has_interface<PPB_CompositorLayer_0_1>()) { return get_interface<PPB_CompositorLayer_0_1>()->SetOpacity( pp_resource(), opacity); @@ -108,6 +146,10 @@ int32_t CompositorLayer::SetOpacity(float opacity) { } int32_t CompositorLayer::SetBlendMode(PP_BlendMode mode) { + if (has_interface<PPB_CompositorLayer_0_2>()) { + return get_interface<PPB_CompositorLayer_0_2>()->SetBlendMode( + pp_resource(), mode); + } if (has_interface<PPB_CompositorLayer_0_1>()) { return get_interface<PPB_CompositorLayer_0_1>()->SetBlendMode( pp_resource(), mode); @@ -116,6 +158,10 @@ int32_t CompositorLayer::SetBlendMode(PP_BlendMode mode) { } int32_t CompositorLayer::SetSourceRect(const FloatRect& rect) { + if (has_interface<PPB_CompositorLayer_0_2>()) { + return get_interface<PPB_CompositorLayer_0_2>()->SetSourceRect( + pp_resource(), &rect.pp_float_rect()); + } if (has_interface<PPB_CompositorLayer_0_1>()) { return get_interface<PPB_CompositorLayer_0_1>()->SetSourceRect( pp_resource(), &rect.pp_float_rect()); @@ -124,6 +170,10 @@ int32_t CompositorLayer::SetSourceRect(const FloatRect& rect) { } int32_t CompositorLayer::SetPremultipliedAlpha(bool premult) { + if (has_interface<PPB_CompositorLayer_0_2>()) { + return get_interface<PPB_CompositorLayer_0_2>()->SetPremultipliedAlpha( + pp_resource(), PP_FromBool(premult)); + } if (has_interface<PPB_CompositorLayer_0_1>()) { return get_interface<PPB_CompositorLayer_0_1>()->SetPremultipliedAlpha( pp_resource(), PP_FromBool(premult)); @@ -132,6 +182,10 @@ int32_t CompositorLayer::SetPremultipliedAlpha(bool premult) { } bool CompositorLayer::IsCompositorLayer(const Resource& resource) { + if (has_interface<PPB_CompositorLayer_0_2>()) { + return PP_ToBool(get_interface<PPB_CompositorLayer_0_2>()-> + IsCompositorLayer(resource.pp_resource())); + } if (has_interface<PPB_CompositorLayer_0_1>()) { return PP_ToBool(get_interface<PPB_CompositorLayer_0_1>()-> IsCompositorLayer(resource.pp_resource())); diff --git a/chromium/ppapi/cpp/compositor_layer.h b/chromium/ppapi/cpp/compositor_layer.h index f431bd8d5ae..9e65e87964d 100644 --- a/chromium/ppapi/cpp/compositor_layer.h +++ b/chromium/ppapi/cpp/compositor_layer.h @@ -70,6 +70,7 @@ class CompositorLayer : public Resource { /// /// param[in] context A <code>Graphics3D</code> corresponding to a graphics 3d /// resource which owns the GL texture. + /// param[in] target GL texture target (GL_TEXTURE_2D, etc). /// param[in] texture A GL texture object id. /// param[in] size A <code>Size</code> for the size of the layer before /// transform. @@ -78,6 +79,7 @@ class CompositorLayer : public Resource { /// /// @return An int32_t containing a result code from <code>pp_errors.h</code>. int32_t SetTexture(const Graphics3D& context, + uint32_t target, uint32_t texture, const Size& size, const CompletionCallback& cc); diff --git a/chromium/ppapi/cpp/dev/buffer_dev.cc b/chromium/ppapi/cpp/dev/buffer_dev.cc index aca7b1b795f..5435afdcece 100644 --- a/chromium/ppapi/cpp/dev/buffer_dev.cc +++ b/chromium/ppapi/cpp/dev/buffer_dev.cc @@ -59,11 +59,13 @@ Buffer_Dev& Buffer_Dev::operator=(const Buffer_Dev& rhs) { } void Buffer_Dev::Init() { - if (!get_interface<PPB_Buffer_Dev>()->Describe(pp_resource(), &size_) || - !(data_ = get_interface<PPB_Buffer_Dev>()->Map(pp_resource()))) { - data_ = NULL; - size_ = 0; + if (get_interface<PPB_Buffer_Dev>()->Describe(pp_resource(), &size_)) { + data_ = get_interface<PPB_Buffer_Dev>()->Map(pp_resource()); + if (data_) + return; } + data_ = NULL; + size_ = 0; } } // namespace pp diff --git a/chromium/ppapi/cpp/image_data.cc b/chromium/ppapi/cpp/image_data.cc index a0c3aeff796..d9738964795 100644 --- a/chromium/ppapi/cpp/image_data.cc +++ b/chromium/ppapi/cpp/image_data.cc @@ -92,9 +92,12 @@ PP_ImageDataFormat ImageData::GetNativeImageDataFormat() { void ImageData::InitData() { if (!has_interface<PPB_ImageData_1_0>()) return; - if (!get_interface<PPB_ImageData_1_0>()->Describe(pp_resource(), &desc_) || - !(data_ = get_interface<PPB_ImageData_1_0>()->Map(pp_resource()))) - *this = ImageData(); + if (get_interface<PPB_ImageData_1_0>()->Describe(pp_resource(), &desc_)) { + data_ = get_interface<PPB_ImageData_1_0>()->Map(pp_resource()); + if (data_) + return; + } + *this = ImageData(); } } // namespace pp diff --git a/chromium/ppapi/cpp/instance.cc b/chromium/ppapi/cpp/instance.cc index a5be2b97613..74b93216729 100644 --- a/chromium/ppapi/cpp/instance.cc +++ b/chromium/ppapi/cpp/instance.cc @@ -9,12 +9,15 @@ #include "ppapi/c/ppb_input_event.h" #include "ppapi/c/ppb_instance.h" #include "ppapi/c/ppb_messaging.h" +#include "ppapi/c/ppp_message_handler.h" #include "ppapi/cpp/compositor.h" #include "ppapi/cpp/graphics_2d.h" #include "ppapi/cpp/graphics_3d.h" #include "ppapi/cpp/image_data.h" #include "ppapi/cpp/instance_handle.h" #include "ppapi/cpp/logging.h" +#include "ppapi/cpp/message_handler.h" +#include "ppapi/cpp/message_loop.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/module_impl.h" #include "ppapi/cpp/point.h" @@ -42,6 +45,38 @@ template <> const char* interface_name<PPB_Messaging_1_0>() { return PPB_MESSAGING_INTERFACE_1_0; } +template <> const char* interface_name<PPB_Messaging_1_2>() { + return PPB_MESSAGING_INTERFACE_1_2; +} + +// PPP_MessageHandler implementation ------------------------------------------- +void HandleMessage(PP_Instance pp_instance, + void* user_data, + const PP_Var* var) { + MessageHandler* message_handler = static_cast<MessageHandler*>(user_data); + message_handler->HandleMessage(InstanceHandle(pp_instance), Var(*var)); +} + +void HandleBlockingMessage(PP_Instance pp_instance, + void* user_data, + const PP_Var* var, + PP_Var* result) { + MessageHandler* message_handler = static_cast<MessageHandler*>(user_data); + pp::Var result_var = + message_handler->HandleBlockingMessage(InstanceHandle(pp_instance), + Var(*var)); + *result = result_var.Detach(); +} + +void Destroy(PP_Instance pp_instance, void* user_data) { + MessageHandler* message_handler = static_cast<MessageHandler*>(user_data); + message_handler->WasUnregistered(InstanceHandle(pp_instance)); +} + +static PPP_MessageHandler_0_2 message_handler_if = { + &HandleMessage, &HandleBlockingMessage, &Destroy +}; + } // namespace Instance::Instance(PP_Instance instance) : pp_instance_(instance) { @@ -130,10 +165,30 @@ void Instance::ClearInputEventRequest(uint32_t event_classes) { } void Instance::PostMessage(const Var& message) { - if (!has_interface<PPB_Messaging_1_0>()) + if (has_interface<PPB_Messaging_1_2>()) { + get_interface<PPB_Messaging_1_2>()->PostMessage(pp_instance(), + message.pp_var()); + } else if (has_interface<PPB_Messaging_1_0>()) { + get_interface<PPB_Messaging_1_0>()->PostMessage(pp_instance(), + message.pp_var()); + } +} + +int32_t Instance::RegisterMessageHandler(MessageHandler* message_handler, + const MessageLoop& message_loop) { + if (!has_interface<PPB_Messaging_1_2>()) + return PP_ERROR_NOTSUPPORTED; + return get_interface<PPB_Messaging_1_2>()->RegisterMessageHandler( + pp_instance(), + message_handler, + &message_handler_if, + message_loop.pp_resource()); +} + +void Instance::UnregisterMessageHandler() { + if (!has_interface<PPB_Messaging_1_2>()) return; - get_interface<PPB_Messaging_1_0>()->PostMessage(pp_instance(), - message.pp_var()); + get_interface<PPB_Messaging_1_2>()->UnregisterMessageHandler(pp_instance()); } void Instance::LogToConsole(PP_LogLevel level, const Var& value) { diff --git a/chromium/ppapi/cpp/instance.h b/chromium/ppapi/cpp/instance.h index af024db336a..9bc16fb5727 100644 --- a/chromium/ppapi/cpp/instance.h +++ b/chromium/ppapi/cpp/instance.h @@ -33,6 +33,8 @@ class Graphics2D; class Graphics3D; class InputEvent; class InstanceHandle; +class MessageHandler; +class MessageLoop; class Rect; class URLLoader; class Var; @@ -495,6 +497,55 @@ class Instance { /// All var types are copied when passing them to JavaScript. void PostMessage(const Var& message); + /// Dev-Channel Only + /// + /// Registers a handler for receiving messages from JavaScript. If a handler + /// is registered this way, it will replace the Instance's HandleMessage + /// method, and all messages sent from JavaScript via postMessage and + /// postMessageAndAwaitResponse will be dispatched to + /// <code>message_handler</code>. + /// + /// The function calls will be dispatched via <code>message_loop</code>. This + /// means that the functions will be invoked on the thread to which + /// <code>message_loop</code> is attached, when <code>message_loop</code> is + /// run. It is illegal to pass the main thread message loop; + /// RegisterMessageHandler will return PP_ERROR_WRONG_THREAD in that case. + /// If you quit <code>message_loop</code> before calling Unregister(), + /// the browser will not be able to call functions in the plugin's message + /// handler any more. That could mean missing some messages or could cause a + /// leak if you depend on Destroy() to free hander data. So you should, + /// whenever possible, Unregister() the handler prior to quitting its event + /// loop. + /// + /// Attempting to register a message handler when one is already registered + /// will cause the current MessageHandler to be unregistered and replaced. In + /// that case, no messages will be sent to the "default" message handler + /// (pp::Instance::HandleMessage()). Messages will stop arriving at the prior + /// message handler and will begin to be dispatched at the new message + /// handler. + /// + /// @param[in] message_handler The plugin-provided object for handling + /// messages. The instance does not take ownership of the pointer; it is up + /// to the plugin to ensure that |message_handler| lives until its + /// WasUnregistered() function is invoked. + /// @param[in] message_loop Represents the message loop on which + /// MessageHandler's functions should be invoked. + /// @return PP_OK on success, or an error from pp_errors.h. + int32_t RegisterMessageHandler(MessageHandler* message_handler, + const MessageLoop& message_loop); + + /// Unregisters the current message handler for this instance if one is + /// registered. After this call, the message handler (if one was + /// registered) will have "WasUnregistered" called on it and will receive no + /// further messages. After that point, all messages sent from JavaScript + /// using postMessage() will be dispatched to pp::Instance::HandleMessage() + /// on the main thread. Attempts to call postMessageAndAwaitResponse() from + /// JavaScript after that point will fail. + /// + /// Attempting to unregister a message handler when none is registered has no + /// effect. + void UnregisterMessageHandler(); + /// @} /// @{ diff --git a/chromium/ppapi/cpp/message_handler.h b/chromium/ppapi/cpp/message_handler.h new file mode 100644 index 00000000000..0bb6ad8472c --- /dev/null +++ b/chromium/ppapi/cpp/message_handler.h @@ -0,0 +1,57 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_CPP_MESSAGE_HANDLER_H_ +#define PPAPI_CPP_MESSAGE_HANDLER_H_ + +namespace pp { + +/// <code>MessageHandler</code> is an abstract base class that the plugin may +/// implement if it wants to receive messages from JavaScript on a background +/// thread when JavaScript invokes postMessage() or +/// postMessageAndAwaitResponse(). See pp::Instance::RegisterMessageHandler() +/// for usage. +class MessageHandler { + public: + virtual ~MessageHandler() {}; + + /// Invoked as a result of JavaScript invoking postMessage() on the plugin's + /// DOM element. + /// + /// @param[in] instance An <code>InstanceHandle</code> identifying one + /// instance of a module. + /// @param[in] message_data A copy of the parameter that JavaScript provided + /// to postMessage(). + virtual void HandleMessage(pp::InstanceHandle instance, + const Var& message_data) = 0; + + /// Invoked as a result of JavaScript invoking postMessageAndAwaitResponse() + /// on the plugin's DOM element. + /// + /// NOTE: JavaScript execution is blocked during the duration of this call. + /// Hence, the plugin should respond as quickly as possible. For this reason, + /// blocking completion callbacks are disallowed while handling a blocking + /// message. + /// + /// @param[in] instance An <code>InstanceHandle</code> identifying one + /// instance of a module. + /// @param[in] message_data A copy of the parameter that JavaScript provided + /// to postMessage(). + /// @return Returns a pp::Var that is then copied to a JavaScript object + /// which is returned as the result of JavaScript's call of + /// postMessageAndAwaitResponse(). + virtual pp::Var HandleBlockingMessage(pp::InstanceHandle instance, + const Var& message_data) = 0; + + /// Invoked when this MessageHandler is no longer needed. After this, no more + /// calls will be made to this object. + /// + /// @param[in] instance An <code>InstanceHandle</code> identifying one + /// instance of a module. + virtual void WasUnregistered(pp::InstanceHandle instance) = 0; +}; + +} // namespace pp + +#endif // PPAPI_CPP_MESSAGE_HANDLER_H_ diff --git a/chromium/ppapi/cpp/private/camera_capabilities_private.h b/chromium/ppapi/cpp/private/camera_capabilities_private.h new file mode 100644 index 00000000000..5151c759e77 --- /dev/null +++ b/chromium/ppapi/cpp/private/camera_capabilities_private.h @@ -0,0 +1,83 @@ +/* Copyright 2014 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef PPAPI_CPP_PRIVATE_CAMERA_CAPABILITIES_PRIVATE_H_ +#define PPAPI_CPP_PRIVATE_CAMERA_CAPABILITIES_PRIVATE_H_ + +#include "ppapi/c/private/ppb_camera_capabilities_private.h" +#include "ppapi/cpp/resource.h" +#include "ppapi/cpp/size.h" + +/// @file +/// This file defines the CameraCapabilities_Private interface for +/// establishing an image capture configuration resource within the browser. +namespace pp { + +/// The <code>CameraCapabilities_Private</code> interface contains methods for +/// getting the image capture capabilities within the browser. +class CameraCapabilities_Private : public Resource { + public: + /// Default constructor for creating an is_null() + /// <code>CameraCapabilities_Private</code> object. + CameraCapabilities_Private(); + + /// The copy constructor for <code>CameraCapabilities_Private</code>. + /// + /// @param[in] other A reference to a <code>CameraCapabilities_Private + /// </code>. + CameraCapabilities_Private(const CameraCapabilities_Private& other); + + /// Constructs a <code>CameraCapabilities_Private</code> from a <code> + /// Resource</code>. + /// + /// @param[in] resource A <code>PPB_CameraCapabilities_Private</code> + /// resource. + explicit CameraCapabilities_Private(const Resource& resource); + + /// Constructs a <code>CameraCapabilities_Private</code> object. + /// + /// @param[in] instance The instance with which this resource will be + /// associated. + explicit CameraCapabilities_Private(const InstanceHandle& instance); + + /// A constructor used when you have received a <code>PP_Resource</code> as a + /// return value that has had 1 ref added for you. + /// + /// @param[in] resource A <code>PPB_CameraCapabilities_Private</code> + /// resource. + CameraCapabilities_Private(PassRef, PP_Resource resource); + + // Destructor. + ~CameraCapabilities_Private(); + + /// GetSupportedPreviewSizes() returns the supported preview sizes for the + /// given <code>CameraCapabilities_Private</code>. + /// + /// @param[out] A vector of <code>Size</code> corresponding to the + /// supported preview sizes in pixels. + void GetSupportedPreviewSizes(std::vector<Size>* preview_sizes); + + /// GetSupportedJpegSize() returns the supported JPEG sizes for the given + /// <code>CameraCapabilities_Private</code>. + /// + /// @param[out] A vector of <code>Size</code> corresponding to the + /// supported JPEG image sizes in pixels. + void GetSupportedJpegSizes(std::vector<Size>* jpeg_sizes); + + /// IsCameraCapabilities() determines if the given resource is a + /// <code>CameraCapabilities_Private</code>. + /// + /// @param[in] resource A <code>Resource</code> corresponding to an image + /// capture capabilities resource. + /// + /// @return true if the given resource is an <code> + /// CameraCapabilities_Private</code> resource, otherwise false. + static bool IsCameraCapabilities(const Resource& resource); +}; + +} // namespace pp + +#endif /* PPAPI_CPP_PRIVATE_CAMERA_CAPABILITIES_PRIVATE_H_ */ + diff --git a/chromium/ppapi/cpp/private/content_decryptor_private.cc b/chromium/ppapi/cpp/private/content_decryptor_private.cc index 3142511f7fb..65f822cc2b0 100644 --- a/chromium/ppapi/cpp/private/content_decryptor_private.cc +++ b/chromium/ppapi/cpp/private/content_decryptor_private.cc @@ -15,6 +15,7 @@ #include "ppapi/cpp/module.h" #include "ppapi/cpp/module_impl.h" #include "ppapi/cpp/var.h" +#include "ppapi/cpp/var_array.h" namespace pp { @@ -38,6 +39,23 @@ void Initialize(PP_Instance instance, key_system_var.AsString()); } +void SetServerCertificate(PP_Instance instance, + uint32_t promise_id, + PP_Var server_certificate_arg) { + void* object = + Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); + if (!object) + return; + + pp::Var server_certificate_var(server_certificate_arg); + if (!server_certificate_var.is_array_buffer()) + return; + pp::VarArrayBuffer server_certificate(server_certificate_var); + + static_cast<ContentDecryptor_Private*>(object) + ->SetServerCertificate(promise_id, server_certificate); +} + void CreateSession(PP_Instance instance, uint32_t promise_id, PP_Var init_data_type_arg, @@ -102,9 +120,41 @@ void UpdateSession(PP_Instance instance, ->UpdateSession(promise_id, web_session_id_var.AsString(), response); } -void ReleaseSession(PP_Instance instance, - uint32_t promise_id, - PP_Var web_session_id_arg) { +void CloseSession(PP_Instance instance, + uint32_t promise_id, + PP_Var web_session_id_arg) { + void* object = + Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); + if (!object) + return; + + pp::Var web_session_id_var(web_session_id_arg); + if (!web_session_id_var.is_string()) + return; + + static_cast<ContentDecryptor_Private*>(object) + ->CloseSession(promise_id, web_session_id_var.AsString()); +} + +void RemoveSession(PP_Instance instance, + uint32_t promise_id, + PP_Var web_session_id_arg) { + void* object = + Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); + if (!object) + return; + + pp::Var web_session_id_var(web_session_id_arg); + if (!web_session_id_var.is_string()) + return; + + static_cast<ContentDecryptor_Private*>(object) + ->RemoveSession(promise_id, web_session_id_var.AsString()); +} + +void GetUsableKeyIds(PP_Instance instance, + uint32_t promise_id, + PP_Var web_session_id_arg) { void* object = Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); if (!object) @@ -115,7 +165,7 @@ void ReleaseSession(PP_Instance instance, return; static_cast<ContentDecryptor_Private*>(object) - ->ReleaseSession(promise_id, web_session_id_var.AsString()); + ->GetUsableKeyIds(promise_id, web_session_id_var.AsString()); } void Decrypt(PP_Instance instance, @@ -206,18 +256,20 @@ void DecryptAndDecode(PP_Instance instance, } const PPP_ContentDecryptor_Private ppp_content_decryptor = { - &Initialize, - &CreateSession, - &LoadSession, - &UpdateSession, - &ReleaseSession, - &Decrypt, - &InitializeAudioDecoder, - &InitializeVideoDecoder, - &DeinitializeDecoder, - &ResetDecoder, - &DecryptAndDecode -}; + &Initialize, + &SetServerCertificate, + &CreateSession, + &LoadSession, + &UpdateSession, + &CloseSession, + &RemoveSession, + &GetUsableKeyIds, + &Decrypt, + &InitializeAudioDecoder, + &InitializeVideoDecoder, + &DeinitializeDecoder, + &ResetDecoder, + &DecryptAndDecode}; template <> const char* interface_name<PPB_ContentDecryptor_Private>() { return PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE; @@ -257,6 +309,23 @@ void ContentDecryptor_Private::PromiseResolvedWithSession( } } +void ContentDecryptor_Private::PromiseResolvedWithKeyIds( + uint32_t promise_id, + const std::vector<std::vector<uint8_t> >& key_ids) { + if (has_interface<PPB_ContentDecryptor_Private>()) { + pp::VarArray key_ids_array = pp::VarArray(); + key_ids_array.SetLength(key_ids.size()); + for (size_t i = 0; i < key_ids.size(); ++i) { + const std::vector<uint8_t>& entry = key_ids[i]; + pp::VarArrayBuffer array_buffer(entry.size()); + memcpy(array_buffer.Map(), &entry[0], entry.size()); + key_ids_array.Set(i, array_buffer); + } + get_interface<PPB_ContentDecryptor_Private>()->PromiseResolvedWithKeyIds( + associated_instance_.pp_instance(), promise_id, key_ids_array.pp_var()); + } +} + void ContentDecryptor_Private::PromiseRejected( uint32_t promise_id, PP_CdmExceptionCode exception_code, @@ -288,6 +357,30 @@ void ContentDecryptor_Private::SessionMessage( } } +void ContentDecryptor_Private::SessionKeysChange( + const std::string& web_session_id, + bool has_additional_usable_key) { + if (has_interface<PPB_ContentDecryptor_Private>()) { + pp::Var web_session_id_var(web_session_id); + get_interface<PPB_ContentDecryptor_Private>()->SessionKeysChange( + associated_instance_.pp_instance(), + web_session_id_var.pp_var(), + PP_FromBool(has_additional_usable_key)); + } +} + +void ContentDecryptor_Private::SessionExpirationChange( + const std::string& web_session_id, + PP_Time new_expiry_time) { + if (has_interface<PPB_ContentDecryptor_Private>()) { + pp::Var web_session_id_var(web_session_id); + get_interface<PPB_ContentDecryptor_Private>()->SessionExpirationChange( + associated_instance_.pp_instance(), + web_session_id_var.pp_var(), + new_expiry_time); + } +} + void ContentDecryptor_Private::SessionReady(const std::string& web_session_id) { if (has_interface<PPB_ContentDecryptor_Private>()) { pp::Var web_session_id_var(web_session_id); diff --git a/chromium/ppapi/cpp/private/content_decryptor_private.h b/chromium/ppapi/cpp/private/content_decryptor_private.h index 674bd38a1f2..25aba52c1f8 100644 --- a/chromium/ppapi/cpp/private/content_decryptor_private.h +++ b/chromium/ppapi/cpp/private/content_decryptor_private.h @@ -6,6 +6,7 @@ #define PPAPI_CPP_PRIVATE_CONTENT_DECRYPTOR_PRIVATE_H_ #include <string> +#include <vector> #include "ppapi/c/private/pp_content_decryptor.h" #include "ppapi/c/private/ppb_content_decryptor_private.h" @@ -34,6 +35,8 @@ class ContentDecryptor_Private { // strings. The change would allow the CDM wrapper to reuse vars when // replying to the browser. virtual void Initialize(const std::string& key_system) = 0; + virtual void SetServerCertificate(uint32_t promise_id, + pp::VarArrayBuffer server_certificate) = 0; virtual void CreateSession(uint32_t promise_id, const std::string& init_data_type, pp::VarArrayBuffer init_data, @@ -43,8 +46,12 @@ class ContentDecryptor_Private { virtual void UpdateSession(uint32_t promise_id, const std::string& web_session_id, pp::VarArrayBuffer response) = 0; - virtual void ReleaseSession(uint32_t promise_id, - const std::string& web_session_id) = 0; + virtual void CloseSession(uint32_t promise_id, + const std::string& web_session_id) = 0; + virtual void RemoveSession(uint32_t promise_id, + const std::string& web_session_id) = 0; + virtual void GetUsableKeyIds(uint32_t promise_id, + const std::string& web_session_id) = 0; virtual void Decrypt(pp::Buffer_Dev encrypted_buffer, const PP_EncryptedBlockInfo& encrypted_block_info) = 0; virtual void InitializeAudioDecoder( @@ -68,6 +75,9 @@ class ContentDecryptor_Private { void PromiseResolved(uint32_t promise_id); void PromiseResolvedWithSession(uint32_t promise_id, const std::string& web_session_id); + void PromiseResolvedWithKeyIds( + uint32_t promise_id, + const std::vector<std::vector<uint8_t> >& key_ids); void PromiseRejected(uint32_t promise_id, PP_CdmExceptionCode exception_code, uint32_t system_code, @@ -75,6 +85,10 @@ class ContentDecryptor_Private { void SessionMessage(const std::string& web_session_id, pp::VarArrayBuffer message, const std::string& destination_url); + void SessionKeysChange(const std::string& web_session_id, + bool has_additional_usable_key); + void SessionExpirationChange(const std::string& web_session_id, + PP_Time new_expiry_time); void SessionReady(const std::string& web_session_id); void SessionClosed(const std::string& web_session_id); void SessionError(const std::string& web_session_id, diff --git a/chromium/ppapi/cpp/private/image_capture_config_private.h b/chromium/ppapi/cpp/private/image_capture_config_private.h new file mode 100644 index 00000000000..a4847fb35a4 --- /dev/null +++ b/chromium/ppapi/cpp/private/image_capture_config_private.h @@ -0,0 +1,99 @@ +/* Copyright 2014 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef PPAPI_CPP_PRIVATE_IMAGE_CAPTURE_CONFIG_PRIVATE_H_ +#define PPAPI_CPP_PRIVATE_IMAGE_CAPTURE_CONFIG_PRIVATE_H_ + +#include "ppapi/c/private/ppb_image_capture_config_private.h" +#include "ppapi/cpp/resource.h" +#include "ppapi/cpp/size.h" + +/// @file +/// This file defines the ImageCaptureConfig_Private interface for +/// establishing an image capture configuration resource within the browser. +namespace pp { + +/// The <code>ImageCaptureConfig_Private</code> interface contains methods for +/// establishing image capture configuration within the browser. The new +/// configuration will take effect after <code> +/// ImageCaptureConfig_Private.SetConfig</code> is called. +class ImageCaptureConfig_Private { + public: + /// Default constructor for creating an is_null() + /// <code>ImageCaptureConfig_Private</code> object. + ImageCaptureConfig_Private(); + + /// The copy constructor for <code>ImageCaptureConfig_Private</code>. + /// + /// @param[in] other A reference to a <code>ImageCaptureConfig_Private + /// </code>. + ImageCaptureConfig_Private(const ImageCaptureConfig_Private& other); + + /// Constructs a <code>ImageCaptureConfig_Private</code> from a <code> + /// Resource</code>. + /// + /// @param[in] resource A <code>PPB_ImageCaptureConfig_Private</code> + /// resource. + explicit ImageCaptureConfig_Private(const Resource& resource); + + /// Constructs a <code>ImageCaptureConfig_Private</code> object. + /// + /// @param[in] instance The instance with which this resource will be + /// associated. + explicit ImageCaptureConfig_Private(const InstanceHandle& instance); + + /// A constructor used when you have received a <code>PP_Resource</code> as a + /// return value that has had 1 ref added for you. + /// + /// @param[in] resource A <code>PPB_ImageCaptureConfig_Private</code> + /// resource. + ImageCaptureConfig_Private(PassRef, PP_Resource resource); + + // Destructor. + ~ImageCaptureConfig_Private(); + + /// GetPreviewSize() returns the preview image size in pixels for the given + /// <code>ImageCaptureConfig_Private</code>. + /// + /// @param[out] preview_size A <code>Size</code> that indicates the + /// requested preview image size. + void GetPreviewSize(Size* preview_size); + + /// SetPreviewSize() sets the preview image size for the given <code> + /// ImageCaptureConfig_Private</code>. + /// + /// @param[in] preview_size A <code>Size</code> that indicates the + /// requested preview image size. + void SetPreviewSize(const Size& preview_size); + + /// GetJpegSize() returns the JPEG image size in pixels for the given + /// <code>ImageCaptureConfig_Private</code>. + /// + /// @param[out] jpeg_size A <code>Size</code> that indicates the current + /// JPEG image size. + void GetJpegSize(Size* jpeg_size); + + /// SetJpegSize() sets the JPEG image size for the given <code> + /// ImageCaptureConfig_Private</code>. + /// + /// @param[in] jpeg_size A <code>Size</code> that indicates the requested + /// JPEG image size. + void SetJpegSize(const Size& jpeg_size); + + /// IsImageCaptureConfig() determines if the given resource is a + /// <code>ImageCaptureConfig_Private</code>. + /// + /// @param[in] resource A <code>Resource</code> corresponding to an image + /// capture config resource. + /// + /// @return true if the given resource is an <code> + /// ImageCaptureConfig_Private</code> resource, otherwise false. + static bool IsImageCaptureConfig(const Resource& resource); +}; + +} // namespace pp + +#endif /* PPAPI_CPP_PRIVATE_IMAGE_CAPTURE_CONFIG_PRIVATE_H_ */ + diff --git a/chromium/ppapi/cpp/private/image_capture_private.h b/chromium/ppapi/cpp/private/image_capture_private.h new file mode 100644 index 00000000000..ab4afbbdcd9 --- /dev/null +++ b/chromium/ppapi/cpp/private/image_capture_private.h @@ -0,0 +1,179 @@ +/* Copyright 2014 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef PPAPI_CPP_PRIVATE_IMAGE_CAPTURE_PRIVATE_H_ +#define PPAPI_CPP_PRIVATE_IMAGE_CAPTURE_PRIVATE_H_ + +#include "ppapi/c/private/ppb_image_capture_private.h" +#include "ppapi/cpp/completion_callback.h" +#include "ppapi/cpp/private/camera_capabilities_private.h" +#include "ppapi/cpp/private/image_capture_config_private.h" +#include "ppapi/cpp/resource.h" +#include "ppapi/cpp/var.h" + +/// @file +/// Defines the <code>ImageCapture_Private</code> interface. Used for +/// acquiring a single still image from a camera source. +namespace pp { + +/// To capture a still image with this class, use the following steps. +/// 1. Create an ImageCapture_Private object by the constructor. +/// 2. Call GetCameraCapabilities to get the supported preview sizes. +/// 3. For optimal performance, set one of the supported preview size as the +/// constraints of getUserMedia. Use the created MediaStreamVideoTrack for +/// camera previews. +/// 4. Set the same preview size and other settings by SetConfig. +/// 5. Call CaptureStillImage to capture a still image. Play the shutter sound +/// in the shutter callback. The image from the preview callback can be used +/// for display. JPEG image will be returned to the JPEG callback. +class ImageCapture_Private { + public: + /// Default constructor for creating an is_null() + /// <code>ImageCapture_Private</code> object. + ImageCapture_Private(); + + /// Creates an ImageCapture_Private resource. + /// + /// @param[in] instance A <code>PP_Instance</code> identifying one instance + /// of a module. + /// @param[in] camera_source_id A <code>Var</code> identifying a camera + /// source. The type is string. The ID can be obtained from + /// MediaStreamTrack.getSources() or MediaStreamVideoTrack.id. If a + /// MediaStreamVideoTrack is associated with the same source and the track + /// is closed, this ImageCapture_Private object can still do image capture. + /// @param[in] error_callback A <code>ImageCapture_Private_ErrorCallback + /// </code> callback to indicate the image capture has failed. + /// @param[inout] user_data An opaque pointer that will be passed to the + /// callbacks of ImageCapture_Private. + ImageCapture_Private(const InstanceHandle& instance, + const Var& camera_source_id, + PPB_ImageCapture_Private_ErrorCallback error_callback, + void* user_data); + + /// Constructs a <code>ImageCapture_Private</code> from a <code> + /// Resource</code>. + /// + /// @param[in] resource A <code>ImageCapture_Private</code> + /// resource. + explicit ImageCapture_Private(const Resource& resource); + + /// A constructor used when you have received a <code>PP_Resource</code> as a + /// return value that has had 1 ref added for you. + /// + /// @param[in] resource A <code>ImageCapture_Private</code> + /// resource. + ImageCapture_Private(PassRef, PP_Resource resource); + + // Destructor. + ~ImageCapture_Private(); + + /// Disconnects from the camera and cancels all pending capture requests. + /// After this returns, no callbacks will be called. If <code> + /// ImageCapture_Private</code> is destroyed and is not closed yet, this + /// function will be automatically called. Calling this more than once has no + /// effect. + /// + /// @param[in] callback <code>CompletionCallback</code> to be called upon + /// completion of <code>Close()</code>. + /// + /// @return An int32_t containing a result code from <code>pp_errors.h</code>. + int32_t Close(const CompletionCallback& callback); + + /// Sets the configuration of the image capture. + /// If <code>SetConfig()</code> is not called, default settings will be used. + /// + /// @param[in] config A <code>ImageCaptureConfig_Private</code> object. + /// @param[in] callback <code>CompletionCallback</code> to be called upon + /// completion of <code>SetConfig()</code>. + /// + /// @return An int32_t containing a result code from <code>pp_errors.h</code>. + /// Returns <code>PP_ERROR_INPROGRESS</code> if there is a pending call of + /// <code>SetConfig()</code> or <code>CaptureStillImage()</code>. + /// If an error is returned, the configuration will not be changed. + int32_t SetConfig(const ImageCaptureConfig_Private& config, + const CompletionCallback& callback); + + /// Gets the configuration of the image capture. + /// + /// @param[in] callback A <code>CompletionCallbackWithOutput</code> + /// to be called upon completion. + /// + /// @return An int32_t containing a result code from <code>pp_errors.h</code>. + int32_t GetConfig( + const CompletionCallbackWithOutput<ImageCaptureConfig_Private>& callback); + + /// Gets the camera capabilities. + /// + /// The camera capabilities do not change for a given camera source. + /// + /// @param[in] callback A <code>CompletionCallbackWithOutput</code> + /// to be called upon completion. + /// + /// @return An int32_t containing a result code from <code>pp_errors.h</code>. + int32_t GetCameraCapabilities( + const CompletionCallbackWithOutput<CameraCapabilities_Private>& callback); + + /// Captures a still JPEG image from the camera. + /// + /// Triggers an asynchronous image capture. The camera will initiate a series + /// of callbacks to the application as the image capture progresses. The + /// callbacks will be invoked in the order of shutter callback, preview + /// callback, and JPEG callback. The shutter callback occurs after the image + /// is captured. This can be used to trigger a sound to let the user know that + /// image has been captured. The preview callback occurs when a scaled, fully + /// processed preview image is available. The JPEG callback occurs when the + /// compressed image is available. If there is an error after the capture is + /// in progress, the error callback passed to <code> + /// ImageCapture_Private.Create()</code> will be invoked. All the callbacks + /// are invoked by the thread that calls this function. + /// + /// The size of the preview image in preview callback is determined by + /// <code>ImageCaptureConfig_Private.SetPreviewSize</code>. The format is + /// decided by the camera and can be got from <code>VideoFrame.GetFormat + /// </code>. The size of the JPEG image is determined by <code> + /// ImageCaptureConfig_Private.SetJpegSize</code>. + /// + /// The camera may need to stop and re-start streaming during image capture. + /// If some MediaStreamVideoTrack are associated with the camera source, they + /// will receive mute and unmute events. The mute event will be received + /// before all the callbacks. The unmute event will be received after all the + /// callbacks. The preview image will not be sent to the video tracks + /// associated with the camera. + /// + /// @param[in] shutter_callback A <code> + /// ImageCapture_Private_ShutterCallback</code> callback to indicate the + /// image has been taken. + /// @param[in] preview_callback A <code> + /// ImageCapture_Private_PreviewCallback</code> callback to return a + /// preview of the captured image. + /// @param[in] jpeg_callback A <code> + /// ImageCapture_Private_JpegCallback</code> callback to return captured + /// JPEG image. + /// @param[out] sequence_id The sequence ID is a unique monotonically + /// increasing value starting from 0, incremented every time a new request + /// like image capture is submitted. + /// + /// @return An int32_t containing a result code from <code>pp_errors.h</code>. + /// PP_OK means the callbacks will be triggered. Other values mean the + /// callbacks will not be triggered. + int32_t CaptureStillImage( + PPB_ImageCapture_Private_ShutterCallback shutter_callback, + PPB_ImageCapture_Private_PreviewCallback preview_callback, + PPB_ImageCapture_Private_JpegCallback jpeg_callback, + int64_t* sequence_id); + + /// Determines if a resource is an image capture resource. + /// + /// @param[in] resource The <code>Resource</code> to test. + /// + /// @return true if the given resource is an image capture resource or false + /// otherwise. + static bool IsImageCapture(const Resource& resource); +}; + +} // namespace pp + +#endif /* PPAPI_CPP_PRIVATE_IMAGE_CAPTURE_PRIVATE_H_ */ + diff --git a/chromium/ppapi/cpp/private/internal_module.cc b/chromium/ppapi/cpp/private/internal_module.cc new file mode 100644 index 00000000000..1615e877817 --- /dev/null +++ b/chromium/ppapi/cpp/private/internal_module.cc @@ -0,0 +1,21 @@ +// Copyright (c) 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ppapi/cpp/module.h" +#include "ppapi/cpp/private/internal_module.h" + +namespace pp { +namespace { +static Module* g_module_singleton = NULL; +} // namespace + +Module* Module::Get() { + return g_module_singleton; +} + +void InternalSetModuleSingleton(Module* module) { + g_module_singleton = module; +} + +} // namespace pp diff --git a/chromium/ppapi/cpp/private/internal_module.h b/chromium/ppapi/cpp/private/internal_module.h new file mode 100644 index 00000000000..5bc4191b42f --- /dev/null +++ b/chromium/ppapi/cpp/private/internal_module.h @@ -0,0 +1,16 @@ +// Copyright (c) 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_CPP_PRIVATE_INTERNAL_MODULE_H_ +#define PPAPI_CPP_PRIVATE_INTERNAL_MODULE_H_ + +namespace pp { +class Module; + +// Forcibly sets the value returned by pp::Module::Get(). Do not call this +// function except to support the trusted plugin or the remoting plugin! +void InternalSetModuleSingleton(Module* module); +} + +#endif // PPAPI_CPP_PRIVATE_INTERNAL_MODULE_H_ diff --git a/chromium/ppapi/cpp/private/video_source_private.h b/chromium/ppapi/cpp/private/video_source_private.h index 3d919bfd9ed..487703ed103 100644 --- a/chromium/ppapi/cpp/private/video_source_private.h +++ b/chromium/ppapi/cpp/private/video_source_private.h @@ -61,7 +61,8 @@ class VideoSource_Private : public Resource { int32_t Open(const Var& stream_url, const CompletionCallback& cc); - /// Gets a frame from the video source. + /// Gets a frame from the video source. The returned frame is only valid + /// until the next call to GetFrame. /// /// @param[out] frame A <code>VideoFrame_Private</code> to hold a video /// frame from the source. diff --git a/chromium/ppapi/cpp/video_decoder.cc b/chromium/ppapi/cpp/video_decoder.cc index 3277a213b2a..42236e42a2f 100644 --- a/chromium/ppapi/cpp/video_decoder.cc +++ b/chromium/ppapi/cpp/video_decoder.cc @@ -20,6 +20,49 @@ const char* interface_name<PPB_VideoDecoder_0_1>() { return PPB_VIDEODECODER_INTERFACE_0_1; } +template <> +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; +} + +// This struct is used to adapt CompletionCallbackWithOutput<PP_VideoPicture> to +// the pre-1.0 APIs, which return PP_VideoPicture_0_1. This struct is allocated +// on the heap, and deleted in CallbackConverter. +struct CallbackData_0_1 { + explicit CallbackData_0_1( + const CompletionCallbackWithOutput<PP_VideoPicture>& cc) + : original_picture(cc.output()), + original_callback(cc.pp_completion_callback()) {} + PP_VideoPicture_0_1 picture; + PP_VideoPicture* original_picture; + PP_CompletionCallback original_callback; +}; + +// Convert a 1.0 style callback to pre-1.0 callback. +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; + // Set visible_rect to the entire picture. + 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() { @@ -37,14 +80,28 @@ VideoDecoder::VideoDecoder(const VideoDecoder& other) : Resource(other) { int32_t VideoDecoder::Initialize(const Graphics3D& context, PP_VideoProfile profile, - bool allow_software_fallback, + 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, + cc.pp_completion_callback()); + } if (has_interface<PPB_VideoDecoder_0_1>()) { + if (acceleration == PP_HARDWAREACCELERATION_NONE) + return cc.MayForce(PP_ERROR_NOTSUPPORTED); return get_interface<PPB_VideoDecoder_0_1>()->Initialize( pp_resource(), context.pp_resource(), profile, - PP_FromBool(allow_software_fallback), + acceleration == PP_HARDWAREACCELERATION_WITHFALLBACK + ? PP_TRUE + : PP_FALSE, cc.pp_completion_callback()); } return cc.MayForce(PP_ERROR_NOINTERFACE); @@ -54,6 +111,14 @@ 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()); + } if (has_interface<PPB_VideoDecoder_0_1>()) { return get_interface<PPB_VideoDecoder_0_1>()->Decode( pp_resource(), decode_id, size, buffer, cc.pp_completion_callback()); @@ -63,21 +128,49 @@ 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(), &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_1>()) { + 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>()) { get_interface<PPB_VideoDecoder_0_1>()->RecyclePicture(pp_resource(), &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()); + } if (has_interface<PPB_VideoDecoder_0_1>()) { return get_interface<PPB_VideoDecoder_0_1>()->Flush( pp_resource(), cc.pp_completion_callback()); @@ -86,6 +179,14 @@ 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()); + } if (has_interface<PPB_VideoDecoder_0_1>()) { return get_interface<PPB_VideoDecoder_0_1>()->Reset( pp_resource(), cc.pp_completion_callback()); diff --git a/chromium/ppapi/cpp/video_decoder.h b/chromium/ppapi/cpp/video_decoder.h index c3a2a7c2fdb..60be572cf89 100644 --- a/chromium/ppapi/cpp/video_decoder.h +++ b/chromium/ppapi/cpp/video_decoder.h @@ -15,8 +15,6 @@ /// @file /// This file defines the API to create and use a VideoDecoder resource. -struct PP_FileInfo; - namespace pp { class InstanceHandle; @@ -61,14 +59,13 @@ class VideoDecoder : public Resource { /// Initializes a video decoder resource. This should be called after Create() /// and before any other functions. /// - /// @param[in] video_decoder A <code>PP_Resource</code> identifying the video - /// decoder. + /// @param[in] graphics3d_context A <code>PPB_Graphics3D</code> resource to + /// use during decoding. /// @param[in] profile A <code>PP_VideoProfile</code> specifying the video /// codec profile. - /// @param[in] allow_software_fallback A <code>PP_Bool</code> specifying - /// whether the decoder can fall back to software decoding if a suitable - /// hardware decoder isn't available. - /// @param[in] callback A <code>CompletionCallback</code> to be called on + /// @param[in] acceleration A <code>PP_HardwareAcceleration</code> specifying + /// whether to use a hardware accelerated or a software implementation. + /// @param[in] callback A <code>PP_CompletionCallback</code> to be called upon /// completion. /// /// @return An int32_t containing an error code from <code>pp_errors.h</code>. @@ -77,7 +74,7 @@ class VideoDecoder : public Resource { /// Initialize() again with different parameters to find a good configuration. int32_t Initialize(const Graphics3D& graphics3d_context, PP_VideoProfile profile, - bool allow_software_fallback, + PP_HardwareAcceleration acceleration, const CompletionCallback& callback); /// Decodes a bitstream buffer. Copies |size| bytes of data from the plugin's @@ -120,8 +117,6 @@ class VideoDecoder : public Resource { /// When the plugin is finished using the picture, it should return it to the /// system by calling RecyclePicture(). /// - /// @param[in] video_decoder A <code>PP_Resource</code> identifying the video - /// decoder. /// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be /// called on completion, and on success, to hold the picture descriptor. /// |