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.
6 /* From private/ppb_content_decryptor_private.idl,
7 * modified Mon Mar 30 22:35:33 2015.
10 #ifndef PPAPI_C_PRIVATE_PPB_CONTENT_DECRYPTOR_PRIVATE_H_
11 #define PPAPI_C_PRIVATE_PPB_CONTENT_DECRYPTOR_PRIVATE_H_
13 #include "ppapi/c/pp_bool.h"
14 #include "ppapi/c/pp_instance.h"
15 #include "ppapi/c/pp_macros.h"
16 #include "ppapi/c/pp_resource.h"
17 #include "ppapi/c/pp_stdint.h"
18 #include "ppapi/c/pp_time.h"
19 #include "ppapi/c/pp_var.h"
20 #include "ppapi/c/private/pp_content_decryptor.h"
22 #define PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_14 \
23 "PPB_ContentDecryptor_Private;0.14"
24 #define PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE \
25 PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_14
29 * This file defines the <code>PPB_ContentDecryptor_Private</code>
30 * interface. Note: This is a special interface, only to be used for Content
31 * Decryption Modules, not normal plugins.
36 * @addtogroup Interfaces
40 * <code>PPB_ContentDecryptor_Private</code> structure contains the function
41 * pointers the browser must implement to support plugins implementing the
42 * <code>PPP_ContentDecryptor_Private</code> interface. This interface provides
43 * browser side support for the Content Decryption Module (CDM) for Encrypted
44 * Media Extensions: http://www.w3.org/TR/encrypted-media/
46 struct PPB_ContentDecryptor_Private_0_14
{
48 * A promise has been resolved by the CDM.
50 * @param[in] promise_id Identifies the promise that the CDM resolved.
52 void (*PromiseResolved
)(PP_Instance instance
, uint32_t promise_id
);
54 * A promise that resulted in a new session has been resolved by the CDM.
56 * @param[in] promise_id Identifies the promise that the CDM resolved.
58 * @param[in] session_id A <code>PP_Var</code> of type
59 * <code>PP_VARTYPE_STRING</code> containing the session's ID attribute.
61 void (*PromiseResolvedWithSession
)(PP_Instance instance
,
63 struct PP_Var session_id
);
65 * A promise has been rejected by the CDM due to an error.
67 * @param[in] promise_id Identifies the promise that the CDM rejected.
69 * @param[in] exception_code A <code>PP_CdmExceptionCode</code> containing
72 * @param[in] system_code A system error code.
74 * @param[in] error_description A <code>PP_Var</code> of type
75 * <code>PP_VARTYPE_STRING</code> containing the error description.
77 void (*PromiseRejected
)(PP_Instance instance
,
79 PP_CdmExceptionCode exception_code
,
81 struct PP_Var error_description
);
83 * A message or request has been generated for key_system in the CDM, and
84 * must be sent to the web application.
86 * For example, when the browser invokes <code>CreateSession()</code>
87 * on the <code>PPP_ContentDecryptor_Private</code> interface, the plugin
88 * must send a message containing the license request.
90 * Note that <code>SessionMessage()</code> can be used for purposes other than
91 * responses to <code>CreateSession()</code> calls. See also the text
92 * in the comment for <code>SessionReady()</code>, which describes a sequence
93 * of <code>UpdateSession()</code> and <code>SessionMessage()</code> calls
94 * required to prepare for decryption.
96 * @param[in] session_id A <code>PP_Var</code> of type
97 * <code>PP_VARTYPE_STRING</code> containing the ID of a session for
98 * which this message is intended.
100 * @param[in] message_type A <code>PP_CdmMessageType</code> containing the
103 * @param[in] message A <code>PP_Var</code> of type
104 * <code>PP_VARTYPE_ARRAY_BUFFER</code> that contains the message.
106 * @param[in] legacy_destination_url A <code>PP_Var</code> of type
107 * <code>PP_VARTYPE_STRING</code> containing the destination URL for the
110 void (*SessionMessage
)(PP_Instance instance
,
111 struct PP_Var session_id
,
112 PP_CdmMessageType message_type
,
113 struct PP_Var message
,
114 struct PP_Var legacy_destination_url
);
116 * The keys for a session have changed.
118 * @param[in] session_id A <code>PP_Var</code> of type
119 * <code>PP_VARTYPE_STRING</code> containing the ID of the session that has
122 * @param[in] has_additional_usable_key A <code>PP_Bool</code> indicating if
123 * a new usable key has been added.
125 * @param[in] key_count The number of arguments contained in
126 * <code>key_information</code>
128 * @param[in] key_information An array of type <code>PP_KeyInformation</code>
129 * that are the session's key IDs and their status.
131 void (*SessionKeysChange
)(PP_Instance instance
,
132 struct PP_Var session_id
,
133 PP_Bool has_additional_usable_key
,
135 const struct PP_KeyInformation key_information
[]);
137 * The expiration time for a session has changed.
139 * @param[in] session_id A <code>PP_Var</code> of type
140 * <code>PP_VARTYPE_STRING</code> containing the ID of the session that has
141 * a new expiration time.
143 * @param[in] new_expiry_time A <code>PP_Time</code> indicating the new
144 * expiry time of the session. The value is defined as the number of seconds
145 * since the Epoch (00:00:00 UTC, January 1, 1970).
147 void (*SessionExpirationChange
)(PP_Instance instance
,
148 struct PP_Var session_id
,
149 PP_Time new_expiry_time
);
151 * The session has been closed as the result of a call to the
152 * <code>ReleaseSession()</code> method on the
153 * <code>PPP_ContentDecryptor_Private</code> interface, or due to other
154 * factors as determined by the CDM.
156 * @param[in] session_id A <code>PP_Var</code> of type
157 * <code>PP_VARTYPE_STRING</code> containing the session's ID attribute of
158 * the session that is now closed.
160 void (*SessionClosed
)(PP_Instance instance
, struct PP_Var session_id
);
162 * An error occurred in a <code>PPP_ContentDecryptor_Private</code> method,
163 * or within the plugin implementing the interface.
165 * @param[in] session_id A <code>PP_Var</code> of type
166 * <code>PP_VARTYPE_STRING</code> containing the session's ID attribute of
167 * the session that caused the error.
169 * @param[in] exception_code A <code>PP_CdmExceptionCode</code> containing
170 * the exception code.
172 * @param[in] system_code A system error code.
174 * @param[in] error_description A <code>PP_Var</code> of type
175 * <code>PP_VARTYPE_STRING</code> containing the error description.
177 void (*LegacySessionError
)(PP_Instance instance
,
178 struct PP_Var session_id
,
179 PP_CdmExceptionCode exception_code
,
180 uint32_t system_code
,
181 struct PP_Var error_description
);
183 * Called after the <code>Decrypt()</code> method on the
184 * <code>PPP_ContentDecryptor_Private</code> interface completes to
185 * deliver decrypted_block to the browser for decoding and rendering.
187 * The plugin must not hold a reference to the encrypted buffer resource
188 * provided to <code>Decrypt()</code> when it calls this method. The browser
189 * will reuse the buffer in a subsequent <code>Decrypt()</code> call.
191 * @param[in] decrypted_block A <code>PP_Resource</code> corresponding to a
192 * <code>PPB_Buffer_Dev</code> resource that contains a decrypted data
195 * @param[in] decrypted_block_info A <code>PP_DecryptedBlockInfo</code> that
196 * contains the result code and tracking info associated with the
197 * <code>decrypted_block</code>.
199 void (*DeliverBlock
)(
200 PP_Instance instance
,
201 PP_Resource decrypted_block
,
202 const struct PP_DecryptedBlockInfo
* decrypted_block_info
);
204 * Called after the <code>InitializeAudioDecoder()</code> or
205 * <code>InitializeVideoDecoder()</code> method on the
206 * <code>PPP_ContentDecryptor_Private</code> interface completes to report
207 * decoder initialization status to the browser.
209 * @param[in] success A <code>PP_Bool</code> that is set to
210 * <code>PP_TRUE</code> when the decoder initialization request associated
211 * with <code>request_id</code> was successful.
213 * @param[in] decoder_type A <code>PP_DecryptorStreamType</code> identifying
214 * the decoder type for which this initialization status response was sent.
216 * @param[in] request_id The <code>request_id</code> value passed to
217 * <code>InitializeAudioDecoder</code> or <code>InitializeVideoDecoder</code>
218 * in <code>PP_AudioDecoderConfig</code> or
219 * <code>PP_VideoDecoderConfig</code>.
221 void (*DecoderInitializeDone
)(PP_Instance instance
,
222 PP_DecryptorStreamType decoder_type
,
226 * Called after the <code>DeinitializeDecoder()</code> method on the
227 * <code>PPP_ContentDecryptor_Private</code> interface completes to report
228 * decoder de-initialization completion to the browser.
230 * @param[in] decoder_type The <code>PP_DecryptorStreamType</code> passed to
231 * <code>DeinitializeDecoder()</code>.
233 * @param[in] request_id The <code>request_id</code> value passed to
234 * <code>DeinitializeDecoder()</code>.
236 void (*DecoderDeinitializeDone
)(PP_Instance instance
,
237 PP_DecryptorStreamType decoder_type
,
238 uint32_t request_id
);
240 * Called after the <code>ResetDecoder()</code> method on the
241 * <code>PPP_ContentDecryptor_Private</code> interface completes to report
242 * decoder reset completion to the browser.
244 * @param[in] decoder_type The <code>PP_DecryptorStreamType</code> passed to
245 * <code>ResetDecoder()</code>.
247 * @param[in] request_id The <code>request_id</code> value passed to
248 * <code>ResetDecoder()</code>.
250 void (*DecoderResetDone
)(PP_Instance instance
,
251 PP_DecryptorStreamType decoder_type
,
252 uint32_t request_id
);
254 * Called after the <code>DecryptAndDecode()</code> method on the
255 * <code>PPP_ContentDecryptor_Private</code> interface completes to deliver
256 * a decrypted and decoded video frame to the browser for rendering.
258 * The plugin must not hold a reference to the encrypted buffer resource
259 * provided to <code>DecryptAndDecode()</code> when it calls this method. The
260 * browser will reuse the buffer in a subsequent
261 * <code>DecryptAndDecode()</code> call.
263 * @param[in] decrypted_frame A <code>PP_Resource</code> corresponding to a
264 * <code>PPB_Buffer_Dev</code> resource that contains a video frame.
266 * @param[in] decrypted_frame_info A <code>PP_DecryptedFrameInfo</code> that
267 * contains the result code, tracking info, and buffer format associated with
268 * <code>decrypted_frame</code>.
270 void (*DeliverFrame
)(
271 PP_Instance instance
,
272 PP_Resource decrypted_frame
,
273 const struct PP_DecryptedFrameInfo
* decrypted_frame_info
);
275 * Called after the <code>DecryptAndDecode()</code> method on the
276 * <code>PPP_ContentDecryptor_Private</code> interface completes to deliver
277 * a buffer of decrypted and decoded audio samples to the browser for
280 * The plugin must not hold a reference to the encrypted buffer resource
281 * provided to <code>DecryptAndDecode()</code> when it calls this method. The
282 * browser will reuse the buffer in a subsequent
283 * <code>DecryptAndDecode()</code> call.
285 * <code>audio_frames</code> can contain multiple audio output buffers. Each
286 * buffer is serialized in this format:
288 * |<------------------- serialized audio buffer ------------------->|
289 * | int64_t timestamp | int64_t length | length bytes of audio data |
291 * For example, with three audio output buffers, |audio_frames| will look
294 * |<---------------- audio_frames ------------------>|
295 * | audio buffer 0 | audio buffer 1 | audio buffer 2 |
297 * @param[in] audio_frames A <code>PP_Resource</code> corresponding to a
298 * <code>PPB_Buffer_Dev</code> resource that contains a decrypted buffer
299 * of decoded audio samples.
301 * @param[in] decrypted_sample_info A <code>PP_DecryptedSampleInfo</code> that
302 * contains the tracking info and result code associated with the decrypted
305 void (*DeliverSamples
)(
306 PP_Instance instance
,
307 PP_Resource audio_frames
,
308 const struct PP_DecryptedSampleInfo
* decrypted_sample_info
);
311 typedef struct PPB_ContentDecryptor_Private_0_14 PPB_ContentDecryptor_Private
;
316 #endif /* PPAPI_C_PRIVATE_PPB_CONTENT_DECRYPTOR_PRIVATE_H_ */