From fa1f14351809dd17dba1171be48952b292ff4fa3 Mon Sep 17 00:00:00 2001 From: jchuang Date: Fri, 20 Feb 2015 00:22:30 -0800 Subject: PPAPI: Rename PPB_ImageCapture_Private to PPB_CameraDevice_Private BUG=387547 TEST=Call the API from a trusted plugin. Review URL: https://codereview.chromium.org/929053003 Cr-Commit-Position: refs/heads/master@{#317271} --- ppapi/api/private/ppb_camera_device_private.idl | 96 +++++++++++++++++ ppapi/api/private/ppb_image_capture_private.idl | 96 ----------------- ppapi/c/private/ppb_camera_device_private.h | 118 ++++++++++++++++++++ ppapi/c/private/ppb_image_capture_private.h | 118 -------------------- ppapi/cpp/private/camera_device_private.cc | 87 +++++++++++++++ ppapi/cpp/private/camera_device_private.h | 103 ++++++++++++++++++ ppapi/cpp/private/image_capture_private.cc | 87 --------------- ppapi/cpp/private/image_capture_private.h | 103 ------------------ .../src/untrusted/pnacl_irt_shim/pnacl_shim.c | 92 ++++++++-------- ppapi/ppapi_proxy.gypi | 6 +- ppapi/ppapi_shared.gypi | 6 +- ppapi/ppapi_sources.gypi | 6 +- ppapi/proxy/BUILD.gn | 4 +- ppapi/proxy/camera_capabilities_resource.h | 2 - ppapi/proxy/camera_device_resource.cc | 120 +++++++++++++++++++++ ppapi/proxy/camera_device_resource.h | 67 ++++++++++++ ppapi/proxy/image_capture_resource.cc | 120 --------------------- ppapi/proxy/image_capture_resource.h | 68 ------------ ppapi/proxy/interface_list.cc | 2 +- ppapi/proxy/ppapi_messages.h | 14 +-- ppapi/proxy/resource_creation_proxy.cc | 12 +-- ppapi/proxy/resource_creation_proxy.h | 2 +- ppapi/shared_impl/resource.h | 2 +- ppapi/tests/all_c_includes.h | 2 +- ppapi/tests/all_cpp_includes.h | 2 +- ppapi/thunk/BUILD.gn | 4 +- ppapi/thunk/interfaces_ppb_private.h | 4 +- ppapi/thunk/ppb_camera_device_api.h | 33 ++++++ ppapi/thunk/ppb_camera_device_private_thunk.cc | 74 +++++++++++++ ppapi/thunk/ppb_image_capture_api.h | 33 ------ ppapi/thunk/ppb_image_capture_private_thunk.cc | 74 ------------- ppapi/thunk/resource_creation_api.h | 2 +- 32 files changed, 778 insertions(+), 781 deletions(-) create mode 100644 ppapi/api/private/ppb_camera_device_private.idl delete mode 100644 ppapi/api/private/ppb_image_capture_private.idl create mode 100644 ppapi/c/private/ppb_camera_device_private.h delete mode 100644 ppapi/c/private/ppb_image_capture_private.h create mode 100644 ppapi/cpp/private/camera_device_private.cc create mode 100644 ppapi/cpp/private/camera_device_private.h delete mode 100644 ppapi/cpp/private/image_capture_private.cc delete mode 100644 ppapi/cpp/private/image_capture_private.h create mode 100644 ppapi/proxy/camera_device_resource.cc create mode 100644 ppapi/proxy/camera_device_resource.h delete mode 100644 ppapi/proxy/image_capture_resource.cc delete mode 100644 ppapi/proxy/image_capture_resource.h create mode 100644 ppapi/thunk/ppb_camera_device_api.h create mode 100644 ppapi/thunk/ppb_camera_device_private_thunk.cc delete mode 100644 ppapi/thunk/ppb_image_capture_api.h delete mode 100644 ppapi/thunk/ppb_image_capture_private_thunk.cc (limited to 'ppapi') diff --git a/ppapi/api/private/ppb_camera_device_private.idl b/ppapi/api/private/ppb_camera_device_private.idl new file mode 100644 index 0000000..d87ac20 --- /dev/null +++ b/ppapi/api/private/ppb_camera_device_private.idl @@ -0,0 +1,96 @@ +/* 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. + */ + +/** + * Defines the PPB_CameraDevice_Private interface. Used for + * manipulating a camera device. + */ + +[generate_thunk] + +label Chrome { + M42 = 0.1 +}; + +/** + * To query camera capabilities: + * 1. Get a PPB_CameraDevice_Private object by Create(). + * 2. Open() camera device with track id of MediaStream video track. + * 3. Call GetCameraCapabilities() to get a + * PPB_CameraCapabilities_Private object, which can be used to + * query camera capabilities. + */ +interface PPB_CameraDevice_Private { + /** + * Creates a PPB_CameraDevice_Private resource. + * + * @param[in] instance A PP_Instance identifying one instance + * of a module. + * + * @return A PP_Resource corresponding to a + * PPB_CameraDevice_Private resource if successful, 0 if failed. + */ + PP_Resource Create([in] PP_Instance instance); + + /** + * Determines if a resource is a camera device resource. + * + * @param[in] resource The PP_Resource to test. + * + * @return A PP_Bool with PP_TRUE if the given + * resource is a camera device resource or PP_FALSE + * otherwise. + */ + PP_Bool IsCameraDevice([in] PP_Resource resource); + + /** + * Opens a camera device. + * + * @param[in] camera_device A PP_Resource corresponding to a + * camera device resource. + * @param[in] device_id A PP_Var identifying a camera device. The + * type is string. The ID can be obtained from MediaStreamTrack.getSources() + * or MediaStreamVideoTrack.id. + * @param[in] callback A PP_CompletionCallback to be called upon + * completion of Open(). + * + * @return An error code from pp_errors.h. + */ + int32_t Open( + [in] PP_Resource camera_device, + [in] PP_Var device_id, + [in] PP_CompletionCallback callback); + + /** + * Disconnects from the camera and cancels all pending requests. + * After this returns, no callbacks will be called. If + * PPB_CameraDevice_Private is destroyed and is not closed yet, this + * function will be automatically called. Calling this more than once has no + * effect. + * + * @param[in] camera_device A PP_Resource corresponding to a + * camera device resource. + */ + void Close([in] PP_Resource camera_device); + + /** + * Gets the camera capabilities. + * + * The camera capabilities do not change for a given camera source. + * + * @param[in] camera_device A PP_Resource corresponding to a + * camera device resource. + * @param[out] capabilities A PPB_CameraCapabilities_Private for + * storing the camera capabilities on success. Otherwise, the value will not + * be changed. + * @param[in] callback PP_CompletionCallback to be called upon + * completion of GetCameraCapabilities(). + * + * @return An int32_t containing a result code from pp_errors.h. + */ + int32_t GetCameraCapabilities([in] PP_Resource camera_device, + [out] PP_Resource capabilities, + [in] PP_CompletionCallback callback); +}; diff --git a/ppapi/api/private/ppb_image_capture_private.idl b/ppapi/api/private/ppb_image_capture_private.idl deleted file mode 100644 index 75c75d5..0000000 --- a/ppapi/api/private/ppb_image_capture_private.idl +++ /dev/null @@ -1,96 +0,0 @@ -/* 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. - */ - -/** - * Defines the PPB_ImageCapture_Private interface. Used for - * acquiring a single still image from a camera source. - */ - -[generate_thunk] - -label Chrome { - M42 = 0.1 -}; - -/** - * To query camera capabilities: - * 1. Get a PPB_ImageCapture_Private object by Create(). - * 2. Open() camera device with track id of MediaStream video track. - * 3. Call GetCameraCapabilities() to get a - * PPB_CameraCapabilities_Private object, which can be used to - * query camera capabilities. - */ -interface PPB_ImageCapture_Private { - /** - * Creates a PPB_ImageCapture_Private resource. - * - * @param[in] instance A PP_Instance identifying one instance - * of a module. - * - * @return A PP_Resource corresponding to a - * PPB_ImageCapture_Private resource if successful, 0 if failed. - */ - PP_Resource Create([in] PP_Instance instance); - - /** - * Determines if a resource is an image capture resource. - * - * @param[in] resource The PP_Resource to test. - * - * @return A PP_Bool with PP_TRUE if the given - * resource is an image capture resource or PP_FALSE - * otherwise. - */ - PP_Bool IsImageCapture([in] PP_Resource resource); - - /** - * Opens a video capture device. - * - * @param[in] image_capture A PP_Resource corresponding to an - * image capture resource. - * @param[in] device_id A PP_Var identifying a camera device. The - * type is string. The ID can be obtained from MediaStreamTrack.getSources() - * or MediaStreamVideoTrack.id. - * @param[in] callback A PP_CompletionCallback to be called upon - * completion of Open(). - * - * @return An error code from pp_errors.h. - */ - int32_t Open( - [in] PP_Resource image_capture, - [in] PP_Var device_id, - [in] PP_CompletionCallback callback); - - /** - * Disconnects from the camera and cancels all pending capture requests. - * After this returns, no callbacks will be called. If - * PPB_ImageCapture_Private is destroyed and is not closed yet, this - * function will be automatically called. Calling this more than once has no - * effect. - * - * @param[in] image_capture A PP_Resource corresponding to an - * image capture resource. - */ - void Close([in] PP_Resource image_capture); - - /** - * Gets the camera capabilities. - * - * The camera capabilities do not change for a given camera source. - * - * @param[in] image_capture A PP_Resource corresponding to an - * image capture resource. - * @param[out] capabilities A PPB_CameraCapabilities_Private for - * storing the image capture capabilities on success. Otherwise, the value - * will not be changed. - * @param[in] callback PP_CompletionCallback to be called upon - * completion of GetCameraCapabilities(). - * - * @return An int32_t containing a result code from pp_errors.h. - */ - int32_t GetCameraCapabilities([in] PP_Resource image_capture, - [out] PP_Resource capabilities, - [in] PP_CompletionCallback callback); -}; diff --git a/ppapi/c/private/ppb_camera_device_private.h b/ppapi/c/private/ppb_camera_device_private.h new file mode 100644 index 0000000..821ad299 --- /dev/null +++ b/ppapi/c/private/ppb_camera_device_private.h @@ -0,0 +1,118 @@ +/* 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. + */ + +/* From private/ppb_camera_device_private.idl, + * modified Fri Feb 20 13:48:52 2015. + */ + +#ifndef PPAPI_C_PRIVATE_PPB_CAMERA_DEVICE_PRIVATE_H_ +#define PPAPI_C_PRIVATE_PPB_CAMERA_DEVICE_PRIVATE_H_ + +#include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_completion_callback.h" +#include "ppapi/c/pp_instance.h" +#include "ppapi/c/pp_macros.h" +#include "ppapi/c/pp_resource.h" +#include "ppapi/c/pp_stdint.h" +#include "ppapi/c/pp_var.h" + +#define PPB_CAMERADEVICE_PRIVATE_INTERFACE_0_1 "PPB_CameraDevice_Private;0.1" +#define PPB_CAMERADEVICE_PRIVATE_INTERFACE \ + PPB_CAMERADEVICE_PRIVATE_INTERFACE_0_1 + +/** + * @file + * Defines the PPB_CameraDevice_Private interface. Used for + * manipulating a camera device. + */ + + +/** + * @addtogroup Interfaces + * @{ + */ +/** + * To query camera capabilities: + * 1. Get a PPB_CameraDevice_Private object by Create(). + * 2. Open() camera device with track id of MediaStream video track. + * 3. Call GetCameraCapabilities() to get a + * PPB_CameraCapabilities_Private object, which can be used to + * query camera capabilities. + */ +struct PPB_CameraDevice_Private_0_1 { + /** + * Creates a PPB_CameraDevice_Private resource. + * + * @param[in] instance A PP_Instance identifying one instance + * of a module. + * + * @return A PP_Resource corresponding to a + * PPB_CameraDevice_Private resource if successful, 0 if failed. + */ + PP_Resource (*Create)(PP_Instance instance); + /** + * Determines if a resource is a camera device resource. + * + * @param[in] resource The PP_Resource to test. + * + * @return A PP_Bool with PP_TRUE if the given + * resource is a camera device resource or PP_FALSE + * otherwise. + */ + PP_Bool (*IsCameraDevice)(PP_Resource resource); + /** + * Opens a camera device. + * + * @param[in] camera_device A PP_Resource corresponding to a + * camera device resource. + * @param[in] device_id A PP_Var identifying a camera device. The + * type is string. The ID can be obtained from MediaStreamTrack.getSources() + * or MediaStreamVideoTrack.id. + * @param[in] callback A PP_CompletionCallback to be called upon + * completion of Open(). + * + * @return An error code from pp_errors.h. + */ + int32_t (*Open)(PP_Resource camera_device, + struct PP_Var device_id, + struct PP_CompletionCallback callback); + /** + * Disconnects from the camera and cancels all pending requests. + * After this returns, no callbacks will be called. If + * PPB_CameraDevice_Private is destroyed and is not closed yet, this + * function will be automatically called. Calling this more than once has no + * effect. + * + * @param[in] camera_device A PP_Resource corresponding to a + * camera device resource. + */ + void (*Close)(PP_Resource camera_device); + /** + * Gets the camera capabilities. + * + * The camera capabilities do not change for a given camera source. + * + * @param[in] camera_device A PP_Resource corresponding to a + * camera device resource. + * @param[out] capabilities A PPB_CameraCapabilities_Private for + * storing the camera capabilities on success. Otherwise, the value will not + * be changed. + * @param[in] callback PP_CompletionCallback to be called upon + * completion of GetCameraCapabilities(). + * + * @return An int32_t containing a result code from pp_errors.h. + */ + int32_t (*GetCameraCapabilities)(PP_Resource camera_device, + PP_Resource* capabilities, + struct PP_CompletionCallback callback); +}; + +typedef struct PPB_CameraDevice_Private_0_1 PPB_CameraDevice_Private; +/** + * @} + */ + +#endif /* PPAPI_C_PRIVATE_PPB_CAMERA_DEVICE_PRIVATE_H_ */ + diff --git a/ppapi/c/private/ppb_image_capture_private.h b/ppapi/c/private/ppb_image_capture_private.h deleted file mode 100644 index 23dfdef..0000000 --- a/ppapi/c/private/ppb_image_capture_private.h +++ /dev/null @@ -1,118 +0,0 @@ -/* 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. - */ - -/* From private/ppb_image_capture_private.idl, - * modified Fri Feb 6 15:40:49 2015. - */ - -#ifndef PPAPI_C_PRIVATE_PPB_IMAGE_CAPTURE_PRIVATE_H_ -#define PPAPI_C_PRIVATE_PPB_IMAGE_CAPTURE_PRIVATE_H_ - -#include "ppapi/c/pp_bool.h" -#include "ppapi/c/pp_completion_callback.h" -#include "ppapi/c/pp_instance.h" -#include "ppapi/c/pp_macros.h" -#include "ppapi/c/pp_resource.h" -#include "ppapi/c/pp_stdint.h" -#include "ppapi/c/pp_var.h" - -#define PPB_IMAGECAPTURE_PRIVATE_INTERFACE_0_1 "PPB_ImageCapture_Private;0.1" -#define PPB_IMAGECAPTURE_PRIVATE_INTERFACE \ - PPB_IMAGECAPTURE_PRIVATE_INTERFACE_0_1 - -/** - * @file - * Defines the PPB_ImageCapture_Private interface. Used for - * acquiring a single still image from a camera source. - */ - - -/** - * @addtogroup Interfaces - * @{ - */ -/** - * To query camera capabilities: - * 1. Get a PPB_ImageCapture_Private object by Create(). - * 2. Open() camera device with track id of MediaStream video track. - * 3. Call GetCameraCapabilities() to get a - * PPB_CameraCapabilities_Private object, which can be used to - * query camera capabilities. - */ -struct PPB_ImageCapture_Private_0_1 { - /** - * Creates a PPB_ImageCapture_Private resource. - * - * @param[in] instance A PP_Instance identifying one instance - * of a module. - * - * @return A PP_Resource corresponding to a - * PPB_ImageCapture_Private resource if successful, 0 if failed. - */ - PP_Resource (*Create)(PP_Instance instance); - /** - * Determines if a resource is an image capture resource. - * - * @param[in] resource The PP_Resource to test. - * - * @return A PP_Bool with PP_TRUE if the given - * resource is an image capture resource or PP_FALSE - * otherwise. - */ - PP_Bool (*IsImageCapture)(PP_Resource resource); - /** - * Opens a video capture device. - * - * @param[in] image_capture A PP_Resource corresponding to an - * image capture resource. - * @param[in] device_id A PP_Var identifying a camera device. The - * type is string. The ID can be obtained from MediaStreamTrack.getSources() - * or MediaStreamVideoTrack.id. - * @param[in] callback A PP_CompletionCallback to be called upon - * completion of Open(). - * - * @return An error code from pp_errors.h. - */ - int32_t (*Open)(PP_Resource image_capture, - struct PP_Var device_id, - struct PP_CompletionCallback callback); - /** - * Disconnects from the camera and cancels all pending capture requests. - * After this returns, no callbacks will be called. If - * PPB_ImageCapture_Private is destroyed and is not closed yet, this - * function will be automatically called. Calling this more than once has no - * effect. - * - * @param[in] image_capture A PP_Resource corresponding to an - * image capture resource. - */ - void (*Close)(PP_Resource image_capture); - /** - * Gets the camera capabilities. - * - * The camera capabilities do not change for a given camera source. - * - * @param[in] image_capture A PP_Resource corresponding to an - * image capture resource. - * @param[out] capabilities A PPB_CameraCapabilities_Private for - * storing the image capture capabilities on success. Otherwise, the value - * will not be changed. - * @param[in] callback PP_CompletionCallback to be called upon - * completion of GetCameraCapabilities(). - * - * @return An int32_t containing a result code from pp_errors.h. - */ - int32_t (*GetCameraCapabilities)(PP_Resource image_capture, - PP_Resource* capabilities, - struct PP_CompletionCallback callback); -}; - -typedef struct PPB_ImageCapture_Private_0_1 PPB_ImageCapture_Private; -/** - * @} - */ - -#endif /* PPAPI_C_PRIVATE_PPB_IMAGE_CAPTURE_PRIVATE_H_ */ - diff --git a/ppapi/cpp/private/camera_device_private.cc b/ppapi/cpp/private/camera_device_private.cc new file mode 100644 index 0000000..1ca39f7 --- /dev/null +++ b/ppapi/cpp/private/camera_device_private.cc @@ -0,0 +1,87 @@ +// Copyright 2015 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/private/camera_device_private.h" + +#include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/cpp/completion_callback.h" +#include "ppapi/cpp/instance_handle.h" +#include "ppapi/cpp/module_impl.h" +#include "ppapi/cpp/private/camera_capabilities_private.h" + +namespace pp { + +namespace { + +template <> +const char* interface_name() { + return PPB_CAMERADEVICE_PRIVATE_INTERFACE_0_1; +} + +} // namespace + +CameraDevice_Private::CameraDevice_Private() { +} + +CameraDevice_Private::CameraDevice_Private(const CameraDevice_Private& other) + : Resource(other) { +} + +CameraDevice_Private::CameraDevice_Private(const Resource& resource) + : Resource(resource) { + PP_DCHECK(IsCameraDevice(resource)); +} + +CameraDevice_Private::CameraDevice_Private(const InstanceHandle& instance) { + if (has_interface()) { + PassRefFromConstructor( + get_interface()->Create( + instance.pp_instance())); + return; + } + PP_DCHECK(false); +} + +CameraDevice_Private::CameraDevice_Private(PassRef, PP_Resource resource) + : Resource(PASS_REF, resource) { +} + +CameraDevice_Private::~CameraDevice_Private() { +} + +int32_t CameraDevice_Private::Open(const Var& device_id, + const CompletionCallback& callback) { + if (!has_interface()) + return callback.MayForce(PP_ERROR_NOINTERFACE); + + return get_interface()->Open( + pp_resource(), device_id.pp_var(), callback.pp_completion_callback()); +} + +void CameraDevice_Private::Close() { + if (has_interface()) + get_interface()->Close(pp_resource()); +} + +int32_t CameraDevice_Private::GetCameraCapabilities( + const CompletionCallbackWithOutput& callback) { + if (!has_interface()) + return callback.MayForce(PP_ERROR_NOINTERFACE); + + return get_interface()->GetCameraCapabilities( + pp_resource(), callback.output(), callback.pp_completion_callback()); +} + +// static +bool CameraDevice_Private::IsCameraDevice(const Resource& resource) { + if (!has_interface()) + return false; + + return PP_ToBool( + get_interface()->IsCameraDevice( + resource.pp_resource())); +} + +} // namespace pp diff --git a/ppapi/cpp/private/camera_device_private.h b/ppapi/cpp/private/camera_device_private.h new file mode 100644 index 0000000..dce1e1b --- /dev/null +++ b/ppapi/cpp/private/camera_device_private.h @@ -0,0 +1,103 @@ +/* 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_DEVICE_PRIVATE_H_ +#define PPAPI_CPP_PRIVATE_CAMERA_DEVICE_PRIVATE_H_ + +#include "ppapi/c/private/ppb_camera_device_private.h" +#include "ppapi/cpp/resource.h" +#include "ppapi/cpp/var.h" + +/// @file +/// Defines the CameraDevice_Private interface. Used for +/// manipulating a camera device. +namespace pp { + +class CameraCapabilities_Private; +class CompletionCallback; +class InstanceHandle; + +template +class CompletionCallbackWithOutput; + +/// To query camera capabilities: +/// 1. Create a CameraDevice_Private object. +/// 2. Open() camera device with track id of MediaStream video track. +/// 3. Call GetCameraCapabilities() to get a +/// CameraCapabilities_Private object, which can be used to +/// query camera capabilities. +class CameraDevice_Private : public Resource { + public: + /// Default constructor for creating an is_null() + /// CameraDevice_Private object. + CameraDevice_Private(); + + /// The copy constructor for CameraDevice_Private. + /// + /// @param[in] other A reference to a CameraDevice_Private. + CameraDevice_Private(const CameraDevice_Private& other); + + /// Constructs a CameraDevice_Private from a + /// Resource. + /// + /// @param[in] resource A PPB_CameraDevice_Private resource. + explicit CameraDevice_Private(const Resource& resource); + + /// Constructs a CameraDevice_Private resource. + /// + /// @param[in] instance A PP_Instance identifying one instance + /// of a module. + explicit CameraDevice_Private(const InstanceHandle& instance); + + /// A constructor used when you have received a PP_Resource as a + /// return value that has had 1 ref added for you. + /// + /// @param[in] resource A PPB_CameraDevice_Private resource. + CameraDevice_Private(PassRef, PP_Resource resource); + + // Destructor. + ~CameraDevice_Private(); + + /// Opens a camera device. + /// + /// @param[in] device_id A Var identifying a camera + /// device. The type is string. The ID can be obtained from + /// MediaStreamTrack.getSources() or MediaStreamVideoTrack.id. + /// @param[in] callback A CompletionCallback to be called upon + /// completion of Open(). + /// + /// @return An int32_t containing a result code from pp_errors.h. + int32_t Open(const Var& device_id, const CompletionCallback& callback); + + /// Disconnects from the camera and cancels all pending requests. + /// After this returns, no callbacks will be called. If + /// CameraDevice_Private is destroyed and is not closed yet, this + /// function will be automatically called. Calling this more than once has no + /// effect. + void Close(); + + /// Gets the camera capabilities. + /// + /// The camera capabilities do not change for a given camera source. + /// + /// @param[in] callback A CompletionCallbackWithOutput + /// to be called upon completion. + /// + /// @return An int32_t containing a result code from pp_errors.h. + int32_t GetCameraCapabilities( + const CompletionCallbackWithOutput& callback); + + /// Determines if a resource is a camera device resource. + /// + /// @param[in] resource The Resource to test. + /// + /// @return true if the given resource is a camera device resource or false + /// otherwise. + static bool IsCameraDevice(const Resource& resource); +}; + +} // namespace pp + +#endif /* PPAPI_CPP_PRIVATE_CAMERA_DEVICE_PRIVATE_H_ */ diff --git a/ppapi/cpp/private/image_capture_private.cc b/ppapi/cpp/private/image_capture_private.cc deleted file mode 100644 index 539f8a3..0000000 --- a/ppapi/cpp/private/image_capture_private.cc +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2015 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/private/image_capture_private.h" - -#include "ppapi/c/pp_bool.h" -#include "ppapi/c/pp_errors.h" -#include "ppapi/cpp/completion_callback.h" -#include "ppapi/cpp/instance_handle.h" -#include "ppapi/cpp/module_impl.h" -#include "ppapi/cpp/private/camera_capabilities_private.h" - -namespace pp { - -namespace { - -template <> -const char* interface_name() { - return PPB_IMAGECAPTURE_PRIVATE_INTERFACE_0_1; -} - -} // namespace - -ImageCapture_Private::ImageCapture_Private() { -} - -ImageCapture_Private::ImageCapture_Private(const ImageCapture_Private& other) - : Resource(other) { -} - -ImageCapture_Private::ImageCapture_Private(const Resource& resource) - : Resource(resource) { - PP_DCHECK(IsImageCapture(resource)); -} - -ImageCapture_Private::ImageCapture_Private(const InstanceHandle& instance) { - if (has_interface()) { - PassRefFromConstructor( - get_interface()->Create( - instance.pp_instance())); - return; - } - PP_DCHECK(false); -} - -ImageCapture_Private::ImageCapture_Private(PassRef, PP_Resource resource) - : Resource(PASS_REF, resource) { -} - -ImageCapture_Private::~ImageCapture_Private() { -} - -int32_t ImageCapture_Private::Open(const Var& device_id, - const CompletionCallback& callback) { - if (!has_interface()) - return callback.MayForce(PP_ERROR_NOINTERFACE); - - return get_interface()->Open( - pp_resource(), device_id.pp_var(), callback.pp_completion_callback()); -} - -void ImageCapture_Private::Close() { - if (has_interface()) - get_interface()->Close(pp_resource()); -} - -int32_t ImageCapture_Private::GetCameraCapabilities( - const CompletionCallbackWithOutput& callback) { - if (!has_interface()) - return callback.MayForce(PP_ERROR_NOINTERFACE); - - return get_interface()->GetCameraCapabilities( - pp_resource(), callback.output(), callback.pp_completion_callback()); -} - -// static -bool ImageCapture_Private::IsImageCapture(const Resource& resource) { - if (!has_interface()) - return false; - - return PP_ToBool( - get_interface()->IsImageCapture( - resource.pp_resource())); -} - -} // namespace pp diff --git a/ppapi/cpp/private/image_capture_private.h b/ppapi/cpp/private/image_capture_private.h deleted file mode 100644 index 98382a2..0000000 --- a/ppapi/cpp/private/image_capture_private.h +++ /dev/null @@ -1,103 +0,0 @@ -/* 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/resource.h" -#include "ppapi/cpp/var.h" - -/// @file -/// Defines the ImageCapture_Private interface. Used for -/// acquiring a single still image from a camera source. -namespace pp { - -class CameraCapabilities_Private; -class CompletionCallback; -class InstanceHandle; - -template -class CompletionCallbackWithOutput; - -/// To query camera capabilities: -/// 1. Create an ImageCapture_Private object. -/// 2. Open() camera device with track id of MediaStream video track. -/// 3. Call GetCameraCapabilities() to get a -/// CameraCapabilities_Private object, which can be used to -/// query camera capabilities. -class ImageCapture_Private : public Resource { - public: - /// Default constructor for creating an is_null() - /// ImageCapture_Private object. - ImageCapture_Private(); - - /// The copy constructor for ImageCapture_Private. - /// - /// @param[in] other A reference to a ImageCapture_Private. - ImageCapture_Private(const ImageCapture_Private& other); - - /// Constructs an ImageCapture_Private from - /// a Resource. - /// - /// @param[in] resource A PPB_ImageCapture_Private resource. - explicit ImageCapture_Private(const Resource& resource); - - /// Constructs an ImageCapture_Private resource. - /// - /// @param[in] instance A PP_Instance identifying one instance - /// of a module. - explicit ImageCapture_Private(const InstanceHandle& instance); - - /// A constructor used when you have received a PP_Resource as a - /// return value that has had 1 ref added for you. - /// - /// @param[in] resource A PPB_ImageCapture_Private resource. - ImageCapture_Private(PassRef, PP_Resource resource); - - // Destructor. - ~ImageCapture_Private(); - - /// Opens a video capture device. - /// - /// @param[in] device_id A Var identifying a camera - /// device. The type is string. The ID can be obtained from - /// MediaStreamTrack.getSources() or MediaStreamVideoTrack.id. - /// @param[in] callback A CompletionCallback to be called upon - /// completion of Open(). - /// - /// @return An int32_t containing a result code from pp_errors.h. - int32_t Open(const Var& device_id, const CompletionCallback& callback); - - /// Disconnects from the camera and cancels all pending capture requests. - /// After this returns, no callbacks will be called. If - /// ImageCapture_Private is destroyed and is not closed yet, this - /// function will be automatically called. Calling this more than once has no - /// effect. - void Close(); - - /// Gets the camera capabilities. - /// - /// The camera capabilities do not change for a given camera source. - /// - /// @param[in] callback A CompletionCallbackWithOutput - /// to be called upon completion. - /// - /// @return An int32_t containing a result code from pp_errors.h. - int32_t GetCameraCapabilities( - const CompletionCallbackWithOutput& callback); - - /// Determines if a resource is an image capture resource. - /// - /// @param[in] resource The Resource 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/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c index b47a250..1ceec96 100644 --- a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c +++ b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c @@ -53,6 +53,7 @@ #include "ppapi/c/ppb_video_encoder.h" #include "ppapi/c/ppb_websocket.h" #include "ppapi/c/ppp_messaging.h" +#include "ppapi/c/private/ppb_camera_device_private.h" #include "ppapi/c/private/ppb_content_decryptor_private.h" #include "ppapi/c/private/ppb_display_color_profile_private.h" #include "ppapi/c/private/ppb_ext_crx_file_system_private.h" @@ -64,7 +65,6 @@ #include "ppapi/c/private/ppb_flash_drm.h" #include "ppapi/c/private/ppb_flash_menu.h" #include "ppapi/c/private/ppb_host_resolver_private.h" -#include "ppapi/c/private/ppb_image_capture_private.h" #include "ppapi/c/private/ppb_instance_private.h" #include "ppapi/c/private/ppb_isolated_file_system_private.h" #include "ppapi/c/private/ppb_net_address_private.h" @@ -166,6 +166,7 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_7; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoCapture_Dev_0_3; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoDecoder_Dev_0_16; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_Selection_Dev_0_3; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_CameraDevice_Private_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_13; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_DisplayColorProfile_Private_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Ext_CrxFileSystem_Private_0_1; @@ -183,7 +184,6 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Flash_DRM_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Flash_DRM_1_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Flash_Menu_0_2; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_HostResolver_Private_0_1; -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_ImageCapture_Private_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Instance_Private_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_IsolatedFileSystem_Private_0_2; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetAddress_Private_0_1; @@ -2946,6 +2946,35 @@ static struct PP_Var Pnacl_M13_PPP_Selection_Dev_GetSelectedText(PP_Instance ins /* Not generating wrapper methods for PPB_CameraCapabilities_Private_0_1 */ +/* Begin wrapper methods for PPB_CameraDevice_Private_0_1 */ + +static PP_Resource Pnacl_M42_PPB_CameraDevice_Private_Create(PP_Instance instance) { + const struct PPB_CameraDevice_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_CameraDevice_Private_0_1.real_iface; + return iface->Create(instance); +} + +static PP_Bool Pnacl_M42_PPB_CameraDevice_Private_IsCameraDevice(PP_Resource resource) { + const struct PPB_CameraDevice_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_CameraDevice_Private_0_1.real_iface; + return iface->IsCameraDevice(resource); +} + +static int32_t Pnacl_M42_PPB_CameraDevice_Private_Open(PP_Resource camera_device, struct PP_Var* device_id, struct PP_CompletionCallback* callback) { + const struct PPB_CameraDevice_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_CameraDevice_Private_0_1.real_iface; + return iface->Open(camera_device, *device_id, *callback); +} + +static void Pnacl_M42_PPB_CameraDevice_Private_Close(PP_Resource camera_device) { + const struct PPB_CameraDevice_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_CameraDevice_Private_0_1.real_iface; + iface->Close(camera_device); +} + +static int32_t Pnacl_M42_PPB_CameraDevice_Private_GetCameraCapabilities(PP_Resource camera_device, PP_Resource* capabilities, struct PP_CompletionCallback* callback) { + const struct PPB_CameraDevice_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_CameraDevice_Private_0_1.real_iface; + return iface->GetCameraCapabilities(camera_device, capabilities, *callback); +} + +/* End wrapper methods for PPB_CameraDevice_Private_0_1 */ + /* Begin wrapper methods for PPB_ContentDecryptor_Private_0_13 */ static void Pnacl_M41_PPB_ContentDecryptor_Private_PromiseResolved(PP_Instance instance, uint32_t promise_id) { @@ -3591,35 +3620,6 @@ static PP_Bool Pnacl_M19_PPB_HostResolver_Private_GetNetAddress(PP_Resource host /* End wrapper methods for PPB_HostResolver_Private_0_1 */ -/* Begin wrapper methods for PPB_ImageCapture_Private_0_1 */ - -static PP_Resource Pnacl_M42_PPB_ImageCapture_Private_Create(PP_Instance instance) { - const struct PPB_ImageCapture_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_ImageCapture_Private_0_1.real_iface; - return iface->Create(instance); -} - -static PP_Bool Pnacl_M42_PPB_ImageCapture_Private_IsImageCapture(PP_Resource resource) { - const struct PPB_ImageCapture_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_ImageCapture_Private_0_1.real_iface; - return iface->IsImageCapture(resource); -} - -static int32_t Pnacl_M42_PPB_ImageCapture_Private_Open(PP_Resource image_capture, struct PP_Var* device_id, struct PP_CompletionCallback* callback) { - const struct PPB_ImageCapture_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_ImageCapture_Private_0_1.real_iface; - return iface->Open(image_capture, *device_id, *callback); -} - -static void Pnacl_M42_PPB_ImageCapture_Private_Close(PP_Resource image_capture) { - const struct PPB_ImageCapture_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_ImageCapture_Private_0_1.real_iface; - iface->Close(image_capture); -} - -static int32_t Pnacl_M42_PPB_ImageCapture_Private_GetCameraCapabilities(PP_Resource image_capture, PP_Resource* capabilities, struct PP_CompletionCallback* callback) { - const struct PPB_ImageCapture_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_ImageCapture_Private_0_1.real_iface; - return iface->GetCameraCapabilities(image_capture, capabilities, *callback); -} - -/* End wrapper methods for PPB_ImageCapture_Private_0_1 */ - /* Not generating wrapper methods for PPB_InputEvent_Private_0_1 */ /* Begin wrapper methods for PPB_Instance_Private_0_1 */ @@ -5319,6 +5319,14 @@ static const struct PPP_Selection_Dev_0_3 Pnacl_Wrappers_PPP_Selection_Dev_0_3 = /* Not generating wrapper interface for PPB_CameraCapabilities_Private_0_1 */ +static const struct PPB_CameraDevice_Private_0_1 Pnacl_Wrappers_PPB_CameraDevice_Private_0_1 = { + .Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M42_PPB_CameraDevice_Private_Create, + .IsCameraDevice = (PP_Bool (*)(PP_Resource resource))&Pnacl_M42_PPB_CameraDevice_Private_IsCameraDevice, + .Open = (int32_t (*)(PP_Resource camera_device, struct PP_Var device_id, struct PP_CompletionCallback callback))&Pnacl_M42_PPB_CameraDevice_Private_Open, + .Close = (void (*)(PP_Resource camera_device))&Pnacl_M42_PPB_CameraDevice_Private_Close, + .GetCameraCapabilities = (int32_t (*)(PP_Resource camera_device, PP_Resource* capabilities, struct PP_CompletionCallback callback))&Pnacl_M42_PPB_CameraDevice_Private_GetCameraCapabilities +}; + static const struct PPB_ContentDecryptor_Private_0_13 Pnacl_Wrappers_PPB_ContentDecryptor_Private_0_13 = { .PromiseResolved = (void (*)(PP_Instance instance, uint32_t promise_id))&Pnacl_M41_PPB_ContentDecryptor_Private_PromiseResolved, .PromiseResolvedWithSession = (void (*)(PP_Instance instance, uint32_t promise_id, struct PP_Var session_id))&Pnacl_M41_PPB_ContentDecryptor_Private_PromiseResolvedWithSession, @@ -5495,14 +5503,6 @@ static const struct PPB_HostResolver_Private_0_1 Pnacl_Wrappers_PPB_HostResolver .GetNetAddress = (PP_Bool (*)(PP_Resource host_resolver, uint32_t index, struct PP_NetAddress_Private* addr))&Pnacl_M19_PPB_HostResolver_Private_GetNetAddress }; -static const struct PPB_ImageCapture_Private_0_1 Pnacl_Wrappers_PPB_ImageCapture_Private_0_1 = { - .Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M42_PPB_ImageCapture_Private_Create, - .IsImageCapture = (PP_Bool (*)(PP_Resource resource))&Pnacl_M42_PPB_ImageCapture_Private_IsImageCapture, - .Open = (int32_t (*)(PP_Resource image_capture, struct PP_Var device_id, struct PP_CompletionCallback callback))&Pnacl_M42_PPB_ImageCapture_Private_Open, - .Close = (void (*)(PP_Resource image_capture))&Pnacl_M42_PPB_ImageCapture_Private_Close, - .GetCameraCapabilities = (int32_t (*)(PP_Resource image_capture, PP_Resource* capabilities, struct PP_CompletionCallback callback))&Pnacl_M42_PPB_ImageCapture_Private_GetCameraCapabilities -}; - /* Not generating wrapper interface for PPB_InputEvent_Private_0_1 */ static const struct PPB_Instance_Private_0_1 Pnacl_Wrappers_PPB_Instance_Private_0_1 = { @@ -6160,6 +6160,12 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_Selection_Dev_0_3 = { .real_iface = NULL }; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_CameraDevice_Private_0_1 = { + .iface_macro = PPB_CAMERADEVICE_PRIVATE_INTERFACE_0_1, + .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_CameraDevice_Private_0_1, + .real_iface = NULL +}; + static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_13 = { .iface_macro = PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_13, .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_ContentDecryptor_Private_0_13, @@ -6262,12 +6268,6 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_HostResolver_Private_0_1 .real_iface = NULL }; -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_ImageCapture_Private_0_1 = { - .iface_macro = PPB_IMAGECAPTURE_PRIVATE_INTERFACE_0_1, - .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_ImageCapture_Private_0_1, - .real_iface = NULL -}; - static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Instance_Private_0_1 = { .iface_macro = PPB_INSTANCE_PRIVATE_INTERFACE_0_1, .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_Instance_Private_0_1, @@ -6481,6 +6481,7 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = { &Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_7, &Pnacl_WrapperInfo_PPB_VideoCapture_Dev_0_3, &Pnacl_WrapperInfo_PPB_VideoDecoder_Dev_0_16, + &Pnacl_WrapperInfo_PPB_CameraDevice_Private_0_1, &Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_13, &Pnacl_WrapperInfo_PPB_DisplayColorProfile_Private_0_1, &Pnacl_WrapperInfo_PPB_Ext_CrxFileSystem_Private_0_1, @@ -6498,7 +6499,6 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = { &Pnacl_WrapperInfo_PPB_Flash_DRM_1_1, &Pnacl_WrapperInfo_PPB_Flash_Menu_0_2, &Pnacl_WrapperInfo_PPB_HostResolver_Private_0_1, - &Pnacl_WrapperInfo_PPB_ImageCapture_Private_0_1, &Pnacl_WrapperInfo_PPB_Instance_Private_0_1, &Pnacl_WrapperInfo_PPB_IsolatedFileSystem_Private_0_2, &Pnacl_WrapperInfo_PPB_NetAddress_Private_0_1, diff --git a/ppapi/ppapi_proxy.gypi b/ppapi/ppapi_proxy.gypi index c5bebdd..7a7f0cd 100644 --- a/ppapi/ppapi_proxy.gypi +++ b/ppapi/ppapi_proxy.gypi @@ -31,6 +31,8 @@ 'proxy/browser_font_singleton_resource.h', 'proxy/camera_capabilities_resource.cc', 'proxy/camera_capabilities_resource.h', + 'proxy/camera_device_resource.cc', + 'proxy/camera_device_resource.h', 'proxy/compositor_layer_resource.cc', 'proxy/compositor_layer_resource.h', 'proxy/compositor_resource.cc', @@ -83,8 +85,6 @@ 'proxy/host_resolver_resource_base.h', 'proxy/host_var_serialization_rules.cc', 'proxy/host_var_serialization_rules.h', - 'proxy/image_capture_resource.cc', - 'proxy/image_capture_resource.h', 'proxy/interface_list.cc', 'proxy/interface_list.h', 'proxy/interface_proxy.cc', @@ -273,6 +273,7 @@ 'proxy/broker_dispatcher.cc', 'proxy/browser_font_singleton_resource.cc', 'proxy/camera_capabilities_resource.cc', + 'proxy/camera_device_resource.cc', 'proxy/device_enumeration_resource_helper.cc', 'proxy/flash_clipboard_resource.cc', 'proxy/flash_drm_resource.cc', @@ -283,7 +284,6 @@ 'proxy/flash_resource.cc', 'proxy/host_dispatcher.cc', 'proxy/host_var_serialization_rules.cc', - 'proxy/image_capture_resource.cc', 'proxy/pdf_resource.cc', 'proxy/platform_verification_private_resource.cc', 'proxy/platform_verification_private_resource.h', diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi index fb359fe..974ba01 100644 --- a/ppapi/ppapi_shared.gypi +++ b/ppapi/ppapi_shared.gypi @@ -158,6 +158,8 @@ 'thunk/ppb_buffer_thunk.cc', 'thunk/ppb_camera_capabilities_api.h', 'thunk/ppb_camera_capabilities_private_thunk.cc', + 'thunk/ppb_camera_device_api.h', + 'thunk/ppb_camera_device_private_thunk.cc', 'thunk/ppb_char_set_thunk.cc', 'thunk/ppb_compositor_api.h', 'thunk/ppb_compositor_layer_api.h', @@ -211,8 +213,6 @@ 'thunk/ppb_host_resolver_private_api.h', 'thunk/ppb_host_resolver_private_thunk.cc', 'thunk/ppb_host_resolver_thunk.cc', - 'thunk/ppb_image_capture_api.h', - 'thunk/ppb_image_capture_private_thunk.cc', 'thunk/ppb_image_data_api.h', 'thunk/ppb_image_data_thunk.cc', 'thunk/ppb_input_event_api.h', @@ -324,6 +324,7 @@ 'thunk/ppb_browser_font_trusted_thunk.cc', 'thunk/ppb_buffer_thunk.cc', 'thunk/ppb_camera_capabilities_private_thunk.cc', + 'thunk/ppb_camera_device_private_thunk.cc', 'thunk/ppb_char_set_thunk.cc', 'thunk/ppb_content_decryptor_private_thunk.cc', 'thunk/ppb_flash_clipboard_thunk.cc', @@ -338,7 +339,6 @@ 'thunk/ppb_flash_message_loop_thunk.cc', 'thunk/ppb_flash_thunk.cc', 'thunk/ppb_gles_chromium_texture_mapping_thunk.cc', - 'thunk/ppb_image_capture_private_thunk.cc', 'thunk/ppb_pdf_thunk.cc', 'thunk/ppb_platform_verification_private_thunk.cc', 'thunk/ppb_scrollbar_thunk.cc', diff --git a/ppapi/ppapi_sources.gypi b/ppapi/ppapi_sources.gypi index c3c709e..e182b05 100644 --- a/ppapi/ppapi_sources.gypi +++ b/ppapi/ppapi_sources.gypi @@ -107,6 +107,7 @@ 'c/private/pp_private_font_charset.h', 'c/private/pp_video_frame_private.h', 'c/private/ppb_camera_capabilities_private.h', + 'c/private/ppb_camera_device_private.h', 'c/private/ppb_content_decryptor_private.h', 'c/private/ppb_ext_crx_file_system_private.h', 'c/private/ppb_find_private.h', @@ -118,7 +119,6 @@ 'c/private/ppb_flash_menu.h', 'c/private/ppb_flash_message_loop.h', 'c/private/ppb_host_resolver_private.h', - 'c/private/ppb_image_capture_private.h', 'c/private/ppb_input_event_private.h', 'c/private/ppb_instance_private.h', 'c/private/ppb_isolated_file_system_private.h', @@ -310,6 +310,8 @@ # Private interfaces. 'cpp/private/camera_capabilities_private.cc', 'cpp/private/camera_capabilities_private.h', + 'cpp/private/camera_device_private.cc', + 'cpp/private/camera_device_private.h', 'cpp/private/content_decryptor_private.cc', 'cpp/private/content_decryptor_private.h', 'cpp/private/ext_crx_file_system_private.cc', @@ -338,8 +340,6 @@ 'cpp/private/flash_message_loop.h', 'cpp/private/host_resolver_private.cc', 'cpp/private/host_resolver_private.h', - 'cpp/private/image_capture_private.cc', - 'cpp/private/image_capture_private.h', 'cpp/private/input_event_private.cc', 'cpp/private/input_event_private.h', 'cpp/private/instance_private.cc', diff --git a/ppapi/proxy/BUILD.gn b/ppapi/proxy/BUILD.gn index c9019ca..f6b7a6d 100644 --- a/ppapi/proxy/BUILD.gn +++ b/ppapi/proxy/BUILD.gn @@ -214,6 +214,8 @@ component("proxy") { "browser_font_singleton_resource.h", "camera_capabilities_resource.cc", "camera_capabilities_resource.h", + "camera_device_resource.cc", + "camera_device_resource.h", "device_enumeration_resource_helper.cc", "device_enumeration_resource_helper.h", "flash_clipboard_resource.cc", @@ -234,8 +236,6 @@ component("proxy") { "host_dispatcher.h", "host_var_serialization_rules.cc", "host_var_serialization_rules.h", - "image_capture_resource.cc", - "image_capture_resource.h", "pdf_resource.cc", "pdf_resource.h", "platform_verification_private_resource.cc", diff --git a/ppapi/proxy/camera_capabilities_resource.h b/ppapi/proxy/camera_capabilities_resource.h index 1430500..82e8df8 100644 --- a/ppapi/proxy/camera_capabilities_resource.h +++ b/ppapi/proxy/camera_capabilities_resource.h @@ -16,8 +16,6 @@ namespace ppapi { namespace proxy { -class ImageCaptureResource; - class PPAPI_PROXY_EXPORT CameraCapabilitiesResource : public Resource, public thunk::PPB_CameraCapabilities_API { diff --git a/ppapi/proxy/camera_device_resource.cc b/ppapi/proxy/camera_device_resource.cc new file mode 100644 index 0000000..1ec5af2 --- /dev/null +++ b/ppapi/proxy/camera_device_resource.cc @@ -0,0 +1,120 @@ +// Copyright 2015 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/proxy/camera_device_resource.h" + +#include "ppapi/proxy/camera_capabilities_resource.h" +#include "ppapi/proxy/plugin_resource_tracker.h" +#include "ppapi/proxy/ppapi_messages.h" +#include "ppapi/shared_impl/var.h" + +namespace ppapi { +namespace proxy { + +CameraDeviceResource::CameraDeviceResource(Connection connection, + PP_Instance instance) + : PluginResource(connection, instance), + open_state_(OpenState::BEFORE_OPEN) { + SendCreate(RENDERER, PpapiHostMsg_CameraDevice_Create()); +} + +CameraDeviceResource::~CameraDeviceResource() { +} + +int32_t CameraDeviceResource::Open( + PP_Var device_id, + const scoped_refptr& callback) { + if (open_state_ != OpenState::BEFORE_OPEN) + return PP_ERROR_FAILED; + + if (TrackedCallback::IsPending(open_callback_)) + return PP_ERROR_INPROGRESS; + + scoped_refptr source_string_var(StringVar::FromPPVar(device_id)); + if (!source_string_var || source_string_var->value().empty()) + return PP_ERROR_BADARGUMENT; + + open_callback_ = callback; + + Call( + RENDERER, PpapiHostMsg_CameraDevice_Open(source_string_var->value()), + base::Bind(&CameraDeviceResource::OnPluginMsgOpenReply, + base::Unretained(this))); + return PP_OK_COMPLETIONPENDING; +} + +void CameraDeviceResource::Close() { + if (open_state_ == OpenState::CLOSED) + return; + + if (TrackedCallback::IsPending(open_callback_)) { + open_callback_->PostAbort(); + open_callback_ = nullptr; + } + + if (TrackedCallback::IsPending(get_capabilities_callback_)) { + get_capabilities_callback_->PostAbort(); + get_capabilities_callback_ = nullptr; + } + + Post(RENDERER, PpapiHostMsg_CameraDevice_Close()); + + open_state_ = OpenState::CLOSED; +} + +int32_t CameraDeviceResource::GetCameraCapabilities( + PP_Resource* capabilities, + const scoped_refptr& callback) { + if (!is_opened()) + return PP_ERROR_FAILED; + + if (TrackedCallback::IsPending(get_capabilities_callback_)) + return PP_ERROR_INPROGRESS; + + if (camera_capabilities_.get()) { + *capabilities = camera_capabilities_->GetReference(); + return PP_OK; + } + + get_capabilities_callback_ = callback; + Call( + RENDERER, PpapiHostMsg_CameraDevice_GetSupportedVideoCaptureFormats(), + base::Bind(&CameraDeviceResource::OnPluginMsgGetVideoCaptureFormatsReply, + base::Unretained(this), capabilities)); + + return PP_OK_COMPLETIONPENDING; +} + +void CameraDeviceResource::OnPluginMsgOpenReply( + const ResourceMessageReplyParams& params) { + // The callback may have been aborted by Close(). + if (TrackedCallback::IsPending(open_callback_)) { + if (open_state_ == OpenState::BEFORE_OPEN && params.result() == PP_OK) + open_state_ = OpenState::OPENED; + + open_callback_->Run(params.result()); + } +} + +void CameraDeviceResource::OnPluginMsgGetVideoCaptureFormatsReply( + PP_Resource* capabilities_output, + const ResourceMessageReplyParams& params, + const std::vector& formats) { + if (!TrackedCallback::IsPending(get_capabilities_callback_)) + return; + + // Return camera capabilities. + int32_t result = params.result(); + scoped_refptr callback; + callback.swap(get_capabilities_callback_); + if (result == PP_OK) { + camera_capabilities_ = + new CameraCapabilitiesResource(pp_instance(), formats); + *capabilities_output = camera_capabilities_->GetReference(); + } + callback->Run(result == PP_OK ? PP_OK : PP_ERROR_FAILED); +} + +} // namespace proxy +} // namespace ppapi diff --git a/ppapi/proxy/camera_device_resource.h b/ppapi/proxy/camera_device_resource.h new file mode 100644 index 0000000..93878fe --- /dev/null +++ b/ppapi/proxy/camera_device_resource.h @@ -0,0 +1,67 @@ +// Copyright 2015 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_PROXY_CAMERA_DEVICE_RESOURCE_H_ +#define PPAPI_PROXY_CAMERA_DEVICE_RESOURCE_H_ + +#include "base/basictypes.h" +#include "ppapi/c/pp_size.h" +#include "ppapi/c/private/pp_video_capture_format.h" +#include "ppapi/proxy/connection.h" +#include "ppapi/proxy/plugin_resource.h" +#include "ppapi/proxy/ppapi_proxy_export.h" +#include "ppapi/shared_impl/resource.h" +#include "ppapi/thunk/ppb_camera_device_api.h" + +namespace ppapi { +namespace proxy { + +class CameraCapabilitiesResource; + +class PPAPI_PROXY_EXPORT CameraDeviceResource + : public PluginResource, + public thunk::PPB_CameraDevice_API { + public: + CameraDeviceResource(Connection connection, PP_Instance instance); + ~CameraDeviceResource() override; + + // Resource overrides: + thunk::PPB_CameraDevice_API* AsPPB_CameraDevice_API() override { + return this; + } + + // PPB_CameraDevice_API implementation. + int32_t Open(PP_Var device_id, + const scoped_refptr& callback) override; + void Close() override; + int32_t GetCameraCapabilities( + PP_Resource* capabilities, + const scoped_refptr& callback) override; + + private: + enum class OpenState { BEFORE_OPEN, OPENED, CLOSED }; + + void OnPluginMsgGetVideoCaptureFormatsReply( + PP_Resource* capabilities_output, + const ResourceMessageReplyParams& params, + const std::vector& formats); + + void OnPluginMsgOpenReply(const ResourceMessageReplyParams& params); + + bool is_opened() const { return open_state_ == OpenState::OPENED; } + + // Holds a reference of the callback so that Close() can cancel it. + scoped_refptr open_callback_; + OpenState open_state_; + + scoped_refptr get_capabilities_callback_; + scoped_refptr camera_capabilities_; + + DISALLOW_COPY_AND_ASSIGN(CameraDeviceResource); +}; + +} // namespace proxy +} // namespace ppapi + +#endif // PPAPI_PROXY_CAMERA_DEVICE_RESOURCE_H_ diff --git a/ppapi/proxy/image_capture_resource.cc b/ppapi/proxy/image_capture_resource.cc deleted file mode 100644 index 9cf2cda..0000000 --- a/ppapi/proxy/image_capture_resource.cc +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright 2015 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/proxy/image_capture_resource.h" - -#include "ppapi/proxy/camera_capabilities_resource.h" -#include "ppapi/proxy/plugin_resource_tracker.h" -#include "ppapi/proxy/ppapi_messages.h" -#include "ppapi/shared_impl/var.h" - -namespace ppapi { -namespace proxy { - -ImageCaptureResource::ImageCaptureResource(Connection connection, - PP_Instance instance) - : PluginResource(connection, instance), - open_state_(OpenState::BEFORE_OPEN) { - SendCreate(RENDERER, PpapiHostMsg_ImageCapture_Create()); -} - -ImageCaptureResource::~ImageCaptureResource() { -} - -int32_t ImageCaptureResource::Open( - PP_Var device_id, - const scoped_refptr& callback) { - if (open_state_ != OpenState::BEFORE_OPEN) - return PP_ERROR_FAILED; - - if (TrackedCallback::IsPending(open_callback_)) - return PP_ERROR_INPROGRESS; - - scoped_refptr source_string_var(StringVar::FromPPVar(device_id)); - if (!source_string_var || source_string_var->value().empty()) - return PP_ERROR_BADARGUMENT; - - open_callback_ = callback; - - Call( - RENDERER, PpapiHostMsg_ImageCapture_Open(source_string_var->value()), - base::Bind(&ImageCaptureResource::OnPluginMsgOpenReply, - base::Unretained(this))); - return PP_OK_COMPLETIONPENDING; -} - -void ImageCaptureResource::Close() { - if (open_state_ == OpenState::CLOSED) - return; - - if (TrackedCallback::IsPending(open_callback_)) { - open_callback_->PostAbort(); - open_callback_ = nullptr; - } - - if (TrackedCallback::IsPending(get_capabilities_callback_)) { - get_capabilities_callback_->PostAbort(); - get_capabilities_callback_ = nullptr; - } - - Post(RENDERER, PpapiHostMsg_ImageCapture_Close()); - - open_state_ = OpenState::CLOSED; -} - -int32_t ImageCaptureResource::GetCameraCapabilities( - PP_Resource* capabilities, - const scoped_refptr& callback) { - if (!is_opened()) - return PP_ERROR_FAILED; - - if (TrackedCallback::IsPending(get_capabilities_callback_)) - return PP_ERROR_INPROGRESS; - - if (camera_capabilities_.get()) { - *capabilities = camera_capabilities_->GetReference(); - return PP_OK; - } - - get_capabilities_callback_ = callback; - Call( - RENDERER, PpapiHostMsg_ImageCapture_GetSupportedVideoCaptureFormats(), - base::Bind(&ImageCaptureResource::OnPluginMsgGetVideoCaptureFormatsReply, - base::Unretained(this), capabilities)); - - return PP_OK_COMPLETIONPENDING; -} - -void ImageCaptureResource::OnPluginMsgOpenReply( - const ResourceMessageReplyParams& params) { - // The callback may have been aborted by Close(). - if (TrackedCallback::IsPending(open_callback_)) { - if (open_state_ == OpenState::BEFORE_OPEN && params.result() == PP_OK) - open_state_ = OpenState::OPENED; - - open_callback_->Run(params.result()); - } -} - -void ImageCaptureResource::OnPluginMsgGetVideoCaptureFormatsReply( - PP_Resource* capabilities_output, - const ResourceMessageReplyParams& params, - const std::vector& formats) { - if (!TrackedCallback::IsPending(get_capabilities_callback_)) - return; - - // Return camera capabilities. - int32_t result = params.result(); - scoped_refptr callback; - callback.swap(get_capabilities_callback_); - if (result == PP_OK) { - camera_capabilities_ = - new CameraCapabilitiesResource(pp_instance(), formats); - *capabilities_output = camera_capabilities_->GetReference(); - } - callback->Run(result == PP_OK ? PP_OK : PP_ERROR_FAILED); -} - -} // namespace proxy -} // namespace ppapi diff --git a/ppapi/proxy/image_capture_resource.h b/ppapi/proxy/image_capture_resource.h deleted file mode 100644 index 2db3a0f..0000000 --- a/ppapi/proxy/image_capture_resource.h +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2015 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_PROXY_IMAGE_CAPTURE_RESOURCE_H_ -#define PPAPI_PROXY_IMAGE_CAPTURE_RESOURCE_H_ - -#include "base/basictypes.h" -#include "ppapi/c/pp_size.h" -#include "ppapi/c/private/pp_video_capture_format.h" -#include "ppapi/proxy/connection.h" -#include "ppapi/proxy/plugin_resource.h" -#include "ppapi/proxy/ppapi_proxy_export.h" -#include "ppapi/shared_impl/resource.h" -#include "ppapi/thunk/ppb_image_capture_api.h" - -namespace ppapi { -namespace proxy { - -class CameraCapabilitiesResource; -class ImageCaptureConfigResource; - -class PPAPI_PROXY_EXPORT ImageCaptureResource - : public PluginResource, - public thunk::PPB_ImageCapture_API { - public: - ImageCaptureResource(Connection connection, PP_Instance instance); - ~ImageCaptureResource() override; - - // Resource overrides: - thunk::PPB_ImageCapture_API* AsPPB_ImageCapture_API() override { - return this; - } - - // PPB_ImageCapture_API implementation. - int32_t Open(PP_Var device_id, - const scoped_refptr& callback) override; - void Close() override; - int32_t GetCameraCapabilities( - PP_Resource* capabilities, - const scoped_refptr& callback) override; - - private: - enum class OpenState { BEFORE_OPEN, OPENED, CLOSED }; - - void OnPluginMsgGetVideoCaptureFormatsReply( - PP_Resource* capabilities_output, - const ResourceMessageReplyParams& params, - const std::vector& formats); - - void OnPluginMsgOpenReply(const ResourceMessageReplyParams& params); - - bool is_opened() const { return open_state_ == OpenState::OPENED; } - - // Holds a reference of the callback so that Close() can cancel it. - scoped_refptr open_callback_; - OpenState open_state_; - - scoped_refptr get_capabilities_callback_; - scoped_refptr camera_capabilities_; - - DISALLOW_COPY_AND_ASSIGN(ImageCaptureResource); -}; - -} // namespace proxy -} // namespace ppapi - -#endif // PPAPI_PROXY_IMAGE_CAPTURE_RESOURCE_H_ diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc index 81c4375..806ab94 100644 --- a/ppapi/proxy/interface_list.cc +++ b/ppapi/proxy/interface_list.cc @@ -74,6 +74,7 @@ #include "ppapi/c/pp_errors.h" #include "ppapi/c/ppp_instance.h" #include "ppapi/c/private/ppb_camera_capabilities_private.h" +#include "ppapi/c/private/ppb_camera_device_private.h" #include "ppapi/c/private/ppb_content_decryptor_private.h" #include "ppapi/c/private/ppb_ext_crx_file_system_private.h" #include "ppapi/c/private/ppb_file_io_private.h" @@ -90,7 +91,6 @@ #include "ppapi/c/private/ppb_flash_message_loop.h" #include "ppapi/c/private/ppb_flash_print.h" #include "ppapi/c/private/ppb_host_resolver_private.h" -#include "ppapi/c/private/ppb_image_capture_private.h" #include "ppapi/c/private/ppb_input_event_private.h" #include "ppapi/c/private/ppb_isolated_file_system_private.h" #include "ppapi/c/private/ppb_net_address_private.h" diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index 2f153f3..243e783 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -1547,18 +1547,18 @@ IPC_MESSAGE_CONTROL2(PpapiHostMsg_Graphics2D_ReadImageData, PP_Point /* top_left */) IPC_MESSAGE_CONTROL0(PpapiPluginMsg_Graphics2D_ReadImageDataAck) -// ImageCapture ---------------------------------------------------------------- -IPC_MESSAGE_CONTROL0(PpapiHostMsg_ImageCapture_Create) -IPC_MESSAGE_CONTROL0(PpapiHostMsg_ImageCapture_Close) +// CameraDevice ---------------------------------------------------------------- +IPC_MESSAGE_CONTROL0(PpapiHostMsg_CameraDevice_Create) +IPC_MESSAGE_CONTROL0(PpapiHostMsg_CameraDevice_Close) -IPC_MESSAGE_CONTROL1(PpapiHostMsg_ImageCapture_Open, +IPC_MESSAGE_CONTROL1(PpapiHostMsg_CameraDevice_Open, std::string /* camera_source_id */) -IPC_MESSAGE_CONTROL0(PpapiPluginMsg_ImageCapture_OpenReply) +IPC_MESSAGE_CONTROL0(PpapiPluginMsg_CameraDevice_OpenReply) IPC_MESSAGE_CONTROL0( - PpapiHostMsg_ImageCapture_GetSupportedVideoCaptureFormats) + PpapiHostMsg_CameraDevice_GetSupportedVideoCaptureFormats) IPC_MESSAGE_CONTROL1( - PpapiPluginMsg_ImageCapture_GetSupportedVideoCaptureFormatsReply, + PpapiPluginMsg_CameraDevice_GetSupportedVideoCaptureFormatsReply, std::vector /* video_capture_formats */) // IsolatedFileSystem ---------------------------------------------------------- diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc index 1599589..4ca95ba 100644 --- a/ppapi/proxy/resource_creation_proxy.cc +++ b/ppapi/proxy/resource_creation_proxy.cc @@ -7,6 +7,7 @@ #include "ppapi/c/pp_errors.h" #include "ppapi/c/pp_size.h" #include "ppapi/proxy/audio_input_resource.h" +#include "ppapi/proxy/camera_device_resource.h" #include "ppapi/proxy/compositor_resource.h" #include "ppapi/proxy/connection.h" #include "ppapi/proxy/file_chooser_resource.h" @@ -19,7 +20,6 @@ #include "ppapi/proxy/graphics_2d_resource.h" #include "ppapi/proxy/host_resolver_private_resource.h" #include "ppapi/proxy/host_resolver_resource.h" -#include "ppapi/proxy/image_capture_resource.h" #include "ppapi/proxy/media_stream_video_track_resource.h" #include "ppapi/proxy/net_address_resource.h" #include "ppapi/proxy/network_monitor_resource.h" @@ -432,6 +432,11 @@ PP_Resource ResourceCreationProxy::CreateBuffer(PP_Instance instance, return PPB_Buffer_Proxy::CreateProxyResource(instance, size); } +PP_Resource ResourceCreationProxy::CreateCameraDevicePrivate( + PP_Instance instance) { + return (new CameraDeviceResource(GetConnection(), instance))->GetReference(); +} + PP_Resource ResourceCreationProxy::CreateFlashDRM(PP_Instance instance) { return (new FlashDRMResource(GetConnection(), instance))->GetReference(); } @@ -459,11 +464,6 @@ PP_Resource ResourceCreationProxy::CreateFlashMessageLoop( return PPB_Flash_MessageLoop_Proxy::CreateProxyResource(instance); } -PP_Resource ResourceCreationProxy::CreateImageCapturePrivate( - PP_Instance instance) { - return (new ImageCaptureResource(GetConnection(), instance))->GetReference(); -} - PP_Resource ResourceCreationProxy::CreatePlatformVerificationPrivate( PP_Instance instance) { return (new PlatformVerificationPrivateResource(GetConnection(), instance))-> diff --git a/ppapi/proxy/resource_creation_proxy.h b/ppapi/proxy/resource_creation_proxy.h index 70acd1e9..194cf7d 100644 --- a/ppapi/proxy/resource_creation_proxy.h +++ b/ppapi/proxy/resource_creation_proxy.h @@ -169,6 +169,7 @@ class ResourceCreationProxy : public InterfaceProxy, const PP_BrowserFont_Trusted_Description* description) override; virtual PP_Resource CreateBuffer(PP_Instance instance, uint32_t size) override; + virtual PP_Resource CreateCameraDevicePrivate(PP_Instance instance) override; virtual PP_Resource CreateFlashDRM(PP_Instance instance) override; virtual PP_Resource CreateFlashFontFile( PP_Instance instance, @@ -177,7 +178,6 @@ class ResourceCreationProxy : public InterfaceProxy, virtual PP_Resource CreateFlashMenu(PP_Instance instance, const PP_Flash_Menu* menu_data) override; virtual PP_Resource CreateFlashMessageLoop(PP_Instance instance) override; - virtual PP_Resource CreateImageCapturePrivate(PP_Instance instance) override; virtual PP_Resource CreatePlatformVerificationPrivate( PP_Instance instance) override; virtual PP_Resource CreateScrollbar(PP_Instance instance, diff --git a/ppapi/shared_impl/resource.h b/ppapi/shared_impl/resource.h index 5db4ce7..b703784 100644 --- a/ppapi/shared_impl/resource.h +++ b/ppapi/shared_impl/resource.h @@ -30,6 +30,7 @@ F(PPB_BrowserFont_Trusted_API) \ F(PPB_Buffer_API) \ F(PPB_CameraCapabilities_API) \ + F(PPB_CameraDevice_API) \ F(PPB_Compositor_API) \ F(PPB_CompositorLayer_API) \ F(PPB_DeviceRef_API) \ @@ -53,7 +54,6 @@ F(PPB_Graphics3D_API) \ F(PPB_HostResolver_API) \ F(PPB_HostResolver_Private_API) \ - F(PPB_ImageCapture_API) \ F(PPB_ImageData_API) \ F(PPB_InputEvent_API) \ F(PPB_IsolatedFileSystem_Private_API) \ diff --git a/ppapi/tests/all_c_includes.h b/ppapi/tests/all_c_includes.h index 0ea651e..3b54a78 100644 --- a/ppapi/tests/all_c_includes.h +++ b/ppapi/tests/all_c_includes.h @@ -106,6 +106,7 @@ #include "ppapi/c/private/pp_private_font_charset.h" #include "ppapi/c/private/pp_video_frame_private.h" #include "ppapi/c/private/ppb_camera_capabilities_private.h" +#include "ppapi/c/private/ppb_camera_device_private.h" #include "ppapi/c/private/ppb_content_decryptor_private.h" #include "ppapi/c/private/ppb_display_color_profile_private.h" #include "ppapi/c/private/ppb_ext_crx_file_system_private.h" @@ -117,7 +118,6 @@ #include "ppapi/c/private/ppb_flash_menu.h" #include "ppapi/c/private/ppb_flash_message_loop.h" #include "ppapi/c/private/ppb_host_resolver_private.h" -#include "ppapi/c/private/ppb_image_capture_private.h" #include "ppapi/c/private/ppb_input_event_private.h" #include "ppapi/c/private/ppb_instance_private.h" #include "ppapi/c/private/ppb_net_address_private.h" diff --git a/ppapi/tests/all_cpp_includes.h b/ppapi/tests/all_cpp_includes.h index 130ed67..94b033d 100644 --- a/ppapi/tests/all_cpp_includes.h +++ b/ppapi/tests/all_cpp_includes.h @@ -53,11 +53,11 @@ #include "ppapi/cpp/network_proxy.h" #include "ppapi/cpp/point.h" #include "ppapi/cpp/private/camera_capabilities_private.h" +#include "ppapi/cpp/private/camera_device_private.h" #include "ppapi/cpp/private/content_decryptor_private.h" #include "ppapi/cpp/private/find_private.h" #include "ppapi/cpp/private/flash_font_file.h" #include "ppapi/cpp/private/flash_fullscreen.h" -#include "ppapi/cpp/private/image_capture_private.h" #include "ppapi/cpp/private/instance_private.h" #include "ppapi/cpp/private/instance_private.h" #include "ppapi/cpp/private/net_address_private.h" diff --git a/ppapi/thunk/BUILD.gn b/ppapi/thunk/BUILD.gn index 6226b48..0f034e6 100644 --- a/ppapi/thunk/BUILD.gn +++ b/ppapi/thunk/BUILD.gn @@ -149,6 +149,8 @@ source_set("thunk") { "ppb_buffer_thunk.cc", "ppb_camera_capabilities_api.h", "ppb_camera_capabilities_private_thunk.cc", + "ppb_camera_device_api.h", + "ppb_camera_device_private_thunk.cc", "ppb_char_set_thunk.cc", "ppb_content_decryptor_private_thunk.cc", "ppb_flash_clipboard_thunk.cc", @@ -162,8 +164,6 @@ source_set("thunk") { "ppb_flash_message_loop_thunk.cc", "ppb_flash_thunk.cc", "ppb_gles_chromium_texture_mapping_thunk.cc", - "ppb_image_capture_api.h", - "ppb_image_capture_private_thunk.cc", "ppb_pdf_thunk.cc", "ppb_platform_verification_private_thunk.cc", "ppb_scrollbar_thunk.cc", diff --git a/ppapi/thunk/interfaces_ppb_private.h b/ppapi/thunk/interfaces_ppb_private.h index 3d24b01..9f0e61c 100644 --- a/ppapi/thunk/interfaces_ppb_private.h +++ b/ppapi/thunk/interfaces_ppb_private.h @@ -25,6 +25,8 @@ PROXIED_IFACE(PPB_BROWSERFONT_TRUSTED_INTERFACE_1_0, PPB_BrowserFont_Trusted_1_0) PROXIED_IFACE(PPB_CAMERACAPABILITIES_PRIVATE_INTERFACE_0_1, PPB_CameraCapabilities_Private_0_1) +PROXIED_IFACE(PPB_CAMERADEVICE_PRIVATE_INTERFACE_0_1, + PPB_CameraDevice_Private_0_1) PROXIED_IFACE(PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_13, PPB_ContentDecryptor_Private_0_13) PROXIED_IFACE(PPB_CHARSET_TRUSTED_INTERFACE_1_0, @@ -41,8 +43,6 @@ PROXIED_IFACE(PPB_FLASHFULLSCREEN_INTERFACE_0_1, PPB_FlashFullscreen_0_1) PROXIED_IFACE(PPB_FLASHFULLSCREEN_INTERFACE_1_0, PPB_FlashFullscreen_0_1) -PROXIED_IFACE(PPB_IMAGECAPTURE_PRIVATE_INTERFACE_0_1, - PPB_ImageCapture_Private_0_1) PROXIED_IFACE(PPB_PDF_INTERFACE, PPB_PDF) #if defined(OS_CHROMEOS) diff --git a/ppapi/thunk/ppb_camera_device_api.h b/ppapi/thunk/ppb_camera_device_api.h new file mode 100644 index 0000000..29e6a27 --- /dev/null +++ b/ppapi/thunk/ppb_camera_device_api.h @@ -0,0 +1,33 @@ +// Copyright 2015 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_THUNK_PPB_CAMERA_DEVICE_API_H_ +#define PPAPI_THUNK_PPB_CAMERA_DEVICE_API_H_ + +#include + +#include "ppapi/c/private/ppb_camera_device_private.h" +#include "ppapi/thunk/ppapi_thunk_export.h" + +namespace ppapi { + +class TrackedCallback; + +namespace thunk { + +class PPAPI_THUNK_EXPORT PPB_CameraDevice_API { + public: + virtual ~PPB_CameraDevice_API() {} + virtual int32_t Open(PP_Var device_id, + const scoped_refptr& callback) = 0; + virtual void Close() = 0; + virtual int32_t GetCameraCapabilities( + PP_Resource* capabilities, + const scoped_refptr& callback) = 0; +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_PPB_CAMERA_DEVICE_API_H_ diff --git a/ppapi/thunk/ppb_camera_device_private_thunk.cc b/ppapi/thunk/ppb_camera_device_private_thunk.cc new file mode 100644 index 0000000..94b3129 --- /dev/null +++ b/ppapi/thunk/ppb_camera_device_private_thunk.cc @@ -0,0 +1,74 @@ +// 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. + +// From private/ppb_camera_device_private.idl modified Wed Feb 18 16:44:52 2015. + +#include "ppapi/c/pp_completion_callback.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/c/private/ppb_camera_device_private.h" +#include "ppapi/shared_impl/tracked_callback.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppapi_thunk_export.h" +#include "ppapi/thunk/ppb_camera_device_api.h" + +namespace ppapi { +namespace thunk { + +namespace { + +PP_Resource Create(PP_Instance instance) { + VLOG(4) << "PPB_CameraDevice_Private::Create()"; + EnterResourceCreation enter(instance); + if (enter.failed()) + return 0; + return enter.functions()->CreateCameraDevicePrivate(instance); +} + +PP_Bool IsCameraDevice(PP_Resource resource) { + VLOG(4) << "PPB_CameraDevice_Private::IsCameraDevice()"; + EnterResource enter(resource, false); + return PP_FromBool(enter.succeeded()); +} + +int32_t Open(PP_Resource camera_device, + struct PP_Var device_id, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_CameraDevice_Private::Open()"; + EnterResource enter(camera_device, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult(enter.object()->Open(device_id, enter.callback())); +} + +void Close(PP_Resource camera_device) { + VLOG(4) << "PPB_CameraDevice_Private::Close()"; + EnterResource enter(camera_device, true); + if (enter.failed()) + return; + enter.object()->Close(); +} + +int32_t GetCameraCapabilities(PP_Resource camera_device, + PP_Resource* capabilities, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_CameraDevice_Private::GetCameraCapabilities()"; + EnterResource enter(camera_device, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult( + enter.object()->GetCameraCapabilities(capabilities, enter.callback())); +} + +const PPB_CameraDevice_Private_0_1 g_ppb_cameradevice_private_thunk_0_1 = + {&Create, &IsCameraDevice, &Open, &Close, &GetCameraCapabilities}; + +} // namespace + +PPAPI_THUNK_EXPORT const PPB_CameraDevice_Private_0_1* +GetPPB_CameraDevice_Private_0_1_Thunk() { + return &g_ppb_cameradevice_private_thunk_0_1; +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/ppb_image_capture_api.h b/ppapi/thunk/ppb_image_capture_api.h deleted file mode 100644 index d0d92ae..0000000 --- a/ppapi/thunk/ppb_image_capture_api.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2015 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_THUNK_PPB_IMAGE_CAPTURE_API_H_ -#define PPAPI_THUNK_PPB_IMAGE_CAPTURE_API_H_ - -#include - -#include "ppapi/c/private/ppb_image_capture_private.h" -#include "ppapi/thunk/ppapi_thunk_export.h" - -namespace ppapi { - -class TrackedCallback; - -namespace thunk { - -class PPAPI_THUNK_EXPORT PPB_ImageCapture_API { - public: - virtual ~PPB_ImageCapture_API() {} - virtual int32_t Open(PP_Var device_id, - const scoped_refptr& callback) = 0; - virtual void Close() = 0; - virtual int32_t GetCameraCapabilities( - PP_Resource* capabilities, - const scoped_refptr& callback) = 0; -}; - -} // namespace thunk -} // namespace ppapi - -#endif // PPAPI_THUNK_PPB_IMAGE_CAPTURE_API_H_ diff --git a/ppapi/thunk/ppb_image_capture_private_thunk.cc b/ppapi/thunk/ppb_image_capture_private_thunk.cc deleted file mode 100644 index 2b55183..0000000 --- a/ppapi/thunk/ppb_image_capture_private_thunk.cc +++ /dev/null @@ -1,74 +0,0 @@ -// 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. - -// From private/ppb_image_capture_private.idl modified Fri Feb 6 14:55:55 2015. - -#include "ppapi/c/pp_completion_callback.h" -#include "ppapi/c/pp_errors.h" -#include "ppapi/c/private/ppb_image_capture_private.h" -#include "ppapi/shared_impl/tracked_callback.h" -#include "ppapi/thunk/enter.h" -#include "ppapi/thunk/ppapi_thunk_export.h" -#include "ppapi/thunk/ppb_image_capture_api.h" - -namespace ppapi { -namespace thunk { - -namespace { - -PP_Resource Create(PP_Instance instance) { - VLOG(4) << "PPB_ImageCapture_Private::Create()"; - EnterResourceCreation enter(instance); - if (enter.failed()) - return 0; - return enter.functions()->CreateImageCapturePrivate(instance); -} - -PP_Bool IsImageCapture(PP_Resource resource) { - VLOG(4) << "PPB_ImageCapture_Private::IsImageCapture()"; - EnterResource enter(resource, false); - return PP_FromBool(enter.succeeded()); -} - -int32_t Open(PP_Resource image_capture, - struct PP_Var device_id, - struct PP_CompletionCallback callback) { - VLOG(4) << "PPB_ImageCapture_Private::Open()"; - EnterResource enter(image_capture, callback, true); - if (enter.failed()) - return enter.retval(); - return enter.SetResult(enter.object()->Open(device_id, enter.callback())); -} - -void Close(PP_Resource image_capture) { - VLOG(4) << "PPB_ImageCapture_Private::Close()"; - EnterResource enter(image_capture, true); - if (enter.failed()) - return; - enter.object()->Close(); -} - -int32_t GetCameraCapabilities(PP_Resource image_capture, - PP_Resource* capabilities, - struct PP_CompletionCallback callback) { - VLOG(4) << "PPB_ImageCapture_Private::GetCameraCapabilities()"; - EnterResource enter(image_capture, callback, true); - if (enter.failed()) - return enter.retval(); - return enter.SetResult( - enter.object()->GetCameraCapabilities(capabilities, enter.callback())); -} - -const PPB_ImageCapture_Private_0_1 g_ppb_imagecapture_private_thunk_0_1 = - {&Create, &IsImageCapture, &Open, &Close, &GetCameraCapabilities}; - -} // namespace - -PPAPI_THUNK_EXPORT const PPB_ImageCapture_Private_0_1* -GetPPB_ImageCapture_Private_0_1_Thunk() { - return &g_ppb_imagecapture_private_thunk_0_1; -} - -} // namespace thunk -} // namespace ppapi diff --git a/ppapi/thunk/resource_creation_api.h b/ppapi/thunk/resource_creation_api.h index 204b8a1..6c781e3 100644 --- a/ppapi/thunk/resource_creation_api.h +++ b/ppapi/thunk/resource_creation_api.h @@ -182,6 +182,7 @@ class ResourceCreationAPI { PP_Instance instance, const PP_BrowserFont_Trusted_Description* description) = 0; virtual PP_Resource CreateBuffer(PP_Instance instance, uint32_t size) = 0; + virtual PP_Resource CreateCameraDevicePrivate(PP_Instance instance) = 0; virtual PP_Resource CreateFlashDRM(PP_Instance instance) = 0; virtual PP_Resource CreateFlashFontFile( PP_Instance instance, @@ -190,7 +191,6 @@ class ResourceCreationAPI { virtual PP_Resource CreateFlashMenu(PP_Instance instance, const PP_Flash_Menu* menu_data) = 0; virtual PP_Resource CreateFlashMessageLoop(PP_Instance instance) = 0; - virtual PP_Resource CreateImageCapturePrivate(PP_Instance instance) = 0; virtual PP_Resource CreatePlatformVerificationPrivate( PP_Instance instance) = 0; virtual PP_Resource CreateScrollbar(PP_Instance instance, -- cgit v1.1