Shaka Packager SDK
raw_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 PACKAGER_MEDIA_BASE_RAW_KEY_SOURCE_H_
8 #define PACKAGER_MEDIA_BASE_RAW_KEY_SOURCE_H_
9 
10 #include <memory>
11 #include <string>
12 #include <vector>
13 
14 #include "packager/media/base/key_source.h"
15 #include "packager/media/public/crypto_params.h"
16 
17 namespace shaka {
18 namespace media {
19 
20 // Unofficial fairplay system id extracted from
21 // https://forums.developer.apple.com/thread/6185.
22 const uint8_t kFairplaySystemId[] = {0x29, 0x70, 0x1F, 0xE4, 0x3C, 0xC7,
23  0x4A, 0x34, 0x8C, 0x5B, 0xAE, 0x90,
24  0xC7, 0x43, 0x9A, 0x47};
25 
27 class RawKeySource : public KeySource {
28  public:
29  ~RawKeySource() override;
30 
33  Status FetchKeys(EmeInitDataType init_data_type,
34  const std::vector<uint8_t>& init_data) override;
35  Status GetKey(const std::string& stream_label, 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  const std::string& stream_label,
40  EncryptionKey* key) override;
42 
46  static std::unique_ptr<RawKeySource> Create(const RawKeyParams& raw_key,
47  int protection_system_flags);
48 
49  protected:
50  // Allow default constructor for mock key sources.
51  RawKeySource();
52 
53  private:
54  explicit RawKeySource(EncryptionKeyMap&& encryption_key_map,
55  int protection_systems_flags);
56  RawKeySource(const RawKeySource&) = delete;
57  RawKeySource& operator=(const RawKeySource&) = delete;
58 
59  EncryptionKeyMap encryption_key_map_;
60 };
61 
62 } // namespace media
63 } // namespace shaka
64 
65 #endif // PACKAGER_MEDIA_BASE_RAW_KEY_SOURCE_H_
Status GetCryptoPeriodKey(uint32_t crypto_period_index, const std::string &stream_label, EncryptionKey *key) override
All the methods that are virtual are virtual for mocking.
Raw key encryption/decryption parameters, i.e. with key parameters provided.
Definition: crypto_params.h:90
A key source that uses raw keys for encryption.
Status GetKey(const std::string &stream_label, EncryptionKey *key) override
static std::unique_ptr< RawKeySource > Create(const RawKeyParams &raw_key, int protection_system_flags)
KeySource is responsible for encryption key acquisition.
Definition: key_source.h:50
Status FetchKeys(EmeInitDataType init_data_type, const std::vector< uint8_t > &init_data) override