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/fourccs.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;
40 Status
FetchKeys(EmeInitDataType init_data_type,
41 const std::vector<uint8_t>& init_data)
override;
43 Status
GetKey(
const std::vector<uint8_t>& key_id,
46 const std::string& stream_label,
54 Status
FetchKeys(
const std::vector<uint8_t>& content_id,
55 const std::string& policy);
59 protection_scheme_ = protection_scheme;
64 void set_signer(std::unique_ptr<RequestSigner> signer);
72 void set_group_id(
const std::vector<uint8_t>& group_id);
75 typedef std::map<std::string, std::unique_ptr<EncryptionKey>>
81 Status GetKeyInternal(uint32_t crypto_period_index,
82 const std::string& stream_label,
89 Status FetchKeysInternal(
bool enable_key_rotation,
90 uint32_t first_crypto_period_index,
91 bool widevine_classic);
95 void FillRequest(
bool enable_key_rotation,
96 uint32_t first_crypto_period_index,
97 std::string* request);
100 Status GenerateKeyMessage(
const std::string& request, std::string* message);
103 bool DecodeResponse(
const std::string& raw_response, std::string* response);
108 bool ExtractEncryptionKey(
bool enable_key_rotation,
109 bool widevine_classic,
110 const std::string& response,
111 bool* transient_error);
113 bool PushToKeyPool(EncryptionKeyMap* encryption_key_map);
119 std::unique_ptr<KeyFetcher> key_fetcher_;
120 std::string server_url_;
121 std::unique_ptr<RequestSigner> signer_;
122 base::DictionaryValue request_dict_;
124 const uint32_t crypto_period_count_;
125 FourCC protection_scheme_;
127 bool add_common_pssh_;
128 bool key_production_started_;
129 base::WaitableEvent start_key_production_;
130 uint32_t first_crypto_period_index_;
131 std::vector<uint8_t> group_id_;
132 std::unique_ptr<EncryptionKeyQueue> key_pool_;
133 EncryptionKeyMap encryption_key_map_;
134 Status common_encryption_request_status_;
142 #endif // MEDIA_BASE_WIDEVINE_KEY_SOURCE_H_