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;
35 int protection_systems_flags);
42 const std::vector<uint8_t>& init_data)
override;
47 const std::string& stream_label,
56 const std::string& policy);
60 protection_scheme_ = protection_scheme;
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);
119 std::unique_ptr<KeyFetcher> key_fetcher_;
120 std::string server_url_;
121 std::unique_ptr<RequestSigner> signer_;
122 std::unique_ptr<CommonEncryptionRequest> common_encryption_request_;
124 const int crypto_period_count_;
125 FourCC protection_scheme_;
127 bool key_production_started_;
128 base::WaitableEvent start_key_production_;
129 uint32_t first_crypto_period_index_;
130 std::vector<uint8_t> group_id_;
131 bool enable_entitlement_license_;
132 std::unique_ptr<EncryptionKeyQueue> key_pool_;
133 EncryptionKeyMap encryption_key_map_;
134 Status common_encryption_request_status_;
142 #endif // PACKAGER_MEDIA_BASE_WIDEVINE_KEY_SOURCE_H_ All the methods that are virtual are virtual for mocking.