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 
21 class RawKeySource : public KeySource {
22  public:
23  ~RawKeySource() override;
24 
27  Status FetchKeys(EmeInitDataType init_data_type,
28  const std::vector<uint8_t>& init_data) override;
29  Status GetKey(const std::string& stream_label, EncryptionKey* key) override;
30  Status GetKey(const std::vector<uint8_t>& key_id,
31  EncryptionKey* key) override;
32  Status GetCryptoPeriodKey(uint32_t crypto_period_index,
33  const std::string& stream_label,
34  EncryptionKey* key) override;
36 
45  static std::unique_ptr<RawKeySource> Create(const RawKeyParams& raw_key,
46  int protection_system_flags,
47  FourCC protection_scheme);
48 
49  protected:
50  // Allow default constructor for mock key sources.
51  RawKeySource();
52 
53  private:
54  RawKeySource(EncryptionKeyMap&& encryption_key_map,
55  int protection_systems_flags,
56  FourCC protection_scheme);
57  RawKeySource(const RawKeySource&) = delete;
58  RawKeySource& operator=(const RawKeySource&) = delete;
59 
60  EncryptionKeyMap encryption_key_map_;
61 };
62 
63 } // namespace media
64 } // namespace shaka
65 
66 #endif // PACKAGER_MEDIA_BASE_RAW_KEY_SOURCE_H_
Status GetCryptoPeriodKey(uint32_t crypto_period_index, const std::string &stream_label, EncryptionKey *key) override
static std::unique_ptr< RawKeySource > Create(const RawKeyParams &raw_key, int protection_system_flags, FourCC protection_scheme)
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:86
A key source that uses raw keys for encryption.
Status GetKey(const std::string &stream_label, EncryptionKey *key) override
KeySource is responsible for encryption key acquisition.
Definition: key_source.h:48
Status FetchKeys(EmeInitDataType init_data_type, const std::vector< uint8_t > &init_data) override