Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 #ifndef WEBKIT_MEDIA_CRYPTO_CONTENT_DECRYPTION_MODULE_H_ | |
| 6 #define WEBKIT_MEDIA_CRYPTO_CONTENT_DECRYPTION_MODULE_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
|
ddorwin
2012/08/13 23:28:20
This may fail MSVC 2008. See https://groups.google
xhwang
2012/08/14 16:26:07
Summary of the discussion:
- stdint types are avai
| |
| 9 | |
| 10 class ContentDecryptionModule; | |
| 11 | |
| 12 extern ContentDecryptionModule* CdmCreateInstance(const void* config_data, | |
| 13 uint32_t config_data_size); | |
| 14 extern const char* CdmGetVersion(); | |
| 15 | |
| 16 enum CdmStatus { | |
| 17 kCdmStatusSuccess = 0, | |
|
ddorwin
2012/08/13 23:28:20
"Though the Google C++ Style Guide says to use kCo
xhwang
2012/08/14 16:26:07
We are already using kConstantNaming at least in m
| |
| 18 kCdmStatusErrorUnknown = 1, | |
| 19 kCdmStatusErrorClient = 2, | |
| 20 kCdmStatusErrorService = 3, | |
| 21 kCdmStatusErrorOutput = 4, | |
| 22 kCdmStatusErrorHardwareChange = 5, | |
| 23 kCdmStatusErrorDomain = 6 | |
| 24 }; | |
| 25 | |
| 26 // The Common Encryption spec supports subsample encryption, where portions | |
|
ddorwin
2012/08/13 23:28:20
The ISO...
But, I think we should just define thi
xhwang
2012/08/14 16:26:07
Updated comment with examples and w/o mentioning I
| |
| 27 // of a sample are set in cleartext. A SubsampleEntry specifies the number of | |
| 28 // clear and encrypted bytes in each subsample. For decryption, all of the | |
| 29 // encrypted bytes in a sample should be considered a single logical stream, | |
| 30 // regardless of how they are divided into subsamples, and the clear bytes | |
| 31 // should not be considered as part of decryption. This is logically equivalent | |
| 32 // to concatenating all 'cypher_bytes' portions of subsamples, decrypting that | |
| 33 // result, and then copying each byte from the decrypted block over the | |
| 34 // position of the corresponding encrypted byte. | |
| 35 struct SubsampleEntry { | |
| 36 uint32_t clear_bytes; | |
| 37 uint32_t cypher_bytes; | |
| 38 }; | |
| 39 | |
| 40 struct InputBuffer { | |
| 41 uint8_t* data; // Pointer to the beginning of the input data. | |
| 42 uint32_t data_size; // Size (in bytes) of |data|. | |
| 43 uint32_t data_offset; // Number of bytes to be discarded before decryption. | |
| 44 uint8_t* key_id; // Key ID to identify the decryption key. | |
| 45 uint32_t key_id_size; // Size (in bytes) of |key_id|. | |
| 46 uint8_t* iv; // Initialization vector. | |
| 47 uint32_t iv_len; // Size (in bytes) of |iv|. | |
| 48 uint8_t* checksum; // Pointer to the beginning of the checksum. | |
| 49 uint32_t checksum_size; // Size (in bytes) of the |checksum|. | |
| 50 // Subsamples as specified in ISO common encryption. | |
|
ddorwin
2012/08/13 23:28:20
Same. No need for a comment really since it's alre
xhwang
2012/08/14 16:26:07
Done.
| |
| 51 struct SubsampleEntry* subsamples; | |
| 52 uint32_t num_subsamples; // Number of subsamples in |subsamples|. | |
| 53 int64_t timestamp; // Presentation timestamp in milliseconds. | |
|
ddorwin
2012/08/13 23:28:20
Any idea what the CDM does with this value and the
xhwang
2012/08/14 16:26:07
We need timestamp to track buffers since buffer ca
| |
| 54 int64_t duration; // Duration in milliseconds. | |
| 55 }; | |
| 56 | |
| 57 struct OutputBuffer { | |
| 58 uint8_t* data; // Pointer to the beginning of the output data. | |
|
ddorwin
2012/08/13 23:28:20
This assumes the caller is allocating the output b
xhwang
2012/08/14 16:26:07
In Decrypt(), the OutputBuffer is passed in as "Ou
ddorwin
2012/08/14 22:52:11
Probably worth commenting this somewhere. Decrypt(
xhwang
2012/08/15 01:18:26
Done.
| |
| 59 uint32_t data_size; // Size (in bytes) of |data|. | |
| 60 int64_t timestamp; // Presentation timestamp in milliseconds. | |
| 61 int64_t duration; // Duration in milliseconds. | |
| 62 }; | |
| 63 | |
| 64 class ContentDecryptionModule { | |
| 65 public: | |
| 66 virtual CdmStatus GenerateKeyRequest(const uint8_t* init_data, | |
| 67 uint32_t init_data_size, | |
| 68 char** session_id, | |
| 69 uint32_t* session_id_size, | |
| 70 uint8_t** key_request, | |
| 71 uint32_t* key_request_size) = 0; | |
| 72 | |
| 73 virtual CdmStatus AddKey(const char* session_id, | |
| 74 uint32_t session_id_size, | |
| 75 const uint8_t* init_data, | |
|
ddorwin
2012/08/13 23:28:20
key, not init_data.
EME supports init_data today,
xhwang
2012/08/14 16:26:07
Done.
| |
| 76 uint32_t init_data_size) = 0; | |
| 77 | |
| 78 virtual CdmStatus CancelKeyRequest(const char* session_id, | |
| 79 uint32_t session_id_size) = 0; | |
| 80 | |
| 81 virtual CdmStatus Decrypt(const char* session_id, | |
| 82 uint32_t session_id_size, | |
| 83 const InputBuffer &encrypted_buffer, | |
| 84 OutputBuffer* decrypted_buffer) = 0; | |
|
ddorwin
2012/08/13 23:28:20
space after &
| |
| 85 | |
| 86 virtual ~ContentDecryptionModule() {}; | |
| 87 }; | |
| 88 | |
| 89 #endif // WEBKIT_MEDIA_CRYPTO_CONTENT_DECRYPTION_MODULE_H_ | |
| OLD | NEW |