7 #ifndef PACKAGER_MEDIA_BASE_WIDEVINE_KEY_SOURCE_H_ 8 #define PACKAGER_MEDIA_BASE_WIDEVINE_KEY_SOURCE_H_ 12 #include "packager/base/synchronization/waitable_event.h" 13 #include "packager/media/base/closure_thread.h" 14 #include "packager/media/base/fourccs.h" 15 #include "packager/media/base/key_source.h" 19 class CommonEncryptionRequest;
25 template <
class T>
class ProducerConsumerQueue;
38 int protection_systems_flags,
39 FourCC protection_scheme);
46 const std::vector<uint8_t>& init_data)
override;
51 uint32_t crypto_period_duration_in_seconds,
52 const std::string& stream_label,
61 const std::string& policy);
65 void set_signer(std::unique_ptr<RequestSigner> signer);
71 void set_group_id(
const std::vector<uint8_t>& group_id) {
74 void set_enable_entitlement_license(
bool enable_entitlement_license) {
75 enable_entitlement_license_ = enable_entitlement_license;
83 Status GetKeyInternal(uint32_t crypto_period_index,
84 const std::string& stream_label,
91 Status FetchKeysInternal(
bool enable_key_rotation,
92 uint32_t first_crypto_period_index,
93 bool widevine_classic);
97 void FillRequest(
bool enable_key_rotation,
98 uint32_t first_crypto_period_index,
99 CommonEncryptionRequest* request);
102 Status GenerateKeyMessage(
const CommonEncryptionRequest& request,
103 std::string* message);
108 bool ExtractEncryptionKey(
bool enable_key_rotation,
109 bool widevine_classic,
110 const std::string& response,
111 bool* transient_error);
113 bool PushToKeyPool(EncryptionKeyMap* encryption_key_map);
116 bool generate_widevine_protection_system_ =
true;
122 std::unique_ptr<KeyFetcher> key_fetcher_;
123 std::string server_url_;
124 std::unique_ptr<RequestSigner> signer_;
125 std::unique_ptr<CommonEncryptionRequest> common_encryption_request_;
127 const int crypto_period_count_;
128 FourCC protection_scheme_ = FOURCC_NULL;
130 bool key_production_started_ =
false;
131 base::WaitableEvent start_key_production_;
132 uint32_t first_crypto_period_index_ = 0;
133 uint32_t crypto_period_duration_in_seconds_ = 0;
134 std::vector<uint8_t> group_id_;
135 bool enable_entitlement_license_ =
false;
136 std::unique_ptr<EncryptionKeyQueue> key_pool_;
137 EncryptionKeyMap encryption_key_map_;
138 Status common_encryption_request_status_;
146 #endif // PACKAGER_MEDIA_BASE_WIDEVINE_KEY_SOURCE_H_ All the methods that are virtual are virtual for mocking.