Fix build break
[chromium-blink-merge.git] / ppapi / c / private / pp_content_decryptor.h
blob43ea559f128f64d99f850515719d53f00b7cc0bb
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 */
6 /* From private/pp_content_decryptor.idl modified Tue Dec 4 16:42:46 2012. */
8 #ifndef PPAPI_C_PRIVATE_PP_CONTENT_DECRYPTOR_H_
9 #define PPAPI_C_PRIVATE_PP_CONTENT_DECRYPTOR_H_
11 #include "ppapi/c/pp_macros.h"
12 #include "ppapi/c/pp_stdint.h"
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.
22 /**
23 * @addtogroup Structs
24 * @{
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.
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.
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.
50 int64_t timestamp;
52 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_DecryptTrackingInfo, 16);
54 /**
55 * The <code>PP_DecryptSubsampleDescription</code> struct contains information
56 * to support subsample decryption.
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:
63 * |<----- subsample1 ----->|<----- subsample2 ----->|<----- subsample3 ----->|
64 * | clear1 | cipher1 | clear2 | cipher2 | clear3 | cipher3 |
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.
70 * Logical stream to decrypt: | cipher1 | cipher2 | cipher3 |
71 * Decrypted stream: | decrypted1| decrypted2 | decrypted3 |
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:
77 * |<----- subsample1 ----->|<----- subsample2 ----->|<----- subsample3 ----->|
78 * | clear1 | decrypted1| clear2 | decrypted2 | clear3 | decrypted3 |
80 struct PP_DecryptSubsampleDescription {
81 /**
82 * Size in bytes of clear data in a subsample entry.
84 uint32_t clear_bytes;
85 /**
86 * Size in bytes of encrypted data in a subsample entry.
88 uint32_t cipher_bytes;
90 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_DecryptSubsampleDescription, 8);
92 /**
93 * The <code>PP_EncryptedBlockInfo</code> struct contains all the information
94 * needed to decrypt an encrypted block.
96 struct PP_EncryptedBlockInfo {
97 /**
98 * Information needed by the client to track the block to be decrypted.
100 struct PP_DecryptTrackingInfo tracking_info;
102 * Size in bytes of data to be decrypted (data_offset included).
104 uint32_t data_size;
106 * Size in bytes of data to be discarded before applying the decryption.
108 uint32_t data_offset;
110 * Key ID of the block to be decrypted.
112 * TODO(xhwang): For WebM the key ID can be as large as 2048 bytes in theory.
113 * But it's not used in current implementations. If we really need to support
114 * it, we should move key ID out as a separate parameter, e.g.
115 * as a <code>PP_Var</code>, or make the whole
116 * <code>PP_EncryptedBlockInfo</code> as a <code>PP_Resource</code>.
118 uint8_t key_id[64];
119 uint32_t key_id_size;
121 * Initialization vector of the block to be decrypted.
123 uint8_t iv[16];
124 uint32_t iv_size;
126 * Subsample information of the block to be decrypted.
128 struct PP_DecryptSubsampleDescription subsamples[16];
129 uint32_t num_subsamples;
131 * 4-byte padding to make the size of <code>PP_EncryptedBlockInfo</code>
132 * a multiple of 8 bytes. The value of this field should not be used.
134 uint32_t padding;
136 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_EncryptedBlockInfo, 248);
138 * @}
142 * @addtogroup Enums
143 * @{
146 * <code>PP_DecryptedFrameFormat</code> contains video frame formats.
148 typedef enum {
149 PP_DECRYPTEDFRAMEFORMAT_UNKNOWN = 0,
150 PP_DECRYPTEDFRAMEFORMAT_YV12 = 1,
151 PP_DECRYPTEDFRAMEFORMAT_I420 = 2
152 } PP_DecryptedFrameFormat;
153 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_DecryptedFrameFormat, 4);
156 * The <code>PP_DecryptResult</code> enum contains decryption and decoding
157 * result constants.
159 typedef enum {
160 /** The decryption (and/or decoding) operation finished successfully. */
161 PP_DECRYPTRESULT_SUCCESS = 0,
162 /** The decryptor did not have the necessary decryption key. */
163 PP_DECRYPTRESULT_DECRYPT_NOKEY = 1,
164 /** The input was accepted by the decoder but no frame(s) can be produced. */
165 PP_DECRYPTRESULT_NEEDMOREDATA = 2,
166 /** An unexpected error happened during decryption. */
167 PP_DECRYPTRESULT_DECRYPT_ERROR = 3,
168 /** An unexpected error happened during decoding. */
169 PP_DECRYPTRESULT_DECODE_ERROR = 4
170 } PP_DecryptResult;
171 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_DecryptResult, 4);
173 * @}
177 * @addtogroup Structs
178 * @{
181 * <code>PP_DecryptedBlockInfo</code> struct contains the decryption result and
182 * tracking info associated with the decrypted block.
184 struct PP_DecryptedBlockInfo {
186 * Result of the decryption (and/or decoding) operation.
188 PP_DecryptResult result;
190 * Size in bytes of decrypted data, which may be less than the size of the
191 * corresponding buffer.
193 uint32_t data_size;
195 * Information needed by the client to track the block to be decrypted.
197 struct PP_DecryptTrackingInfo tracking_info;
199 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_DecryptedBlockInfo, 24);
201 * @}
205 * @addtogroup Enums
206 * @{
209 * <code>PP_DecryptedFramePlanes</code> provides YUV plane index values for
210 * accessing plane offsets stored in <code>PP_DecryptedFrameInfo</code>.
212 typedef enum {
213 PP_DECRYPTEDFRAMEPLANES_Y = 0,
214 PP_DECRYPTEDFRAMEPLANES_U = 1,
215 PP_DECRYPTEDFRAMEPLANES_V = 2
216 } PP_DecryptedFramePlanes;
217 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_DecryptedFramePlanes, 4);
219 * @}
223 * @addtogroup Structs
224 * @{
227 * <code>PP_DecryptedFrameInfo</code> contains the result of the
228 * decrypt and decode operation on the associated frame, information required
229 * to access the frame data in buffer, and tracking info.
231 struct PP_DecryptedFrameInfo {
233 * Result of the decrypt and decode operation.
235 PP_DecryptResult result;
237 * Format of the decrypted frame.
239 PP_DecryptedFrameFormat format;
241 * Offsets into the buffer resource for accessing video planes.
243 int32_t plane_offsets[3];
245 * Stride of each plane.
247 int32_t strides[3];
249 * Width of the video frame, in pixels.
251 int32_t width;
253 * Height of the video frame, in pixels.
255 int32_t height;
257 * Information needed by the client to track the decrypted frame.
259 struct PP_DecryptTrackingInfo tracking_info;
261 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_DecryptedFrameInfo, 56);
263 * @}
267 * @addtogroup Enums
268 * @{
271 * <code>PP_AudioCodec</code> contains audio codec type constants.
273 typedef enum {
274 PP_AUDIOCODEC_UNKNOWN = 0,
275 PP_AUDIOCODEC_VORBIS = 1,
276 PP_AUDIOCODEC_AAC = 2
277 } PP_AudioCodec;
278 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_AudioCodec, 4);
280 * @}
284 * @addtogroup Structs
285 * @{
288 * <code>PP_AudioDecoderConfig</code> contains audio decoder configuration
289 * information required to initialize audio decoders, and a request ID
290 * that allows clients to associate a decoder initialization request with a
291 * status response. Note: When <code>codec</code> requires extra data for
292 * initialization, the data is sent as a <code>PP_Resource</code> carried
293 * alongside <code>PP_AudioDecoderConfig</code>.
295 struct PP_AudioDecoderConfig {
297 * The audio codec to initialize.
299 PP_AudioCodec codec;
301 * Number of audio channels.
303 int32_t channel_count;
305 * Size of each audio channel.
307 int32_t bits_per_channel;
309 * Audio sampling rate.
311 int32_t samples_per_second;
313 * Client-specified identifier for the associated audio decoder initialization
314 * request. By using this value, the client can associate a decoder
315 * initialization status response with an initialization request.
317 uint32_t request_id;
319 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_AudioDecoderConfig, 20);
321 * @}
325 * @addtogroup Enums
326 * @{
329 * <code>PP_VideoCodec</code> contains video codec type constants.
331 typedef enum {
332 PP_VIDEOCODEC_UNKNOWN = 0,
333 PP_VIDEOCODEC_VP8 = 1,
334 PP_VIDEOCODEC_H264 = 2
335 } PP_VideoCodec;
336 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VideoCodec, 4);
339 * <code>PP_VideoCodecProfile</code> contains video codec profile type
340 * constants required for video decoder configuration.
343 typedef enum {
344 PP_VIDEOCODECPROFILE_UNKNOWN = 0,
345 PP_VIDEOCODECPROFILE_VP8_MAIN = 1,
346 PP_VIDEOCODECPROFILE_H264_BASELINE = 2,
347 PP_VIDEOCODECPROFILE_H264_MAIN = 3,
348 PP_VIDEOCODECPROFILE_H264_EXTENDED = 4,
349 PP_VIDEOCODECPROFILE_H264_HIGH = 5,
350 PP_VIDEOCODECPROFILE_H264_HIGH_10 = 6,
351 PP_VIDEOCODECPROFILE_H264_HIGH_422 = 7,
352 PP_VIDEOCODECPROFILE_H264_HIGH_444_PREDICTIVE = 8
353 } PP_VideoCodecProfile;
354 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VideoCodecProfile, 4);
356 * @}
360 * @addtogroup Structs
361 * @{
364 * <code>PP_VideoDecoderConfig</code> contains video decoder configuration
365 * information required to initialize video decoders, and a request ID
366 * that allows clients to associate a decoder initialization request with a
367 * status response. Note: When <code>codec</code> requires extra data for
368 * initialization, the data is sent as a <code>PP_Resource</code> carried
369 * alongside <code>PP_VideoDecoderConfig</code>.
371 struct PP_VideoDecoderConfig {
373 * The video codec to initialize.
375 PP_VideoCodec codec;
377 * Profile to use when initializing the video codec.
379 PP_VideoCodecProfile profile;
381 * Output video format.
383 PP_DecryptedFrameFormat format;
385 * Width of decoded video frames, in pixels.
387 int32_t width;
389 * Height of decoded video frames, in pixels.
391 int32_t height;
393 * Client-specified identifier for the associated video decoder initialization
394 * request. By using this value, the client can associate a decoder
395 * initialization status response with an initialization request.
397 uint32_t request_id;
399 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_VideoDecoderConfig, 24);
401 * @}
405 * @addtogroup Enums
406 * @{
409 * <code>PP_DecryptorStreamType</code> contains stream type constants.
411 typedef enum {
412 PP_DECRYPTORSTREAMTYPE_AUDIO = 0,
413 PP_DECRYPTORSTREAMTYPE_VIDEO = 1
414 } PP_DecryptorStreamType;
415 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_DecryptorStreamType, 4);
417 * @}
420 #endif /* PPAPI_C_PRIVATE_PP_CONTENT_DECRYPTOR_H_ */