• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4  */
5 
6 /* From private/pp_content_decryptor.idl modified Thu Jun  5 13:39:15 2014. */
7 
8 #ifndef PPAPI_C_PRIVATE_PP_CONTENT_DECRYPTOR_H_
9 #define PPAPI_C_PRIVATE_PP_CONTENT_DECRYPTOR_H_
10 
11 #include "ppapi/c/pp_macros.h"
12 #include "ppapi/c/pp_stdint.h"
13 
14 /**
15  * @file
16  * The <code>PP_DecryptTrackingInfo</code> struct contains necessary information
17  * that can be used to associate the decrypted block with a decrypt request
18  * and/or an input block.
19  */
20 
21 
22 /**
23  * @addtogroup Structs
24  * @{
25  */
26 struct PP_DecryptTrackingInfo {
27   /**
28    * Client-specified identifier for the associated decrypt request. By using
29    * this value, the client can associate the decrypted block with a decryption
30    * request.
31    */
32   uint32_t request_id;
33   /**
34    * A unique buffer ID to identify a PPB_Buffer_Dev. Unlike a PP_Resource,
35    * this ID is identical at both the renderer side and the plugin side.
36    * In <code>PPB_ContentDecryptor_Private</code> calls, this is the ID of the
37    * buffer associated with the decrypted block/frame/samples.
38    * In <code>PPP_ContentDecryptor_Private</code> calls, this is the ID of a
39    * buffer that is no longer need at the renderer side, which can be released
40    * or recycled by the plugin. This ID can be 0 if there is no buffer to be
41    * released or recycled.
42    */
43   uint32_t buffer_id;
44   /**
45    * Timestamp in microseconds of the associated block. By using this value,
46    * the client can associate the decrypted (and decoded) data with an input
47    * block. This is needed because buffers may be delivered out of order and
48    * not in response to the <code>request_id</code> they were provided with.
49    */
50   int64_t timestamp;
51 };
52 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_DecryptTrackingInfo, 16);
53 
54 /**
55  * The <code>PP_DecryptSubsampleDescription</code> struct contains information
56  * to support subsample decryption.
57  *
58  * An input block can be split into several continuous subsamples.
59  * A <code>PP_DecryptSubsampleEntry</code> specifies the number of clear and
60  * cipher bytes in each subsample. For example, the following block has three
61  * subsamples:
62  *
63  * |<----- subsample1 ----->|<----- subsample2 ----->|<----- subsample3 ----->|
64  * |   clear1   |  cipher1  |  clear2  |   cipher2   | clear3 |    cipher3    |
65  *
66  * For decryption, all of the cipher bytes in a block should be treated as a
67  * contiguous (in the subsample order) logical stream. The clear bytes should
68  * not be considered as part of decryption.
69  *
70  * Logical stream to decrypt:   |  cipher1  |   cipher2   |    cipher3    |
71  * Decrypted stream:            | decrypted1|  decrypted2 |   decrypted3  |
72  *
73  * After decryption, the decrypted bytes should be copied over the position
74  * of the corresponding cipher bytes in the original block to form the output
75  * block. Following the above example, the decrypted block should be:
76  *
77  * |<----- subsample1 ----->|<----- subsample2 ----->|<----- subsample3 ----->|
78  * |   clear1   | decrypted1|  clear2  |  decrypted2 | clear3 |   decrypted3  |
79  */
80 struct PP_DecryptSubsampleDescription {
81   /**
82    * Size in bytes of clear data in a subsample entry.
83    */
84   uint32_t clear_bytes;
85   /**
86    * Size in bytes of encrypted data in a subsample entry.
87    */
88   uint32_t cipher_bytes;
89 };
90 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_DecryptSubsampleDescription, 8);
91 
92 /**
93  * The <code>PP_EncryptedBlockInfo</code> struct contains all the information
94  * needed to decrypt an encrypted block.
95  */
96 struct PP_EncryptedBlockInfo {
97   /**
98    * Information needed by the client to track the block to be decrypted.
99    */
100   struct PP_DecryptTrackingInfo tracking_info;
101   /**
102    * Size in bytes of data to be decrypted (data_offset included).
103    */
104   uint32_t data_size;
105   /**
106    * Key ID of the block to be decrypted.
107    *
108    * TODO(xhwang): For WebM the key ID can be as large as 2048 bytes in theory.
109    * But it's not used in current implementations. If we really need to support
110    * it, we should move key ID out as a separate parameter, e.g.
111    * as a <code>PP_Var</code>, or make the whole
112    * <code>PP_EncryptedBlockInfo</code> as a <code>PP_Resource</code>.
113    */
114   uint8_t key_id[64];
115   uint32_t key_id_size;
116   /**
117    * Initialization vector of the block to be decrypted.
118    */
119   uint8_t iv[16];
120   uint32_t iv_size;
121   /**
122    * Subsample information of the block to be decrypted.
123    */
124   struct PP_DecryptSubsampleDescription subsamples[16];
125   uint32_t num_subsamples;
126 };
127 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_EncryptedBlockInfo, 240);
128 /**
129  * @}
130  */
131 
132 /**
133  * @addtogroup Enums
134  * @{
135  */
136 /**
137  * <code>PP_DecryptedFrameFormat</code> contains video frame formats.
138  */
139 typedef enum {
140   PP_DECRYPTEDFRAMEFORMAT_UNKNOWN = 0,
141   PP_DECRYPTEDFRAMEFORMAT_YV12 = 1,
142   PP_DECRYPTEDFRAMEFORMAT_I420 = 2
143 } PP_DecryptedFrameFormat;
144 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_DecryptedFrameFormat, 4);
145 
146 /**
147  * <code>PP_DecryptedSampleFormat</code> contains audio sample formats.
148  */
149 typedef enum {
150   PP_DECRYPTEDSAMPLEFORMAT_UNKNOWN = 0,
151   PP_DECRYPTEDSAMPLEFORMAT_U8 = 1,
152   PP_DECRYPTEDSAMPLEFORMAT_S16 = 2,
153   PP_DECRYPTEDSAMPLEFORMAT_S32 = 3,
154   PP_DECRYPTEDSAMPLEFORMAT_F32 = 4,
155   PP_DECRYPTEDSAMPLEFORMAT_PLANAR_S16 = 5,
156   PP_DECRYPTEDSAMPLEFORMAT_PLANAR_F32 = 6
157 } PP_DecryptedSampleFormat;
158 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_DecryptedSampleFormat, 4);
159 
160 /**
161  * The <code>PP_DecryptResult</code> enum contains decryption and decoding
162  * result constants.
163  */
164 typedef enum {
165   /** The decryption (and/or decoding) operation finished successfully. */
166   PP_DECRYPTRESULT_SUCCESS = 0,
167   /** The decryptor did not have the necessary decryption key. */
168   PP_DECRYPTRESULT_DECRYPT_NOKEY = 1,
169   /** The input was accepted by the decoder but no frame(s) can be produced. */
170   PP_DECRYPTRESULT_NEEDMOREDATA = 2,
171   /** An unexpected error happened during decryption. */
172   PP_DECRYPTRESULT_DECRYPT_ERROR = 3,
173   /** An unexpected error happened during decoding. */
174   PP_DECRYPTRESULT_DECODE_ERROR = 4
175 } PP_DecryptResult;
176 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_DecryptResult, 4);
177 /**
178  * @}
179  */
180 
181 /**
182  * @addtogroup Structs
183  * @{
184  */
185 /**
186  * <code>PP_DecryptedBlockInfo</code> struct contains the decryption result and
187  * tracking info associated with the decrypted block.
188  */
189 struct PP_DecryptedBlockInfo {
190   /**
191    * Result of the decryption (and/or decoding) operation.
192    */
193   PP_DecryptResult result;
194   /**
195    * Size in bytes of decrypted data, which may be less than the size of the
196    * corresponding buffer.
197    */
198   uint32_t data_size;
199   /**
200    * Information needed by the client to track the block to be decrypted.
201    */
202   struct PP_DecryptTrackingInfo tracking_info;
203 };
204 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_DecryptedBlockInfo, 24);
205 /**
206  * @}
207  */
208 
209 /**
210  * @addtogroup Enums
211  * @{
212  */
213 /**
214  * <code>PP_DecryptedFramePlanes</code> provides YUV plane index values for
215  * accessing plane offsets stored in <code>PP_DecryptedFrameInfo</code>.
216  */
217 typedef enum {
218   PP_DECRYPTEDFRAMEPLANES_Y = 0,
219   PP_DECRYPTEDFRAMEPLANES_U = 1,
220   PP_DECRYPTEDFRAMEPLANES_V = 2
221 } PP_DecryptedFramePlanes;
222 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_DecryptedFramePlanes, 4);
223 /**
224  * @}
225  */
226 
227 /**
228  * @addtogroup Structs
229  * @{
230  */
231 /**
232  * <code>PP_DecryptedFrameInfo</code> contains the result of the
233  * decrypt and decode operation on the associated frame, information required
234  * to access the frame data in buffer, and tracking info.
235  */
236 struct PP_DecryptedFrameInfo {
237   /**
238    * Result of the decrypt and decode operation.
239    */
240   PP_DecryptResult result;
241   /**
242    * Format of the decrypted frame.
243    */
244   PP_DecryptedFrameFormat format;
245   /**
246    * Offsets into the buffer resource for accessing video planes.
247    */
248   int32_t plane_offsets[3];
249   /**
250    * Stride of each plane.
251    */
252   int32_t strides[3];
253   /**
254    * Width of the video frame, in pixels.
255    */
256   int32_t width;
257   /**
258    * Height of the video frame, in pixels.
259    */
260   int32_t height;
261   /**
262    * Information needed by the client to track the decrypted frame.
263    */
264   struct PP_DecryptTrackingInfo tracking_info;
265 };
266 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_DecryptedFrameInfo, 56);
267 
268 /**
269  * <code>PP_DecryptedSampleInfo</code> contains the result of the
270  * decrypt and decode operation on the associated samples, information required
271  * to access the sample data in buffer, and tracking info.
272  */
273 struct PP_DecryptedSampleInfo {
274   /**
275    * Result of the decrypt and decode operation.
276    */
277   PP_DecryptResult result;
278   /**
279    * Format of the decrypted samples.
280    */
281   PP_DecryptedSampleFormat format;
282   /**
283    * Size in bytes of decrypted samples.
284    */
285   uint32_t data_size;
286   /**
287    * 4-byte padding to make the size of <code>PP_DecryptedSampleInfo</code>
288    * a multiple of 8 bytes. The value of this field should not be used.
289    */
290   uint32_t padding;
291   /**
292    * Information needed by the client to track the decrypted samples.
293    */
294   struct PP_DecryptTrackingInfo tracking_info;
295 };
296 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_DecryptedSampleInfo, 32);
297 /**
298  * @}
299  */
300 
301 /**
302  * @addtogroup Enums
303  * @{
304  */
305 /**
306  * <code>PP_AudioCodec</code> contains audio codec type constants.
307  */
308 typedef enum {
309   PP_AUDIOCODEC_UNKNOWN = 0,
310   PP_AUDIOCODEC_VORBIS = 1,
311   PP_AUDIOCODEC_AAC = 2
312 } PP_AudioCodec;
313 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_AudioCodec, 4);
314 /**
315  * @}
316  */
317 
318 /**
319  * @addtogroup Structs
320  * @{
321  */
322 /**
323  * <code>PP_AudioDecoderConfig</code> contains audio decoder configuration
324  * information required to initialize audio decoders, and a request ID
325  * that allows clients to associate a decoder initialization request with a
326  * status response. Note: When <code>codec</code> requires extra data for
327  * initialization, the data is sent as a <code>PP_Resource</code> carried
328  * alongside <code>PP_AudioDecoderConfig</code>.
329  */
330 struct PP_AudioDecoderConfig {
331   /**
332    * The audio codec to initialize.
333    */
334   PP_AudioCodec codec;
335   /**
336    * Number of audio channels.
337    */
338   int32_t channel_count;
339   /**
340    * Size of each audio channel.
341    */
342   int32_t bits_per_channel;
343   /**
344    * Audio sampling rate.
345    */
346   int32_t samples_per_second;
347   /**
348    * Client-specified identifier for the associated audio decoder initialization
349    * request. By using this value, the client can associate a decoder
350    * initialization status response with an initialization request.
351    */
352   uint32_t request_id;
353 };
354 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_AudioDecoderConfig, 20);
355 /**
356  * @}
357  */
358 
359 /**
360  * @addtogroup Enums
361  * @{
362  */
363 /**
364  * <code>PP_VideoCodec</code> contains video codec type constants.
365  */
366 typedef enum {
367   PP_VIDEOCODEC_UNKNOWN = 0,
368   PP_VIDEOCODEC_VP8 = 1,
369   PP_VIDEOCODEC_H264 = 2,
370   PP_VIDEOCODEC_VP9 = 3
371 } PP_VideoCodec;
372 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VideoCodec, 4);
373 
374 /**
375  * <code>PP_VideoCodecProfile</code> contains video codec profile type
376  * constants required for video decoder configuration.
377  *.
378  */
379 typedef enum {
380   PP_VIDEOCODECPROFILE_UNKNOWN = 0,
381   PP_VIDEOCODECPROFILE_NOT_NEEDED = 1,
382   PP_VIDEOCODECPROFILE_H264_BASELINE = 2,
383   PP_VIDEOCODECPROFILE_H264_MAIN = 3,
384   PP_VIDEOCODECPROFILE_H264_EXTENDED = 4,
385   PP_VIDEOCODECPROFILE_H264_HIGH = 5,
386   PP_VIDEOCODECPROFILE_H264_HIGH_10 = 6,
387   PP_VIDEOCODECPROFILE_H264_HIGH_422 = 7,
388   PP_VIDEOCODECPROFILE_H264_HIGH_444_PREDICTIVE = 8
389 } PP_VideoCodecProfile;
390 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VideoCodecProfile, 4);
391 /**
392  * @}
393  */
394 
395 /**
396  * @addtogroup Structs
397  * @{
398  */
399 /**
400  * <code>PP_VideoDecoderConfig</code> contains video decoder configuration
401  * information required to initialize video decoders, and a request ID
402  * that allows clients to associate a decoder initialization request with a
403  * status response. Note: When <code>codec</code> requires extra data for
404  * initialization, the data is sent as a <code>PP_Resource</code> carried
405  * alongside <code>PP_VideoDecoderConfig</code>.
406  */
407 struct PP_VideoDecoderConfig {
408   /**
409    * The video codec to initialize.
410    */
411   PP_VideoCodec codec;
412   /**
413    * Profile to use when initializing the video codec.
414    */
415   PP_VideoCodecProfile profile;
416   /**
417    * Output video format.
418    */
419   PP_DecryptedFrameFormat format;
420   /**
421    * Width of decoded video frames, in pixels.
422    */
423   int32_t width;
424   /**
425    * Height of decoded video frames, in pixels.
426    */
427   int32_t height;
428   /**
429    * Client-specified identifier for the associated video decoder initialization
430    * request. By using this value, the client can associate a decoder
431    * initialization status response with an initialization request.
432    */
433   uint32_t request_id;
434 };
435 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_VideoDecoderConfig, 24);
436 /**
437  * @}
438  */
439 
440 /**
441  * @addtogroup Enums
442  * @{
443  */
444 /**
445  * <code>PP_DecryptorStreamType</code> contains stream type constants.
446  */
447 typedef enum {
448   PP_DECRYPTORSTREAMTYPE_AUDIO = 0,
449   PP_DECRYPTORSTREAMTYPE_VIDEO = 1
450 } PP_DecryptorStreamType;
451 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_DecryptorStreamType, 4);
452 
453 /**
454  * <code>PP_SessionType</code> contains session type constants.
455  */
456 typedef enum {
457   PP_SESSIONTYPE_TEMPORARY = 0,
458   PP_SESSIONTYPE_PERSISTENT = 1
459 } PP_SessionType;
460 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_SessionType, 4);
461 
462 /**
463  * <code>PP_CdmExceptionCode</code> contains exception code constants.
464  */
465 typedef enum {
466   PP_CDMEXCEPTIONCODE_NOTSUPPORTEDERROR = 1,
467   PP_CDMEXCEPTIONCODE_INVALIDSTATEERROR = 2,
468   PP_CDMEXCEPTIONCODE_INVALIDACCESSERROR = 3,
469   PP_CDMEXCEPTIONCODE_QUOTAEXCEEDEDERROR = 4,
470   PP_CDMEXCEPTIONCODE_UNKNOWNERROR = 5,
471   PP_CDMEXCEPTIONCODE_CLIENTERROR = 6,
472   PP_CDMEXCEPTIONCODE_OUTPUTERROR = 7
473 } PP_CdmExceptionCode;
474 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_CdmExceptionCode, 4);
475 /**
476  * @}
477  */
478 
479 #endif  /* PPAPI_C_PRIVATE_PP_CONTENT_DECRYPTOR_H_ */
480 
481