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 /** 7 * The <code>PP_DecryptTrackingInfo</code> struct contains necessary information 8 * that can be used to associate the decrypted block with a decrypt request 9 * and/or an input block. 10 */ 11 [assert_size(16)] 12 struct PP_DecryptTrackingInfo { 13 /** 14 * Client-specified identifier for the associated decrypt request. By using 15 * this value, the client can associate the decrypted block with a decryption 16 * request. 17 */ 18 uint32_t request_id; 19 20 /** 21 * A unique buffer ID to identify a PPB_Buffer_Dev. Unlike a PP_Resource, 22 * this ID is identical at both the renderer side and the plugin side. 23 * In <code>PPB_ContentDecryptor_Private</code> calls, this is the ID of the 24 * buffer associated with the decrypted block/frame/samples. 25 * In <code>PPP_ContentDecryptor_Private</code> calls, this is the ID of a 26 * buffer that is no longer need at the renderer side, which can be released 27 * or recycled by the plugin. This ID can be 0 if there is no buffer to be 28 * released or recycled. 29 */ 30 uint32_t buffer_id; 31 32 /** 33 * Timestamp in microseconds of the associated block. By using this value, 34 * the client can associate the decrypted (and decoded) data with an input 35 * block. This is needed because buffers may be delivered out of order and 36 * not in response to the <code>request_id</code> they were provided with. 37 */ 38 int64_t timestamp; 39 }; 40 41 /** 42 * The <code>PP_DecryptSubsampleDescription</code> struct contains information 43 * to support subsample decryption. 44 * 45 * An input block can be split into several continuous subsamples. 46 * A <code>PP_DecryptSubsampleEntry</code> specifies the number of clear and 47 * cipher bytes in each subsample. For example, the following block has three 48 * subsamples: 49 * 50 * |<----- subsample1 ----->|<----- subsample2 ----->|<----- subsample3 ----->| 51 * | clear1 | cipher1 | clear2 | cipher2 | clear3 | cipher3 | 52 * 53 * For decryption, all of the cipher bytes in a block should be treated as a 54 * contiguous (in the subsample order) logical stream. The clear bytes should 55 * not be considered as part of decryption. 56 * 57 * Logical stream to decrypt: | cipher1 | cipher2 | cipher3 | 58 * Decrypted stream: | decrypted1| decrypted2 | decrypted3 | 59 * 60 * After decryption, the decrypted bytes should be copied over the position 61 * of the corresponding cipher bytes in the original block to form the output 62 * block. Following the above example, the decrypted block should be: 63 * 64 * |<----- subsample1 ----->|<----- subsample2 ----->|<----- subsample3 ----->| 65 * | clear1 | decrypted1| clear2 | decrypted2 | clear3 | decrypted3 | 66 */ 67 [assert_size(8)] 68 struct PP_DecryptSubsampleDescription { 69 /** 70 * Size in bytes of clear data in a subsample entry. 71 */ 72 uint32_t clear_bytes; 73 74 /** 75 * Size in bytes of encrypted data in a subsample entry. 76 */ 77 uint32_t cipher_bytes; 78 }; 79 80 /** 81 * The <code>PP_EncryptedBlockInfo</code> struct contains all the information 82 * needed to decrypt an encrypted block. 83 */ 84 [assert_size(248)] 85 struct PP_EncryptedBlockInfo { 86 /** 87 * Information needed by the client to track the block to be decrypted. 88 */ 89 PP_DecryptTrackingInfo tracking_info; 90 91 /** 92 * Size in bytes of data to be decrypted (data_offset included). 93 */ 94 uint32_t data_size; 95 96 /** 97 * Size in bytes of data to be discarded before applying the decryption. 98 */ 99 uint32_t data_offset; 100 101 /** 102 * Key ID of the block to be decrypted. 103 * 104 * TODO(xhwang): For WebM the key ID can be as large as 2048 bytes in theory. 105 * But it's not used in current implementations. If we really need to support 106 * it, we should move key ID out as a separate parameter, e.g. 107 * as a <code>PP_Var</code>, or make the whole 108 * <code>PP_EncryptedBlockInfo</code> as a <code>PP_Resource</code>. 109 */ 110 uint8_t[64] key_id; 111 uint32_t key_id_size; 112 113 /** 114 * Initialization vector of the block to be decrypted. 115 */ 116 uint8_t[16] iv; 117 uint32_t iv_size; 118 119 /** 120 * Subsample information of the block to be decrypted. 121 */ 122 PP_DecryptSubsampleDescription[16] subsamples; 123 uint32_t num_subsamples; 124 125 /** 126 * 4-byte padding to make the size of <code>PP_EncryptedBlockInfo</code> 127 * a multiple of 8 bytes. The value of this field should not be used. 128 */ 129 uint32_t padding; 130 }; 131 132 /** 133 * <code>PP_DecryptedFrameFormat</code> contains video frame formats. 134 */ 135 [assert_size(4)] 136 enum PP_DecryptedFrameFormat { 137 PP_DECRYPTEDFRAMEFORMAT_UNKNOWN = 0, 138 PP_DECRYPTEDFRAMEFORMAT_YV12 = 1, 139 PP_DECRYPTEDFRAMEFORMAT_I420 = 2 140 }; 141 142 /** 143 * <code>PP_DecryptedSampleFormat</code> contains audio sample formats. 144 */ 145 [assert_size(4)] 146 enum PP_DecryptedSampleFormat { 147 PP_DECRYPTEDSAMPLEFORMAT_UNKNOWN = 0, 148 PP_DECRYPTEDSAMPLEFORMAT_U8 = 1, 149 PP_DECRYPTEDSAMPLEFORMAT_S16 = 2, 150 PP_DECRYPTEDSAMPLEFORMAT_S32 = 3, 151 PP_DECRYPTEDSAMPLEFORMAT_F32 = 4, 152 PP_DECRYPTEDSAMPLEFORMAT_PLANAR_S16 = 5, 153 PP_DECRYPTEDSAMPLEFORMAT_PLANAR_F32 = 6 154 }; 155 156 /** 157 * The <code>PP_DecryptResult</code> enum contains decryption and decoding 158 * result constants. 159 */ 160 [assert_size(4)] 161 enum PP_DecryptResult { 162 /** The decryption (and/or decoding) operation finished successfully. */ 163 PP_DECRYPTRESULT_SUCCESS = 0, 164 /** The decryptor did not have the necessary decryption key. */ 165 PP_DECRYPTRESULT_DECRYPT_NOKEY = 1, 166 /** The input was accepted by the decoder but no frame(s) can be produced. */ 167 PP_DECRYPTRESULT_NEEDMOREDATA = 2, 168 /** An unexpected error happened during decryption. */ 169 PP_DECRYPTRESULT_DECRYPT_ERROR = 3, 170 /** An unexpected error happened during decoding. */ 171 PP_DECRYPTRESULT_DECODE_ERROR = 4 172 }; 173 174 /** 175 * <code>PP_DecryptedBlockInfo</code> struct contains the decryption result and 176 * tracking info associated with the decrypted block. 177 */ 178 [assert_size(24)] 179 struct PP_DecryptedBlockInfo { 180 /** 181 * Result of the decryption (and/or decoding) operation. 182 */ 183 PP_DecryptResult result; 184 185 /** 186 * Size in bytes of decrypted data, which may be less than the size of the 187 * corresponding buffer. 188 */ 189 uint32_t data_size; 190 191 /** 192 * Information needed by the client to track the block to be decrypted. 193 */ 194 PP_DecryptTrackingInfo tracking_info; 195 }; 196 197 /** 198 * <code>PP_DecryptedFramePlanes</code> provides YUV plane index values for 199 * accessing plane offsets stored in <code>PP_DecryptedFrameInfo</code>. 200 */ 201 [assert_size(4)] 202 enum PP_DecryptedFramePlanes { 203 PP_DECRYPTEDFRAMEPLANES_Y = 0, 204 PP_DECRYPTEDFRAMEPLANES_U = 1, 205 PP_DECRYPTEDFRAMEPLANES_V = 2 206 }; 207 208 /** 209 * <code>PP_DecryptedFrameInfo</code> contains the result of the 210 * decrypt and decode operation on the associated frame, information required 211 * to access the frame data in buffer, and tracking info. 212 */ 213 [assert_size(56)] 214 struct PP_DecryptedFrameInfo { 215 /** 216 * Result of the decrypt and decode operation. 217 */ 218 PP_DecryptResult result; 219 220 /** 221 * Format of the decrypted frame. 222 */ 223 PP_DecryptedFrameFormat format; 224 225 /** 226 * Offsets into the buffer resource for accessing video planes. 227 */ 228 int32_t[3] plane_offsets; 229 230 /** 231 * Stride of each plane. 232 */ 233 int32_t[3] strides; 234 235 /** 236 * Width of the video frame, in pixels. 237 */ 238 int32_t width; 239 240 /** 241 * Height of the video frame, in pixels. 242 */ 243 int32_t height; 244 245 /** 246 * Information needed by the client to track the decrypted frame. 247 */ 248 PP_DecryptTrackingInfo tracking_info; 249 }; 250 251 /** 252 * <code>PP_DecryptedSampleInfo</code> contains the result of the 253 * decrypt and decode operation on the associated samples, information required 254 * to access the sample data in buffer, and tracking info. 255 */ 256 [assert_size(32)] 257 struct PP_DecryptedSampleInfo { 258 /** 259 * Result of the decrypt and decode operation. 260 */ 261 PP_DecryptResult result; 262 263 /** 264 * Format of the decrypted samples. 265 */ 266 PP_DecryptedSampleFormat format; 267 268 /** 269 * Size in bytes of decrypted samples. 270 */ 271 uint32_t data_size; 272 273 /** 274 * 4-byte padding to make the size of <code>PP_DecryptedSampleInfo</code> 275 * a multiple of 8 bytes. The value of this field should not be used. 276 */ 277 uint32_t padding; 278 279 /** 280 * Information needed by the client to track the decrypted samples. 281 */ 282 PP_DecryptTrackingInfo tracking_info; 283 }; 284 285 /** 286 * <code>PP_AudioCodec</code> contains audio codec type constants. 287 */ 288 [assert_size(4)] 289 enum PP_AudioCodec { 290 PP_AUDIOCODEC_UNKNOWN = 0, 291 PP_AUDIOCODEC_VORBIS = 1, 292 PP_AUDIOCODEC_AAC = 2 293 }; 294 295 /** 296 * <code>PP_AudioDecoderConfig</code> contains audio decoder configuration 297 * information required to initialize audio decoders, and a request ID 298 * that allows clients to associate a decoder initialization request with a 299 * status response. Note: When <code>codec</code> requires extra data for 300 * initialization, the data is sent as a <code>PP_Resource</code> carried 301 * alongside <code>PP_AudioDecoderConfig</code>. 302 */ 303 [assert_size(20)] 304 struct PP_AudioDecoderConfig { 305 /** 306 * The audio codec to initialize. 307 */ 308 PP_AudioCodec codec; 309 310 /** 311 * Number of audio channels. 312 */ 313 int32_t channel_count; 314 315 /** 316 * Size of each audio channel. 317 */ 318 int32_t bits_per_channel; 319 320 /** 321 * Audio sampling rate. 322 */ 323 int32_t samples_per_second; 324 325 /** 326 * Client-specified identifier for the associated audio decoder initialization 327 * request. By using this value, the client can associate a decoder 328 * initialization status response with an initialization request. 329 */ 330 uint32_t request_id; 331 }; 332 333 /** 334 * <code>PP_VideoCodec</code> contains video codec type constants. 335 */ 336 [assert_size(4)] 337 enum PP_VideoCodec { 338 PP_VIDEOCODEC_UNKNOWN = 0, 339 PP_VIDEOCODEC_VP8 = 1, 340 PP_VIDEOCODEC_H264 = 2 341 }; 342 343 /** 344 * <code>PP_VideoCodecProfile</code> contains video codec profile type 345 * constants required for video decoder configuration. 346 *. 347 */ 348 [assert_size(4)] 349 enum PP_VideoCodecProfile { 350 PP_VIDEOCODECPROFILE_UNKNOWN = 0, 351 PP_VIDEOCODECPROFILE_VP8_MAIN = 1, 352 PP_VIDEOCODECPROFILE_H264_BASELINE = 2, 353 PP_VIDEOCODECPROFILE_H264_MAIN = 3, 354 PP_VIDEOCODECPROFILE_H264_EXTENDED = 4, 355 PP_VIDEOCODECPROFILE_H264_HIGH = 5, 356 PP_VIDEOCODECPROFILE_H264_HIGH_10 = 6, 357 PP_VIDEOCODECPROFILE_H264_HIGH_422 = 7, 358 PP_VIDEOCODECPROFILE_H264_HIGH_444_PREDICTIVE = 8 359 }; 360 361 /** 362 * <code>PP_VideoDecoderConfig</code> contains video decoder configuration 363 * information required to initialize video decoders, and a request ID 364 * that allows clients to associate a decoder initialization request with a 365 * status response. Note: When <code>codec</code> requires extra data for 366 * initialization, the data is sent as a <code>PP_Resource</code> carried 367 * alongside <code>PP_VideoDecoderConfig</code>. 368 */ 369 [assert_size(24)] 370 struct PP_VideoDecoderConfig { 371 /** 372 * The video codec to initialize. 373 */ 374 PP_VideoCodec codec; 375 376 /** 377 * Profile to use when initializing the video codec. 378 */ 379 PP_VideoCodecProfile profile; 380 381 /** 382 * Output video format. 383 */ 384 PP_DecryptedFrameFormat format; 385 386 /** 387 * Width of decoded video frames, in pixels. 388 */ 389 int32_t width; 390 391 /** 392 * Height of decoded video frames, in pixels. 393 */ 394 int32_t height; 395 396 /** 397 * Client-specified identifier for the associated video decoder initialization 398 * request. By using this value, the client can associate a decoder 399 * initialization status response with an initialization request. 400 */ 401 uint32_t request_id; 402 }; 403 404 /** 405 * <code>PP_DecryptorStreamType</code> contains stream type constants. 406 */ 407 [assert_size(4)] 408 enum PP_DecryptorStreamType { 409 PP_DECRYPTORSTREAMTYPE_AUDIO = 0, 410 PP_DECRYPTORSTREAMTYPE_VIDEO = 1 411 }; 412