7 #ifndef MEDIA_BASE_WIDEVINE_KEY_SOURCE_H_
8 #define MEDIA_BASE_WIDEVINE_KEY_SOURCE_H_
12 #include "packager/base/memory/scoped_ptr.h"
13 #include "packager/base/synchronization/waitable_event.h"
14 #include "packager/base/values.h"
15 #include "packager/media/base/closure_thread.h"
16 #include "packager/media/base/key_source.h"
18 namespace edash_packager {
22 template <
class T>
class ProducerConsumerQueue;
36 const std::string& policy)
override;
38 Status FetchKeys(
const std::vector<std::vector<uint8_t>>& key_ids)
override;
51 void set_signer(scoped_ptr<RequestSigner> signer);
61 typedef std::map<TrackType, EncryptionKey*> EncryptionKeyMap;
62 class RefCountedEncryptionKeyMap;
67 Status GetKeyInternal(uint32_t crypto_period_index,
75 Status FetchKeysInternal(
bool enable_key_rotation,
76 uint32_t first_crypto_period_index,
77 bool widevine_classic);
81 void FillRequest(
bool enable_key_rotation,
82 uint32_t first_crypto_period_index,
83 std::string* request);
86 Status GenerateKeyMessage(
const std::string& request, std::string* message);
89 bool DecodeResponse(
const std::string& raw_response, std::string* response);
94 bool ExtractEncryptionKey(
bool enable_key_rotation,
95 bool widevine_classic,
96 const std::string& response,
97 bool* transient_error);
99 bool PushToKeyPool(EncryptionKeyMap* encryption_key_map);
104 scoped_ptr<KeyFetcher> key_fetcher_;
105 std::string server_url_;
106 scoped_ptr<RequestSigner> signer_;
107 base::DictionaryValue request_dict_;
109 const uint32_t crypto_period_count_;
111 bool key_production_started_;
112 base::WaitableEvent start_key_production_;
113 uint32_t first_crypto_period_index_;
114 scoped_ptr<EncryptionKeyQueue> key_pool_;
115 EncryptionKeyMap encryption_key_map_;
116 Status common_encryption_request_status_;
124 #endif // MEDIA_BASE_WIDEVINE_KEY_SOURCE_H_