Pepper_31_C_interfaces
pp_content_decryptor_samsung.h
Go to the documentation of this file.
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 samsung/pp_content_decryptor_samsung.idl,
7  * modified Mon Sep 16 17:44:49 2013.
8  */
9 
10 #ifndef PPAPI_C_SAMSUNG_PP_CONTENT_DECRYPTOR_SAMSUNG_H_
11 #define PPAPI_C_SAMSUNG_PP_CONTENT_DECRYPTOR_SAMSUNG_H_
12 
13 #include "ppapi/c/pp_macros.h"
14 #include "ppapi/c/pp_stdint.h"
15 
16 /**
17  * @file
18  * Aim of this extension is to provide a way that NaCl application can
19  * provide functionality of ContentDecryptionModule (CDM).
20  *
21  * This API is almost the same as PP[PB]_ContentDecryptor_Private API
22  * with some additional methods allowing NaCl application to register
23  * itself as CDM for given keySystem.
24  *
25  * TODO(samsung) Add support for decoding audio/video present in
26  * ContentDecryptor_Private API
27  */
28 
29 
30 
31 /**
32  * Defines sizes of arrays inside <code>PP_EncryptedBlockInfo</code>
33  *
34  * Keep those defines aligned with size of corresponding arrays
35  * in <code>PP_EncryptedBlockInfo</code>
36  */
37 
38 /** Length PP_EncryptedBlockInfo.key_id field */
39 #define MAX_KEY_ID_LENGTH 64
40 
41 /** Length PP_EncryptedBlockInfo.iv field */
42 #define MAX_IV_LENGTH 16
43 
44 /** Length PP_EncryptedBlockInfo.subsamples field */
45 #define MAX_SUBSAMPLES 16
46 
47 
48 /**
49  * @addtogroup Structs
50  * @{
51  */
52 /**
53  * The <code>PP_DecryptTrackingInfo</code> struct contains necessary information
54  * that can be used to associate the decrypted block with a decrypt request
55  * and/or an input block.
56  */
58  /**
59  * Client-specified identifier for the associated decrypt request. By using
60  * this value, the client can associate the decrypted block with a decryption
61  * request.
62  */
63  uint32_t request_id;
64  /**
65  * A unique buffer ID to identify a PPB_Buffer_Dev. Unlike a PP_Resource,
66  * this ID is identical at both the renderer side and the plugin side.
67  * In <code>PPB_ContentDecryptor_Private</code> calls, this is the ID of the
68  * buffer associated with the decrypted block/frame/samples.
69  * In <code>PPP_ContentDecryptor_Private</code> calls, this is the ID of a
70  * buffer that is no longer need at the renderer side, which can be released
71  * or recycled by the plugin. This ID can be 0 if there is no buffer to be
72  * released or recycled.
73  */
74  uint32_t buffer_id;
75  /**
76  * Timestamp in microseconds of the associated block. By using this value,
77  * the client can associate the decrypted (and decoded) data with an input
78  * block. This is needed because buffers may be delivered out of order and
79  * not in response to the <code>request_id</code> they were provided with.
80  */
81  int64_t timestamp;
82 };
84 
85 /**
86  * The <code>PP_DecryptSubsampleDescription</code> struct contains information
87  * to support subsample decryption.
88  *
89  * An input block can be split into several continuous subsamples.
90  * A <code>PP_DecryptSubsampleEntry</code> specifies the number of clear and
91  * cipher bytes in each subsample. For example, the following block has three
92  * subsamples:
93  *
94  * |<----- subsample1 ----->|<----- subsample2 ----->|<----- subsample3 ----->|
95  * | clear1 | cipher1 | clear2 | cipher2 | clear3 | cipher3 |
96  *
97  * For decryption, all of the cipher bytes in a block should be treated as a
98  * contiguous (in the subsample order) logical stream. The clear bytes should
99  * not be considered as part of decryption.
100  *
101  * Logical stream to decrypt: | cipher1 | cipher2 | cipher3 |
102  * Decrypted stream: | decrypted1| decrypted2 | decrypted3 |
103  *
104  * After decryption, the decrypted bytes should be copied over the position
105  * of the corresponding cipher bytes in the original block to form the output
106  * block. Following the above example, the decrypted block should be:
107  *
108  * |<----- subsample1 ----->|<----- subsample2 ----->|<----- subsample3 ----->|
109  * | clear1 | decrypted1| clear2 | decrypted2 | clear3 | decrypted3 |
110  */
112  /**
113  * Size in bytes of clear data in a subsample entry.
114  */
115  uint32_t clear_bytes;
116  /**
117  * Size in bytes of encrypted data in a subsample entry.
118  */
119  uint32_t cipher_bytes;
120 };
122 
123 /**
124  * The <code>PP_EncryptedBlockInfo</code> struct contains all the information
125  * needed to decrypt an encrypted block.
126  */
128  /**
129  * Information needed by the client to track the block to be decrypted.
130  */
132  /**
133  * Size in bytes of data to be decrypted (data_offset included).
134  */
135  uint32_t data_size;
136  /**
137  * Size in bytes of data to be discarded before applying the decryption.
138  */
139  uint32_t data_offset;
140  /**
141  * Key ID of the block to be decrypted.
142  *
143  * TODO(xhwang): For WebM the key ID can be as large as 2048 bytes in theory.
144  * But it's not used in current implementations. If we really need to support
145  * it, we should move key ID out as a separate parameter, e.g.
146  * as a <code>PP_Var</code>, or make the whole
147  * <code>PP_EncryptedBlockInfo</code> as a <code>PP_Resource</code>.
148  */
149  uint8_t key_id[64];
150  uint32_t key_id_size;
151  /**
152  * Initialization vector of the block to be decrypted.
153  */
154  uint8_t iv[16];
155  uint32_t iv_size;
156  /**
157  * Subsample information of the block to be decrypted.
158  */
160  uint32_t num_subsamples;
161  /**
162  * 4-byte padding to make the size of <code>PP_EncryptedBlockInfo</code>
163  * a multiple of 8 bytes. The value of this field should not be used.
164  */
165  uint32_t padding;
166 };
168 /**
169  * @}
170  */
171 
172 /**
173  * @addtogroup Enums
174  * @{
175  */
176 /**
177  * <code>PP_DecryptedFrameFormat</code> contains video frame formats.
178  */
179 typedef enum {
185 
186 /**
187  * The <code>PP_DecryptResult</code> enum contains decryption and decoding
188  * result constants.
189  */
190 typedef enum {
191  /** The decryption (and/or decoding) operation finished successfully. */
193  /** The decryptor did not have the necessary decryption key. */
195  /** The input was accepted by the decoder but no frame(s) can be produced. */
197  /** An unexpected error happened during decryption. */
199  /** An unexpected error happened during decoding. */
203 
204 /**
205  * The <code>PP_MediaKeyError</code> enum contains media key error type.
206  */
207 typedef enum {
216 /**
217  * @}
218  */
219 
220 /**
221  * @addtogroup Structs
222  * @{
223  */
224 /**
225  * <code>PP_DecryptedBlockInfo</code> struct contains the decryption result and
226  * tracking info associated with the decrypted block.
227  */
229  /**
230  * Result of the decryption (and/or decoding) operation.
231  */
233  /**
234  * Size in bytes of decrypted data, which may be less than the size of the
235  * corresponding buffer.
236  */
237  uint32_t data_size;
238  /**
239  * Information needed by the client to track the block to be decrypted.
240  */
242 };
244 /**
245  * @}
246  */
247 
248 /**
249  * @addtogroup Enums
250  * @{
251  */
252 /**
253  * <code>PP_DecryptedFramePlanes</code> provides YUV plane index values for
254  * accessing plane offsets stored in <code>PP_DecryptedFrameInfo</code>.
255  */
256 typedef enum {
262 /**
263  * @}
264  */
265 
266 /**
267  * @addtogroup Structs
268  * @{
269  */
270 /**
271  * <code>PP_DecryptedFrameInfo</code> contains the result of the
272  * decrypt and decode operation on the associated frame, information required
273  * to access the frame data in buffer, and tracking info.
274  */
276  /**
277  * Result of the decrypt and decode operation.
278  */
280  /**
281  * Format of the decrypted frame.
282  */
284  /**
285  * Offsets into the buffer resource for accessing video planes.
286  */
287  int32_t plane_offsets[3];
288  /**
289  * Stride of each plane.
290  */
291  int32_t strides[3];
292  /**
293  * Width of the video frame, in pixels.
294  */
295  int32_t width;
296  /**
297  * Height of the video frame, in pixels.
298  */
299  int32_t height;
300  /**
301  * Information needed by the client to track the decrypted frame.
302  */
304 };
306 /**
307  * @}
308  */
309 
310 /**
311  * @addtogroup Enums
312  * @{
313  */
314 /**
315  * <code>PP_AudioCodec</code> contains audio codec type constants.
316  */
317 typedef enum {
321 } PP_AudioCodec;
323 /**
324  * @}
325  */
326 
327 /**
328  * @addtogroup Structs
329  * @{
330  */
331 /**
332  * <code>PP_AudioDecoderConfig</code> contains audio decoder configuration
333  * information required to initialize audio decoders, and a request ID
334  * that allows clients to associate a decoder initialization request with a
335  * status response. Note: When <code>codec</code> requires extra data for
336  * initialization, the data is sent as a <code>PP_Resource</code> carried
337  * alongside <code>PP_AudioDecoderConfig</code>.
338  */
340  /**
341  * The audio codec to initialize.
342  */
344  /**
345  * Number of audio channels.
346  */
347  int32_t channel_count;
348  /**
349  * Size of each audio channel.
350  */
352  /**
353  * Audio sampling rate.
354  */
356  /**
357  * Client-specified identifier for the associated audio decoder initialization
358  * request. By using this value, the client can associate a decoder
359  * initialization status response with an initialization request.
360  */
361  uint32_t request_id;
362 };
364 /**
365  * @}
366  */
367 
368 /**
369  * @addtogroup Enums
370  * @{
371  */
372 /**
373  * <code>PP_VideoCodec</code> contains video codec type constants.
374  */
375 typedef enum {
379 } PP_VideoCodec;
381 
382 /**
383  * <code>PP_VideoCodecProfile</code> contains video codec profile type
384  * constants required for video decoder configuration.
385  *.
386  */
387 typedef enum {
399 /**
400  * @}
401  */
402 
403 /**
404  * @addtogroup Structs
405  * @{
406  */
407 /**
408  * <code>PP_VideoDecoderConfig</code> contains video decoder configuration
409  * information required to initialize video decoders, and a request ID
410  * that allows clients to associate a decoder initialization request with a
411  * status response. Note: When <code>codec</code> requires extra data for
412  * initialization, the data is sent as a <code>PP_Resource</code> carried
413  * alongside <code>PP_VideoDecoderConfig</code>.
414  */
416  /**
417  * The video codec to initialize.
418  */
420  /**
421  * Profile to use when initializing the video codec.
422  */
424  /**
425  * Output video format.
426  */
428  /**
429  * Width of decoded video frames, in pixels.
430  */
431  int32_t width;
432  /**
433  * Height of decoded video frames, in pixels.
434  */
435  int32_t height;
436  /**
437  * Client-specified identifier for the associated video decoder initialization
438  * request. By using this value, the client can associate a decoder
439  * initialization status response with an initialization request.
440  */
441  uint32_t request_id;
442 };
444 /**
445  * @}
446  */
447 
448 /**
449  * @addtogroup Enums
450  * @{
451  */
452 /**
453  * <code>PP_DecryptorStreamType</code> contains stream type constants.
454  */
455 typedef enum {
460 /**
461  * @}
462  */
463 
464 #endif /* PPAPI_C_SAMSUNG_PP_CONTENT_DECRYPTOR_SAMSUNG_H_ */
465 
PP_DecryptedFrameFormat format
struct PP_DecryptTrackingInfo tracking_info
struct PP_DecryptTrackingInfo tracking_info
PP_DecryptedFrameFormat format
struct PP_DecryptSubsampleDescription subsamples[16]
PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_DecryptedFrameFormat, 4)
struct PP_DecryptTrackingInfo tracking_info
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_DecryptTrackingInfo, 16)