DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
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 
60  static std::unique_ptr<PlayReadyKeySource> CreateFromKeyAndKeyId(
61  const std::string& key_id_hex, const std::string& key_hex);
63  void SetCaFile(const std::string& ca_file) {
64  ca_file_ = ca_file;
65  }
66 
67  private:
68  Status GetKeyInternal();
69  Status GetCryptoPeriodKeyInternal();
70  explicit PlayReadyKeySource(std::unique_ptr<EncryptionKey> key);
71 
72  std::unique_ptr<EncryptionKey> encryption_key_;
73  std::string server_url_;
74  std::string ca_file_;
75  std::string client_cert_file_;
76  std::string client_cert_private_key_file_;
77  std::string client_cert_private_key_password_;
78 
79  DISALLOW_COPY_AND_ASSIGN(PlayReadyKeySource);
80 };
81 
82 } // namespace media
83 } // namespace shaka
84 
85 #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::string &key_id_hex, const std::string &key_hex)