Shaka Packager SDK
playready_key_source.h
1 // Copyright 2017 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_PLAYREADY_SOURCE_H_
8 #define PACKAGER_MEDIA_BASE_PLAYREADY_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 
20 class PlayReadyKeySource : public KeySource {
21  public:
26  PlayReadyKeySource(const std::string& server_url,
27  ProtectionSystem protection_systems);
28  ~PlayReadyKeySource() override;
29 
32  Status FetchKeys(EmeInitDataType init_data_type,
33  const std::vector<uint8_t>& init_data) override;
34  Status GetKey(const std::string& stream_label, EncryptionKey* key) override;
35  Status GetKey(const std::vector<uint8_t>& key_id,
36  EncryptionKey* key) override;
37  Status GetCryptoPeriodKey(uint32_t crypto_period_index,
38  uint32_t crypto_period_duration_in_seconds,
39  const std::string& stream_label,
40  EncryptionKey* key) override;
42  virtual Status FetchKeysWithProgramIdentifier(const std::string& program_identifier);
43 
48  static std::unique_ptr<PlayReadyKeySource> CreateFromKeyAndKeyId(
49  const std::vector<uint8_t>& key_id,
50  const std::vector<uint8_t>& key);
51 
52  private:
53  Status GetKeyInternal();
54  Status GetCryptoPeriodKeyInternal();
55 
56  // Indicates whether PlayReady protection system should be generated.
57  bool generate_playready_protection_system_ = true;
58 
59  std::unique_ptr<EncryptionKey> encryption_key_;
60  std::string server_url_;
61 
62  DISALLOW_COPY_AND_ASSIGN(PlayReadyKeySource);
63 };
64 
65 } // namespace media
66 } // namespace shaka
67 
68 #endif // PACKAGER_MEDIA_BASE_PLAYREADY_SOURCE_H_
shaka::media::PlayReadyKeySource::GetCryptoPeriodKey
Status GetCryptoPeriodKey(uint32_t crypto_period_index, uint32_t crypto_period_duration_in_seconds, const std::string &stream_label, EncryptionKey *key) override
Definition: playready_key_source.cc:197
shaka
All the methods that are virtual are virtual for mocking.
Definition: gflags_hex_bytes.cc:11
shaka::media::PlayReadyKeySource::PlayReadyKeySource
PlayReadyKeySource(const std::string &server_url, ProtectionSystem protection_systems)
Definition: playready_key_source.cc:65
shaka::Status
Definition: status.h:110
shaka::media::PlayReadyKeySource
A key source that uses PlayReady for encryption.
Definition: playready_key_source.h:20
shaka::media::KeySource
KeySource is responsible for encryption key acquisition.
Definition: key_source.h:51
shaka::ProtectionSystem
ProtectionSystem
Definition: crypto_params.h:31
shaka::media::PlayReadyKeySource::GetKey
Status GetKey(const std::string &stream_label, EncryptionKey *key) override
Definition: playready_key_source.cc:176
shaka::media::PlayReadyKeySource::FetchKeys
Status FetchKeys(EmeInitDataType init_data_type, const std::vector< uint8_t > &init_data) override
Definition: playready_key_source.cc:170
shaka::media::PlayReadyKeySource::CreateFromKeyAndKeyId
static std::unique_ptr< PlayReadyKeySource > CreateFromKeyAndKeyId(const std::vector< uint8_t > &key_id, const std::vector< uint8_t > &key)
shaka::media::EncryptionKey
Definition: key_source.h:38