summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorpiman@google.com <piman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-09 02:47:00 +0000
committerpiman@google.com <piman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-09 02:47:00 +0000
commit7741135df7b043aaf0dbfeaedb05cef26655d108 (patch)
tree0571495999fcd3f35987e75e1392f3277e824aec /ppapi
parentca492c6510a189c0e9a9acd957af488958c62d94 (diff)
downloadchromium_src-7741135df7b043aaf0dbfeaedb05cef26655d108.zip
chromium_src-7741135df7b043aaf0dbfeaedb05cef26655d108.tar.gz
chromium_src-7741135df7b043aaf0dbfeaedb05cef26655d108.tar.bz2
C++ wrappers for PPB_VideoCapture_Dev
BUG=None TEST=VideoCapture sample (in a later CL) Review URL: http://codereview.chromium.org/7528006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95942 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/cpp/dev/buffer_dev.cc5
-rw-r--r--ppapi/cpp/dev/buffer_dev.h1
-rw-r--r--ppapi/cpp/dev/video_capture_client_dev.cc78
-rw-r--r--ppapi/cpp/dev/video_capture_client_dev.h36
-rw-r--r--ppapi/cpp/dev/video_capture_dev.cc59
-rw-r--r--ppapi/cpp/dev/video_capture_dev.h29
-rw-r--r--ppapi/ppapi_cpp.gypi4
7 files changed, 212 insertions, 0 deletions
diff --git a/ppapi/cpp/dev/buffer_dev.cc b/ppapi/cpp/dev/buffer_dev.cc
index d2be1d0..aa616de 100644
--- a/ppapi/cpp/dev/buffer_dev.cc
+++ b/ppapi/cpp/dev/buffer_dev.cc
@@ -27,6 +27,11 @@ Buffer_Dev::Buffer_Dev(const Buffer_Dev& other)
Init();
}
+Buffer_Dev::Buffer_Dev(PP_Resource resource)
+ : Resource(resource) {
+ Init();
+}
+
Buffer_Dev::Buffer_Dev(Instance* instance, uint32_t size)
: data_(NULL),
size_(0) {
diff --git a/ppapi/cpp/dev/buffer_dev.h b/ppapi/cpp/dev/buffer_dev.h
index a8780e0..9e9ac813 100644
--- a/ppapi/cpp/dev/buffer_dev.h
+++ b/ppapi/cpp/dev/buffer_dev.h
@@ -16,6 +16,7 @@ class Buffer_Dev : public Resource {
// Creates an is_null() Buffer object.
Buffer_Dev();
Buffer_Dev(const Buffer_Dev& other);
+ explicit Buffer_Dev(PP_Resource resource);
// Creates & Maps a new Buffer in the browser with the given size. The
// resulting object will be is_null() if either Create() or Map() fails.
diff --git a/ppapi/cpp/dev/video_capture_client_dev.cc b/ppapi/cpp/dev/video_capture_client_dev.cc
new file mode 100644
index 0000000..1bebeec
--- /dev/null
+++ b/ppapi/cpp/dev/video_capture_client_dev.cc
@@ -0,0 +1,78 @@
+// Copyright (c) 2011 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/dev/video_capture_client_dev.h"
+
+#include "ppapi/c/dev/ppp_video_capture_dev.h"
+#include "ppapi/cpp/instance.h"
+#include "ppapi/cpp/module.h"
+
+namespace pp {
+
+namespace {
+
+const char kPPPVideoCaptureInterface[] = PPP_VIDEO_CAPTURE_DEV_INTERFACE;
+
+void OnDeviceInfo(PP_Instance instance,
+ PP_Resource resource,
+ const struct PP_VideoCaptureDeviceInfo_Dev* info,
+ uint32_t buffer_count,
+ const PP_Resource* buffers) {
+ VideoCaptureClient_Dev* client = static_cast<VideoCaptureClient_Dev*>(
+ Instance::GetPerInstanceObject(instance, kPPPVideoCaptureInterface));
+ if (!client)
+ return;
+
+ std::vector<Buffer_Dev> buffer_list;
+ buffer_list.reserve(buffer_count);
+ for (uint32_t i = 0; i < buffer_count; ++i)
+ buffer_list.push_back(Buffer_Dev(buffers[i]));
+
+ client->OnDeviceInfo(resource, *info, buffer_list);
+}
+
+void OnStatus(PP_Instance instance, PP_Resource resource, uint32_t status) {
+ VideoCaptureClient_Dev* client = static_cast<VideoCaptureClient_Dev*>(
+ Instance::GetPerInstanceObject(instance, kPPPVideoCaptureInterface));
+ if (client)
+ client->OnStatus(resource, status);
+}
+
+void OnError(PP_Instance instance, PP_Resource resource, uint32_t error_code) {
+ VideoCaptureClient_Dev* client = static_cast<VideoCaptureClient_Dev*>(
+ Instance::GetPerInstanceObject(instance, kPPPVideoCaptureInterface));
+ if (client)
+ client->OnError(resource, error_code);
+}
+
+void OnBufferReady(PP_Instance instance,
+ PP_Resource resource,
+ uint32_t buffer) {
+ VideoCaptureClient_Dev* client = static_cast<VideoCaptureClient_Dev*>(
+ Instance::GetPerInstanceObject(instance, kPPPVideoCaptureInterface));
+ if (client)
+ client->OnBufferReady(resource, buffer);
+}
+
+PPP_VideoCapture_Dev ppp_video_capture = {
+ OnDeviceInfo,
+ OnStatus,
+ OnError,
+ OnBufferReady
+};
+
+} // namespace
+
+VideoCaptureClient_Dev::VideoCaptureClient_Dev(Instance* instance)
+ : instance_(instance) {
+ pp::Module::Get()->AddPluginInterface(kPPPVideoCaptureInterface,
+ &ppp_video_capture);
+ instance_->AddPerInstanceObject(kPPPVideoCaptureInterface, this);
+}
+
+VideoCaptureClient_Dev::~VideoCaptureClient_Dev() {
+ instance_->RemovePerInstanceObject(kPPPVideoCaptureInterface, this);
+}
+
+} // namespace pp
diff --git a/ppapi/cpp/dev/video_capture_client_dev.h b/ppapi/cpp/dev/video_capture_client_dev.h
new file mode 100644
index 0000000..77d0ed9
--- /dev/null
+++ b/ppapi/cpp/dev/video_capture_client_dev.h
@@ -0,0 +1,36 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PPAPI_CPP_DEV_VIDEO_CAPTURE_CLIENT_DEV_H_
+#define PPAPI_CPP_DEV_VIDEO_CAPTURE_CLIENT_DEV_H_
+
+#include <vector>
+
+#include "ppapi/c/dev/pp_video_capture_dev.h"
+#include "ppapi/cpp/dev/buffer_dev.h"
+#include "ppapi/cpp/resource.h"
+
+namespace pp {
+
+class Instance;
+
+class VideoCaptureClient_Dev {
+ public:
+ explicit VideoCaptureClient_Dev(Instance* instance);
+ virtual ~VideoCaptureClient_Dev();
+
+ virtual void OnDeviceInfo(PP_Resource video_capture,
+ const PP_VideoCaptureDeviceInfo_Dev& info,
+ const std::vector<Buffer_Dev>& buffers) = 0;
+ virtual void OnStatus(PP_Resource video_capture, uint32_t status) = 0;
+ virtual void OnError(PP_Resource video_capture, uint32_t error) = 0;
+ virtual void OnBufferReady(PP_Resource video_capture, uint32_t buffer) = 0;
+
+ private:
+ Instance* instance_;
+};
+
+} // namespace pp
+
+#endif // PPAPI_CPP_DEV_VIDEO_CAPTURE_CLIENT_DEV_H_
diff --git a/ppapi/cpp/dev/video_capture_dev.cc b/ppapi/cpp/dev/video_capture_dev.cc
new file mode 100644
index 0000000..41e36b9
--- /dev/null
+++ b/ppapi/cpp/dev/video_capture_dev.cc
@@ -0,0 +1,59 @@
+// Copyright (c) 2011 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/dev/video_capture_dev.h"
+
+#include "ppapi/c/dev/ppb_video_capture_dev.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/cpp/instance.h"
+#include "ppapi/cpp/module.h"
+#include "ppapi/cpp/module_impl.h"
+
+namespace pp {
+
+namespace {
+
+template <> const char* interface_name<PPB_VideoCapture_Dev>() {
+ return PPB_VIDEO_CAPTURE_DEV_INTERFACE;
+}
+
+} // namespace
+
+VideoCapture_Dev::VideoCapture_Dev(const Instance& instance) {
+ if (!has_interface<PPB_VideoCapture_Dev>())
+ return;
+ PassRefFromConstructor(get_interface<PPB_VideoCapture_Dev>()->Create(
+ instance.pp_instance()));
+}
+
+VideoCapture_Dev::VideoCapture_Dev(PP_Resource resource) : Resource(resource) {
+}
+
+VideoCapture_Dev::VideoCapture_Dev(const VideoCapture_Dev& other)
+ : Resource(other) {
+}
+
+int32_t VideoCapture_Dev::StartCapture(
+ const PP_VideoCaptureDeviceInfo_Dev& requested_info,
+ uint32_t buffer_count) {
+ if (!has_interface<PPB_VideoCapture_Dev>())
+ return PP_ERROR_FAILED;
+ return get_interface<PPB_VideoCapture_Dev>()->StartCapture(
+ pp_resource(), &requested_info, buffer_count);
+}
+
+int32_t VideoCapture_Dev::ReuseBuffer(uint32_t buffer) {
+ if (!has_interface<PPB_VideoCapture_Dev>())
+ return PP_ERROR_FAILED;
+ return get_interface<PPB_VideoCapture_Dev>()->ReuseBuffer(
+ pp_resource(), buffer);
+}
+
+int32_t VideoCapture_Dev::StopCapture(){
+ if (!has_interface<PPB_VideoCapture_Dev>())
+ return PP_ERROR_FAILED;
+ return get_interface<PPB_VideoCapture_Dev>()->StopCapture(pp_resource());
+}
+
+} // namespace pp
diff --git a/ppapi/cpp/dev/video_capture_dev.h b/ppapi/cpp/dev/video_capture_dev.h
new file mode 100644
index 0000000..af996ed
--- /dev/null
+++ b/ppapi/cpp/dev/video_capture_dev.h
@@ -0,0 +1,29 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PPAPI_CPP_DEV_VIDEO_CAPTURE_DEV_H_
+#define PPAPI_CPP_DEV_VIDEO_CAPTURE_DEV_H_
+
+#include "ppapi/c/dev/pp_video_capture_dev.h"
+#include "ppapi/cpp/resource.h"
+
+namespace pp {
+
+class Instance;
+
+class VideoCapture_Dev : public Resource {
+ public:
+ explicit VideoCapture_Dev(const Instance& instance);
+ VideoCapture_Dev(PP_Resource resource);
+ VideoCapture_Dev(const VideoCapture_Dev& other);
+
+ int32_t StartCapture(const PP_VideoCaptureDeviceInfo_Dev& requested_info,
+ uint32_t buffer_count);
+ int32_t ReuseBuffer(uint32_t buffer);
+ int32_t StopCapture();
+};
+
+} // namespace pp
+
+#endif // PPAPI_CPP_DEV_VIDEO_CAPTURE_DEV_H_
diff --git a/ppapi/ppapi_cpp.gypi b/ppapi/ppapi_cpp.gypi
index 829fbe1..5debaed 100644
--- a/ppapi/ppapi_cpp.gypi
+++ b/ppapi/ppapi_cpp.gypi
@@ -212,6 +212,10 @@
'cpp/dev/surface_3d_dev.h',
'cpp/dev/url_util_dev.cc',
'cpp/dev/url_util_dev.h',
+ 'cpp/dev/video_capture_client_dev.cc',
+ 'cpp/dev/video_capture_client_dev.h',
+ 'cpp/dev/video_capture_dev.cc',
+ 'cpp/dev/video_capture_dev.h',
'cpp/dev/video_decoder_client_dev.cc',
'cpp/dev/video_decoder_client_dev.h',
'cpp/dev/video_decoder_dev.cc',