7 #ifndef PACKAGER_MEDIA_BASE_WIDEVINE_KEY_SOURCE_H_
8 #define PACKAGER_MEDIA_BASE_WIDEVINE_KEY_SOURCE_H_
14 #include <absl/synchronization/mutex.h>
15 #include <absl/synchronization/notification.h>
17 #include <packager/macros/classes.h>
18 #include <packager/media/base/fourccs.h>
19 #include <packager/media/base/key_source.h>
23 class CommonEncryptionRequest;
29 template <
class T>
class ProducerConsumerQueue;
42 ProtectionSystem protection_systems,
43 FourCC protection_scheme);
49 Status
FetchKeys(EmeInitDataType init_data_type,
50 const std::vector<uint8_t>& init_data)
override;
52 Status
GetKey(
const std::vector<uint8_t>& key_id,
55 int32_t crypto_period_duration_in_seconds,
56 const std::string& stream_label,
64 Status
FetchKeys(
const std::vector<uint8_t>& content_id,
65 const std::string& policy);
69 void set_signer(std::unique_ptr<RequestSigner> signer);
82 enable_entitlement_license_ = enable_entitlement_license;
90 Status GetKeyInternal(uint32_t crypto_period_index,
91 const std::string& stream_label,
98 Status FetchKeysInternal(
bool enable_key_rotation,
99 uint32_t first_crypto_period_index,
100 bool widevine_classic);
104 void FillRequest(
bool enable_key_rotation,
105 uint32_t first_crypto_period_index,
106 CommonEncryptionRequest* request);
109 Status GenerateKeyMessage(
const CommonEncryptionRequest& request,
110 std::string* message);
115 bool ExtractEncryptionKey(
bool enable_key_rotation,
116 bool widevine_classic,
117 const std::string& response,
118 bool* transient_error);
120 bool PushToKeyPool(EncryptionKeyMap* encryption_key_map);
123 bool generate_widevine_protection_system_ =
true;
128 std::unique_ptr<KeyFetcher> key_fetcher_;
129 std::string server_url_;
130 std::unique_ptr<RequestSigner> signer_;
131 std::unique_ptr<CommonEncryptionRequest> common_encryption_request_;
133 const int crypto_period_count_;
134 FourCC protection_scheme_ = FOURCC_NULL;
137 bool key_production_started_ =
false;
138 absl::Notification start_key_production_;
139 uint32_t first_crypto_period_index_ = 0;
140 int32_t crypto_period_duration_in_seconds_ = 0;
141 std::vector<uint8_t> group_id_;
142 bool enable_entitlement_license_ =
false;
143 std::unique_ptr<EncryptionKeyQueue> key_pool_;
145 EncryptionKeyMap encryption_key_map_;
146 Status common_encryption_request_status_;
148 std::thread key_production_thread_;
All the methods that are virtual are virtual for mocking.