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 
26 // Unofficial fairplay system id extracted from
27 // https://forums.developer.apple.com/thread/6185.
28 const uint8_t kFairplaySystemId[] = {0x29, 0x70, 0x1F, 0xE4, 0x3C, 0xC7,
29  0x4A, 0x34, 0x8C, 0x5B, 0xAE, 0x90,
30  0xC7, 0x43, 0x9A, 0x47};
31 
33 class FixedKeySource : public KeySource {
34  public:
35  ~FixedKeySource() override;
36 
39  Status FetchKeys(EmeInitDataType init_data_type,
40  const std::vector<uint8_t>& init_data) override;
41  Status GetKey(const std::string& stream_label, EncryptionKey* key) override;
42  Status GetKey(const std::vector<uint8_t>& key_id,
43  EncryptionKey* key) override;
44  Status GetCryptoPeriodKey(uint32_t crypto_period_index,
45  const std::string& stream_label,
46  EncryptionKey* key) override;
48 
58  static std::unique_ptr<FixedKeySource> Create(
59  const std::vector<uint8_t>& key_id,
60  const std::vector<uint8_t>& key,
61  const std::vector<uint8_t>& pssh_boxes,
62  const std::vector<uint8_t>& iv);
63 
64  protected:
65  // Allow default constructor for mock key sources.
67 
68  private:
69  explicit FixedKeySource(std::unique_ptr<EncryptionKey> key);
70 
71  std::unique_ptr<EncryptionKey> encryption_key_;
72 
73  DISALLOW_COPY_AND_ASSIGN(FixedKeySource);
74 };
75 
76 } // namespace media
77 } // namespace shaka
78 
79 #endif // MEDIA_BASE_FIXED_KEY_SOURCE_H_
Status GetCryptoPeriodKey(uint32_t crypto_period_index, const std::string &stream_label, EncryptionKey *key) override
Status GetKey(const std::string &stream_label, EncryptionKey *key) override
Status FetchKeys(EmeInitDataType init_data_type, const std::vector< uint8_t > &init_data) override
A key source that uses fixed keys for encryption.
KeySource is responsible for encryption key acquisition.
Definition: key_source.h:45
static std::unique_ptr< FixedKeySource > Create(const std::vector< uint8_t > &key_id, const std::vector< uint8_t > &key, const std::vector< uint8_t > &pssh_boxes, const std::vector< uint8_t > &iv)