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  int protection_scheme_flags);
36  PlayReadyKeySource(const std::string& server_url,
37  const std::string& client_cert_file,
38  const std::string& client_cert_private_key_file,
39  const std::string& client_cert_private_key_password,
40  int protection_scheme_flags);
41  ~PlayReadyKeySource() override;
42 
45  Status FetchKeys(EmeInitDataType init_data_type,
46  const std::vector<uint8_t>& init_data) override;
47  Status GetKey(const std::string& stream_label, EncryptionKey* key) override;
48  Status GetKey(const std::vector<uint8_t>& key_id,
49  EncryptionKey* key) override;
50  Status GetCryptoPeriodKey(uint32_t crypto_period_index,
51  const std::string& stream_label,
52  EncryptionKey* key) override;
54  virtual Status FetchKeysWithProgramIdentifier(const std::string& program_identifier);
55 
60  static std::unique_ptr<PlayReadyKeySource> CreateFromKeyAndKeyId(
61  const std::vector<uint8_t>& key_id,
62  const std::vector<uint8_t>& key);
64  void SetCaFile(const std::string& ca_file) {
65  ca_file_ = ca_file;
66  }
67 
68  private:
69  Status GetKeyInternal();
70  Status GetCryptoPeriodKeyInternal();
71  explicit PlayReadyKeySource(std::unique_ptr<EncryptionKey> key);
72 
73  std::unique_ptr<EncryptionKey> encryption_key_;
74  std::string server_url_;
75  std::string ca_file_;
76  std::string client_cert_file_;
77  std::string client_cert_private_key_file_;
78  std::string client_cert_private_key_password_;
79 
80  DISALLOW_COPY_AND_ASSIGN(PlayReadyKeySource);
81 };
82 
83 } // namespace media
84 } // namespace shaka
85 
86 #endif // PACKAGER_MEDIA_BASE_PLAYREADY_SOURCE_H_
Status GetKey(const std::string &stream_label, EncryptionKey *key) override
static std::unique_ptr< PlayReadyKeySource > CreateFromKeyAndKeyId(const std::vector< uint8_t > &key_id, const std::vector< uint8_t > &key)
All the methods that are virtual are virtual for mocking.
A key source that uses playready for encryption.
PlayReadyKeySource(const std::string &server_url, int protection_scheme_flags)
Status GetCryptoPeriodKey(uint32_t crypto_period_index, const std::string &stream_label, EncryptionKey *key) override
void SetCaFile(const std::string &ca_file)
Sets the Certificate Authority file for validating self-signed certificates.
Status FetchKeys(EmeInitDataType init_data_type, const std::vector< uint8_t > &init_data) override
KeySource is responsible for encryption key acquisition.
Definition: key_source.h:50