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.
5 #include "ppapi/cpp/private/flash_drm.h"
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"
16 template <> const char* interface_name
<PPB_Flash_DRM_1_0
>() {
17 return PPB_FLASH_DRM_INTERFACE_1_0
;
20 template <> const char* interface_name
<PPB_Flash_DRM_1_1
>() {
21 return PPB_FLASH_DRM_INTERFACE_1_1
;
24 template <> const char* interface_name
<PPB_Flash_DeviceID_1_0
>() {
25 return PPB_FLASH_DEVICEID_INTERFACE_1_0
;
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()));
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(
53 callback
.pp_completion_callback());
55 if (has_interface
<PPB_Flash_DRM_1_0
>()) {
56 return get_interface
<PPB_Flash_DRM_1_0
>()->GetDeviceID(
59 callback
.pp_completion_callback());
61 if (has_interface
<PPB_Flash_DeviceID_1_0
>()) {
62 return get_interface
<PPB_Flash_DeviceID_1_0
>()->GetDeviceID(
65 callback
.pp_completion_callback());
67 return callback
.MayForce(PP_ERROR_NOINTERFACE
);
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(
76 if (has_interface
<PPB_Flash_DRM_1_0
>()) {
77 return PP_ToBool(get_interface
<PPB_Flash_DRM_1_0
>()->GetHmonitor(
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(
90 callback
.pp_completion_callback());
92 if (has_interface
<PPB_Flash_DRM_1_0
>()) {
93 return get_interface
<PPB_Flash_DRM_1_0
>()->GetVoucherFile(
96 callback
.pp_completion_callback());
98 return PP_ERROR_NOINTERFACE
;
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(
107 callback
.pp_completion_callback());
109 return PP_ERROR_NOINTERFACE
;