7 #ifndef MEDIA_BASE_WIDEVINE_KEY_SOURCE_H_
8 #define MEDIA_BASE_WIDEVINE_KEY_SOURCE_H_
12 #include "packager/base/synchronization/waitable_event.h"
13 #include "packager/base/values.h"
14 #include "packager/media/base/closure_thread.h"
15 #include "packager/media/base/key_source.h"
20 const uint8_t kWidevineSystemId[] = {0xed, 0xef, 0x8b, 0xa9, 0x79, 0xd6,
21 0x4a, 0xce, 0xa3, 0xc8, 0x27, 0xdc,
22 0xd5, 0x1d, 0x21, 0xed};
26 template <
class T>
class ProducerConsumerQueue;
40 Status FetchKeys(
const std::vector<std::vector<uint8_t>>& key_ids)
override;
56 const std::string& policy);
60 void set_signer(std::unique_ptr<RequestSigner> signer);
70 typedef std::map<TrackType, std::unique_ptr<EncryptionKey>> EncryptionKeyMap;
71 class RefCountedEncryptionKeyMap;
76 Status GetKeyInternal(uint32_t crypto_period_index,
84 Status FetchKeysInternal(
bool enable_key_rotation,
85 uint32_t first_crypto_period_index,
86 bool widevine_classic);
90 void FillRequest(
bool enable_key_rotation,
91 uint32_t first_crypto_period_index,
92 std::string* request);
95 Status GenerateKeyMessage(
const std::string& request, std::string* message);
98 bool DecodeResponse(
const std::string& raw_response, std::string* response);
103 bool ExtractEncryptionKey(
bool enable_key_rotation,
104 bool widevine_classic,
105 const std::string& response,
106 bool* transient_error);
108 bool PushToKeyPool(EncryptionKeyMap* encryption_key_map);
113 std::unique_ptr<KeyFetcher> key_fetcher_;
114 std::string server_url_;
115 std::unique_ptr<RequestSigner> signer_;
116 base::DictionaryValue request_dict_;
118 const uint32_t crypto_period_count_;
120 bool add_common_pssh_;
121 bool key_production_started_;
122 base::WaitableEvent start_key_production_;
123 uint32_t first_crypto_period_index_;
124 std::unique_ptr<EncryptionKeyQueue> key_pool_;
125 EncryptionKeyMap encryption_key_map_;
126 Status common_encryption_request_status_;
134 #endif // MEDIA_BASE_WIDEVINE_KEY_SOURCE_H_