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(const std::vector<uint8_t>& pssh_box) override;
44  Status FetchKeys(const std::vector<std::vector<uint8_t>>& key_ids) override;
45  Status FetchKeys(uint32_t asset_id) override;
46 
47  Status GetKey(TrackType track_type, 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  TrackType track_type,
52  EncryptionKey* key) override;
54  virtual Status FetchKeysWithProgramIdentifier(const std::string& program_identifier);
55 
62  static std::unique_ptr<PlayReadyKeySource> CreateFromKeyAndKeyId(
63  const std::string& key_id_hex, const std::string& key_hex);
65  void SetCaFile(const std::string& ca_file) {
66  ca_file_ = ca_file;
67  }
68 
69  private:
70  Status GetKeyInternal();
71  Status GetCryptoPeriodKeyInternal();
72  explicit PlayReadyKeySource(std::unique_ptr<EncryptionKey> key);
73 
74  std::unique_ptr<EncryptionKey> encryption_key_;
75  std::string server_url_;
76  std::string ca_file_;
77  std::string client_cert_file_;
78  std::string client_cert_private_key_file_;
79  std::string client_cert_private_key_password_;
80 
81  DISALLOW_COPY_AND_ASSIGN(PlayReadyKeySource);
82 };
83 
84 } // namespace media
85 } // namespace shaka
86 
87 #endif // MEDIA_BASE_PLAYREADY_SOURCE_H_
PlayReadyKeySource(const std::string &server_url)
Status GetCryptoPeriodKey(uint32_t crypto_period_index, TrackType track_type, EncryptionKey *key) override
A key source that uses playready for encryption.
void SetCaFile(const std::string &ca_file)
Sets the Certificate Authority file for validating self-signed certificates.
Status GetKey(TrackType track_type, EncryptionKey *key) override
Status FetchKeys(const std::vector< uint8_t > &pssh_box) override
KeySource is responsible for encryption key acquisition.
Definition: key_source.h:30
static std::unique_ptr< PlayReadyKeySource > CreateFromKeyAndKeyId(const std::string &key_id_hex, const std::string &key_hex)