| 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 MEDIA_BASE_DECRYPT_CONFIG_H_ | 5 #ifndef MEDIA_BASE_DECRYPT_CONFIG_H_ |
| 6 #define MEDIA_BASE_DECRYPT_CONFIG_H_ | 6 #define MEDIA_BASE_DECRYPT_CONFIG_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <iosfwd> | 10 #include <iosfwd> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "media/base/media_export.h" | 15 #include "media/base/media_export.h" |
| 16 #include "media/base/subsample_entry.h" |
| 16 | 17 |
| 17 namespace media { | 18 namespace media { |
| 18 | 19 |
| 19 // The Common Encryption spec provides for subsample encryption, where portions | |
| 20 // of a sample are set in cleartext. A SubsampleEntry specifies the number of | |
| 21 // clear and encrypted bytes in each subsample. For decryption, all of the | |
| 22 // encrypted bytes in a sample should be considered a single logical stream, | |
| 23 // regardless of how they are divided into subsamples, and the clear bytes | |
| 24 // should not be considered as part of decryption. This is logically equivalent | |
| 25 // to concatenating all 'cypher_bytes' portions of subsamples, decrypting that | |
| 26 // result, and then copying each byte from the decrypted block over the | |
| 27 // position of the corresponding encrypted byte. | |
| 28 struct SubsampleEntry { | |
| 29 SubsampleEntry() : clear_bytes(0), cypher_bytes(0) {} | |
| 30 SubsampleEntry(uint32_t clear_bytes, uint32_t cypher_bytes) | |
| 31 : clear_bytes(clear_bytes), cypher_bytes(cypher_bytes) {} | |
| 32 uint32_t clear_bytes; | |
| 33 uint32_t cypher_bytes; | |
| 34 }; | |
| 35 | |
| 36 // Contains all information that a decryptor needs to decrypt a media sample. | 20 // Contains all information that a decryptor needs to decrypt a media sample. |
| 37 class MEDIA_EXPORT DecryptConfig { | 21 class MEDIA_EXPORT DecryptConfig { |
| 38 public: | 22 public: |
| 39 // Keys are always 128 bits. | 23 // Keys are always 128 bits. |
| 40 static const int kDecryptionKeySize = 16; | 24 static const int kDecryptionKeySize = 16; |
| 41 | 25 |
| 42 // |key_id| is the ID that references the decryption key for this sample. | 26 // |key_id| is the ID that references the decryption key for this sample. |
| 43 // |iv| is the initialization vector defined by the encrypted format. | 27 // |iv| is the initialization vector defined by the encrypted format. |
| 44 // Currently |iv| must be 16 bytes as defined by WebM and ISO. Or must be | 28 // Currently |iv| must be 16 bytes as defined by WebM and ISO. Or must be |
| 45 // empty which signals an unencrypted frame. | 29 // empty which signals an unencrypted frame. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 }; | 63 }; |
| 80 | 64 |
| 81 } // namespace media | 65 } // namespace media |
| 82 | 66 |
| 83 inline std::ostream& operator<<(std::ostream& os, | 67 inline std::ostream& operator<<(std::ostream& os, |
| 84 const media::DecryptConfig& obj) { | 68 const media::DecryptConfig& obj) { |
| 85 return obj.Print(os); | 69 return obj.Print(os); |
| 86 } | 70 } |
| 87 | 71 |
| 88 #endif // MEDIA_BASE_DECRYPT_CONFIG_H_ | 72 #endif // MEDIA_BASE_DECRYPT_CONFIG_H_ |
| OLD | NEW |