Web Speech API: cancel outstanding infobar requests when aborting.
[chromium-blink-merge.git] / media / base / decrypt_config.h
blobbe0bb4d61b1e51e6e22b8d399247a53eb7d50fb7
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_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "media/base/media_export.h"
15 namespace media {
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 {
27 uint32 clear_bytes;
28 uint32 cypher_bytes;
31 // Contains all information that a decryptor needs to decrypt a media sample.
32 class MEDIA_EXPORT DecryptConfig {
33 public:
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 // |data_offset| is the amount of data that should be discarded from the
42 // head of the sample buffer before applying subsample information. A
43 // decrypted buffer will be shorter than an encrypted buffer by this amount.
44 // |subsamples| defines the clear and encrypted portions of the sample as
45 // described above. A decrypted buffer will be equal in size to the sum
46 // of the subsample sizes.
48 // |data_offset| is applied before |subsamples|.
49 DecryptConfig(const std::string& key_id,
50 const std::string& iv,
51 const int data_offset,
52 const std::vector<SubsampleEntry>& subsamples);
53 ~DecryptConfig();
55 const std::string& key_id() const { return key_id_; }
56 const std::string& iv() const { return iv_; }
57 int data_offset() const { return data_offset_; }
58 const std::vector<SubsampleEntry>& subsamples() const { return subsamples_; }
60 private:
61 const std::string key_id_;
63 // Initialization vector.
64 const std::string iv_;
66 // TODO(fgalligan): Remove |data_offset_| if there is no plan to use it in
67 // the future.
68 // Amount of data to be discarded before applying subsample information.
69 const int data_offset_;
71 // Subsample information. May be empty for some formats, meaning entire frame
72 // (less data ignored by data_offset_) is encrypted.
73 const std::vector<SubsampleEntry> subsamples_;
75 DISALLOW_COPY_AND_ASSIGN(DecryptConfig);
78 } // namespace media
80 #endif // MEDIA_BASE_DECRYPT_CONFIG_H_