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.
6 /* From private/pp_content_decryptor.idl modified Mon Oct 21 18:38:44 2013. */
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"
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.
26 struct PP_DecryptTrackingInfo {
28 * Client-specified identifier for the associated decrypt request. By using
29 * this value, the client can associate the decrypted block with a decryption
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.
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.
52 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_DecryptTrackingInfo, 16);
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
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 {
82 * Size in bytes of clear data in a subsample entry.
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);
93 * The <code>PP_EncryptedBlockInfo</code> struct contains all the information
94 * needed to decrypt an encrypted block.
96 struct PP_EncryptedBlockInfo {
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).
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>.
119 uint32_t key_id_size;
121 * Initialization vector of the block to be decrypted.
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.
136 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_EncryptedBlockInfo, 248);
146 * <code>PP_DecryptedFrameFormat</code> contains video frame formats.
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 * <code>PP_DecryptedSampleFormat</code> contains audio sample formats.
159 PP_DECRYPTEDSAMPLEFORMAT_UNKNOWN = 0,
160 PP_DECRYPTEDSAMPLEFORMAT_U8 = 1,
161 PP_DECRYPTEDSAMPLEFORMAT_S16 = 2,
162 PP_DECRYPTEDSAMPLEFORMAT_S32 = 3,
163 PP_DECRYPTEDSAMPLEFORMAT_F32 = 4,
164 PP_DECRYPTEDSAMPLEFORMAT_PLANAR_S16 = 5,
165 PP_DECRYPTEDSAMPLEFORMAT_PLANAR_F32 = 6
166 } PP_DecryptedSampleFormat;
167 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_DecryptedSampleFormat, 4);
170 * The <code>PP_DecryptResult</code> enum contains decryption and decoding
174 /** The decryption (and/or decoding) operation finished successfully. */
175 PP_DECRYPTRESULT_SUCCESS = 0,
176 /** The decryptor did not have the necessary decryption key. */
177 PP_DECRYPTRESULT_DECRYPT_NOKEY = 1,
178 /** The input was accepted by the decoder but no frame(s) can be produced. */
179 PP_DECRYPTRESULT_NEEDMOREDATA = 2,
180 /** An unexpected error happened during decryption. */
181 PP_DECRYPTRESULT_DECRYPT_ERROR = 3,
182 /** An unexpected error happened during decoding. */
183 PP_DECRYPTRESULT_DECODE_ERROR = 4
185 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_DecryptResult, 4);
191 * @addtogroup Structs
195 * <code>PP_DecryptedBlockInfo</code> struct contains the decryption result and
196 * tracking info associated with the decrypted block.
198 struct PP_DecryptedBlockInfo {
200 * Result of the decryption (and/or decoding) operation.
202 PP_DecryptResult result;
204 * Size in bytes of decrypted data, which may be less than the size of the
205 * corresponding buffer.
209 * Information needed by the client to track the block to be decrypted.
211 struct PP_DecryptTrackingInfo tracking_info;
213 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_DecryptedBlockInfo, 24);
223 * <code>PP_DecryptedFramePlanes</code> provides YUV plane index values for
224 * accessing plane offsets stored in <code>PP_DecryptedFrameInfo</code>.
227 PP_DECRYPTEDFRAMEPLANES_Y = 0,
228 PP_DECRYPTEDFRAMEPLANES_U = 1,
229 PP_DECRYPTEDFRAMEPLANES_V = 2
230 } PP_DecryptedFramePlanes;
231 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_DecryptedFramePlanes, 4);
237 * @addtogroup Structs
241 * <code>PP_DecryptedFrameInfo</code> contains the result of the
242 * decrypt and decode operation on the associated frame, information required
243 * to access the frame data in buffer, and tracking info.
245 struct PP_DecryptedFrameInfo {
247 * Result of the decrypt and decode operation.
249 PP_DecryptResult result;
251 * Format of the decrypted frame.
253 PP_DecryptedFrameFormat format;
255 * Offsets into the buffer resource for accessing video planes.
257 int32_t plane_offsets[3];
259 * Stride of each plane.
263 * Width of the video frame, in pixels.
267 * Height of the video frame, in pixels.
271 * Information needed by the client to track the decrypted frame.
273 struct PP_DecryptTrackingInfo tracking_info;
275 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_DecryptedFrameInfo, 56);
278 * <code>PP_DecryptedSampleInfo</code> contains the result of the
279 * decrypt and decode operation on the associated samples, information required
280 * to access the sample data in buffer, and tracking info.
282 struct PP_DecryptedSampleInfo {
284 * Result of the decrypt and decode operation.
286 PP_DecryptResult result;
288 * Format of the decrypted samples.
290 PP_DecryptedSampleFormat format;
292 * Size in bytes of decrypted samples.
296 * 4-byte padding to make the size of <code>PP_DecryptedSampleInfo</code>
297 * a multiple of 8 bytes. The value of this field should not be used.
301 * Information needed by the client to track the decrypted samples.
303 struct PP_DecryptTrackingInfo tracking_info;
305 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_DecryptedSampleInfo, 32);
315 * <code>PP_AudioCodec</code> contains audio codec type constants.
318 PP_AUDIOCODEC_UNKNOWN = 0,
319 PP_AUDIOCODEC_VORBIS = 1,
320 PP_AUDIOCODEC_AAC = 2
322 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_AudioCodec, 4);
328 * @addtogroup Structs
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>.
339 struct PP_AudioDecoderConfig {
341 * The audio codec to initialize.
345 * Number of audio channels.
347 int32_t channel_count;
349 * Size of each audio channel.
351 int32_t bits_per_channel;
353 * Audio sampling rate.
355 int32_t samples_per_second;
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.
363 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_AudioDecoderConfig, 20);
373 * <code>PP_VideoCodec</code> contains video codec type constants.
376 PP_VIDEOCODEC_UNKNOWN = 0,
377 PP_VIDEOCODEC_VP8 = 1,
378 PP_VIDEOCODEC_H264 = 2
380 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VideoCodec, 4);
383 * <code>PP_VideoCodecProfile</code> contains video codec profile type
384 * constants required for video decoder configuration.
388 PP_VIDEOCODECPROFILE_UNKNOWN = 0,
389 PP_VIDEOCODECPROFILE_VP8_MAIN = 1,
390 PP_VIDEOCODECPROFILE_H264_BASELINE = 2,
391 PP_VIDEOCODECPROFILE_H264_MAIN = 3,
392 PP_VIDEOCODECPROFILE_H264_EXTENDED = 4,
393 PP_VIDEOCODECPROFILE_H264_HIGH = 5,
394 PP_VIDEOCODECPROFILE_H264_HIGH_10 = 6,
395 PP_VIDEOCODECPROFILE_H264_HIGH_422 = 7,
396 PP_VIDEOCODECPROFILE_H264_HIGH_444_PREDICTIVE = 8
397 } PP_VideoCodecProfile;
398 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VideoCodecProfile, 4);
404 * @addtogroup Structs
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>.
415 struct PP_VideoDecoderConfig {
417 * The video codec to initialize.
421 * Profile to use when initializing the video codec.
423 PP_VideoCodecProfile profile;
425 * Output video format.
427 PP_DecryptedFrameFormat format;
429 * Width of decoded video frames, in pixels.
433 * Height of decoded video frames, in pixels.
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.
443 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_VideoDecoderConfig, 24);
453 * <code>PP_DecryptorStreamType</code> contains stream type constants.
456 PP_DECRYPTORSTREAMTYPE_AUDIO = 0,
457 PP_DECRYPTORSTREAMTYPE_VIDEO = 1
458 } PP_DecryptorStreamType;
459 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_DecryptorStreamType, 4);
464 #endif /* PPAPI_C_PRIVATE_PP_CONTENT_DECRYPTOR_H_ */