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

Side by Side 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, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/cpp/dev/video_capture_dev.h" 5 #include "ppapi/cpp/dev/video_capture_dev.h"
6 6
7 #include "ppapi/c/dev/ppb_video_capture_dev.h" 7 #include "ppapi/c/dev/ppb_video_capture_dev.h"
8 #include "ppapi/c/pp_errors.h" 8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/cpp/completion_callback.h"
10 #include "ppapi/cpp/dev/device_ref_dev.h"
11 #include "ppapi/cpp/dev/resource_array_dev.h"
9 #include "ppapi/cpp/instance.h" 12 #include "ppapi/cpp/instance.h"
10 #include "ppapi/cpp/module.h" 13 #include "ppapi/cpp/module.h"
11 #include "ppapi/cpp/module_impl.h" 14 #include "ppapi/cpp/module_impl.h"
12 15
13 namespace pp { 16 namespace pp {
14 17
15 namespace { 18 namespace {
16 19
17 template <> const char* interface_name<PPB_VideoCapture_Dev>() { 20 template <> const char* interface_name<PPB_VideoCapture_Dev>() {
18 return PPB_VIDEOCAPTURE_DEV_INTERFACE; 21 return PPB_VIDEOCAPTURE_DEV_INTERFACE;
(...skipping 13 matching lines...) Expand all
32 35
33 VideoCapture_Dev::VideoCapture_Dev(const VideoCapture_Dev& other) 36 VideoCapture_Dev::VideoCapture_Dev(const VideoCapture_Dev& other)
34 : Resource(other) { 37 : Resource(other) {
35 } 38 }
36 39
37 // static 40 // static
38 bool VideoCapture_Dev::IsAvailable() { 41 bool VideoCapture_Dev::IsAvailable() {
39 return has_interface<PPB_VideoCapture_Dev>(); 42 return has_interface<PPB_VideoCapture_Dev>();
40 } 43 }
41 44
45 int32_t VideoCapture_Dev::EnumerateDevices(const CompletionCallback& callback) {
46 if (!has_interface<PPB_VideoCapture_Dev>())
47 return callback.MayForce(PP_ERROR_NOINTERFACE);
48 return get_interface<PPB_VideoCapture_Dev>()->EnumerateDevices(
49 pp_resource(), callback.pp_completion_callback());
50 }
51
52 void VideoCapture_Dev::GetDevices(std::vector<DeviceRef_Dev>* devices) {
53 if (!has_interface<PPB_VideoCapture_Dev>() || !devices)
54 return;
55 devices->clear();
56 ResourceArray_Dev resources(
57 ResourceArray_Dev::PassRef(),
58 get_interface<PPB_VideoCapture_Dev>()->GetDevices(pp_resource()));
59 for (uint32_t index = 0; index < resources.size(); ++index) {
60 DeviceRef_Dev device(resources[index]);
61 devices->push_back(device);
62 }
63 }
64
42 int32_t VideoCapture_Dev::StartCapture( 65 int32_t VideoCapture_Dev::StartCapture(
66 const DeviceRef_Dev& device_ref,
43 const PP_VideoCaptureDeviceInfo_Dev& requested_info, 67 const PP_VideoCaptureDeviceInfo_Dev& requested_info,
44 uint32_t buffer_count) { 68 uint32_t buffer_count) {
45 if (!has_interface<PPB_VideoCapture_Dev>()) 69 if (!has_interface<PPB_VideoCapture_Dev>())
46 return PP_ERROR_FAILED; 70 return PP_ERROR_FAILED;
47 return get_interface<PPB_VideoCapture_Dev>()->StartCapture( 71 return get_interface<PPB_VideoCapture_Dev>()->StartCapture(
48 pp_resource(), &requested_info, buffer_count); 72 pp_resource(), device_ref.pp_resource(), &requested_info, buffer_count);
49 } 73 }
50 74
51 int32_t VideoCapture_Dev::ReuseBuffer(uint32_t buffer) { 75 int32_t VideoCapture_Dev::ReuseBuffer(uint32_t buffer) {
52 if (!has_interface<PPB_VideoCapture_Dev>()) 76 if (!has_interface<PPB_VideoCapture_Dev>())
53 return PP_ERROR_FAILED; 77 return PP_ERROR_FAILED;
54 return get_interface<PPB_VideoCapture_Dev>()->ReuseBuffer( 78 return get_interface<PPB_VideoCapture_Dev>()->ReuseBuffer(
55 pp_resource(), buffer); 79 pp_resource(), buffer);
56 } 80 }
57 81
58 int32_t VideoCapture_Dev::StopCapture(){ 82 int32_t VideoCapture_Dev::StopCapture(){
59 if (!has_interface<PPB_VideoCapture_Dev>()) 83 if (!has_interface<PPB_VideoCapture_Dev>())
60 return PP_ERROR_FAILED; 84 return PP_ERROR_FAILED;
61 return get_interface<PPB_VideoCapture_Dev>()->StopCapture(pp_resource()); 85 return get_interface<PPB_VideoCapture_Dev>()->StopCapture(pp_resource());
62 } 86 }
63 87
64 } // namespace pp 88 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698