Shaka Packager SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
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 MEDIA_BASE_PLAYREADY_SOURCE_H_
8 #define 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 
19 // SystemID defined for PlayReady Drm.
20 const uint8_t kPlayReadySystemId[] = {0x9a, 0x04, 0xf0, 0x79, 0x98, 0x40, 0x42,
21  0x86, 0xab, 0x92, 0xe6, 0x5b, 0xe0, 0x88, 0x5f, 0x95};
22 
24 class PlayReadyKeySource : public KeySource {
25  public:
28  PlayReadyKeySource(const std::string& server_url);
35  PlayReadyKeySource(const std::string& server_url,
36  const std::string& client_cert_file,
37  const std::string& client_cert_private_key_file,
38  const std::string& client_cert_private_key_password);
39  ~PlayReadyKeySource() override;
40 
43  Status FetchKeys(EmeInitDataType init_data_type,
44  const std::vector<uint8_t>& init_data) override;
45  Status GetKey(const std::string& stream_label, EncryptionKey* key) override;
46  Status GetKey(const std::vector<uint8_t>& key_id,
47  EncryptionKey* key) override;
48  Status GetCryptoPeriodKey(uint32_t crypto_period_index,
49  const std::string& stream_label,
50  EncryptionKey* key) override;
52  virtual Status FetchKeysWithProgramIdentifier(const std::string& program_identifier);
53 
58  static std::unique_ptr<PlayReadyKeySource> CreateFromKeyAndKeyId(
59  const std::vector<uint8_t>& key_id,
60  const std::vector<uint8_t>& key);
62  void SetCaFile(const std::string& ca_file) {
63  ca_file_ = ca_file;
64  }
65 
66  private:
67  Status GetKeyInternal();
68  Status GetCryptoPeriodKeyInternal();
69  explicit PlayReadyKeySource(std::unique_ptr<EncryptionKey> key);
70 
71  std::unique_ptr<EncryptionKey> encryption_key_;
72  std::string server_url_;
73  std::string ca_file_;
74  std::string client_cert_file_;
75  std::string client_cert_private_key_file_;
76  std::string client_cert_private_key_password_;
77 
78  DISALLOW_COPY_AND_ASSIGN(PlayReadyKeySource);
79 };
80 
81 } // namespace media
82 } // namespace shaka
83 
84 #endif // MEDIA_BASE_PLAYREADY_SOURCE_H_
Status GetKey(const std::string &stream_label, EncryptionKey *key) override
PlayReadyKeySource(const std::string &server_url)
A key source that uses playready for encryption.
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:45
static std::unique_ptr< PlayReadyKeySource > CreateFromKeyAndKeyId(const std::vector< uint8_t > &key_id, const std::vector< uint8_t > &key)