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;
47 std::string
UUID()
override;
52 void set_signer(scoped_ptr<RequestSigner> signer);
62 typedef std::map<TrackType, EncryptionKey*> EncryptionKeyMap;
63 class RefCountedEncryptionKeyMap;
68 Status GetKeyInternal(uint32_t crypto_period_index,
76 Status FetchKeysInternal(
bool enable_key_rotation,
77 uint32_t first_crypto_period_index,
78 bool widevine_classic);
82 void FillRequest(
bool enable_key_rotation,
83 uint32_t first_crypto_period_index,
84 std::string* request);
87 Status GenerateKeyMessage(
const std::string& request, std::string* message);
90 bool DecodeResponse(
const std::string& raw_response, std::string* response);
95 bool ExtractEncryptionKey(
bool enable_key_rotation,
96 bool widevine_classic,
97 const std::string& response,
98 bool* transient_error);
100 bool PushToKeyPool(EncryptionKeyMap* encryption_key_map);
105 scoped_ptr<KeyFetcher> key_fetcher_;
106 std::string server_url_;
107 scoped_ptr<RequestSigner> signer_;
108 base::DictionaryValue request_dict_;
110 const uint32_t crypto_period_count_;
112 bool key_production_started_;
113 base::WaitableEvent start_key_production_;
114 uint32_t first_crypto_period_index_;
115 scoped_ptr<EncryptionKeyQueue> key_pool_;
116 EncryptionKeyMap encryption_key_map_;
117 Status common_encryption_request_status_;
125 #endif // MEDIA_BASE_WIDEVINE_KEY_SOURCE_H_