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"
21 const uint8_t kWidevineSystemId[] = {0xed, 0xef, 0x8b, 0xa9, 0x79, 0xd6,
22 0x4a, 0xce, 0xa3, 0xc8, 0x27, 0xdc,
23 0xd5, 0x1d, 0x21, 0xed};
27 template <
class T>
class ProducerConsumerQueue;
41 Status FetchKeys(
const std::vector<std::vector<uint8_t>>& key_ids)
override;
57 const std::string& policy);
61 void set_signer(scoped_ptr<RequestSigner> signer);
71 typedef std::map<TrackType, EncryptionKey*> EncryptionKeyMap;
72 class RefCountedEncryptionKeyMap;
77 Status GetKeyInternal(uint32_t crypto_period_index,
85 Status FetchKeysInternal(
bool enable_key_rotation,
86 uint32_t first_crypto_period_index,
87 bool widevine_classic);
91 void FillRequest(
bool enable_key_rotation,
92 uint32_t first_crypto_period_index,
93 std::string* request);
96 Status GenerateKeyMessage(
const std::string& request, std::string* message);
99 bool DecodeResponse(
const std::string& raw_response, std::string* response);
104 bool ExtractEncryptionKey(
bool enable_key_rotation,
105 bool widevine_classic,
106 const std::string& response,
107 bool* transient_error);
109 bool PushToKeyPool(EncryptionKeyMap* encryption_key_map);
114 scoped_ptr<KeyFetcher> key_fetcher_;
115 std::string server_url_;
116 scoped_ptr<RequestSigner> signer_;
117 base::DictionaryValue request_dict_;
119 const uint32_t crypto_period_count_;
121 bool add_common_pssh_;
122 bool key_production_started_;
123 base::WaitableEvent start_key_production_;
124 uint32_t first_crypto_period_index_;
125 scoped_ptr<EncryptionKeyQueue> key_pool_;
126 EncryptionKeyMap encryption_key_map_;
127 Status common_encryption_request_status_;
135 #endif // MEDIA_BASE_WIDEVINE_KEY_SOURCE_H_