• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #include "ppapi/cpp/private/flash_drm.h"
6 
7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/c/private/ppb_flash_device_id.h"
9 #include "ppapi/c/private/ppb_flash_drm.h"
10 #include "ppapi/cpp/module_impl.h"
11 
12 namespace pp {
13 
14 namespace {
15 
interface_name()16 template <> const char* interface_name<PPB_Flash_DRM_1_0>() {
17   return PPB_FLASH_DRM_INTERFACE_1_0;
18 }
19 
interface_name()20 template <> const char* interface_name<PPB_Flash_DRM_1_1>() {
21   return PPB_FLASH_DRM_INTERFACE_1_1;
22 }
23 
interface_name()24 template <> const char* interface_name<PPB_Flash_DeviceID_1_0>() {
25   return PPB_FLASH_DEVICEID_INTERFACE_1_0;
26 }
27 
28 }  // namespace
29 
30 namespace flash {
31 
DRM()32 DRM::DRM() {
33 }
34 
DRM(const InstanceHandle & instance)35 DRM::DRM(const InstanceHandle& instance) : Resource() {
36   if (has_interface<PPB_Flash_DRM_1_1>()) {
37     PassRefFromConstructor(get_interface<PPB_Flash_DRM_1_1>()->Create(
38         instance.pp_instance()));
39   } else if (has_interface<PPB_Flash_DRM_1_0>()) {
40     PassRefFromConstructor(get_interface<PPB_Flash_DRM_1_0>()->Create(
41         instance.pp_instance()));
42   } else if (has_interface<PPB_Flash_DeviceID_1_0>()) {
43     PassRefFromConstructor(get_interface<PPB_Flash_DeviceID_1_0>()->Create(
44         instance.pp_instance()));
45   }
46 }
47 
GetDeviceID(const CompletionCallbackWithOutput<Var> & callback)48 int32_t DRM::GetDeviceID(const CompletionCallbackWithOutput<Var>& callback) {
49   if (has_interface<PPB_Flash_DRM_1_1>()) {
50     return get_interface<PPB_Flash_DRM_1_1>()->GetDeviceID(
51         pp_resource(),
52         callback.output(),
53         callback.pp_completion_callback());
54   }
55   if (has_interface<PPB_Flash_DRM_1_0>()) {
56     return get_interface<PPB_Flash_DRM_1_0>()->GetDeviceID(
57         pp_resource(),
58         callback.output(),
59         callback.pp_completion_callback());
60   }
61   if (has_interface<PPB_Flash_DeviceID_1_0>()) {
62     return get_interface<PPB_Flash_DeviceID_1_0>()->GetDeviceID(
63         pp_resource(),
64         callback.output(),
65         callback.pp_completion_callback());
66   }
67   return callback.MayForce(PP_ERROR_NOINTERFACE);
68 }
69 
GetHmonitor(int64_t * hmonitor)70 bool DRM::GetHmonitor(int64_t* hmonitor) {
71   if (has_interface<PPB_Flash_DRM_1_1>()) {
72     return PP_ToBool(get_interface<PPB_Flash_DRM_1_1>()->GetHmonitor(
73         pp_resource(),
74         hmonitor));
75   }
76   if (has_interface<PPB_Flash_DRM_1_0>()) {
77     return PP_ToBool(get_interface<PPB_Flash_DRM_1_0>()->GetHmonitor(
78         pp_resource(),
79         hmonitor));
80   }
81   return 0;
82 }
83 
GetVoucherFile(const CompletionCallbackWithOutput<FileRef> & callback)84 int32_t DRM::GetVoucherFile(
85     const CompletionCallbackWithOutput<FileRef>& callback) {
86   if (has_interface<PPB_Flash_DRM_1_1>()) {
87     return get_interface<PPB_Flash_DRM_1_1>()->GetVoucherFile(
88         pp_resource(),
89         callback.output(),
90         callback.pp_completion_callback());
91   }
92   if (has_interface<PPB_Flash_DRM_1_0>()) {
93     return get_interface<PPB_Flash_DRM_1_0>()->GetVoucherFile(
94         pp_resource(),
95         callback.output(),
96         callback.pp_completion_callback());
97   }
98   return PP_ERROR_NOINTERFACE;
99 }
100 
MonitorIsExternal(const CompletionCallbackWithOutput<PP_Bool> & callback)101 int32_t DRM::MonitorIsExternal(
102     const CompletionCallbackWithOutput<PP_Bool>& callback) {
103   if (has_interface<PPB_Flash_DRM_1_1>()) {
104     return get_interface<PPB_Flash_DRM_1_1>()->MonitorIsExternal(
105         pp_resource(),
106         callback.output(),
107         callback.pp_completion_callback());
108   }
109   return PP_ERROR_NOINTERFACE;
110 }
111 
112 }  // namespace flash
113 }  // namespace pp
114