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  uint32_t crypto_period_duration_in_seconds,
34  const std::string& stream_label,
35  EncryptionKey* key) override;
37 
41  static std::unique_ptr<RawKeySource> Create(const RawKeyParams& raw_key);
42 
43  protected:
44  // Allow default constructor for mock key sources.
45  RawKeySource();
46 
47  private:
48  RawKeySource(EncryptionKeyMap&& encryption_key_map);
49  RawKeySource(const RawKeySource&) = delete;
50  RawKeySource& operator=(const RawKeySource&) = delete;
51 
52  EncryptionKeyMap encryption_key_map_;
53 };
54 
55 } // namespace media
56 } // namespace shaka
57 
58 #endif // PACKAGER_MEDIA_BASE_RAW_KEY_SOURCE_H_
shaka::media::RawKeySource::GetKey
Status GetKey(const std::string &stream_label, EncryptionKey *key) override
Definition: raw_key_source.cc:30
shaka::media::RawKeySource::Create
static std::unique_ptr< RawKeySource > Create(const RawKeyParams &raw_key)
Definition: raw_key_source.cc:85
shaka
All the methods that are virtual are virtual for mocking.
Definition: gflags_hex_bytes.cc:11
shaka::media::RawKeySource::FetchKeys
Status FetchKeys(EmeInitDataType init_data_type, const std::vector< uint8_t > &init_data) override
Definition: raw_key_source.cc:24
shaka::Status
Definition: status.h:110
shaka::RawKeyParams
Raw key encryption/decryption parameters, i.e. with key parameters provided.
Definition: crypto_params.h:123
shaka::media::RawKeySource
A key source that uses raw keys for encryption.
Definition: raw_key_source.h:21
shaka::media::KeySource
KeySource is responsible for encryption key acquisition.
Definition: key_source.h:51
shaka::media::EncryptionKey
Definition: key_source.h:38
shaka::media::RawKeySource::GetCryptoPeriodKey
Status GetCryptoPeriodKey(uint32_t crypto_period_index, uint32_t crypto_period_duration_in_seconds, const std::string &stream_label, EncryptionKey *key) override
Definition: raw_key_source.cc:61