Chromium Code Reviews| Index: webkit/media/crypto/content_decryption_module.h |
| diff --git a/webkit/media/crypto/content_decryption_module.h b/webkit/media/crypto/content_decryption_module.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..84ffd10dc1cc6c2b244e670806b1a2a624443314 |
| --- /dev/null |
| +++ b/webkit/media/crypto/content_decryption_module.h |
| @@ -0,0 +1,89 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef WEBKIT_MEDIA_CRYPTO_CONTENT_DECRYPTION_MODULE_H_ |
| +#define WEBKIT_MEDIA_CRYPTO_CONTENT_DECRYPTION_MODULE_H_ |
| + |
| +#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
|
| + |
| +class ContentDecryptionModule; |
| + |
| +extern ContentDecryptionModule* CdmCreateInstance(const void* config_data, |
| + uint32_t config_data_size); |
| +extern const char* CdmGetVersion(); |
| + |
| +enum CdmStatus { |
| + 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
|
| + kCdmStatusErrorUnknown = 1, |
| + kCdmStatusErrorClient = 2, |
| + kCdmStatusErrorService = 3, |
| + kCdmStatusErrorOutput = 4, |
| + kCdmStatusErrorHardwareChange = 5, |
| + kCdmStatusErrorDomain = 6 |
| +}; |
| + |
| +// 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
|
| +// of a sample are set in cleartext. A SubsampleEntry specifies the number of |
| +// clear and encrypted bytes in each subsample. For decryption, all of the |
| +// encrypted bytes in a sample should be considered a single logical stream, |
| +// regardless of how they are divided into subsamples, and the clear bytes |
| +// should not be considered as part of decryption. This is logically equivalent |
| +// to concatenating all 'cypher_bytes' portions of subsamples, decrypting that |
| +// result, and then copying each byte from the decrypted block over the |
| +// position of the corresponding encrypted byte. |
| +struct SubsampleEntry { |
| + uint32_t clear_bytes; |
| + uint32_t cypher_bytes; |
| +}; |
| + |
| +struct InputBuffer { |
| + uint8_t* data; // Pointer to the beginning of the input data. |
| + uint32_t data_size; // Size (in bytes) of |data|. |
| + uint32_t data_offset; // Number of bytes to be discarded before decryption. |
| + uint8_t* key_id; // Key ID to identify the decryption key. |
| + uint32_t key_id_size; // Size (in bytes) of |key_id|. |
| + uint8_t* iv; // Initialization vector. |
| + uint32_t iv_len; // Size (in bytes) of |iv|. |
| + uint8_t* checksum; // Pointer to the beginning of the checksum. |
| + uint32_t checksum_size; // Size (in bytes) of the |checksum|. |
| + // 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.
|
| + struct SubsampleEntry* subsamples; |
| + uint32_t num_subsamples; // Number of subsamples in |subsamples|. |
| + 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
|
| + int64_t duration; // Duration in milliseconds. |
| +}; |
| + |
| +struct OutputBuffer { |
| + 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.
|
| + uint32_t data_size; // Size (in bytes) of |data|. |
| + int64_t timestamp; // Presentation timestamp in milliseconds. |
| + int64_t duration; // Duration in milliseconds. |
| +}; |
| + |
| +class ContentDecryptionModule { |
| + public: |
| + virtual CdmStatus GenerateKeyRequest(const uint8_t* init_data, |
| + uint32_t init_data_size, |
| + char** session_id, |
| + uint32_t* session_id_size, |
| + uint8_t** key_request, |
| + uint32_t* key_request_size) = 0; |
| + |
| + virtual CdmStatus AddKey(const char* session_id, |
| + uint32_t session_id_size, |
| + 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.
|
| + uint32_t init_data_size) = 0; |
| + |
| + virtual CdmStatus CancelKeyRequest(const char* session_id, |
| + uint32_t session_id_size) = 0; |
| + |
| + virtual CdmStatus Decrypt(const char* session_id, |
| + uint32_t session_id_size, |
| + const InputBuffer &encrypted_buffer, |
| + OutputBuffer* decrypted_buffer) = 0; |
|
ddorwin
2012/08/13 23:28:20
space after &
|
| + |
| + virtual ~ContentDecryptionModule() {}; |
| +}; |
| + |
| +#endif // WEBKIT_MEDIA_CRYPTO_CONTENT_DECRYPTION_MODULE_H_ |