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

Unified Diff: ppapi/cpp/dev/video_capture_dev.cc

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: ppapi/cpp/dev/video_capture_dev.cc
diff --git a/ppapi/cpp/dev/video_capture_dev.cc b/ppapi/cpp/dev/video_capture_dev.cc
index ecb55729309c5badbf17fb4efa2f0cef32d8593f..7a4502835ce377d21789e0b4ccc7cebb1aadd38d 100644
--- a/ppapi/cpp/dev/video_capture_dev.cc
+++ b/ppapi/cpp/dev/video_capture_dev.cc
@@ -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.
@@ -6,6 +6,9 @@
#include "ppapi/c/dev/ppb_video_capture_dev.h"
#include "ppapi/c/pp_errors.h"
+#include "ppapi/cpp/completion_callback.h"
+#include "ppapi/cpp/dev/device_ref_dev.h"
+#include "ppapi/cpp/dev/resource_array_dev.h"
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/module_impl.h"
@@ -39,13 +42,34 @@ bool VideoCapture_Dev::IsAvailable() {
return has_interface<PPB_VideoCapture_Dev>();
}
+int32_t VideoCapture_Dev::EnumerateDevices(const CompletionCallback& callback) {
+ if (!has_interface<PPB_VideoCapture_Dev>())
+ return callback.MayForce(PP_ERROR_NOINTERFACE);
+ return get_interface<PPB_VideoCapture_Dev>()->EnumerateDevices(
+ pp_resource(), callback.pp_completion_callback());
+}
+
+void VideoCapture_Dev::GetDevices(std::vector<DeviceRef_Dev>* devices) {
+ if (!has_interface<PPB_VideoCapture_Dev>() || !devices)
+ return;
+ devices->clear();
+ ResourceArray_Dev resources(
+ ResourceArray_Dev::PassRef(),
+ get_interface<PPB_VideoCapture_Dev>()->GetDevices(pp_resource()));
+ for (uint32_t index = 0; index < resources.size(); ++index) {
+ DeviceRef_Dev device(resources[index]);
+ devices->push_back(device);
+ }
+}
+
int32_t VideoCapture_Dev::StartCapture(
+ const DeviceRef_Dev& device_ref,
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);
+ pp_resource(), device_ref.pp_resource(), &requested_info, buffer_count);
}
int32_t VideoCapture_Dev::ReuseBuffer(uint32_t buffer) {

Powered by Google App Engine
This is Rietveld 408576698