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.
5 #ifndef MEDIA_BASE_DECRYPT_CONFIG_H_
6 #define MEDIA_BASE_DECRYPT_CONFIG_H_
11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "media/base/media_export.h"
17 // The Common Encryption spec provides for subsample encryption, where portions
18 // of a sample are set in cleartext. A SubsampleEntry specifies the number of
19 // clear and encrypted bytes in each subsample. For decryption, all of the
20 // encrypted bytes in a sample should be considered a single logical stream,
21 // regardless of how they are divided into subsamples, and the clear bytes
22 // should not be considered as part of decryption. This is logically equivalent
23 // to concatenating all 'cypher_bytes' portions of subsamples, decrypting that
24 // result, and then copying each byte from the decrypted block over the
25 // position of the corresponding encrypted byte.
26 struct SubsampleEntry
{
31 // Contains all information that a decryptor needs to decrypt a media sample.
32 class MEDIA_EXPORT DecryptConfig
{
34 // Keys are always 128 bits.
35 static const int kDecryptionKeySize
= 16;
37 // |key_id| is the ID that references the decryption key for this sample.
38 // |iv| is the initialization vector defined by the encrypted format.
39 // Currently |iv| must be 16 bytes as defined by WebM and ISO. Or must be
40 // empty which signals an unencrypted frame.
41 // |subsamples| defines the clear and encrypted portions of the sample as
42 // described above. A decrypted buffer will be equal in size to the sum
43 // of the subsample sizes.
44 DecryptConfig(const std::string
& key_id
,
45 const std::string
& iv
,
46 const std::vector
<SubsampleEntry
>& subsamples
);
49 const std::string
& key_id() const { return key_id_
; }
50 const std::string
& iv() const { return iv_
; }
51 const std::vector
<SubsampleEntry
>& subsamples() const { return subsamples_
; }
54 const std::string key_id_
;
56 // Initialization vector.
57 const std::string iv_
;
59 // Subsample information. May be empty for some formats, meaning entire frame
60 // (less data ignored by data_offset_) is encrypted.
61 const std::vector
<SubsampleEntry
> subsamples_
;
63 DISALLOW_COPY_AND_ASSIGN(DecryptConfig
);
68 #endif // MEDIA_BASE_DECRYPT_CONFIG_H_