Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Unified Diff: webkit/plugins/ppapi/ppb_video_capture_impl.h

Issue 9234064: Implement device enumeration for PPB_VideoCapture_Dev. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changes in response to Antoine's comments. Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webkit/plugins/ppapi/ppb_video_capture_impl.h
diff --git a/webkit/plugins/ppapi/ppb_video_capture_impl.h b/webkit/plugins/ppapi/ppb_video_capture_impl.h
index 7486e1764d615b45db8da75b8b830c4826a33f20..2947aaeabac315adb1c62d78590b739388896091 100644
--- a/webkit/plugins/ppapi/ppb_video_capture_impl.h
+++ b/webkit/plugins/ppapi/ppb_video_capture_impl.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -9,10 +9,11 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/ref_counted.h"
#include "media/video/capture/video_capture.h"
#include "ppapi/c/dev/ppp_video_capture_dev.h"
#include "ppapi/shared_impl/resource.h"
+#include "ppapi/shared_impl/tracked_callback.h"
#include "ppapi/thunk/ppb_video_capture_api.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/ppapi/ppb_buffer_impl.h"
@@ -22,9 +23,11 @@ struct PP_VideoCaptureDeviceInfo_Dev;
namespace webkit {
namespace ppapi {
-class PPB_VideoCapture_Impl : public ::ppapi::Resource,
- public ::ppapi::thunk::PPB_VideoCapture_API,
- public media::VideoCapture::EventHandler {
+class PPB_VideoCapture_Impl
+ : public ::ppapi::Resource,
+ public ::ppapi::thunk::PPB_VideoCapture_API,
+ public PluginDelegate::PlatformVideoCaptureEventHandler,
+ public base::SupportsWeakPtr<PPB_VideoCapture_Impl> {
public:
explicit PPB_VideoCapture_Impl(PP_Instance instance);
virtual ~PPB_VideoCapture_Impl();
@@ -33,16 +36,20 @@ class PPB_VideoCapture_Impl : public ::ppapi::Resource,
// Resource overrides.
virtual PPB_VideoCapture_API* AsPPB_VideoCapture_API() OVERRIDE;
- virtual void LastPluginRefWasDeleted() OVERRIDE;
- // PPB_VideoCapture implementation.
+ // PPB_VideoCapture_API implementation.
+ virtual int32_t EnumerateDevices(PP_CompletionCallback callback) OVERRIDE;
+ virtual PP_Resource GetDevices() OVERRIDE;
virtual int32_t StartCapture(
+ const std::string& device_id,
const PP_VideoCaptureDeviceInfo_Dev& requested_info,
uint32_t buffer_count) OVERRIDE;
virtual int32_t ReuseBuffer(uint32_t buffer) OVERRIDE;
virtual int32_t StopCapture() OVERRIDE;
+ virtual const std::vector<::ppapi::DeviceRefData>& GetDeviceRefData(
+ ) const OVERRIDE;
- // media::VideoCapture::EventHandler implementation.
+ // PluginDelegate::PlatformVideoCaptureEventHandler implementation.
virtual void OnStarted(media::VideoCapture* capture) OVERRIDE;
virtual void OnStopped(media::VideoCapture* capture) OVERRIDE;
virtual void OnPaused(media::VideoCapture* capture) OVERRIDE;
@@ -54,12 +61,22 @@ class PPB_VideoCapture_Impl : public ::ppapi::Resource,
virtual void OnDeviceInfoReceived(
media::VideoCapture* capture,
const media::VideoCaptureParams& device_info) OVERRIDE;
+ virtual void OnInitialized(media::VideoCapture* capture,
+ bool succeeded) OVERRIDE;
private:
void ReleaseBuffers();
void SendStatus();
- scoped_ptr<PluginDelegate::PlatformVideoCapture> platform_video_capture_;
+ void ClearCachedDeviceResourceArray();
+ void DetachPlatformVideoCapture();
+
+ void OnEnumerateDevicesComplete(
+ int request_id,
+ bool succeeded,
+ const std::vector<::ppapi::DeviceRefData>& devices);
brettw 2012/02/06 21:51:52 You'll need a space before the :: to make GCC happ
yzshen1 2012/02/10 07:10:44 Done.
+
+ scoped_refptr<PluginDelegate::PlatformVideoCapture> platform_video_capture_;
size_t buffer_count_hint_;
struct BufferInfo {
@@ -75,11 +92,14 @@ class PPB_VideoCapture_Impl : public ::ppapi::Resource,
const PPP_VideoCapture_Dev* ppp_videocapture_;
PP_VideoCaptureStatus_Dev status_;
- // Signifies that the plugin has given up all its refs, but the object is
- // still alive, possibly because the backend hasn't released the object as
- // |EventHandler| yet. It can be removed if/when |EventHandler| is made to be
- // refcounted (and made into a "member" of this object instead).
- bool is_dead_;
+ scoped_refptr<::ppapi::TrackedCallback> enumerate_devices_callback_;
+
+ // A resource array holding the enumeration result. When nonzero, we're
+ // holding a reference to it.
+ PP_Resource devices_;
+ std::vector<::ppapi::DeviceRefData> devices_data_;
brettw 2012/02/06 21:51:52 Ditto.
yzshen1 2012/02/10 07:10:44 Done.
+
+ media::VideoCapture::VideoCaptureCapability capability_;
DISALLOW_COPY_AND_ASSIGN(PPB_VideoCapture_Impl);
};

Powered by Google App Engine
This is Rietveld 408576698