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(const std::vector<uint8_t>& pssh_box) override;
34  Status FetchKeys(const std::vector<std::vector<uint8_t>>& key_ids) override;
35  Status FetchKeys(uint32_t asset_id) override;
36 
37  Status GetKey(TrackType track_type, EncryptionKey* key) override;
38  Status GetKey(const std::vector<uint8_t>& key_id,
39  EncryptionKey* key) override;
40  Status GetCryptoPeriodKey(uint32_t crypto_period_index,
41  TrackType track_type,
42  EncryptionKey* key) override;
44 
54  static std::unique_ptr<FixedKeySource> CreateFromHexStrings(
55  const std::string& key_id_hex,
56  const std::string& key_hex,
57  const std::string& pssh_boxes_hex,
58  const std::string& iv_hex);
59 
60  protected:
61  // Allow default constructor for mock key sources.
63 
64  private:
65  explicit FixedKeySource(std::unique_ptr<EncryptionKey> key);
66 
67  std::unique_ptr<EncryptionKey> encryption_key_;
68 
69  DISALLOW_COPY_AND_ASSIGN(FixedKeySource);
70 };
71 
72 } // namespace media
73 } // namespace shaka
74 
75 #endif // MEDIA_BASE_FIXED_KEY_SOURCE_H_
Status FetchKeys(const std::vector< uint8_t > &pssh_box) override
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)
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:30
Status GetCryptoPeriodKey(uint32_t crypto_period_index, TrackType track_type, EncryptionKey *key) override