Delete unused downloads page asset.
[chromium-blink-merge.git] / ppapi / c / private / pp_content_decryptor.h
blobdef630379357c43117a2ae151142d46efef19618
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 Mon Jul 20 16:41:39 2015. */
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 * Key ID of the block to be decrypted.
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>.
114 uint8_t key_id[64];
115 uint32_t key_id_size;
117 * Initialization vector of the block to be decrypted.
119 uint8_t iv[16];
120 uint32_t iv_size;
122 * Subsample information of the block to be decrypted.
124 struct PP_DecryptSubsampleDescription subsamples[16];
125 uint32_t num_subsamples;
127 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_EncryptedBlockInfo, 240);
129 * @}
133 * @addtogroup Enums
134 * @{
137 * <code>PP_DecryptedFrameFormat</code> contains video frame formats.
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);
147 * <code>PP_DecryptedSampleFormat</code> contains audio sample formats.
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);
161 * The <code>PP_DecryptResult</code> enum contains decryption and decoding
162 * result constants.
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);
178 * @}
182 * @addtogroup Structs
183 * @{
186 * <code>PP_DecryptedBlockInfo</code> struct contains the decryption result and
187 * tracking info associated with the decrypted block.
189 struct PP_DecryptedBlockInfo {
191 * Result of the decryption (and/or decoding) operation.
193 PP_DecryptResult result;
195 * Size in bytes of decrypted data, which may be less than the size of the
196 * corresponding buffer.
198 uint32_t data_size;
200 * Information needed by the client to track the block to be decrypted.
202 struct PP_DecryptTrackingInfo tracking_info;
204 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_DecryptedBlockInfo, 24);
206 * @}
210 * @addtogroup Enums
211 * @{
214 * <code>PP_DecryptedFramePlanes</code> provides YUV plane index values for
215 * accessing plane offsets stored in <code>PP_DecryptedFrameInfo</code>.
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);
224 * @}
228 * @addtogroup Structs
229 * @{
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.
236 struct PP_DecryptedFrameInfo {
238 * Result of the decrypt and decode operation.
240 PP_DecryptResult result;
242 * Format of the decrypted frame.
244 PP_DecryptedFrameFormat format;
246 * Offsets into the buffer resource for accessing video planes.
248 int32_t plane_offsets[3];
250 * Stride of each plane.
252 int32_t strides[3];
254 * Width of the video frame, in pixels.
256 int32_t width;
258 * Height of the video frame, in pixels.
260 int32_t height;
262 * Information needed by the client to track the decrypted frame.
264 struct PP_DecryptTrackingInfo tracking_info;
266 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_DecryptedFrameInfo, 56);
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.
273 struct PP_DecryptedSampleInfo {
275 * Result of the decrypt and decode operation.
277 PP_DecryptResult result;
279 * Format of the decrypted samples.
281 PP_DecryptedSampleFormat format;
283 * Size in bytes of decrypted samples.
285 uint32_t data_size;
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.
290 uint32_t padding;
292 * Information needed by the client to track the decrypted samples.
294 struct PP_DecryptTrackingInfo tracking_info;
296 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_DecryptedSampleInfo, 32);
298 * @}
302 * @addtogroup Enums
303 * @{
306 * <code>PP_AudioCodec</code> contains audio codec type constants.
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);
315 * @}
319 * @addtogroup Structs
320 * @{
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>.
330 struct PP_AudioDecoderConfig {
332 * The audio codec to initialize.
334 PP_AudioCodec codec;
336 * Number of audio channels.
338 int32_t channel_count;
340 * Size of each audio channel.
342 int32_t bits_per_channel;
344 * Audio sampling rate.
346 int32_t samples_per_second;
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.
352 uint32_t request_id;
354 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_AudioDecoderConfig, 20);
356 * @}
360 * @addtogroup Enums
361 * @{
364 * <code>PP_VideoCodec</code> contains video codec type constants.
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);
375 * <code>PP_VideoCodecProfile</code> contains video codec profile type
376 * constants required for video decoder configuration.
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);
392 * @}
396 * @addtogroup Structs
397 * @{
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>.
407 struct PP_VideoDecoderConfig {
409 * The video codec to initialize.
411 PP_VideoCodec codec;
413 * Profile to use when initializing the video codec.
415 PP_VideoCodecProfile profile;
417 * Output video format.
419 PP_DecryptedFrameFormat format;
421 * Width of decoded video frames, in pixels.
423 int32_t width;
425 * Height of decoded video frames, in pixels.
427 int32_t height;
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.
433 uint32_t request_id;
435 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_VideoDecoderConfig, 24);
437 * @}
441 * @addtogroup Enums
442 * @{
445 * <code>PP_DecryptorStreamType</code> contains stream type constants.
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);
454 * <code>PP_SessionType</code> contains session type constants.
456 typedef enum {
457 PP_SESSIONTYPE_TEMPORARY = 0,
458 PP_SESSIONTYPE_PERSISTENT_LICENSE = 1,
459 PP_SESSIONTYPE_PERSISTENT_RELEASE = 2
460 } PP_SessionType;
461 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_SessionType, 4);
464 * <code>PP_InitDataType</code> contains Initialization Data Type constants.
466 typedef enum {
467 PP_INITDATATYPE_CENC = 0,
468 PP_INITDATATYPE_KEYIDS = 1,
469 PP_INITDATATYPE_WEBM = 2
470 } PP_InitDataType;
471 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_InitDataType, 4);
474 * <code>PP_CdmExceptionCode</code> contains exception code constants.
476 typedef enum {
477 PP_CDMEXCEPTIONCODE_NOTSUPPORTEDERROR = 1,
478 PP_CDMEXCEPTIONCODE_INVALIDSTATEERROR = 2,
479 PP_CDMEXCEPTIONCODE_INVALIDACCESSERROR = 3,
480 PP_CDMEXCEPTIONCODE_QUOTAEXCEEDEDERROR = 4,
481 PP_CDMEXCEPTIONCODE_UNKNOWNERROR = 5,
482 PP_CDMEXCEPTIONCODE_CLIENTERROR = 6,
483 PP_CDMEXCEPTIONCODE_OUTPUTERROR = 7
484 } PP_CdmExceptionCode;
485 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_CdmExceptionCode, 4);
488 * <code>PP_CdmMessageType</code> contains message type constants.
490 typedef enum {
491 PP_CDMMESSAGETYPE_LICENSE_REQUEST = 0,
492 PP_CDMMESSAGETYPE_LICENSE_RENEWAL = 1,
493 PP_CDMMESSAGETYPE_LICENSE_RELEASE = 2
494 } PP_CdmMessageType;
495 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_CdmMessageType, 4);
498 * <code>PP_CdmKeyStatus</code> contains key status constants.
500 typedef enum {
501 PP_CDMKEYSTATUS_USABLE = 0,
502 PP_CDMKEYSTATUS_INVALID = 1,
503 PP_CDMKEYSTATUS_EXPIRED = 2,
504 PP_CDMKEYSTATUS_OUTPUTRESTRICTED = 3,
505 PP_CDMKEYSTATUS_OUTPUTDOWNSCALED = 4,
506 PP_CDMKEYSTATUS_STATUSPENDING = 5
507 } PP_CdmKeyStatus;
508 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_CdmKeyStatus, 4);
510 * @}
514 * @addtogroup Structs
515 * @{
518 * The <code>PP_KeyInformation</code> struct contains information about a
519 * key used for decryption.
521 struct PP_KeyInformation {
523 * Key ID.
525 uint8_t key_id[512];
526 uint32_t key_id_size;
528 * Status of this key.
530 PP_CdmKeyStatus key_status;
532 * Optional error code for keys that are not usable.
534 uint32_t system_code;
536 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_KeyInformation, 524);
538 * @}
541 #endif /* PPAPI_C_PRIVATE_PP_CONTENT_DECRYPTOR_H_ */