summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/component_updater/ppapi_utils.cc2
-rw-r--r--content/content_renderer.gypi4
-rw-r--r--content/renderer/pepper/content_renderer_pepper_host_factory.cc12
-rw-r--r--content/renderer/pepper/pepper_image_capture_host.cc125
-rw-r--r--content/renderer/pepper/pepper_image_capture_host.h64
-rw-r--r--content/renderer/pepper/pepper_platform_image_capture.cc127
-rw-r--r--content/renderer/pepper/pepper_platform_image_capture.h73
-rw-r--r--content/renderer/pepper/plugin_module.cc2
-rw-r--r--content/renderer/pepper/resource_creation_impl.cc5
-rw-r--r--content/renderer/pepper/resource_creation_impl.h1
-rw-r--r--ppapi/api/private/ppb_camera_capabilities_private.idl32
-rw-r--r--ppapi/api/private/ppb_image_capture_private.idl40
-rw-r--r--ppapi/c/private/ppb_camera_capabilities_private.h30
-rw-r--r--ppapi/c/private/ppb_image_capture_private.h37
-rw-r--r--ppapi/cpp/private/camera_capabilities_private.cc73
-rw-r--r--ppapi/cpp/private/camera_capabilities_private.h16
-rw-r--r--ppapi/cpp/private/image_capture_private.cc87
-rw-r--r--ppapi/cpp/private/image_capture_private.h70
-rw-r--r--ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c26
-rw-r--r--ppapi/ppapi_proxy.gypi6
-rw-r--r--ppapi/ppapi_shared.gypi6
-rw-r--r--ppapi/ppapi_sources.gypi6
-rw-r--r--ppapi/proxy/BUILD.gn4
-rw-r--r--ppapi/proxy/camera_capabilities_resource.cc36
-rw-r--r--ppapi/proxy/camera_capabilities_resource.h47
-rw-r--r--ppapi/proxy/image_capture_resource.cc119
-rw-r--r--ppapi/proxy/image_capture_resource.h66
-rw-r--r--ppapi/proxy/interface_list.cc2
-rw-r--r--ppapi/proxy/ppapi_messages.h16
-rw-r--r--ppapi/proxy/resource_creation_proxy.cc6
-rw-r--r--ppapi/proxy/resource_creation_proxy.h1
-rw-r--r--ppapi/shared_impl/resource.h2
-rw-r--r--ppapi/thunk/BUILD.gn4
-rw-r--r--ppapi/thunk/interfaces_ppb_private.h4
-rw-r--r--ppapi/thunk/ppb_camera_capabilities_api.h25
-rw-r--r--ppapi/thunk/ppb_camera_capabilities_private_thunk.cc28
-rw-r--r--ppapi/thunk/ppb_image_capture_api.h33
-rw-r--r--ppapi/thunk/ppb_image_capture_private_thunk.cc29
-rw-r--r--ppapi/thunk/resource_creation_api.h1
-rw-r--r--tools/metrics/histograms/histograms.xml2
40 files changed, 1078 insertions, 191 deletions
diff --git a/chrome/browser/component_updater/ppapi_utils.cc b/chrome/browser/component_updater/ppapi_utils.cc
index a9c097e..544e165 100644
--- a/chrome/browser/component_updater/ppapi_utils.cc
+++ b/chrome/browser/component_updater/ppapi_utils.cc
@@ -75,6 +75,7 @@
#include "ppapi/c/ppb_video_frame.h"
#include "ppapi/c/ppb_view.h"
#include "ppapi/c/ppb_websocket.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"
@@ -91,6 +92,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_output_protection_private.h"
diff --git a/content/content_renderer.gypi b/content/content_renderer.gypi
index 12f91ac..c4b1672 100644
--- a/content/content_renderer.gypi
+++ b/content/content_renderer.gypi
@@ -486,6 +486,8 @@
'renderer/pepper/pepper_graphics_2d_host.h',
'renderer/pepper/pepper_hung_plugin_filter.cc',
'renderer/pepper/pepper_hung_plugin_filter.h',
+ 'renderer/pepper/pepper_image_capture_host.cc',
+ 'renderer/pepper/pepper_image_capture_host.h',
'renderer/pepper/pepper_in_process_resource_creation.cc',
'renderer/pepper/pepper_in_process_resource_creation.h',
'renderer/pepper/pepper_in_process_router.cc',
@@ -496,6 +498,8 @@
'renderer/pepper/pepper_platform_audio_input.h',
'renderer/pepper/pepper_platform_audio_output.cc',
'renderer/pepper/pepper_platform_audio_output.h',
+ 'renderer/pepper/pepper_platform_image_capture.cc',
+ 'renderer/pepper/pepper_platform_image_capture.h',
'renderer/pepper/pepper_platform_video_capture.cc',
'renderer/pepper/pepper_platform_video_capture.h',
'renderer/pepper/pepper_plugin_instance_impl.cc',
diff --git a/content/renderer/pepper/content_renderer_pepper_host_factory.cc b/content/renderer/pepper/content_renderer_pepper_host_factory.cc
index 9d7fae6..598c18a 100644
--- a/content/renderer/pepper/content_renderer_pepper_host_factory.cc
+++ b/content/renderer/pepper/content_renderer_pepper_host_factory.cc
@@ -15,6 +15,7 @@
#include "content/renderer/pepper/pepper_file_ref_renderer_host.h"
#include "content/renderer/pepper/pepper_file_system_host.h"
#include "content/renderer/pepper/pepper_graphics_2d_host.h"
+#include "content/renderer/pepper/pepper_image_capture_host.h"
#include "content/renderer/pepper/pepper_media_stream_video_track_host.h"
#include "content/renderer/pepper/pepper_plugin_instance_impl.h"
#include "content/renderer/pepper/pepper_url_loader_host.h"
@@ -200,6 +201,17 @@ scoped_ptr<ResourceHost> ContentRendererPepperHostFactory::CreateResourceHost(
}
}
+ // Private interfaces.
+ if (GetPermissions().HasPermission(ppapi::PERMISSION_PRIVATE)) {
+ switch (message.type()) {
+ case PpapiHostMsg_ImageCapture_Create::ID: {
+ scoped_ptr<PepperImageCaptureHost> host(
+ new PepperImageCaptureHost(host_, instance, resource));
+ return host->Init() ? host.Pass() : nullptr;
+ }
+ }
+ }
+
return scoped_ptr<ResourceHost>();
}
diff --git a/content/renderer/pepper/pepper_image_capture_host.cc b/content/renderer/pepper/pepper_image_capture_host.cc
new file mode 100644
index 0000000..0734891
--- /dev/null
+++ b/content/renderer/pepper/pepper_image_capture_host.cc
@@ -0,0 +1,125 @@
+// 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 "content/renderer/pepper/pepper_image_capture_host.h"
+
+#include "content/renderer/pepper/pepper_platform_image_capture.h"
+#include "content/renderer/pepper/renderer_ppapi_host_impl.h"
+#include "content/renderer/render_frame_impl.h"
+#include "ppapi/host/dispatch_host_message.h"
+#include "ppapi/proxy/ppapi_messages.h"
+
+namespace content {
+
+PepperImageCaptureHost::PepperImageCaptureHost(RendererPpapiHostImpl* host,
+ PP_Instance instance,
+ PP_Resource resource)
+ : ResourceHost(host->GetPpapiHost(), instance, resource),
+ renderer_ppapi_host_(host) {
+}
+
+PepperImageCaptureHost::~PepperImageCaptureHost() {
+ DetachPlatformImageCapture();
+}
+
+bool PepperImageCaptureHost::Init() {
+ return !!renderer_ppapi_host_->GetPluginInstance(pp_instance());
+}
+
+int32_t PepperImageCaptureHost::OnResourceMessageReceived(
+ const IPC::Message& msg,
+ ppapi::host::HostMessageContext* context) {
+ int32_t result = PP_ERROR_FAILED;
+
+ PPAPI_BEGIN_MESSAGE_MAP(PepperImageCaptureHost, msg)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_ImageCapture_Open, OnOpen)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(
+ PpapiHostMsg_ImageCapture_GetSupportedPreviewSizes,
+ OnGetSupportedPreviewSizes)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_ImageCapture_Close,
+ OnClose)
+ PPAPI_END_MESSAGE_MAP()
+ return result;
+}
+
+void PepperImageCaptureHost::OnInitialized(bool succeeded) {
+ if (!open_reply_context_.is_valid())
+ return;
+
+ if (succeeded) {
+ open_reply_context_.params.set_result(PP_OK);
+ } else {
+ DetachPlatformImageCapture();
+ open_reply_context_.params.set_result(PP_ERROR_FAILED);
+ }
+
+ host()->SendReply(open_reply_context_,
+ PpapiPluginMsg_ImageCapture_OpenReply());
+ open_reply_context_ = ppapi::host::ReplyMessageContext();
+}
+
+void PepperImageCaptureHost::OnPreviewSizesEnumerated(
+ const std::vector<PP_Size>& sizes) {
+ if (!preview_sizes_reply_context_.is_valid())
+ return;
+
+ if (sizes.size() > 0)
+ preview_sizes_reply_context_.params.set_result(PP_OK);
+ else
+ preview_sizes_reply_context_.params.set_result(PP_ERROR_FAILED);
+ host()->SendReply(
+ preview_sizes_reply_context_,
+ PpapiPluginMsg_ImageCapture_GetSupportedPreviewSizesReply(sizes));
+ preview_sizes_reply_context_ = ppapi::host::ReplyMessageContext();
+}
+
+int32_t PepperImageCaptureHost::OnOpen(ppapi::host::HostMessageContext* context,
+ const std::string& device_id) {
+ if (open_reply_context_.is_valid())
+ return PP_ERROR_INPROGRESS;
+
+ if (platform_image_capture_.get())
+ return PP_ERROR_FAILED;
+
+ GURL document_url = renderer_ppapi_host_->GetDocumentURL(pp_instance());
+ if (!document_url.is_valid())
+ return PP_ERROR_FAILED;
+
+ platform_image_capture_.reset(new PepperPlatformImageCapture(
+ renderer_ppapi_host_->GetRenderFrameForInstance(pp_instance())
+ ->GetRoutingID(),
+ device_id, document_url, this));
+
+ open_reply_context_ = context->MakeReplyMessageContext();
+
+ return PP_OK_COMPLETIONPENDING;
+}
+
+int32_t PepperImageCaptureHost::OnClose(
+ ppapi::host::HostMessageContext* context) {
+ DetachPlatformImageCapture();
+ return PP_OK;
+}
+
+int32_t PepperImageCaptureHost::OnGetSupportedPreviewSizes(
+ ppapi::host::HostMessageContext* context) {
+ if (preview_sizes_reply_context_.is_valid())
+ return PP_ERROR_INPROGRESS;
+ if (!platform_image_capture_)
+ return PP_ERROR_FAILED;
+
+ preview_sizes_reply_context_ = context->MakeReplyMessageContext();
+ platform_image_capture_->GetPreviewSizes();
+
+ return PP_OK_COMPLETIONPENDING;
+}
+
+void PepperImageCaptureHost::DetachPlatformImageCapture() {
+ if (platform_image_capture_) {
+ platform_image_capture_->DetachEventHandler();
+ platform_image_capture_.reset();
+ }
+}
+
+} // namespace content
diff --git a/content/renderer/pepper/pepper_image_capture_host.h b/content/renderer/pepper/pepper_image_capture_host.h
new file mode 100644
index 0000000..126e462
--- /dev/null
+++ b/content/renderer/pepper/pepper_image_capture_host.h
@@ -0,0 +1,64 @@
+// 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 CONTENT_RENDERER_PEPPER_PEPPER_IMAGE_CAPTURE_HOST_H_
+#define CONTENT_RENDERER_PEPPER_PEPPER_IMAGE_CAPTURE_HOST_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "content/public/renderer/renderer_ppapi_host.h"
+#include "content/renderer/pepper/ppb_buffer_impl.h"
+#include "ppapi/c/pp_size.h"
+#include "ppapi/host/host_message_context.h"
+#include "ppapi/host/resource_host.h"
+
+namespace content {
+class PepperPlatformImageCapture;
+class RendererPpapiHostImpl;
+
+class PepperImageCaptureHost : public ppapi::host::ResourceHost {
+ public:
+ PepperImageCaptureHost(RendererPpapiHostImpl* host,
+ PP_Instance instance,
+ PP_Resource resource);
+
+ ~PepperImageCaptureHost() override;
+
+ bool Init();
+
+ int32_t OnResourceMessageReceived(
+ const IPC::Message& msg,
+ ppapi::host::HostMessageContext* context) override;
+
+ // These methods are called by PepperPlatformImageCapture only.
+
+ // Called when image capture is initialized.
+ void OnInitialized(bool succeeded);
+
+ // Called when the preview frame sizes are enumerated.
+ void OnPreviewSizesEnumerated(const std::vector<PP_Size>& sizes);
+
+ private:
+ // Plugin -> host message handlers.
+ int32_t OnOpen(ppapi::host::HostMessageContext* context,
+ const std::string& device_id);
+ int32_t OnClose(ppapi::host::HostMessageContext* context);
+ int32_t OnGetSupportedPreviewSizes(ppapi::host::HostMessageContext* context);
+
+ // Utility methods.
+ void DetachPlatformImageCapture();
+
+ scoped_ptr<PepperPlatformImageCapture> platform_image_capture_;
+
+ RendererPpapiHostImpl* renderer_ppapi_host_;
+
+ ppapi::host::ReplyMessageContext open_reply_context_;
+
+ ppapi::host::ReplyMessageContext preview_sizes_reply_context_;
+
+ DISALLOW_COPY_AND_ASSIGN(PepperImageCaptureHost);
+};
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_PEPPER_PEPPER_IMAGE_CAPTURE_HOST_H_
diff --git a/content/renderer/pepper/pepper_platform_image_capture.cc b/content/renderer/pepper/pepper_platform_image_capture.cc
new file mode 100644
index 0000000..65f8f9d
--- /dev/null
+++ b/content/renderer/pepper/pepper_platform_image_capture.cc
@@ -0,0 +1,127 @@
+// 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 "content/renderer/pepper/pepper_platform_image_capture.h"
+
+#include "base/bind.h"
+#include "base/callback_helpers.h"
+#include "base/logging.h"
+#include "base/message_loop/message_loop_proxy.h"
+#include "content/renderer/media/video_capture_impl_manager.h"
+#include "content/renderer/pepper/gfx_conversion.h"
+#include "content/renderer/pepper/pepper_image_capture_host.h"
+#include "content/renderer/pepper/pepper_media_device_manager.h"
+#include "content/renderer/render_frame_impl.h"
+#include "content/renderer/render_thread_impl.h"
+#include "media/base/bind_to_current_loop.h"
+#include "url/gurl.h"
+
+namespace content {
+
+PepperPlatformImageCapture::PepperPlatformImageCapture(
+ int render_frame_id,
+ const std::string& device_id,
+ const GURL& document_url,
+ PepperImageCaptureHost* handler)
+ : render_frame_id_(render_frame_id),
+ device_id_(device_id),
+ session_id_(0),
+ handler_(handler),
+ pending_open_device_(false),
+ pending_open_device_id_(-1),
+ weak_factory_(this) {
+ // We need to open the device and obtain the label and session ID before
+ // initializing.
+ PepperMediaDeviceManager* const device_manager = GetMediaDeviceManager();
+ if (device_manager) {
+ pending_open_device_id_ = device_manager->OpenDevice(
+ PP_DEVICETYPE_DEV_VIDEOCAPTURE, device_id, document_url,
+ base::Bind(&PepperPlatformImageCapture::OnDeviceOpened,
+ weak_factory_.GetWeakPtr()));
+ pending_open_device_ = true;
+ }
+}
+
+void PepperPlatformImageCapture::GetPreviewSizes() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ VideoCaptureImplManager* manager =
+ RenderThreadImpl::current()->video_capture_impl_manager();
+ manager->GetDeviceSupportedFormats(
+ session_id_,
+ media::BindToCurrentLoop(base::Bind(
+ &PepperPlatformImageCapture::OnDeviceSupportedFormatsEnumerated,
+ weak_factory_.GetWeakPtr())));
+}
+
+void PepperPlatformImageCapture::DetachEventHandler() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ handler_ = NULL;
+ if (!release_device_cb_.is_null()) {
+ base::ResetAndReturn(&release_device_cb_).Run();
+ }
+ if (!label_.empty()) {
+ PepperMediaDeviceManager* const device_manager = GetMediaDeviceManager();
+ if (device_manager)
+ device_manager->CloseDevice(label_);
+ label_.clear();
+ }
+ if (pending_open_device_) {
+ PepperMediaDeviceManager* const device_manager = GetMediaDeviceManager();
+ if (device_manager)
+ device_manager->CancelOpenDevice(pending_open_device_id_);
+ pending_open_device_ = false;
+ pending_open_device_id_ = -1;
+ }
+}
+
+PepperPlatformImageCapture::~PepperPlatformImageCapture() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(release_device_cb_.is_null());
+ DCHECK(label_.empty());
+ DCHECK(!pending_open_device_);
+}
+
+void PepperPlatformImageCapture::OnDeviceOpened(int request_id,
+ bool succeeded,
+ const std::string& label) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(handler_);
+
+ pending_open_device_ = false;
+ pending_open_device_id_ = -1;
+
+ PepperMediaDeviceManager* const device_manager = GetMediaDeviceManager();
+ succeeded = succeeded && device_manager;
+ if (succeeded) {
+ label_ = label;
+ session_id_ =
+ device_manager->GetSessionID(PP_DEVICETYPE_DEV_VIDEOCAPTURE, label);
+ VideoCaptureImplManager* manager =
+ RenderThreadImpl::current()->video_capture_impl_manager();
+ release_device_cb_ = manager->UseDevice(session_id_);
+ }
+
+ handler_->OnInitialized(succeeded);
+}
+
+void PepperPlatformImageCapture::OnDeviceSupportedFormatsEnumerated(
+ const media::VideoCaptureFormats& formats) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(handler_);
+
+ std::vector<PP_Size> sizes;
+ for (const auto& format : formats)
+ sizes.push_back(PP_FromGfxSize(format.frame_size));
+ handler_->OnPreviewSizesEnumerated(sizes);
+}
+
+PepperMediaDeviceManager* PepperPlatformImageCapture::GetMediaDeviceManager() {
+ RenderFrameImpl* const render_frame =
+ RenderFrameImpl::FromRoutingID(render_frame_id_);
+ return render_frame
+ ? PepperMediaDeviceManager::GetForRenderFrame(render_frame).get()
+ : NULL;
+}
+
+} // namespace content
diff --git a/content/renderer/pepper/pepper_platform_image_capture.h b/content/renderer/pepper/pepper_platform_image_capture.h
new file mode 100644
index 0000000..b65acee
--- /dev/null
+++ b/content/renderer/pepper/pepper_platform_image_capture.h
@@ -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.
+
+#ifndef CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_VIDEO_CAPTURE_H_
+#define CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_VIDEO_CAPTURE_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/callback.h"
+#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "base/threading/thread_checker.h"
+#include "content/common/media/video_capture.h"
+#include "media/video/capture/video_capture_types.h"
+
+class GURL;
+
+namespace content {
+class PepperMediaDeviceManager;
+class PepperImageCaptureHost;
+
+// This object must only be used on the thread it's constructed on.
+class PepperPlatformImageCapture {
+ public:
+ PepperPlatformImageCapture(int render_frame_id,
+ const std::string& device_id,
+ const GURL& document_url,
+ PepperImageCaptureHost* handler);
+ ~PepperPlatformImageCapture();
+
+ // Detaches the event handler and stops sending notifications to it.
+ void DetachEventHandler();
+
+ void GetPreviewSizes();
+
+ private:
+ void OnDeviceOpened(int request_id, bool succeeded, const std::string& label);
+
+ // Called by VideoCaptureImplManager.
+ void OnDeviceSupportedFormatsEnumerated(
+ const media::VideoCaptureFormats& formats);
+
+ // Can return NULL if the RenderFrame referenced by |render_frame_id_| has
+ // gone away.
+ PepperMediaDeviceManager* GetMediaDeviceManager();
+
+ const int render_frame_id_;
+ const std::string device_id_;
+
+ std::string label_;
+ int session_id_;
+ base::Closure release_device_cb_;
+
+ PepperImageCaptureHost* handler_;
+
+ // Whether we have a pending request to open a device. We have to make sure
+ // there isn't any pending request before this object goes away.
+ bool pending_open_device_;
+ int pending_open_device_id_;
+
+ base::ThreadChecker thread_checker_;
+
+ base::WeakPtrFactory<PepperPlatformImageCapture> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(PepperPlatformImageCapture);
+};
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_VIDEO_CAPTURE_H_
diff --git a/content/renderer/pepper/plugin_module.cc b/content/renderer/pepper/plugin_module.cc
index 40b42bb..1164c43 100644
--- a/content/renderer/pepper/plugin_module.cc
+++ b/content/renderer/pepper/plugin_module.cc
@@ -98,6 +98,7 @@
#include "ppapi/c/ppb_view.h"
#include "ppapi/c/ppp.h"
#include "ppapi/c/ppp_instance.h"
+#include "ppapi/c/private/ppb_camera_capabilities_private.h"
#include "ppapi/c/private/ppb_ext_crx_file_system_private.h"
#include "ppapi/c/private/ppb_file_io_private.h"
#include "ppapi/c/private/ppb_file_ref_private.h"
@@ -113,6 +114,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_instance_private.h"
#include "ppapi/c/private/ppb_isolated_file_system_private.h"
diff --git a/content/renderer/pepper/resource_creation_impl.cc b/content/renderer/pepper/resource_creation_impl.cc
index 94c8db9..7935785 100644
--- a/content/renderer/pepper/resource_creation_impl.cc
+++ b/content/renderer/pepper/resource_creation_impl.cc
@@ -128,6 +128,11 @@ PP_Resource ResourceCreationImpl::CreateHostResolverPrivate(
return 0; // Not supported in-process.
}
+PP_Resource ResourceCreationImpl::CreateImageCapturePrivate(
+ PP_Instance instance) {
+ return 0; // Not supported in-process.
+}
+
PP_Resource ResourceCreationImpl::CreateImageData(PP_Instance instance,
PP_ImageDataFormat format,
const PP_Size* size,
diff --git a/content/renderer/pepper/resource_creation_impl.h b/content/renderer/pepper/resource_creation_impl.h
index 834b68a..fc8c6aac 100644
--- a/content/renderer/pepper/resource_creation_impl.h
+++ b/content/renderer/pepper/resource_creation_impl.h
@@ -58,6 +58,7 @@ class ResourceCreationImpl : public ppapi::thunk::ResourceCreationAPI {
base::SharedMemoryHandle* shared_state) override;
PP_Resource CreateHostResolver(PP_Instance instance) override;
PP_Resource CreateHostResolverPrivate(PP_Instance instance) override;
+ PP_Resource CreateImageCapturePrivate(PP_Instance instance) override;
PP_Resource CreateImageData(PP_Instance instance,
PP_ImageDataFormat format,
const PP_Size* size,
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,
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml
index 2fbb3f0..e26a958 100644
--- a/tools/metrics/histograms/histograms.xml
+++ b/tools/metrics/histograms/histograms.xml
@@ -54724,6 +54724,7 @@ To add a new entry, add it with any value and run test to compute valid value.
<int value="62905097" label="PPB_TrueTypeFont(Dev);0.1"/>
<int value="79708274" label="PPB_TCPSocket;1.1"/>
<int value="110360074" label="PPB_Var;1.1"/>
+ <int value="125017713" label="PPB_CameraCapabilities_Private;0.1"/>
<int value="126651696" label="PPB_ContentDecryptor_Private;0.12"/>
<int value="138418890" label="PPB_Memory(Dev);0.1"/>
<int value="153443470" label="PPB_URLResponseInfo;1.0"/>
@@ -54834,6 +54835,7 @@ To add a new entry, add it with any value and run test to compute valid value.
<int value="1577776196" label="PPB_InputEvent_Private;0.1"/>
<int value="1641037564" label="PPB_VideoSource_Private;0.1"/>
<int value="1645591549" label="PPB_Widget(Dev);0.3"/>
+ <int value="1659973365" label="PPB_ImageCapture_Private;0.1"/>
<int value="1677958987" label="PPB_ImageData;1.0"/>
<int value="1680873803" label="PPB_Console;1.0"/>
<int value="1681523535" label="PPB_TCPSocket;1.2"/>