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 const std::string& stream_label,
60 const std::string& policy);
64 void set_signer(std::unique_ptr<RequestSigner> signer);
70 void set_group_id(
const std::vector<uint8_t>& group_id) {
73 void set_enable_entitlement_license(
bool enable_entitlement_license) {
74 enable_entitlement_license_ = enable_entitlement_license;
82 Status GetKeyInternal(uint32_t crypto_period_index,
83 const std::string& stream_label,
90 Status FetchKeysInternal(
bool enable_key_rotation,
91 uint32_t first_crypto_period_index,
92 bool widevine_classic);
96 void FillRequest(
bool enable_key_rotation,
97 uint32_t first_crypto_period_index,
98 CommonEncryptionRequest* request);
101 Status GenerateKeyMessage(
const CommonEncryptionRequest& request,
102 std::string* message);
107 bool ExtractEncryptionKey(
bool enable_key_rotation,
108 bool widevine_classic,
109 const std::string& response,
110 bool* transient_error);
112 bool PushToKeyPool(EncryptionKeyMap* encryption_key_map);
115 bool generate_widevine_protection_system_ =
true;
121 std::unique_ptr<KeyFetcher> key_fetcher_;
122 std::string server_url_;
123 std::unique_ptr<RequestSigner> signer_;
124 std::unique_ptr<CommonEncryptionRequest> common_encryption_request_;
126 const int crypto_period_count_;
127 FourCC protection_scheme_ = FOURCC_NULL;
129 bool key_production_started_ =
false;
130 base::WaitableEvent start_key_production_;
131 uint32_t first_crypto_period_index_ = 0;
132 std::vector<uint8_t> group_id_;
133 bool enable_entitlement_license_ =
false;
134 std::unique_ptr<EncryptionKeyQueue> key_pool_;
135 EncryptionKeyMap encryption_key_map_;
136 Status common_encryption_request_status_;
144 #endif // PACKAGER_MEDIA_BASE_WIDEVINE_KEY_SOURCE_H_ All the methods that are virtual are virtual for mocking.