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.
7 * This file defines the <code>PPB_ContentDecryptor_Private</code>
8 * interface. Note: This is a special interface, only to be used for Content
9 * Decryption Modules, not normal plugins.
16 * <code>PPB_ContentDecryptor_Private</code> structure contains the function
17 * pointers the browser must implement to support plugins implementing the
18 * <code>PPP_ContentDecryptor_Private</code> interface. This interface provides
19 * browser side support for the Content Decryption Module (CDM) for v0.1 of the
20 * proposed Encrypted Media Extensions: http://goo.gl/rbdnR
22 interface PPB_ContentDecryptor_Private
{
24 * The decryptor requires a key that has not been provided.
26 * Sent when the decryptor encounters encrypted content, but it does not have
27 * the key required to decrypt the data. The plugin will call this method in
28 * response to a call to the <code>Decrypt()</code> method on the
29 * <code>PPP_ContentDecryptor_Private<code> interface.
31 * The browser must notify the application that a key is needed, and, in
32 * response, the web application must direct the browser to call
33 * <code>AddKey()</code> on the <code>PPP_ContentDecryptor_Private<code>
36 * @param[in] key_system A <code>PP_Var</code> of type
37 * <code>PP_VARTYPE_STRING</code> containing the name of the key system.
39 * @param[in] session_id A <code>PP_Var</code> of type
40 * <code>PP_VARTYPE_STRING</code> containing the session ID.
42 * @param[in] init_data A <code>PP_Var</code> of type
43 * <code>PP_VARTYPE_ARRAY_BUFFER</code> containing container-specific
44 * initialization data.
47 [in] PP_Instance instance
,
48 [in] PP_Var key_system
,
49 [in] PP_Var session_id
,
50 [in] PP_Var init_data
);
53 * A key has been added as the result of a call to the <code>AddKey()</code>
54 * method on the <code>PPP_ContentDecryptor_Private</code> interface.
56 * Note: The above describes the most simple case. Depending on the key
57 * system, a series of <code>KeyMessage()</code> calls from the CDM will be
58 * sent to the browser, and then on to the web application. The web
59 * application must then provide more data to the CDM by directing the browser
60 * to pass the data to the CDM via calls to <code>AddKey()</code> on the
61 * <code>PPP_ContentDecryptor_Private</code> interface.
62 * The CDM must call <code>KeyAdded()</code> when the sequence is completed,
63 * and, in response, the browser must notify the web application.
65 * @param[in] key_system A <code>PP_Var</code> of type
66 * <code>PP_VARTYPE_STRING</code> containing the name of the key system.
68 * @param[in] session_id A <code>PP_Var</code> of type
69 * <code>PP_VARTYPE_STRING</code> containing the session ID.
72 [in] PP_Instance instance
,
73 [in] PP_Var key_system
,
74 [in] PP_Var session_id
);
77 * A message or request has been generated for key_system in the CDM, and
78 * must be sent to the web application.
80 * For example, when the browser invokes <code>GenerateKeyRequest()</code>
81 * on the <code>PPP_ContentDecryptor_Private</code> interface, the plugin
82 * must send a key message containing the key request.
84 * Note that <code>KeyMessage()</code> can be used for purposes other than
85 * responses to <code>GenerateKeyRequest()</code> calls. See also the text
86 * in the comment for <code>KeyAdded()</code>, which describes a sequence of
87 * <code>AddKey()</code> and <code>KeyMessage()</code> calls required to
88 * prepare for decryption.
90 * @param[in] key_system A <code>PP_Var</code> of type
91 * <code>PP_VARTYPE_STRING</code> containing the name of the key system.
93 * @param[in] session_id A <code>PP_Var</code> of type
94 * <code>PP_VARTYPE_STRING</code> containing the session ID.
96 * @param[in] message A <code>PP_Var</code> of type
97 * <code>PP_VARTYPE_ARRAY_BUFFER</code> that contains the message.
99 * @param[in] default_url A <code>PP_Var</code> of type
100 * <code>PP_VARTYPE_STRING</code> containing the default URL for the message.
103 [in] PP_Instance instance
,
104 [in] PP_Var key_system
,
105 [in] PP_Var session_id
,
107 [in] PP_Var default_url
);
110 * An error occurred in a <code>PPP_ContentDecryptor_Private</code> method,
111 * or within the plugin implementing the interface.
113 * @param[in] key_system A <code>PP_Var</code> of type
114 * <code>PP_VARTYPE_STRING</code> containing the name of the key system.
116 * @param[in] session_id A <code>PP_Var</code> of type
117 * <code>PP_VARTYPE_STRING</code> containing the session ID.
119 * @param[in] media_error A MediaKeyError.
121 * @param[in] system_error A system error code.
124 [in] PP_Instance instance
,
125 [in] PP_Var key_system
,
126 [in] PP_Var session_id
,
127 [in] int32_t media_error
,
128 [in] int32_t system_code
);
131 * Called after the <code>Decrypt()</code> method on the
132 * <code>PPP_ContentDecryptor_Private</code> interface completes to
133 * deliver decrypted_block to the browser for decoding and rendering.
135 * The plugin must not hold a reference to the encrypted buffer resource
136 * provided to <code>Decrypt()</code> when it calls this method. The browser
137 * will reuse the buffer in a subsequent <code>Decrypt()</code> call.
139 * @param[in] decrypted_block A <code>PP_Resource</code> corresponding to a
140 * <code>PPB_Buffer_Dev</code> resource that contains a decrypted data
143 * @param[in] decrypted_block_info A <code>PP_DecryptedBlockInfo</code> that
144 * contains the result code and tracking info associated with the
145 * <code>decrypted_block</code>.
148 [in] PP_Instance instance
,
149 [in] PP_Resource decrypted_block
,
150 [in] PP_DecryptedBlockInfo decrypted_block_info
);
153 * Called after the <code>InitializeAudioDecoder()</code> or
154 * <code>InitializeVideoDecoder()</code> method on the
155 * <code>PPP_ContentDecryptor_Private</code> interface completes to report
156 * decoder initialization status to the browser.
158 * @param[in] success A <code>PP_Bool</code> that is set to
159 * <code>PP_TRUE</code> when the decoder initialization request associated
160 * with <code>request_id</code> was successful.
162 * @param[in] decoder_type A <code>PP_DecryptorStreamType</code> identifying
163 * the decoder type for which this initialization status response was sent.
165 * @param[in] request_id The <code>request_id</code> value passed to
166 * <code>InitializeAudioDecoder</code> or <code>InitializeVideoDecoder</code>
167 * in <code>PP_AudioDecoderConfig</code> or
168 * <code>PP_VideoDecoderConfig</code>.
170 void DecoderInitializeDone
(
171 [in] PP_Instance instance
,
172 [in] PP_DecryptorStreamType decoder_type
,
173 [in] uint32_t request_id
,
174 [in] PP_Bool success
);
177 * Called after the <code>DeinitializeDecoder()</code> method on the
178 * <code>PPP_ContentDecryptor_Private</code> interface completes to report
179 * decoder de-initialization completion to the browser.
181 * @param[in] decoder_type The <code>PP_DecryptorStreamType</code> passed to
182 * <code>DeinitializeDecoder()</code>.
184 * @param[in] request_id The <code>request_id</code> value passed to
185 * <code>DeinitializeDecoder()</code>.
187 void DecoderDeinitializeDone
(
188 [in] PP_Instance instance
,
189 [in] PP_DecryptorStreamType decoder_type
,
190 [in] uint32_t request_id
);
193 * Called after the <code>ResetDecoder()</code> method on the
194 * <code>PPP_ContentDecryptor_Private</code> interface completes to report
195 * decoder reset completion to the browser.
197 * @param[in] decoder_type The <code>PP_DecryptorStreamType</code> passed to
198 * <code>ResetDecoder()</code>.
200 * @param[in] request_id The <code>request_id</code> value passed to
201 * <code>ResetDecoder()</code>.
203 void DecoderResetDone
(
204 [in] PP_Instance instance
,
205 [in] PP_DecryptorStreamType decoder_type
,
206 [in] uint32_t request_id
);
209 * Called after the <code>DecryptAndDecode()</code> method on the
210 * <code>PPP_ContentDecryptor_Private</code> interface completes to deliver
211 * a decrypted and decoded video frame to the browser for rendering.
213 * The plugin must not hold a reference to the encrypted buffer resource
214 * provided to <code>DecryptAndDecode()</code> when it calls this method. The
215 * browser will reuse the buffer in a subsequent
216 * <code>DecryptAndDecode()</code> call.
218 * @param[in] decrypted_frame A <code>PP_Resource</code> corresponding to a
219 * <code>PPB_Buffer_Dev</code> resource that contains a video frame.
221 * @param[in] decrypted_frame_info A <code>PP_DecryptedFrameInfo</code> that
222 * contains the result code, tracking info, and buffer format associated with
223 * <code>decrypted_frame</code>.
226 [in] PP_Instance instance
,
227 [in] PP_Resource decrypted_frame
,
228 [in] PP_DecryptedFrameInfo decrypted_frame_info
);
231 * Called after the <code>DecryptAndDecode()</code> method on the
232 * <code>PPP_ContentDecryptor_Private</code> interface completes to deliver
233 * a buffer of decrypted and decoded audio samples to the browser for
236 * The plugin must not hold a reference to the encrypted buffer resource
237 * provided to <code>DecryptAndDecode()</code> when it calls this method. The
238 * browser will reuse the buffer in a subsequent
239 * <code>DecryptAndDecode()</code> call.
241 * <code>audio_frames</code> can contain multiple audio output buffers. Each
242 * buffer is serialized in this format:
244 * |<------------------- serialized audio buffer ------------------->|
245 * | int64_t timestamp | int64_t length | length bytes of audio data |
247 * For example, with three audio output buffers, |audio_frames| will look
250 * |<---------------- audio_frames ------------------>|
251 * | audio buffer 0 | audio buffer 1 | audio buffer 2 |
253 * @param[in] audio_frames A <code>PP_Resource</code> corresponding to a
254 * <code>PPB_Buffer_Dev</code> resource that contains a decrypted buffer
255 * of decoded audio samples.
257 * @param[in] decrypted_block_info A <code>PP_DecryptedBlockInfo</code> that
258 * contains the tracking info and result code associated with the
259 * <code>decrypted_block</code>.
262 [in] PP_Instance instance
,
263 [in] PP_Resource audio_frames
,
264 [in] PP_DecryptedBlockInfo decrypted_block_info
);