Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef WEBKIT_MEDIA_CRYPTO_PPAPI_CONTENT_DECRYPTION_MODULE_H_ | 5 #ifndef WEBKIT_MEDIA_CRYPTO_PPAPI_CONTENT_DECRYPTION_MODULE_H_ |
| 6 #define WEBKIT_MEDIA_CRYPTO_PPAPI_CONTENT_DECRYPTION_MODULE_H_ | 6 #define WEBKIT_MEDIA_CRYPTO_PPAPI_CONTENT_DECRYPTION_MODULE_H_ |
| 7 | 7 |
| 8 #if defined(_MSC_VER) | 8 #if defined(_MSC_VER) |
| 9 typedef unsigned char uint8_t; | 9 typedef unsigned char uint8_t; |
| 10 typedef unsigned int uint32_t; | 10 typedef unsigned int uint32_t; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 } | 26 } |
| 27 | 27 |
| 28 namespace cdm { | 28 namespace cdm { |
| 29 | 29 |
| 30 enum Status { | 30 enum Status { |
| 31 kSuccess = 0, | 31 kSuccess = 0, |
| 32 kErrorUnknown, | 32 kErrorUnknown, |
| 33 kErrorNoKey | 33 kErrorNoKey |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 // TODO(xhwang): Use int32_t instead of uint32_t for sizes here and below. | |
|
ddorwin
2012/08/27 17:33:54
and update checks to include <0.
xhwang
2012/08/27 18:07:26
Done.
| |
| 36 struct KeyMessage { | 37 struct KeyMessage { |
| 38 KeyMessage() | |
| 39 : session_id(NULL), | |
| 40 session_id_size(0), | |
| 41 message(NULL), | |
| 42 message_size(0), | |
| 43 default_url(NULL), | |
| 44 default_url_size(0) {} | |
| 45 | |
| 37 char* session_id; | 46 char* session_id; |
| 38 uint32_t session_id_size; | 47 uint32_t session_id_size; |
| 39 uint8_t* message; | 48 uint8_t* message; |
| 40 uint32_t message_size; | 49 uint32_t message_size; |
| 41 char* default_url; | 50 char* default_url; |
| 42 uint32_t default_url_size; | 51 uint32_t default_url_size; |
| 43 }; | 52 }; |
| 44 | 53 |
| 45 // An input buffer can be split into several continuous subsamples. | 54 // An input buffer can be split into several continuous subsamples. |
| 46 // A SubsampleEntry specifies the number of clear and cipher bytes in each | 55 // A SubsampleEntry specifies the number of clear and cipher bytes in each |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 58 // | 67 // |
| 59 // After decryption, the decrypted bytes should be copied over the position | 68 // After decryption, the decrypted bytes should be copied over the position |
| 60 // of the corresponding cipher bytes in the original buffer to form the output | 69 // of the corresponding cipher bytes in the original buffer to form the output |
| 61 // buffer. Following the above example, the decrypted buffer should be: | 70 // buffer. Following the above example, the decrypted buffer should be: |
| 62 // | 71 // |
| 63 // |<----- subsample1 ----->|<----- subsample2 ----->|<----- subsample3 ----->| | 72 // |<----- subsample1 ----->|<----- subsample2 ----->|<----- subsample3 ----->| |
| 64 // | clear1 | decrypted1| clear2 | decrypted2 | clear3 | decrypted3 | | 73 // | clear1 | decrypted1| clear2 | decrypted2 | clear3 | decrypted3 | |
| 65 // | 74 // |
| 66 // TODO(xhwang): Add checks to make sure these structs have fixed layout. | 75 // TODO(xhwang): Add checks to make sure these structs have fixed layout. |
| 67 struct SubsampleEntry { | 76 struct SubsampleEntry { |
| 77 SubsampleEntry(uint32_t clear_bytes, uint32_t cipher_bytes) | |
| 78 : clear_bytes(clear_bytes), cipher_bytes(cipher_bytes) {} | |
| 79 | |
| 68 uint32_t clear_bytes; | 80 uint32_t clear_bytes; |
| 69 uint32_t cipher_bytes; | 81 uint32_t cipher_bytes; |
| 70 }; | 82 }; |
| 71 | 83 |
| 72 struct InputBuffer { | 84 struct InputBuffer { |
| 73 uint8_t* data; // Pointer to the beginning of the input data. | 85 InputBuffer() |
| 86 : data(NULL), | |
| 87 data_size(0), | |
| 88 data_offset(0), | |
| 89 key_id(NULL), | |
| 90 key_id_size(0), | |
| 91 iv(NULL), | |
| 92 iv_size(0), | |
| 93 checksum(NULL), | |
| 94 checksum_size(0), | |
| 95 subsamples(NULL), | |
| 96 num_subsamples(0), | |
| 97 timestamp(0) {} | |
| 98 | |
| 99 const uint8_t* data; // Pointer to the beginning of the input data. | |
| 74 uint32_t data_size; // Size (in bytes) of |data|. | 100 uint32_t data_size; // Size (in bytes) of |data|. |
| 75 | 101 |
| 76 uint32_t data_offset; // Number of bytes to be discarded before decryption. | 102 uint32_t data_offset; // Number of bytes to be discarded before decryption. |
| 77 | 103 |
| 78 uint8_t* key_id; // Key ID to identify the decryption key. | 104 const uint8_t* key_id; // Key ID to identify the decryption key. |
| 79 uint32_t key_id_size; // Size (in bytes) of |key_id|. | 105 uint32_t key_id_size; // Size (in bytes) of |key_id|. |
| 80 | 106 |
| 81 uint8_t* iv; // Initialization vector. | 107 const uint8_t* iv; // Initialization vector. |
| 82 uint32_t iv_size; // Size (in bytes) of |iv|. | 108 uint32_t iv_size; // Size (in bytes) of |iv|. |
| 83 | 109 |
| 84 uint8_t* checksum; | 110 const uint8_t* checksum; |
| 85 uint32_t checksum_size; // Size (in bytes) of the |checksum|. | 111 uint32_t checksum_size; // Size (in bytes) of the |checksum|. |
| 86 | 112 |
| 87 struct SubsampleEntry* subsamples; | 113 const struct SubsampleEntry* subsamples; |
| 88 uint32_t num_subsamples; // Number of subsamples in |subsamples|. | 114 uint32_t num_subsamples; // Number of subsamples in |subsamples|. |
| 89 | 115 |
| 90 int64_t timestamp; // Presentation timestamp in microseconds. | 116 int64_t timestamp; // Presentation timestamp in microseconds. |
| 91 }; | 117 }; |
| 92 | 118 |
| 93 struct OutputBuffer { | 119 struct OutputBuffer { |
| 94 uint8_t* data; // Pointer to the beginning of the output data. | 120 OutputBuffer() |
| 121 : data(NULL), | |
| 122 data_size(0), | |
| 123 timestamp(0) {} | |
| 124 | |
| 125 const uint8_t* data; // Pointer to the beginning of the output data. | |
| 95 uint32_t data_size; // Size (in bytes) of |data|. | 126 uint32_t data_size; // Size (in bytes) of |data|. |
| 96 | 127 |
| 97 int64_t timestamp; // Presentation timestamp in microseconds. | 128 int64_t timestamp; // Presentation timestamp in microseconds. |
| 98 }; | 129 }; |
| 99 | 130 |
| 100 class ContentDecryptionModule { | 131 class ContentDecryptionModule { |
| 101 public: | 132 public: |
| 102 // Generates a |key_request| given the |init_data|. | 133 // Generates a |key_request| given the |init_data|. |
| 103 // Returns kSuccess if the key request was successfully generated, | 134 // Returns kSuccess if the key request was successfully generated, |
| 104 // in which case the callee should have allocated memory for the output | 135 // in which case the callee should have allocated memory for the output |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 // and sample CDM are landed. | 176 // and sample CDM are landed. |
| 146 virtual Status Decrypt(const InputBuffer& encrypted_buffer, | 177 virtual Status Decrypt(const InputBuffer& encrypted_buffer, |
| 147 OutputBuffer* decrypted_buffer) = 0; | 178 OutputBuffer* decrypted_buffer) = 0; |
| 148 | 179 |
| 149 virtual ~ContentDecryptionModule() {} | 180 virtual ~ContentDecryptionModule() {} |
| 150 }; | 181 }; |
| 151 | 182 |
| 152 } // namespace cdm | 183 } // namespace cdm |
| 153 | 184 |
| 154 #endif // WEBKIT_MEDIA_CRYPTO_PPAPI_CONTENT_DECRYPTION_MODULE_H_ | 185 #endif // WEBKIT_MEDIA_CRYPTO_PPAPI_CONTENT_DECRYPTION_MODULE_H_ |
| OLD | NEW |