| 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 and |
| 37 // update checks to include <0. |
| 36 struct KeyMessage { | 38 struct KeyMessage { |
| 39 KeyMessage() |
| 40 : session_id(NULL), |
| 41 session_id_size(0), |
| 42 message(NULL), |
| 43 message_size(0), |
| 44 default_url(NULL), |
| 45 default_url_size(0) {} |
| 46 |
| 37 char* session_id; | 47 char* session_id; |
| 38 uint32_t session_id_size; | 48 uint32_t session_id_size; |
| 39 uint8_t* message; | 49 uint8_t* message; |
| 40 uint32_t message_size; | 50 uint32_t message_size; |
| 41 char* default_url; | 51 char* default_url; |
| 42 uint32_t default_url_size; | 52 uint32_t default_url_size; |
| 43 }; | 53 }; |
| 44 | 54 |
| 45 // An input buffer can be split into several continuous subsamples. | 55 // An input buffer can be split into several continuous subsamples. |
| 46 // A SubsampleEntry specifies the number of clear and cipher bytes in each | 56 // A SubsampleEntry specifies the number of clear and cipher bytes in each |
| (...skipping 11 matching lines...) Expand all Loading... |
| 58 // | 68 // |
| 59 // After decryption, the decrypted bytes should be copied over the position | 69 // 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 | 70 // of the corresponding cipher bytes in the original buffer to form the output |
| 61 // buffer. Following the above example, the decrypted buffer should be: | 71 // buffer. Following the above example, the decrypted buffer should be: |
| 62 // | 72 // |
| 63 // |<----- subsample1 ----->|<----- subsample2 ----->|<----- subsample3 ----->| | 73 // |<----- subsample1 ----->|<----- subsample2 ----->|<----- subsample3 ----->| |
| 64 // | clear1 | decrypted1| clear2 | decrypted2 | clear3 | decrypted3 | | 74 // | clear1 | decrypted1| clear2 | decrypted2 | clear3 | decrypted3 | |
| 65 // | 75 // |
| 66 // TODO(xhwang): Add checks to make sure these structs have fixed layout. | 76 // TODO(xhwang): Add checks to make sure these structs have fixed layout. |
| 67 struct SubsampleEntry { | 77 struct SubsampleEntry { |
| 78 SubsampleEntry(uint32_t clear_bytes, uint32_t cipher_bytes) |
| 79 : clear_bytes(clear_bytes), cipher_bytes(cipher_bytes) {} |
| 80 |
| 68 uint32_t clear_bytes; | 81 uint32_t clear_bytes; |
| 69 uint32_t cipher_bytes; | 82 uint32_t cipher_bytes; |
| 70 }; | 83 }; |
| 71 | 84 |
| 72 struct InputBuffer { | 85 struct InputBuffer { |
| 73 uint8_t* data; // Pointer to the beginning of the input data. | 86 InputBuffer() |
| 87 : data(NULL), |
| 88 data_size(0), |
| 89 data_offset(0), |
| 90 key_id(NULL), |
| 91 key_id_size(0), |
| 92 iv(NULL), |
| 93 iv_size(0), |
| 94 checksum(NULL), |
| 95 checksum_size(0), |
| 96 subsamples(NULL), |
| 97 num_subsamples(0), |
| 98 timestamp(0) {} |
| 99 |
| 100 const uint8_t* data; // Pointer to the beginning of the input data. |
| 74 uint32_t data_size; // Size (in bytes) of |data|. | 101 uint32_t data_size; // Size (in bytes) of |data|. |
| 75 | 102 |
| 76 uint32_t data_offset; // Number of bytes to be discarded before decryption. | 103 uint32_t data_offset; // Number of bytes to be discarded before decryption. |
| 77 | 104 |
| 78 uint8_t* key_id; // Key ID to identify the decryption key. | 105 const uint8_t* key_id; // Key ID to identify the decryption key. |
| 79 uint32_t key_id_size; // Size (in bytes) of |key_id|. | 106 uint32_t key_id_size; // Size (in bytes) of |key_id|. |
| 80 | 107 |
| 81 uint8_t* iv; // Initialization vector. | 108 const uint8_t* iv; // Initialization vector. |
| 82 uint32_t iv_size; // Size (in bytes) of |iv|. | 109 uint32_t iv_size; // Size (in bytes) of |iv|. |
| 83 | 110 |
| 84 uint8_t* checksum; | 111 const uint8_t* checksum; |
| 85 uint32_t checksum_size; // Size (in bytes) of the |checksum|. | 112 uint32_t checksum_size; // Size (in bytes) of the |checksum|. |
| 86 | 113 |
| 87 struct SubsampleEntry* subsamples; | 114 const struct SubsampleEntry* subsamples; |
| 88 uint32_t num_subsamples; // Number of subsamples in |subsamples|. | 115 uint32_t num_subsamples; // Number of subsamples in |subsamples|. |
| 89 | 116 |
| 90 int64_t timestamp; // Presentation timestamp in microseconds. | 117 int64_t timestamp; // Presentation timestamp in microseconds. |
| 91 }; | 118 }; |
| 92 | 119 |
| 93 struct OutputBuffer { | 120 struct OutputBuffer { |
| 94 uint8_t* data; // Pointer to the beginning of the output data. | 121 OutputBuffer() |
| 122 : data(NULL), |
| 123 data_size(0), |
| 124 timestamp(0) {} |
| 125 |
| 126 const uint8_t* data; // Pointer to the beginning of the output data. |
| 95 uint32_t data_size; // Size (in bytes) of |data|. | 127 uint32_t data_size; // Size (in bytes) of |data|. |
| 96 | 128 |
| 97 int64_t timestamp; // Presentation timestamp in microseconds. | 129 int64_t timestamp; // Presentation timestamp in microseconds. |
| 98 }; | 130 }; |
| 99 | 131 |
| 100 class ContentDecryptionModule { | 132 class ContentDecryptionModule { |
| 101 public: | 133 public: |
| 102 // Generates a |key_request| given the |init_data|. | 134 // Generates a |key_request| given the |init_data|. |
| 103 // Returns kSuccess if the key request was successfully generated, | 135 // Returns kSuccess if the key request was successfully generated, |
| 104 // in which case the callee should have allocated memory for the output | 136 // 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. | 177 // and sample CDM are landed. |
| 146 virtual Status Decrypt(const InputBuffer& encrypted_buffer, | 178 virtual Status Decrypt(const InputBuffer& encrypted_buffer, |
| 147 OutputBuffer* decrypted_buffer) = 0; | 179 OutputBuffer* decrypted_buffer) = 0; |
| 148 | 180 |
| 149 virtual ~ContentDecryptionModule() {} | 181 virtual ~ContentDecryptionModule() {} |
| 150 }; | 182 }; |
| 151 | 183 |
| 152 } // namespace cdm | 184 } // namespace cdm |
| 153 | 185 |
| 154 #endif // WEBKIT_MEDIA_CRYPTO_PPAPI_CONTENT_DECRYPTION_MODULE_H_ | 186 #endif // WEBKIT_MEDIA_CRYPTO_PPAPI_CONTENT_DECRYPTION_MODULE_H_ |
| OLD | NEW |