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 Status FetchKeys(
const std::vector<std::vector<uint8_t>>& key_ids)
override;
52 const std::string& policy);
56 void set_signer(scoped_ptr<RequestSigner> signer);
66 typedef std::map<TrackType, EncryptionKey*> EncryptionKeyMap;
67 class RefCountedEncryptionKeyMap;
72 Status GetKeyInternal(uint32_t crypto_period_index,
80 Status FetchKeysInternal(
bool enable_key_rotation,
81 uint32_t first_crypto_period_index,
82 bool widevine_classic);
86 void FillRequest(
bool enable_key_rotation,
87 uint32_t first_crypto_period_index,
88 std::string* request);
91 Status GenerateKeyMessage(
const std::string& request, std::string* message);
94 bool DecodeResponse(
const std::string& raw_response, std::string* response);
99 bool ExtractEncryptionKey(
bool enable_key_rotation,
100 bool widevine_classic,
101 const std::string& response,
102 bool* transient_error);
104 bool PushToKeyPool(EncryptionKeyMap* encryption_key_map);
109 scoped_ptr<KeyFetcher> key_fetcher_;
110 std::string server_url_;
111 scoped_ptr<RequestSigner> signer_;
112 base::DictionaryValue request_dict_;
114 const uint32_t crypto_period_count_;
116 bool add_common_pssh_;
117 bool key_production_started_;
118 base::WaitableEvent start_key_production_;
119 uint32_t first_crypto_period_index_;
120 scoped_ptr<EncryptionKeyQueue> key_pool_;
121 EncryptionKeyMap encryption_key_map_;
122 Status common_encryption_request_status_;
130 #endif // MEDIA_BASE_WIDEVINE_KEY_SOURCE_H_