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 Aug 25 13:52:39 2014.
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_12 \
23 "PPB_ContentDecryptor_Private;0.12"
24 #define PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE \
25 PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_12
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_12
{
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] web_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 web_session_id
);
65 * A promise that returns a set of key IDs has been resolved by the CDM.
67 * @param[in] promise_id Identifies the promise that the CDM resolved.
69 * @param[in] key_ids A <code>PP_Var</code> of type
70 * <code>PP_VARTYPE_ARRAY</code> containing elements of type
71 * <code>PP_VARTYPE_ARRAYBUFFER</code> that are the session's usable key IDs.
73 void (*PromiseResolvedWithKeyIds
)(PP_Instance instance
,
75 struct PP_Var key_ids_array
);
77 * A promise has been rejected by the CDM due to an error.
79 * @param[in] promise_id Identifies the promise that the CDM rejected.
81 * @param[in] exception_code A <code>PP_CdmExceptionCode</code> containing
84 * @param[in] system_code A system error code.
86 * @param[in] error_description A <code>PP_Var</code> of type
87 * <code>PP_VARTYPE_STRING</code> containing the error description.
89 void (*PromiseRejected
)(PP_Instance instance
,
91 PP_CdmExceptionCode exception_code
,
93 struct PP_Var error_description
);
95 * A message or request has been generated for key_system in the CDM, and
96 * must be sent to the web application.
98 * For example, when the browser invokes <code>CreateSession()</code>
99 * on the <code>PPP_ContentDecryptor_Private</code> interface, the plugin
100 * must send a message containing the license request.
102 * Note that <code>SessionMessage()</code> can be used for purposes other than
103 * responses to <code>CreateSession()</code> calls. See also the text
104 * in the comment for <code>SessionReady()</code>, which describes a sequence
105 * of <code>UpdateSession()</code> and <code>SessionMessage()</code> calls
106 * required to prepare for decryption.
108 * @param[in] web_session_id A <code>PP_Var</code> of type
109 * <code>PP_VARTYPE_STRING</code> containing the ID of a session for
110 * which this message is intended.
112 * @param[in] message A <code>PP_Var</code> of type
113 * <code>PP_VARTYPE_ARRAY_BUFFER</code> that contains the message.
115 * @param[in] destination_url A <code>PP_Var</code> of type
116 * <code>PP_VARTYPE_STRING</code> containing the destination URL for the
119 void (*SessionMessage
)(PP_Instance instance
,
120 struct PP_Var web_session_id
,
121 struct PP_Var message
,
122 struct PP_Var destination_url
);
124 * The keys for a session have changed.
126 * @param[in] web_session_id A <code>PP_Var</code> of type
127 * <code>PP_VARTYPE_STRING</code> containing the ID of the session that has
130 * @param[in] has_additional_usable_key A <code>PP_Bool</code> indicating if
131 * a new usable key has been added.
133 void (*SessionKeysChange
)(PP_Instance instance
,
134 struct PP_Var web_session_id
,
135 PP_Bool has_additional_usable_key
);
137 * The expiration time for a session has changed.
139 * @param[in] web_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 web_session_id
,
149 PP_Time new_expiry_time
);
151 * The session is now ready to decrypt the media stream.
153 * Note: The above describes the most simple case. Depending on the key
154 * system, a series of <code>SessionMessage()</code> calls from the CDM will
155 * be sent to the browser, and then on to the web application. The web
156 * application must then provide more data to the CDM by directing the browser
157 * to pass the data to the CDM via calls to <code>UpdateSession()</code> on
158 * the <code>PPP_ContentDecryptor_Private</code> interface.
159 * The CDM must call <code>SessionReady()</code> when the sequence is
160 * completed, and, in response, the browser must notify the web application.
162 * @param[in] web_session_id A <code>PP_Var</code> of type
163 * <code>PP_VARTYPE_STRING</code> containing the session's ID attribute of
164 * the session that is now ready.
166 void (*SessionReady
)(PP_Instance instance
, struct PP_Var web_session_id
);
168 * The session has been closed as the result of a call to the
169 * <code>ReleaseSession()</code> method on the
170 * <code>PPP_ContentDecryptor_Private</code> interface, or due to other
171 * factors as determined by the CDM.
173 * @param[in] web_session_id A <code>PP_Var</code> of type
174 * <code>PP_VARTYPE_STRING</code> containing the session's ID attribute of
175 * the session that is now closed.
177 void (*SessionClosed
)(PP_Instance instance
, struct PP_Var web_session_id
);
179 * An error occurred in a <code>PPP_ContentDecryptor_Private</code> method,
180 * or within the plugin implementing the interface.
182 * @param[in] web_session_id A <code>PP_Var</code> of type
183 * <code>PP_VARTYPE_STRING</code> containing the session's ID attribute of
184 * the session that caused the error.
186 * @param[in] exception_code A <code>PP_CdmExceptionCode</code> containing
187 * the exception code.
189 * @param[in] system_code A system error code.
191 * @param[in] error_description A <code>PP_Var</code> of type
192 * <code>PP_VARTYPE_STRING</code> containing the error description.
194 void (*SessionError
)(PP_Instance instance
,
195 struct PP_Var web_session_id
,
196 PP_CdmExceptionCode exception_code
,
197 uint32_t system_code
,
198 struct PP_Var error_description
);
200 * Called after the <code>Decrypt()</code> method on the
201 * <code>PPP_ContentDecryptor_Private</code> interface completes to
202 * deliver decrypted_block to the browser for decoding and rendering.
204 * The plugin must not hold a reference to the encrypted buffer resource
205 * provided to <code>Decrypt()</code> when it calls this method. The browser
206 * will reuse the buffer in a subsequent <code>Decrypt()</code> call.
208 * @param[in] decrypted_block A <code>PP_Resource</code> corresponding to a
209 * <code>PPB_Buffer_Dev</code> resource that contains a decrypted data
212 * @param[in] decrypted_block_info A <code>PP_DecryptedBlockInfo</code> that
213 * contains the result code and tracking info associated with the
214 * <code>decrypted_block</code>.
216 void (*DeliverBlock
)(
217 PP_Instance instance
,
218 PP_Resource decrypted_block
,
219 const struct PP_DecryptedBlockInfo
* decrypted_block_info
);
221 * Called after the <code>InitializeAudioDecoder()</code> or
222 * <code>InitializeVideoDecoder()</code> method on the
223 * <code>PPP_ContentDecryptor_Private</code> interface completes to report
224 * decoder initialization status to the browser.
226 * @param[in] success A <code>PP_Bool</code> that is set to
227 * <code>PP_TRUE</code> when the decoder initialization request associated
228 * with <code>request_id</code> was successful.
230 * @param[in] decoder_type A <code>PP_DecryptorStreamType</code> identifying
231 * the decoder type for which this initialization status response was sent.
233 * @param[in] request_id The <code>request_id</code> value passed to
234 * <code>InitializeAudioDecoder</code> or <code>InitializeVideoDecoder</code>
235 * in <code>PP_AudioDecoderConfig</code> or
236 * <code>PP_VideoDecoderConfig</code>.
238 void (*DecoderInitializeDone
)(PP_Instance instance
,
239 PP_DecryptorStreamType decoder_type
,
243 * Called after the <code>DeinitializeDecoder()</code> method on the
244 * <code>PPP_ContentDecryptor_Private</code> interface completes to report
245 * decoder de-initialization completion to the browser.
247 * @param[in] decoder_type The <code>PP_DecryptorStreamType</code> passed to
248 * <code>DeinitializeDecoder()</code>.
250 * @param[in] request_id The <code>request_id</code> value passed to
251 * <code>DeinitializeDecoder()</code>.
253 void (*DecoderDeinitializeDone
)(PP_Instance instance
,
254 PP_DecryptorStreamType decoder_type
,
255 uint32_t request_id
);
257 * Called after the <code>ResetDecoder()</code> method on the
258 * <code>PPP_ContentDecryptor_Private</code> interface completes to report
259 * decoder reset completion to the browser.
261 * @param[in] decoder_type The <code>PP_DecryptorStreamType</code> passed to
262 * <code>ResetDecoder()</code>.
264 * @param[in] request_id The <code>request_id</code> value passed to
265 * <code>ResetDecoder()</code>.
267 void (*DecoderResetDone
)(PP_Instance instance
,
268 PP_DecryptorStreamType decoder_type
,
269 uint32_t request_id
);
271 * Called after the <code>DecryptAndDecode()</code> method on the
272 * <code>PPP_ContentDecryptor_Private</code> interface completes to deliver
273 * a decrypted and decoded video frame to the browser for rendering.
275 * The plugin must not hold a reference to the encrypted buffer resource
276 * provided to <code>DecryptAndDecode()</code> when it calls this method. The
277 * browser will reuse the buffer in a subsequent
278 * <code>DecryptAndDecode()</code> call.
280 * @param[in] decrypted_frame A <code>PP_Resource</code> corresponding to a
281 * <code>PPB_Buffer_Dev</code> resource that contains a video frame.
283 * @param[in] decrypted_frame_info A <code>PP_DecryptedFrameInfo</code> that
284 * contains the result code, tracking info, and buffer format associated with
285 * <code>decrypted_frame</code>.
287 void (*DeliverFrame
)(
288 PP_Instance instance
,
289 PP_Resource decrypted_frame
,
290 const struct PP_DecryptedFrameInfo
* decrypted_frame_info
);
292 * Called after the <code>DecryptAndDecode()</code> method on the
293 * <code>PPP_ContentDecryptor_Private</code> interface completes to deliver
294 * a buffer of decrypted and decoded audio samples to the browser for
297 * The plugin must not hold a reference to the encrypted buffer resource
298 * provided to <code>DecryptAndDecode()</code> when it calls this method. The
299 * browser will reuse the buffer in a subsequent
300 * <code>DecryptAndDecode()</code> call.
302 * <code>audio_frames</code> can contain multiple audio output buffers. Each
303 * buffer is serialized in this format:
305 * |<------------------- serialized audio buffer ------------------->|
306 * | int64_t timestamp | int64_t length | length bytes of audio data |
308 * For example, with three audio output buffers, |audio_frames| will look
311 * |<---------------- audio_frames ------------------>|
312 * | audio buffer 0 | audio buffer 1 | audio buffer 2 |
314 * @param[in] audio_frames A <code>PP_Resource</code> corresponding to a
315 * <code>PPB_Buffer_Dev</code> resource that contains a decrypted buffer
316 * of decoded audio samples.
318 * @param[in] decrypted_sample_info A <code>PP_DecryptedSampleInfo</code> that
319 * contains the tracking info and result code associated with the decrypted
322 void (*DeliverSamples
)(
323 PP_Instance instance
,
324 PP_Resource audio_frames
,
325 const struct PP_DecryptedSampleInfo
* decrypted_sample_info
);
328 typedef struct PPB_ContentDecryptor_Private_0_12 PPB_ContentDecryptor_Private
;
333 #endif /* PPAPI_C_PRIVATE_PPB_CONTENT_DECRYPTOR_PRIVATE_H_ */