- add sources.
[platform/framework/web/crosswalk.git] / src / ppapi / c / private / ppb_output_protection_private.h
1 /* Copyright 2013 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
6 /* From private/ppb_output_protection_private.idl,
7  *   modified Tue Oct  8 13:22:13 2013.
8  */
9
10 #ifndef PPAPI_C_PRIVATE_PPB_OUTPUT_PROTECTION_PRIVATE_H_
11 #define PPAPI_C_PRIVATE_PPB_OUTPUT_PROTECTION_PRIVATE_H_
12
13 #include "ppapi/c/pp_bool.h"
14 #include "ppapi/c/pp_completion_callback.h"
15 #include "ppapi/c/pp_instance.h"
16 #include "ppapi/c/pp_macros.h"
17 #include "ppapi/c/pp_resource.h"
18 #include "ppapi/c/pp_stdint.h"
19
20 #define PPB_OUTPUTPROTECTION_PRIVATE_INTERFACE_0_1 \
21     "PPB_OutputProtection_Private;0.1"
22 #define PPB_OUTPUTPROTECTION_PRIVATE_INTERFACE \
23     PPB_OUTPUTPROTECTION_PRIVATE_INTERFACE_0_1
24
25 /**
26  * @file
27  * This file defines the API for output protection. Currently, it only supports
28  * Chrome OS.
29  */
30
31
32 /**
33  * @addtogroup Enums
34  * @{
35  */
36 /**
37  * Content protection methods applied on video output link.
38  */
39 typedef enum {
40   PP_OUTPUT_PROTECTION_METHOD_PRIVATE_NONE = 0,
41   PP_OUTPUT_PROTECTION_METHOD_PRIVATE_HDCP = 1 << 0
42 } PP_OutputProtectionMethod_Private;
43 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_OutputProtectionMethod_Private, 4);
44
45 /**
46  * Video output link types.
47  */
48 typedef enum {
49   PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_NONE = 0,
50   PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_UNKNOWN = 1 << 0,
51   PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_INTERNAL = 1 << 1,
52   PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_VGA = 1 << 2,
53   PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_HDMI = 1 << 3,
54   PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_DVI = 1 << 4,
55   PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_DISPLAYPORT = 1 << 5,
56   PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_NETWORK = 1 << 6
57 } PP_OutputProtectionLinkType_Private;
58 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_OutputProtectionLinkType_Private, 4);
59 /**
60  * @}
61  */
62
63 /**
64  * @addtogroup Interfaces
65  * @{
66  */
67 /**
68  * The <code>PPB_OutputProtection_Private</code> interface allows controlling
69  * output protection.
70  *
71  * <strong>Example:</strong>
72  *
73  * @code
74  * op = output_protection->Create(instance);
75  * output_protection->QueryStatus(op, &link_mask, &protection_mask,
76  *                                done_callback);
77  * @endcode
78  *
79  * In this example, the plugin wants to enforce HDCP for HDMI link.
80  * @code
81  * if (link_mask & PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_HDMI) {
82  *   output_protection->EnableProtection(
83  *       op, PP_OUTPUT_PROTECTION_METHOD_PRIVATE_HDCP, done_callback);
84  * }
85  * @endcode
86  *
87  * After EnableProtection() completes, the plugin has to query protection
88  * status periodically to make sure the protection is enabled and remains
89  * enabled.
90  */
91 struct PPB_OutputProtection_Private_0_1 {
92   /**
93    * Create() creates a new <code>PPB_OutputProtection_Private</code> object.
94    *
95    * @pram[in] instance A <code>PP_Instance</code> identifying one instance of
96    * a module.
97    *
98    * @return A <code>PP_Resource</code> corresponding to a
99    * <code>PPB_OutputProtection_Private</code> if successful, 0 if creation
100    * failed.
101    */
102   PP_Resource (*Create)(PP_Instance instance);
103   /**
104    * IsOutputProtection() determines if the provided resource is a
105    * <code>PPB_OutputProtection_Private</code>.
106    *
107    * @param[in] resource A <code>PP_Resource</code> corresponding to a
108    * <code>PPB_OutputProtection_Private</code>.
109    *
110    * @return <code>PP_TRUE</code> if the resource is a
111    * <code>PPB_OutputProtection_Private</code>, <code>PP_FALSE</code> if the
112    * resource is invalid or some type other than
113    * <code>PPB_OutputProtection_Private</code>.
114    */
115   PP_Bool (*IsOutputProtection)(PP_Resource resource);
116   /**
117    * Query link status and protection status.
118    * Clients have to query status periodically in order to detect changes.
119    *
120    * @param[in] resource A <code>PP_Resource</code> corresponding to a
121    * <code>PPB_OutputProtection_Private</code>.
122    * @param[out] link_mask The type of connected output links, which is a
123    * bit-mask of the <code>PP_OutputProtectionLinkType_Private</code> values.
124    * @param[out] protection_mask Enabled protection methods, which is a
125    * bit-mask of the <code>PP_OutputProtectionMethod_Private</code> values.
126    * @param[in] callback A <code>PP_CompletionCallback</code> to run on
127    * asynchronous completion of QueryStatus(). This callback will only run if
128    * QueryStatus() returns <code>PP_OK_COMPLETIONPENDING</code>.
129    *
130    * @return An int32_t containing an error code from <code>pp_errors.h</code>.
131    */
132   int32_t (*QueryStatus)(PP_Resource resource,
133                          uint32_t* link_mask,
134                          uint32_t* protection_mask,
135                          struct PP_CompletionCallback callback);
136   /**
137    * Set desired protection methods.
138    *
139    * When the desired protection method(s) have been applied to all applicable
140    * output links, the relevant bit(s) of the protection_mask returned by
141    * QueryStatus() will be set. Otherwise, the relevant bit(s) of
142    * protection_mask will not be set; there is no separate error code or
143    * callback.
144    *
145    * Protections will be disabled if no longer desired by all instances.
146    *
147    * @param[in] resource A <code>PP_Resource</code> corresponding to a
148    * <code>PPB_OutputProtection_Private</code>.
149    * @param[in] desired_protection_mask The desired protection methods, which
150    * is a bit-mask of the <code>PP_OutputProtectionMethod_Private</code>
151    * values.
152    * @param[in] callback A <code>PP_CompletionCallback</code> to be called with
153    * <code>PP_OK</code> when the protection request has been made. This may be
154    * before the protection have actually been applied. Call QueryStatus to get
155    * protection status. If it failed to make the protection request, the
156    * callback is called with <code>PP_ERROR_FAILED</code> and there is no need
157    * to call QueryStatus().
158    *
159    * @return An int32_t containing an error code from <code>pp_errors.h</code>.
160    */
161   int32_t (*EnableProtection)(PP_Resource resource,
162                               uint32_t desired_protection_mask,
163                               struct PP_CompletionCallback callback);
164 };
165
166 typedef struct PPB_OutputProtection_Private_0_1 PPB_OutputProtection_Private;
167 /**
168  * @}
169  */
170
171 #endif  /* PPAPI_C_PRIVATE_PPB_OUTPUT_PROTECTION_PRIVATE_H_ */
172