diff options
author | jchuang <jchuang@chromium.org> | 2015-02-17 02:10:50 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-17 10:11:56 +0000 |
commit | add2f05d32384647371c56bba67bec3fc2f1ee2f (patch) | |
tree | 8c9ce8b0b98e99039a5ecb6b78ab6803f2133a12 /ppapi | |
parent | 3487f329fc13a6a90741c216f2534c9f4aa48c08 (diff) | |
download | chromium_src-add2f05d32384647371c56bba67bec3fc2f1ee2f.zip chromium_src-add2f05d32384647371c56bba67bec3fc2f1ee2f.tar.gz chromium_src-add2f05d32384647371c56bba67bec3fc2f1ee2f.tar.bz2 |
PPAPI: implement GetSupportedPreviewSizes
1. Support PPB_CameraCapabilities_Private.GetSupportedPreviewSizes()
2. Implement basic skeleton of image capture PPAPI
BUG=387547
TEST=Call the API from a trusted plugin and print all preview
sizes.
Review URL: https://codereview.chromium.org/848863002
Cr-Commit-Position: refs/heads/master@{#316552}
Diffstat (limited to 'ppapi')
29 files changed, 661 insertions, 191 deletions
diff --git a/ppapi/api/private/ppb_camera_capabilities_private.idl b/ppapi/api/private/ppb_camera_capabilities_private.idl index 57c7421..cb97fb1 100644 --- a/ppapi/api/private/ppb_camera_capabilities_private.idl +++ b/ppapi/api/private/ppb_camera_capabilities_private.idl @@ -11,7 +11,7 @@ [generate_thunk] label Chrome { - M39 = 0.1 + M42 = 0.1 }; /** @@ -22,17 +22,6 @@ label Chrome { [version=0.1] interface PPB_CameraCapabilities_Private { /** - * Creates a PPB_CameraCapabilities_Private resource. - * - * @param[in] instance A <code>PP_Instance</code> identifying one instance of - * a module. - * - * @return A <code>PP_Resource</code> corresponding to a - * PPB_CameraCapabilities_Private resource if successful, 0 if failed. - */ - PP_Resource Create([in] PP_Instance instance); - - /** * IsCameraCapabilities() determines if the given resource is a * <code>PPB_CameraCapabilities_Private</code>. * @@ -63,23 +52,4 @@ interface PPB_CameraCapabilities_Private { [in] PP_Resource capabilities, [out] int32_t array_size, [out, size_is(array_size)] PP_Size[] preview_sizes); - - /** - * GetSupportedJpegSize() returns the supported JPEG sizes for the given - * <code>PPB_CameraCapabilities_Private</code>. - * - * @param[in] capabilities A <code>PP_Resource</code> corresponding to an - * image capture capabilities resource. - * @param[out] array_size The size of JPEG size array. If the output of this - * is 0, the camera has no support for generating JPEG images. - * @param[out] jpeg_sizes An array of <code>PP_Size</code> corresponding to - * the supported JPEG image sizes in pixels. The ownership of the array - * belongs to <code>PPB_CameraCapabilities_Private</code> and the caller - * should not free it. When a PPB_CameraCapabilities_Private is deleted, the - * array returning from this is no longer valid. - */ - void GetSupportedJpegSizes( - [in] PP_Resource capabilities, - [out] int32_t array_size, - [out, size_is(array_size)] PP_Size[] jpeg_sizes); }; diff --git a/ppapi/api/private/ppb_image_capture_private.idl b/ppapi/api/private/ppb_image_capture_private.idl index 36c410f..75c75d5 100644 --- a/ppapi/api/private/ppb_image_capture_private.idl +++ b/ppapi/api/private/ppb_image_capture_private.idl @@ -11,7 +11,7 @@ [generate_thunk] label Chrome { - M39 = 0.1 + M42 = 0.1 }; /** @@ -28,22 +28,11 @@ interface PPB_ImageCapture_Private { * * @param[in] instance A <code>PP_Instance</code> identifying one instance * of a module. - * @param[in] camera_source_id A <code>PP_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 PPB_ImageCapture_Private object can still do image capture. - * @param[in] error_callback A <code>PPB_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 PPB_ImageCapture_Private. * * @return A <code>PP_Resource</code> corresponding to a * PPB_ImageCapture_Private resource if successful, 0 if failed. */ - PP_Resource Create([in] PP_Instance instance, - [in] PP_Var camera_source_id, - [inout] mem_t user_data); + PP_Resource Create([in] PP_Instance instance); /** * Determines if a resource is an image capture resource. @@ -57,6 +46,24 @@ interface PPB_ImageCapture_Private { PP_Bool IsImageCapture([in] PP_Resource resource); /** + * Opens a video capture device. + * + * @param[in] image_capture A <code>PP_Resource</code> corresponding to an + * image capture resource. + * @param[in] device_id A <code>PP_Var</code> identifying a camera device. The + * type is string. The ID can be obtained from MediaStreamTrack.getSources() + * or MediaStreamVideoTrack.id. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion of <code>Open()</code>. + * + * @return An error code from <code>pp_errors.h</code>. + */ + 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 <code> * PPB_ImageCapture_Private</code> is destroyed and is not closed yet, this @@ -65,13 +72,8 @@ interface PPB_ImageCapture_Private { * * @param[in] image_capture A <code>PP_Resource</code> corresponding to an * image capture resource. - * @param[in] callback <code>PP_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([in] PP_Resource resource, - [in] PP_CompletionCallback callback); + void Close([in] PP_Resource image_capture); /** * Gets the camera capabilities. diff --git a/ppapi/c/private/ppb_camera_capabilities_private.h b/ppapi/c/private/ppb_camera_capabilities_private.h index c5c17d6e..7326549 100644 --- a/ppapi/c/private/ppb_camera_capabilities_private.h +++ b/ppapi/c/private/ppb_camera_capabilities_private.h @@ -4,14 +4,13 @@ */ /* From private/ppb_camera_capabilities_private.idl, - * modified Fri Aug 22 11:08:14 2014. + * modified Tue Feb 3 19:54:34 2015. */ #ifndef PPAPI_C_PRIVATE_PPB_CAMERA_CAPABILITIES_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_CAMERA_CAPABILITIES_PRIVATE_H_ #include "ppapi/c/pp_bool.h" -#include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_size.h" @@ -40,16 +39,6 @@ */ struct PPB_CameraCapabilities_Private_0_1 { /** - * Creates a PPB_CameraCapabilities_Private resource. - * - * @param[in] instance A <code>PP_Instance</code> identifying one instance of - * a module. - * - * @return A <code>PP_Resource</code> corresponding to a - * PPB_CameraCapabilities_Private resource if successful, 0 if failed. - */ - PP_Resource (*Create)(PP_Instance instance); - /** * IsCameraCapabilities() determines if the given resource is a * <code>PPB_CameraCapabilities_Private</code>. * @@ -77,23 +66,6 @@ struct PPB_CameraCapabilities_Private_0_1 { void (*GetSupportedPreviewSizes)(PP_Resource capabilities, int32_t* array_size, struct PP_Size** preview_sizes); - /** - * GetSupportedJpegSize() returns the supported JPEG sizes for the given - * <code>PPB_CameraCapabilities_Private</code>. - * - * @param[in] capabilities A <code>PP_Resource</code> corresponding to an - * image capture capabilities resource. - * @param[out] array_size The size of JPEG size array. If the output of this - * is 0, the camera has no support for generating JPEG images. - * @param[out] jpeg_sizes An array of <code>PP_Size</code> corresponding to - * the supported JPEG image sizes in pixels. The ownership of the array - * belongs to <code>PPB_CameraCapabilities_Private</code> and the caller - * should not free it. When a PPB_CameraCapabilities_Private is deleted, the - * array returning from this is no longer valid. - */ - void (*GetSupportedJpegSizes)(PP_Resource capabilities, - int32_t* array_size, - struct PP_Size** jpeg_sizes); }; typedef struct PPB_CameraCapabilities_Private_0_1 diff --git a/ppapi/c/private/ppb_image_capture_private.h b/ppapi/c/private/ppb_image_capture_private.h index 0c04c05..23dfdef 100644 --- a/ppapi/c/private/ppb_image_capture_private.h +++ b/ppapi/c/private/ppb_image_capture_private.h @@ -4,7 +4,7 @@ */ /* From private/ppb_image_capture_private.idl, - * modified Thu Feb 5 22:47:43 2015. + * modified Fri Feb 6 15:40:49 2015. */ #ifndef PPAPI_C_PRIVATE_PPB_IMAGE_CAPTURE_PRIVATE_H_ @@ -47,22 +47,11 @@ struct PPB_ImageCapture_Private_0_1 { * * @param[in] instance A <code>PP_Instance</code> identifying one instance * of a module. - * @param[in] camera_source_id A <code>PP_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 PPB_ImageCapture_Private object can still do image capture. - * @param[in] error_callback A <code>PPB_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 PPB_ImageCapture_Private. * * @return A <code>PP_Resource</code> corresponding to a * PPB_ImageCapture_Private resource if successful, 0 if failed. */ - PP_Resource (*Create)(PP_Instance instance, - struct PP_Var camera_source_id, - void* user_data); + PP_Resource (*Create)(PP_Instance instance); /** * Determines if a resource is an image capture resource. * @@ -74,6 +63,22 @@ struct PPB_ImageCapture_Private_0_1 { */ PP_Bool (*IsImageCapture)(PP_Resource resource); /** + * Opens a video capture device. + * + * @param[in] image_capture A <code>PP_Resource</code> corresponding to an + * image capture resource. + * @param[in] device_id A <code>PP_Var</code> identifying a camera device. The + * type is string. The ID can be obtained from MediaStreamTrack.getSources() + * or MediaStreamVideoTrack.id. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion of <code>Open()</code>. + * + * @return An error code from <code>pp_errors.h</code>. + */ + 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 <code> * PPB_ImageCapture_Private</code> is destroyed and is not closed yet, this @@ -82,12 +87,8 @@ struct PPB_ImageCapture_Private_0_1 { * * @param[in] image_capture A <code>PP_Resource</code> corresponding to an * image capture resource. - * @param[in] callback <code>PP_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)(PP_Resource resource, struct PP_CompletionCallback callback); + void (*Close)(PP_Resource image_capture); /** * Gets the camera capabilities. * diff --git a/ppapi/cpp/private/camera_capabilities_private.cc b/ppapi/cpp/private/camera_capabilities_private.cc new file mode 100644 index 0000000..ce2ebb4 --- /dev/null +++ b/ppapi/cpp/private/camera_capabilities_private.cc @@ -0,0 +1,73 @@ +// 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_capabilities_private.h" + +#include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_size.h" +#include "ppapi/cpp/instance_handle.h" +#include "ppapi/cpp/module_impl.h" + +namespace pp { + +namespace { + +template <> +const char* interface_name<PPB_CameraCapabilities_Private_0_1>() { + return PPB_CAMERACAPABILITIES_PRIVATE_INTERFACE_0_1; +} + +} // namespace + +CameraCapabilities_Private::CameraCapabilities_Private() { +} + +CameraCapabilities_Private::CameraCapabilities_Private( + const CameraCapabilities_Private& other) + : Resource(other) { +} + +CameraCapabilities_Private::CameraCapabilities_Private(const Resource& resource) + : Resource(resource) { + PP_DCHECK(IsCameraCapabilities(resource)); +} + +CameraCapabilities_Private::CameraCapabilities_Private(PassRef, + PP_Resource resource) + : Resource(PASS_REF, resource) { +} + +CameraCapabilities_Private::~CameraCapabilities_Private() { +} + +void CameraCapabilities_Private::GetSupportedPreviewSizes( + std::vector<Size>* preview_sizes) { + if (!has_interface<PPB_CameraCapabilities_Private_0_1>()) { + PP_DCHECK(false); + return; + } + + int32_t array_size; + PP_Size* array; + get_interface<PPB_CameraCapabilities_Private_0_1>()->GetSupportedPreviewSizes( + pp_resource(), &array_size, &array); + preview_sizes->clear(); + preview_sizes->reserve(array_size); + for (int32_t i = 0; i < array_size; i++) { + preview_sizes->push_back(Size(array[i])); + } +} + +// static +bool CameraCapabilities_Private::IsCameraCapabilities( + const Resource& resource) { + if (!has_interface<PPB_CameraCapabilities_Private_0_1>()) + return false; + + return PP_ToBool( + get_interface<PPB_CameraCapabilities_Private_0_1>()->IsCameraCapabilities( + resource.pp_resource())); +} + +} // namespace pp diff --git a/ppapi/cpp/private/camera_capabilities_private.h b/ppapi/cpp/private/camera_capabilities_private.h index 5151c75..5686d88 100644 --- a/ppapi/cpp/private/camera_capabilities_private.h +++ b/ppapi/cpp/private/camera_capabilities_private.h @@ -6,6 +6,8 @@ #ifndef PPAPI_CPP_PRIVATE_CAMERA_CAPABILITIES_PRIVATE_H_ #define PPAPI_CPP_PRIVATE_CAMERA_CAPABILITIES_PRIVATE_H_ +#include <vector> + #include "ppapi/c/private/ppb_camera_capabilities_private.h" #include "ppapi/cpp/resource.h" #include "ppapi/cpp/size.h" @@ -36,12 +38,6 @@ class CameraCapabilities_Private : public Resource { /// 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. /// @@ -59,13 +55,6 @@ class CameraCapabilities_Private : public Resource { /// 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>. /// @@ -80,4 +69,3 @@ class CameraCapabilities_Private : public Resource { } // namespace pp #endif /* PPAPI_CPP_PRIVATE_CAMERA_CAPABILITIES_PRIVATE_H_ */ - diff --git a/ppapi/cpp/private/image_capture_private.cc b/ppapi/cpp/private/image_capture_private.cc new file mode 100644 index 0000000..539f8a3 --- /dev/null +++ b/ppapi/cpp/private/image_capture_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/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<PPB_ImageCapture_Private_0_1>() { + 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<PPB_ImageCapture_Private_0_1>()) { + PassRefFromConstructor( + get_interface<PPB_ImageCapture_Private_0_1>()->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<PPB_ImageCapture_Private_0_1>()) + return callback.MayForce(PP_ERROR_NOINTERFACE); + + return get_interface<PPB_ImageCapture_Private_0_1>()->Open( + pp_resource(), device_id.pp_var(), callback.pp_completion_callback()); +} + +void ImageCapture_Private::Close() { + if (has_interface<PPB_ImageCapture_Private_0_1>()) + get_interface<PPB_ImageCapture_Private_0_1>()->Close(pp_resource()); +} + +int32_t ImageCapture_Private::GetCameraCapabilities( + const CompletionCallbackWithOutput<CameraCapabilities_Private>& callback) { + if (!has_interface<PPB_ImageCapture_Private_0_1>()) + return callback.MayForce(PP_ERROR_NOINTERFACE); + + return get_interface<PPB_ImageCapture_Private_0_1>()->GetCameraCapabilities( + pp_resource(), callback.output(), callback.pp_completion_callback()); +} + +// static +bool ImageCapture_Private::IsImageCapture(const Resource& resource) { + if (!has_interface<PPB_ImageCapture_Private_0_1>()) + return false; + + return PP_ToBool( + get_interface<PPB_ImageCapture_Private_0_1>()->IsImageCapture( + resource.pp_resource())); +} + +} // namespace pp diff --git a/ppapi/cpp/private/image_capture_private.h b/ppapi/cpp/private/image_capture_private.h index eede24a..98382a2 100644 --- a/ppapi/cpp/private/image_capture_private.h +++ b/ppapi/cpp/private/image_capture_private.h @@ -7,8 +7,6 @@ #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/resource.h" #include "ppapi/cpp/var.h" @@ -17,63 +15,68 @@ /// acquiring a single still image from a camera source. namespace pp { +class CameraCapabilities_Private; +class CompletionCallback; +class InstanceHandle; + +template <typename T> +class CompletionCallbackWithOutput; + /// To query camera capabilities: -/// 1. Get a PPB_ImageCapture_Private object by Create(). +/// 1. Create an ImageCapture_Private object. /// 2. Open() camera device with track id of MediaStream video track. /// 3. Call GetCameraCapabilities() to get a -/// <code>PPB_CameraCapabilities_Private</code> object, which can be used to +/// <code>CameraCapabilities_Private</code> object, which can be used to /// query camera capabilities. -class ImageCapture_Private { +class ImageCapture_Private : public Resource { public: /// Default constructor for creating an is_null() /// <code>ImageCapture_Private</code> object. ImageCapture_Private(); - /// Creates an ImageCapture_Private resource. + /// The copy constructor for <code>ImageCapture_Private</code>. /// - /// @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, - void* user_data); - - /// Constructs a <code>ImageCapture_Private</code> from a <code> - /// Resource</code>. + /// @param[in] other A reference to a <code>ImageCapture_Private</code>. + ImageCapture_Private(const ImageCapture_Private& other); + + /// Constructs an <code>ImageCapture_Private</code> from + /// a <code>Resource</code>. /// - /// @param[in] resource A <code>ImageCapture_Private</code> - /// resource. + /// @param[in] resource A <code>PPB_ImageCapture_Private</code> resource. explicit ImageCapture_Private(const Resource& resource); + /// Constructs an ImageCapture_Private resource. + /// + /// @param[in] instance A <code>PP_Instance</code> identifying one instance + /// of a module. + explicit ImageCapture_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>ImageCapture_Private</code> - /// resource. + /// @param[in] resource A <code>PPB_ImageCapture_Private</code> resource. ImageCapture_Private(PassRef, PP_Resource resource); // Destructor. ~ImageCapture_Private(); + /// Opens a video capture device. + /// + /// @param[in] device_id A <code>Var</code> identifying a camera + /// device. The type is string. The ID can be obtained from + /// MediaStreamTrack.getSources() or MediaStreamVideoTrack.id. + /// @param[in] callback A <code>CompletionCallback</code> to be called upon + /// completion of <code>Open()</code>. + /// + /// @return An int32_t containing a result code from <code>pp_errors.h</code>. + 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 <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); + void Close(); /// Gets the camera capabilities. /// @@ -98,4 +101,3 @@ class ImageCapture_Private { } // 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 dd28b03..b47a250 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 @@ -3593,22 +3593,27 @@ static PP_Bool Pnacl_M19_PPB_HostResolver_Private_GetNetAddress(PP_Resource host /* Begin wrapper methods for PPB_ImageCapture_Private_0_1 */ -static PP_Resource Pnacl_M39_PPB_ImageCapture_Private_Create(PP_Instance instance, struct PP_Var* camera_source_id, void* user_data) { +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, *camera_source_id, user_data); + return iface->Create(instance); } -static PP_Bool Pnacl_M39_PPB_ImageCapture_Private_IsImageCapture(PP_Resource resource) { +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_M39_PPB_ImageCapture_Private_Close(PP_Resource resource, struct PP_CompletionCallback* callback) { +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; - return iface->Close(resource, *callback); + iface->Close(image_capture); } -static int32_t Pnacl_M39_PPB_ImageCapture_Private_GetCameraCapabilities(PP_Resource image_capture, PP_Resource* capabilities, struct PP_CompletionCallback* callback) { +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); } @@ -5491,10 +5496,11 @@ static const struct PPB_HostResolver_Private_0_1 Pnacl_Wrappers_PPB_HostResolver }; static const struct PPB_ImageCapture_Private_0_1 Pnacl_Wrappers_PPB_ImageCapture_Private_0_1 = { - .Create = (PP_Resource (*)(PP_Instance instance, struct PP_Var camera_source_id, void* user_data))&Pnacl_M39_PPB_ImageCapture_Private_Create, - .IsImageCapture = (PP_Bool (*)(PP_Resource resource))&Pnacl_M39_PPB_ImageCapture_Private_IsImageCapture, - .Close = (int32_t (*)(PP_Resource resource, struct PP_CompletionCallback callback))&Pnacl_M39_PPB_ImageCapture_Private_Close, - .GetCameraCapabilities = (int32_t (*)(PP_Resource image_capture, PP_Resource* capabilities, struct PP_CompletionCallback callback))&Pnacl_M39_PPB_ImageCapture_Private_GetCameraCapabilities + .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 */ diff --git a/ppapi/ppapi_proxy.gypi b/ppapi/ppapi_proxy.gypi index 312b649..c5bebdd 100644 --- a/ppapi/ppapi_proxy.gypi +++ b/ppapi/ppapi_proxy.gypi @@ -29,6 +29,8 @@ 'proxy/broker_resource.h', 'proxy/browser_font_singleton_resource.cc', 'proxy/browser_font_singleton_resource.h', + 'proxy/camera_capabilities_resource.cc', + 'proxy/camera_capabilities_resource.h', 'proxy/compositor_layer_resource.cc', 'proxy/compositor_layer_resource.h', 'proxy/compositor_resource.cc', @@ -81,6 +83,8 @@ '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', @@ -268,6 +272,7 @@ 'proxy/audio_input_resource.cc', 'proxy/broker_dispatcher.cc', 'proxy/browser_font_singleton_resource.cc', + 'proxy/camera_capabilities_resource.cc', 'proxy/device_enumeration_resource_helper.cc', 'proxy/flash_clipboard_resource.cc', 'proxy/flash_drm_resource.cc', @@ -278,6 +283,7 @@ '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 07a2886..fb359fe 100644 --- a/ppapi/ppapi_shared.gypi +++ b/ppapi/ppapi_shared.gypi @@ -156,6 +156,8 @@ 'thunk/ppb_browser_font_trusted_thunk.cc', 'thunk/ppb_buffer_api.h', 'thunk/ppb_buffer_thunk.cc', + 'thunk/ppb_camera_capabilities_api.h', + 'thunk/ppb_camera_capabilities_private_thunk.cc', 'thunk/ppb_char_set_thunk.cc', 'thunk/ppb_compositor_api.h', 'thunk/ppb_compositor_layer_api.h', @@ -209,6 +211,8 @@ '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', @@ -319,6 +323,7 @@ 'thunk/ppb_broker_thunk.cc', 'thunk/ppb_browser_font_trusted_thunk.cc', 'thunk/ppb_buffer_thunk.cc', + 'thunk/ppb_camera_capabilities_private_thunk.cc', 'thunk/ppb_char_set_thunk.cc', 'thunk/ppb_content_decryptor_private_thunk.cc', 'thunk/ppb_flash_clipboard_thunk.cc', @@ -333,6 +338,7 @@ '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 5560ab9..c3c709e 100644 --- a/ppapi/ppapi_sources.gypi +++ b/ppapi/ppapi_sources.gypi @@ -106,6 +106,7 @@ 'c/private/pp_file_handle.h', 'c/private/pp_private_font_charset.h', 'c/private/pp_video_frame_private.h', + 'c/private/ppb_camera_capabilities_private.h', 'c/private/ppb_content_decryptor_private.h', 'c/private/ppb_ext_crx_file_system_private.h', 'c/private/ppb_find_private.h', @@ -117,6 +118,7 @@ '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', @@ -306,6 +308,8 @@ 'cpp/dev/scriptable_object_deprecated.h', # Private interfaces. + 'cpp/private/camera_capabilities_private.cc', + 'cpp/private/camera_capabilities_private.h', 'cpp/private/content_decryptor_private.cc', 'cpp/private/content_decryptor_private.h', 'cpp/private/ext_crx_file_system_private.cc', @@ -334,6 +338,8 @@ '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 adda193..c9019ca 100644 --- a/ppapi/proxy/BUILD.gn +++ b/ppapi/proxy/BUILD.gn @@ -212,6 +212,8 @@ component("proxy") { "broker_dispatcher.h", "browser_font_singleton_resource.cc", "browser_font_singleton_resource.h", + "camera_capabilities_resource.cc", + "camera_capabilities_resource.h", "device_enumeration_resource_helper.cc", "device_enumeration_resource_helper.h", "flash_clipboard_resource.cc", @@ -232,6 +234,8 @@ 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.cc b/ppapi/proxy/camera_capabilities_resource.cc new file mode 100644 index 0000000..1854097 --- /dev/null +++ b/ppapi/proxy/camera_capabilities_resource.cc @@ -0,0 +1,36 @@ +// 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 "base/logging.h" +#include "ppapi/proxy/camera_capabilities_resource.h" + +namespace ppapi { +namespace proxy { + +CameraCapabilitiesResource::CameraCapabilitiesResource( + PP_Instance instance, + const std::vector<PP_Size>& preview_sizes) + : Resource(OBJECT_IS_PROXY, instance), + num_preview_sizes_(static_cast<int32_t>(preview_sizes.size())), + preview_sizes_(new PP_Size[num_preview_sizes_]) { + std::copy(preview_sizes.begin(), preview_sizes.end(), preview_sizes_.get()); +} + +CameraCapabilitiesResource::~CameraCapabilitiesResource() { +} + +thunk::PPB_CameraCapabilities_API* +CameraCapabilitiesResource::AsPPB_CameraCapabilities_API() { + return this; +} + +void CameraCapabilitiesResource::GetSupportedPreviewSizes( + int32_t* array_size, + PP_Size** preview_sizes) { + *array_size = num_preview_sizes_; + *preview_sizes = preview_sizes_.get(); +} + +} // namespace proxy +} // namespace ppapi diff --git a/ppapi/proxy/camera_capabilities_resource.h b/ppapi/proxy/camera_capabilities_resource.h new file mode 100644 index 0000000..237910a --- /dev/null +++ b/ppapi/proxy/camera_capabilities_resource.h @@ -0,0 +1,47 @@ +// 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_CAPABILITIES_RESOURCE_H_ +#define PPAPI_PROXY_CAMERA_CAPABILITIES_RESOURCE_H_ + +#include <vector> + +#include "base/basictypes.h" +#include "base/memory/scoped_ptr.h" +#include "ppapi/proxy/ppapi_proxy_export.h" +#include "ppapi/shared_impl/resource.h" +#include "ppapi/thunk/ppb_camera_capabilities_api.h" + +namespace ppapi { +namespace proxy { + +class ImageCaptureResource; + +class PPAPI_PROXY_EXPORT CameraCapabilitiesResource + : public Resource, + public thunk::PPB_CameraCapabilities_API { + public: + CameraCapabilitiesResource(PP_Instance instance, + const std::vector<PP_Size>& preview_sizes); + + ~CameraCapabilitiesResource() override; + + // Resource overrides. + thunk::PPB_CameraCapabilities_API* AsPPB_CameraCapabilities_API() override; + + // PPB_CameraCapabilities_API implementation. + void GetSupportedPreviewSizes(int32_t* array_size, + PP_Size** preview_sizes) override; + + private: + int32_t num_preview_sizes_; + scoped_ptr<PP_Size[]> preview_sizes_; + + DISALLOW_COPY_AND_ASSIGN(CameraCapabilitiesResource); +}; + +} // namespace proxy +} // namespace ppapi + +#endif // PPAPI_PROXY_CAMERA_CAPABILITIES_RESOURCE_H_ diff --git a/ppapi/proxy/image_capture_resource.cc b/ppapi/proxy/image_capture_resource.cc new file mode 100644 index 0000000..cccd1c6 --- /dev/null +++ b/ppapi/proxy/image_capture_resource.cc @@ -0,0 +1,119 @@ +// 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<TrackedCallback>& callback) { + if (open_state_ != OpenState::BEFORE_OPEN) + return PP_ERROR_FAILED; + + if (TrackedCallback::IsPending(open_callback_)) + return PP_ERROR_INPROGRESS; + + scoped_refptr<StringVar> source_string_var(StringVar::FromPPVar(device_id)); + if (!source_string_var || source_string_var->value().empty()) + return PP_ERROR_BADARGUMENT; + + open_callback_ = callback; + + Call<PpapiPluginMsg_ImageCapture_OpenReply>( + 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<TrackedCallback>& 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<PpapiPluginMsg_ImageCapture_GetSupportedPreviewSizesReply>( + RENDERER, PpapiHostMsg_ImageCapture_GetSupportedPreviewSizes(), + base::Bind(&ImageCaptureResource::OnPluginMsgGetPreviewSizesReply, + 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::OnPluginMsgGetPreviewSizesReply( + PP_Resource* capabilities_output, + const ResourceMessageReplyParams& params, + const std::vector<PP_Size>& preview_sizes) { + if (!TrackedCallback::IsPending(get_capabilities_callback_)) + return; + + // Return camera capabilities. + int32_t result = params.result(); + scoped_refptr<TrackedCallback> callback; + callback.swap(get_capabilities_callback_); + if (result == PP_OK) { + camera_capabilities_ = + new CameraCapabilitiesResource(pp_instance(), preview_sizes); + *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 new file mode 100644 index 0000000..491c91e --- /dev/null +++ b/ppapi/proxy/image_capture_resource.h @@ -0,0 +1,66 @@ +// 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/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<TrackedCallback>& callback) override; + void Close() override; + int32_t GetCameraCapabilities( + PP_Resource* capabilities, + const scoped_refptr<TrackedCallback>& callback) override; + + private: + enum class OpenState { BEFORE_OPEN, OPENED, CLOSED }; + + void OnPluginMsgGetPreviewSizesReply( + PP_Resource* capabilities_output, + const ResourceMessageReplyParams& params, + const std::vector<PP_Size>& preview_sizes); + 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<TrackedCallback> open_callback_; + OpenState open_state_; + + scoped_refptr<TrackedCallback> get_capabilities_callback_; + scoped_refptr<CameraCapabilitiesResource> 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 413b7cf..81c4375 100644 --- a/ppapi/proxy/interface_list.cc +++ b/ppapi/proxy/interface_list.cc @@ -73,6 +73,7 @@ #include "ppapi/c/ppb_view.h" #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_content_decryptor_private.h" #include "ppapi/c/private/ppb_ext_crx_file_system_private.h" #include "ppapi/c/private/ppb_file_io_private.h" @@ -89,6 +90,7 @@ #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 d23a077..2899371 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -1541,7 +1541,19 @@ IPC_MESSAGE_CONTROL2(PpapiHostMsg_Graphics2D_ReadImageData, PP_Point /* top_left */) IPC_MESSAGE_CONTROL0(PpapiPluginMsg_Graphics2D_ReadImageDataAck) -// IsolatedFileSystem +// ImageCapture ---------------------------------------------------------------- +IPC_MESSAGE_CONTROL0(PpapiHostMsg_ImageCapture_Create) +IPC_MESSAGE_CONTROL0(PpapiHostMsg_ImageCapture_Close) + +IPC_MESSAGE_CONTROL1(PpapiHostMsg_ImageCapture_Open, + std::string /* camera_source_id */) +IPC_MESSAGE_CONTROL0(PpapiPluginMsg_ImageCapture_OpenReply) + +IPC_MESSAGE_CONTROL0(PpapiHostMsg_ImageCapture_GetSupportedPreviewSizes) +IPC_MESSAGE_CONTROL1(PpapiPluginMsg_ImageCapture_GetSupportedPreviewSizesReply, + std::vector<PP_Size> /* preview_sizes */) + +// IsolatedFileSystem ---------------------------------------------------------- IPC_MESSAGE_CONTROL0(PpapiHostMsg_IsolatedFileSystem_Create) IPC_MESSAGE_CONTROL1(PpapiHostMsg_IsolatedFileSystem_BrowserOpen, PP_IsolatedFileSystemType_Private /* type */) @@ -2243,6 +2255,8 @@ IPC_MESSAGE_CONTROL1(PpapiHostMsg_PDF_SetSelectedText, IPC_MESSAGE_CONTROL1(PpapiHostMsg_PDF_SetLinkUnderCursor, std::string /* url */) +// VideoCapture ---------------------------------------------------------------- + // VideoCapture_Dev, plugin -> host IPC_MESSAGE_CONTROL0(PpapiHostMsg_VideoCapture_Create) IPC_MESSAGE_CONTROL0(PpapiHostMsg_VideoCapture_StartCapture) diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc index b00f05c..1599589 100644 --- a/ppapi/proxy/resource_creation_proxy.cc +++ b/ppapi/proxy/resource_creation_proxy.cc @@ -19,6 +19,7 @@ #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" @@ -458,6 +459,11 @@ 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 89aadbc..70acd1e9 100644 --- a/ppapi/proxy/resource_creation_proxy.h +++ b/ppapi/proxy/resource_creation_proxy.h @@ -177,6 +177,7 @@ 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 97a5b4e..5db4ce7 100644 --- a/ppapi/shared_impl/resource.h +++ b/ppapi/shared_impl/resource.h @@ -29,6 +29,7 @@ F(PPB_BrowserFont_Singleton_API) \ F(PPB_BrowserFont_Trusted_API) \ F(PPB_Buffer_API) \ + F(PPB_CameraCapabilities_API) \ F(PPB_Compositor_API) \ F(PPB_CompositorLayer_API) \ F(PPB_DeviceRef_API) \ @@ -52,6 +53,7 @@ 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/thunk/BUILD.gn b/ppapi/thunk/BUILD.gn index 8e66d92..2dee0d7 100644 --- a/ppapi/thunk/BUILD.gn +++ b/ppapi/thunk/BUILD.gn @@ -147,6 +147,8 @@ source_set("thunk") { "ppb_broker_thunk.cc", "ppb_browser_font_trusted_thunk.cc", "ppb_buffer_thunk.cc", + "ppb_camera_capabilities_api.h", + "ppb_camera_capabilities_private_thunk.cc", "ppb_char_set_thunk.cc", "ppb_content_decryptor_private_thunk.cc", "ppb_flash_clipboard_thunk.cc", @@ -160,6 +162,8 @@ 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 70c6c2e..3d24b01 100644 --- a/ppapi/thunk/interfaces_ppb_private.h +++ b/ppapi/thunk/interfaces_ppb_private.h @@ -23,6 +23,8 @@ PROXIED_IFACE(PPB_BROKER_TRUSTED_INTERFACE_0_3, PPB_BrokerTrusted_0_3) 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_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_13, PPB_ContentDecryptor_Private_0_13) PROXIED_IFACE(PPB_CHARSET_TRUSTED_INTERFACE_1_0, @@ -39,6 +41,8 @@ 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_capabilities_api.h b/ppapi/thunk/ppb_camera_capabilities_api.h new file mode 100644 index 0000000..ba51f5f --- /dev/null +++ b/ppapi/thunk/ppb_camera_capabilities_api.h @@ -0,0 +1,25 @@ +// 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_CAPABILITIES_API_H_ +#define PPAPI_THUNK_PPB_CAMERA_CAPABILITIES_API_H_ + +#include "ppapi/c/private/ppb_camera_capabilities_private.h" +#include "ppapi/thunk/ppapi_thunk_export.h" + +namespace ppapi { + +namespace thunk { + +class PPAPI_THUNK_EXPORT PPB_CameraCapabilities_API { + public: + virtual ~PPB_CameraCapabilities_API() {} + virtual void GetSupportedPreviewSizes(int32_t* array_size, + PP_Size** preview_sizes) = 0; +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_PPB_CAMERA_CAPABILITIES_API_H_ diff --git a/ppapi/thunk/ppb_camera_capabilities_private_thunk.cc b/ppapi/thunk/ppb_camera_capabilities_private_thunk.cc index baebc82..3940a04 100644 --- a/ppapi/thunk/ppb_camera_capabilities_private_thunk.cc +++ b/ppapi/thunk/ppb_camera_capabilities_private_thunk.cc @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// From private/ppb_camera_capabilities_private.idl modified Wed Nov 5 14:29:15 -// 2014. +// From private/ppb_camera_capabilities_private.idl modified Tue Feb 3 19:54:34 +// 2015. #include "ppapi/c/pp_errors.h" #include "ppapi/c/private/ppb_camera_capabilities_private.h" @@ -17,14 +17,6 @@ namespace thunk { namespace { -PP_Resource Create(PP_Instance instance) { - VLOG(4) << "PPB_CameraCapabilities_Private::Create()"; - EnterResourceCreation enter(instance); - if (enter.failed()) - return 0; - return enter.functions()->CreateCameraCapabilitiesPrivate(instance); -} - PP_Bool IsCameraCapabilities(PP_Resource resource) { VLOG(4) << "PPB_CameraCapabilities_Private::IsCameraCapabilities()"; EnterResource<PPB_CameraCapabilities_API> enter(resource, false); @@ -41,21 +33,9 @@ void GetSupportedPreviewSizes(PP_Resource capabilities, enter.object()->GetSupportedPreviewSizes(array_size, preview_sizes); } -void GetSupportedJpegSizes(PP_Resource capabilities, - int32_t* array_size, - struct PP_Size** jpeg_sizes) { - VLOG(4) << "PPB_CameraCapabilities_Private::GetSupportedJpegSizes()"; - EnterResource<PPB_CameraCapabilities_API> enter(capabilities, true); - if (enter.failed()) - return; - enter.object()->GetSupportedJpegSizes(array_size, jpeg_sizes); -} - const PPB_CameraCapabilities_Private_0_1 - g_ppb_cameracapabilities_private_thunk_0_1 = {&Create, - &IsCameraCapabilities, - &GetSupportedPreviewSizes, - &GetSupportedJpegSizes}; + g_ppb_cameracapabilities_private_thunk_0_1 = {&IsCameraCapabilities, + &GetSupportedPreviewSizes}; } // namespace diff --git a/ppapi/thunk/ppb_image_capture_api.h b/ppapi/thunk/ppb_image_capture_api.h new file mode 100644 index 0000000..d0d92ae --- /dev/null +++ b/ppapi/thunk/ppb_image_capture_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_IMAGE_CAPTURE_API_H_ +#define PPAPI_THUNK_PPB_IMAGE_CAPTURE_API_H_ + +#include <string> + +#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<TrackedCallback>& callback) = 0; + virtual void Close() = 0; + virtual int32_t GetCameraCapabilities( + PP_Resource* capabilities, + const scoped_refptr<TrackedCallback>& 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 index 47db157..2b55183 100644 --- a/ppapi/thunk/ppb_image_capture_private_thunk.cc +++ b/ppapi/thunk/ppb_image_capture_private_thunk.cc @@ -2,7 +2,7 @@ // 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 Thu Feb 5 22:47:43 2015. +// 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" @@ -17,15 +17,12 @@ namespace thunk { namespace { -PP_Resource Create(PP_Instance instance, - struct PP_Var camera_source_id, - void* user_data) { +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, camera_source_id, user_data); + return enter.functions()->CreateImageCapturePrivate(instance); } PP_Bool IsImageCapture(PP_Resource resource) { @@ -34,12 +31,22 @@ PP_Bool IsImageCapture(PP_Resource resource) { return PP_FromBool(enter.succeeded()); } -int32_t Close(PP_Resource resource, struct PP_CompletionCallback callback) { - VLOG(4) << "PPB_ImageCapture_Private::Close()"; - EnterResource<PPB_ImageCapture_API> enter(resource, callback, true); +int32_t Open(PP_Resource image_capture, + struct PP_Var device_id, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_ImageCapture_Private::Open()"; + EnterResource<PPB_ImageCapture_API> enter(image_capture, callback, true); if (enter.failed()) return enter.retval(); - return enter.SetResult(enter.object()->Close(enter.callback())); + return enter.SetResult(enter.object()->Open(device_id, enter.callback())); +} + +void Close(PP_Resource image_capture) { + VLOG(4) << "PPB_ImageCapture_Private::Close()"; + EnterResource<PPB_ImageCapture_API> enter(image_capture, true); + if (enter.failed()) + return; + enter.object()->Close(); } int32_t GetCameraCapabilities(PP_Resource image_capture, @@ -54,7 +61,7 @@ int32_t GetCameraCapabilities(PP_Resource image_capture, } const PPB_ImageCapture_Private_0_1 g_ppb_imagecapture_private_thunk_0_1 = - {&Create, &IsImageCapture, &Close, &GetCameraCapabilities}; + {&Create, &IsImageCapture, &Open, &Close, &GetCameraCapabilities}; } // namespace diff --git a/ppapi/thunk/resource_creation_api.h b/ppapi/thunk/resource_creation_api.h index fa2a781..204b8a1 100644 --- a/ppapi/thunk/resource_creation_api.h +++ b/ppapi/thunk/resource_creation_api.h @@ -190,6 +190,7 @@ 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, |