DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
fixed_key_source.h
1 // Copyright 2016 Google Inc. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file or at
5 // https://developers.google.com/open-source/licenses/bsd
6 
7 #ifndef MEDIA_BASE_FIXED_KEY_SOURCE_H_
8 #define MEDIA_BASE_FIXED_KEY_SOURCE_H_
9 
10 #include <memory>
11 #include <string>
12 #include <vector>
13 
14 #include "packager/media/base/key_source.h"
15 
16 namespace shaka {
17 namespace media {
18 
19 // Common SystemID defined by EME, which requires Key System implementations
20 // supporting ISO Common Encryption to support this SystemID and format.
21 // https://goo.gl/kUv2Xd
22 const uint8_t kCommonSystemId[] = {0x10, 0x77, 0xef, 0xec, 0xc0, 0xb2,
23  0x4d, 0x02, 0xac, 0xe3, 0x3c, 0x1e,
24  0x52, 0xe2, 0xfb, 0x4b};
25 
27 class FixedKeySource : public KeySource {
28  public:
29  ~FixedKeySource() override;
30 
33  Status FetchKeys(EmeInitDataType init_data_type,
34  const std::vector<uint8_t>& init_data) override;
35  Status GetKey(TrackType track_type, EncryptionKey* key) override;
36  Status GetKey(const std::vector<uint8_t>& key_id,
37  EncryptionKey* key) override;
38  Status GetCryptoPeriodKey(uint32_t crypto_period_index,
39  TrackType track_type,
40  EncryptionKey* key) override;
42 
52  static std::unique_ptr<FixedKeySource> CreateFromHexStrings(
53  const std::string& key_id_hex,
54  const std::string& key_hex,
55  const std::string& pssh_boxes_hex,
56  const std::string& iv_hex);
57 
58  protected:
59  // Allow default constructor for mock key sources.
61 
62  private:
63  explicit FixedKeySource(std::unique_ptr<EncryptionKey> key);
64 
65  std::unique_ptr<EncryptionKey> encryption_key_;
66 
67  DISALLOW_COPY_AND_ASSIGN(FixedKeySource);
68 };
69 
70 } // namespace media
71 } // namespace shaka
72 
73 #endif // MEDIA_BASE_FIXED_KEY_SOURCE_H_
static std::unique_ptr< FixedKeySource > CreateFromHexStrings(const std::string &key_id_hex, const std::string &key_hex, const std::string &pssh_boxes_hex, const std::string &iv_hex)
Status FetchKeys(EmeInitDataType init_data_type, const std::vector< uint8_t > &init_data) override
A key source that uses fixed keys for encryption.
Status GetKey(TrackType track_type, EncryptionKey *key) override
KeySource is responsible for encryption key acquisition.
Definition: key_source.h:45
Status GetCryptoPeriodKey(uint32_t crypto_period_index, TrackType track_type, EncryptionKey *key) override