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

Side by Side Diff: ppapi/cpp/private/flash.cc

Issue 11016007: Implement host side of sync EnumerateVideoCaptureDevices (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 2 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) 2012 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/private/flash.h" 5 #include "ppapi/cpp/private/flash.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "ppapi/c/pp_bool.h" 9 #include "ppapi/c/pp_bool.h"
10 #include "ppapi/c/pp_errors.h" 10 #include "ppapi/c/pp_errors.h"
11 #include "ppapi/cpp/dev/device_ref_dev.h"
11 #include "ppapi/cpp/dev/font_dev.h" 12 #include "ppapi/cpp/dev/font_dev.h"
13 #include "ppapi/cpp/dev/video_capture_dev.h"
12 #include "ppapi/cpp/image_data.h" 14 #include "ppapi/cpp/image_data.h"
13 #include "ppapi/cpp/instance_handle.h" 15 #include "ppapi/cpp/instance_handle.h"
14 #include "ppapi/cpp/module.h" 16 #include "ppapi/cpp/module.h"
15 #include "ppapi/cpp/module_impl.h" 17 #include "ppapi/cpp/module_impl.h"
16 #include "ppapi/cpp/point.h" 18 #include "ppapi/cpp/point.h"
17 #include "ppapi/cpp/rect.h" 19 #include "ppapi/cpp/rect.h"
18 #include "ppapi/cpp/url_request_info.h" 20 #include "ppapi/cpp/url_request_info.h"
19 #include "ppapi/cpp/var.h" 21 #include "ppapi/cpp/var.h"
20 #include "ppapi/c/private/ppb_flash.h" 22 #include "ppapi/c/private/ppb_flash.h"
21 #include "ppapi/c/private/ppb_flash_print.h" 23 #include "ppapi/c/private/ppb_flash_print.h"
22 24
23 namespace pp { 25 namespace pp {
24 26
25 namespace { 27 namespace {
26 28
29 template <> const char* interface_name<PPB_Flash_12_6>() {
30 return PPB_FLASH_INTERFACE_12_6;
31 }
32
27 template <> const char* interface_name<PPB_Flash_12_5>() { 33 template <> const char* interface_name<PPB_Flash_12_5>() {
28 return PPB_FLASH_INTERFACE_12_5; 34 return PPB_FLASH_INTERFACE_12_5;
29 } 35 }
30 36
31 template <> const char* interface_name<PPB_Flash_12_4>() { 37 template <> const char* interface_name<PPB_Flash_12_4>() {
32 return PPB_FLASH_INTERFACE_12_4; 38 return PPB_FLASH_INTERFACE_12_4;
33 } 39 }
34 40
35 template <> const char* interface_name<PPB_Flash_12_3>() { 41 template <> const char* interface_name<PPB_Flash_12_3>() {
36 return PPB_FLASH_INTERFACE_12_3; 42 return PPB_FLASH_INTERFACE_12_3;
37 } 43 }
38 44
39 template <> const char* interface_name<PPB_Flash_Print_1_0>() { 45 template <> const char* interface_name<PPB_Flash_Print_1_0>() {
40 return PPB_FLASH_PRINT_INTERFACE_1_0; 46 return PPB_FLASH_PRINT_INTERFACE_1_0;
41 } 47 }
42 48
43 // The combined Flash interface is all Flash v12.* interfaces. All v12 49 // The combined Flash interface is all Flash v12.* interfaces. All v12
44 // interfaces just append one or more functions to the previous one, so we can 50 // interfaces just append one or more functions to the previous one, so we can
45 // have this meta one at the most recent version. Function pointers will be 51 // have this meta one at the most recent version. Function pointers will be
46 // null if they're not supported on the current Chrome version. 52 // null if they're not supported on the current Chrome version.
47 bool initialized_combined_interface = false; 53 bool initialized_combined_interface = false;
48 PPB_Flash flash_12_combined_interface; 54 PPB_Flash flash_12_combined_interface;
49 55
50 // Makes sure that the most recent version is loaded into the combined 56 // Makes sure that the most recent version is loaded into the combined
51 // interface struct above. Any unsupported functions will be NULL. If there 57 // interface struct above. Any unsupported functions will be NULL. If there
52 // is no Flash interface supported, all functions will be NULL. 58 // is no Flash interface supported, all functions will be NULL.
53 void InitializeCombinedInterface() { 59 void InitializeCombinedInterface() {
54 if (initialized_combined_interface) 60 if (initialized_combined_interface)
55 return; 61 return;
56 if (has_interface<PPB_Flash_12_5>()) { 62 if (has_interface<PPB_Flash_12_5>()) {
yzshen1 2012/10/10 18:17:39 Haha! Please use 12_6. :)
raymes 2012/10/11 18:39:26 Good catch, thanks.
63 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_6>(),
64 sizeof(PPB_Flash_12_6));
65 } else if (has_interface<PPB_Flash_12_5>()) {
57 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_5>(), 66 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_5>(),
58 sizeof(PPB_Flash_12_5)); 67 sizeof(PPB_Flash_12_5));
59 } else if (has_interface<PPB_Flash_12_4>()) { 68 } else if (has_interface<PPB_Flash_12_4>()) {
60 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_4>(), 69 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_4>(),
61 sizeof(PPB_Flash_12_4)); 70 sizeof(PPB_Flash_12_4));
62 } else if (has_interface<PPB_Flash_12_3>()) { 71 } else if (has_interface<PPB_Flash_12_3>()) {
63 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_3>(), 72 memcpy(&flash_12_combined_interface, get_interface<PPB_Flash_12_3>(),
64 sizeof(PPB_Flash_12_3)); 73 sizeof(PPB_Flash_12_3));
65 } 74 }
66 initialized_combined_interface = true; 75 initialized_combined_interface = true;
67 } 76 }
68 77
69 } // namespace 78 } // namespace
70 79
71 namespace flash { 80 namespace flash {
72 81
73 // static 82 // static
74 bool Flash::IsAvailable() { 83 bool Flash::IsAvailable() {
75 return has_interface<PPB_Flash_12_5>() || 84 return has_interface<PPB_Flash_12_6>() ||
85 has_interface<PPB_Flash_12_5>() ||
76 has_interface<PPB_Flash_12_4>() || 86 has_interface<PPB_Flash_12_4>() ||
77 has_interface<PPB_Flash_12_3>(); 87 has_interface<PPB_Flash_12_3>();
78 } 88 }
79 89
80 // static 90 // static
81 void Flash::SetInstanceAlwaysOnTop(const InstanceHandle& instance, 91 void Flash::SetInstanceAlwaysOnTop(const InstanceHandle& instance,
82 bool on_top) { 92 bool on_top) {
83 InitializeCombinedInterface(); 93 InitializeCombinedInterface();
84 if (flash_12_combined_interface.SetInstanceAlwaysOnTop) { 94 if (flash_12_combined_interface.SetInstanceAlwaysOnTop) {
85 flash_12_combined_interface.SetInstanceAlwaysOnTop( 95 flash_12_combined_interface.SetInstanceAlwaysOnTop(
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 InitializeCombinedInterface(); 249 InitializeCombinedInterface();
240 if (flash_12_combined_interface.SetCrashData) { 250 if (flash_12_combined_interface.SetCrashData) {
241 return PP_ToBool( 251 return PP_ToBool(
242 flash_12_combined_interface.SetCrashData(instance.pp_instance(), 252 flash_12_combined_interface.SetCrashData(instance.pp_instance(),
243 key, value.pp_var())); 253 key, value.pp_var()));
244 } 254 }
245 return false; 255 return false;
246 } 256 }
247 257
248 // static 258 // static
259 int32_t Flash::EnumerateVideoDevicesSync(
260 const InstanceHandle& instance,
261 const VideoCapture_Dev& video_capture,
262 std::vector<DeviceRef_Dev>* devices_out) {
263 InitializeCombinedInterface();
264 if (flash_12_combined_interface.EnumerateVideoDevicesSync) {
265 ResourceArrayOutputAdapter<DeviceRef_Dev> adapter(devices_out);
266 return flash_12_combined_interface.EnumerateVideoDevicesSync(
yzshen1 2012/10/10 18:17:39 Please update the function name.
raymes 2012/10/11 18:39:26 Done.
267 instance.pp_instance(),
268 video_capture.pp_resource(),
269 adapter.pp_array_output());
270 }
271 return PP_ERROR_FAILED;
272 }
273
274 // static
249 bool Flash::InvokePrinting(const InstanceHandle& instance) { 275 bool Flash::InvokePrinting(const InstanceHandle& instance) {
250 if (has_interface<PPB_Flash_Print_1_0>()) { 276 if (has_interface<PPB_Flash_Print_1_0>()) {
251 get_interface<PPB_Flash_Print_1_0>()->InvokePrinting( 277 get_interface<PPB_Flash_Print_1_0>()->InvokePrinting(
252 instance.pp_instance()); 278 instance.pp_instance());
253 return true; 279 return true;
254 } 280 }
255 return false; 281 return false;
256 } 282 }
257 283
258 } // namespace flash 284 } // namespace flash
259 } // namespace pp 285 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698