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 Tue Dec 4 16:42:46 2012. */ 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 * Size in bytes of data to be discarded before applying the decryption. 107 */ 108 uint32_t data_offset; 109 /** 110 * Key ID of the block to be decrypted. 111 * 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>. 117 */ 118 uint8_t key_id[64]; 119 uint32_t key_id_size; 120 /** 121 * Initialization vector of the block to be decrypted. 122 */ 123 uint8_t iv[16]; 124 uint32_t iv_size; 125 /** 126 * Subsample information of the block to be decrypted. 127 */ 128 struct PP_DecryptSubsampleDescription subsamples[16]; 129 uint32_t num_subsamples; 130 /** 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. 133 */ 134 uint32_t padding; 135 }; 136 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_EncryptedBlockInfo, 248); 137 /** 138 * @} 139 */ 140 141 /** 142 * @addtogroup Enums 143 * @{ 144 */ 145 /** 146 * <code>PP_DecryptedFrameFormat</code> contains video frame formats. 147 */ 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); 154 155 /** 156 * The <code>PP_DecryptResult</code> enum contains decryption and decoding 157 * result constants. 158 */ 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); 172 /** 173 * @} 174 */ 175 176 /** 177 * @addtogroup Structs 178 * @{ 179 */ 180 /** 181 * <code>PP_DecryptedBlockInfo</code> struct contains the decryption result and 182 * tracking info associated with the decrypted block. 183 */ 184 struct PP_DecryptedBlockInfo { 185 /** 186 * Result of the decryption (and/or decoding) operation. 187 */ 188 PP_DecryptResult result; 189 /** 190 * Size in bytes of decrypted data, which may be less than the size of the 191 * corresponding buffer. 192 */ 193 uint32_t data_size; 194 /** 195 * Information needed by the client to track the block to be decrypted. 196 */ 197 struct PP_DecryptTrackingInfo tracking_info; 198 }; 199 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_DecryptedBlockInfo, 24); 200 /** 201 * @} 202 */ 203 204 /** 205 * @addtogroup Enums 206 * @{ 207 */ 208 /** 209 * <code>PP_DecryptedFramePlanes</code> provides YUV plane index values for 210 * accessing plane offsets stored in <code>PP_DecryptedFrameInfo</code>. 211 */ 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); 218 /** 219 * @} 220 */ 221 222 /** 223 * @addtogroup Structs 224 * @{ 225 */ 226 /** 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. 230 */ 231 struct PP_DecryptedFrameInfo { 232 /** 233 * Result of the decrypt and decode operation. 234 */ 235 PP_DecryptResult result; 236 /** 237 * Format of the decrypted frame. 238 */ 239 PP_DecryptedFrameFormat format; 240 /** 241 * Offsets into the buffer resource for accessing video planes. 242 */ 243 int32_t plane_offsets[3]; 244 /** 245 * Stride of each plane. 246 */ 247 int32_t strides[3]; 248 /** 249 * Width of the video frame, in pixels. 250 */ 251 int32_t width; 252 /** 253 * Height of the video frame, in pixels. 254 */ 255 int32_t height; 256 /** 257 * Information needed by the client to track the decrypted frame. 258 */ 259 struct PP_DecryptTrackingInfo tracking_info; 260 }; 261 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_DecryptedFrameInfo, 56); 262 /** 263 * @} 264 */ 265 266 /** 267 * @addtogroup Enums 268 * @{ 269 */ 270 /** 271 * <code>PP_AudioCodec</code> contains audio codec type constants. 272 */ 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); 279 /** 280 * @} 281 */ 282 283 /** 284 * @addtogroup Structs 285 * @{ 286 */ 287 /** 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>. 294 */ 295 struct PP_AudioDecoderConfig { 296 /** 297 * The audio codec to initialize. 298 */ 299 PP_AudioCodec codec; 300 /** 301 * Number of audio channels. 302 */ 303 int32_t channel_count; 304 /** 305 * Size of each audio channel. 306 */ 307 int32_t bits_per_channel; 308 /** 309 * Audio sampling rate. 310 */ 311 int32_t samples_per_second; 312 /** 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. 316 */ 317 uint32_t request_id; 318 }; 319 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_AudioDecoderConfig, 20); 320 /** 321 * @} 322 */ 323 324 /** 325 * @addtogroup Enums 326 * @{ 327 */ 328 /** 329 * <code>PP_VideoCodec</code> contains video codec type constants. 330 */ 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); 337 338 /** 339 * <code>PP_VideoCodecProfile</code> contains video codec profile type 340 * constants required for video decoder configuration. 341 *. 342 */ 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); 355 /** 356 * @} 357 */ 358 359 /** 360 * @addtogroup Structs 361 * @{ 362 */ 363 /** 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>. 370 */ 371 struct PP_VideoDecoderConfig { 372 /** 373 * The video codec to initialize. 374 */ 375 PP_VideoCodec codec; 376 /** 377 * Profile to use when initializing the video codec. 378 */ 379 PP_VideoCodecProfile profile; 380 /** 381 * Output video format. 382 */ 383 PP_DecryptedFrameFormat format; 384 /** 385 * Width of decoded video frames, in pixels. 386 */ 387 int32_t width; 388 /** 389 * Height of decoded video frames, in pixels. 390 */ 391 int32_t height; 392 /** 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. 396 */ 397 uint32_t request_id; 398 }; 399 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_VideoDecoderConfig, 24); 400 /** 401 * @} 402 */ 403 404 /** 405 * @addtogroup Enums 406 * @{ 407 */ 408 /** 409 * <code>PP_DecryptorStreamType</code> contains stream type constants. 410 */ 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); 416 /** 417 * @} 418 */ 419 420 #endif /* PPAPI_C_PRIVATE_PP_CONTENT_DECRYPTOR_H_ */ 421 422