Adding the ability to provide the group_id in Widevine Cenc requests

Change-Id: I4903cc9422433f20b76d084578d8fc06d7ed45a8
This commit is contained in:
Yohann Connell 2017-07-18 14:30:02 -07:00
parent cc92cca6b9
commit 8d2b87c773
7 changed files with 22 additions and 0 deletions

View File

@ -166,6 +166,7 @@ base::Optional<PackagingParams> GetPackagingParams() {
widevine.content_id = FLAGS_content_id_bytes;
widevine.policy = FLAGS_policy;
widevine.group_id = FLAGS_group_id_bytes;
if (!GetWidevineSigner(&widevine.signer))
return base::nullopt;
break;

View File

@ -88,6 +88,7 @@ std::unique_ptr<KeySource> CreateEncryptionKeySource(
return std::unique_ptr<KeySource>();
widevine_key_source->set_signer(std::move(request_signer));
}
widevine_key_source->set_group_id(widevine.group_id);
Status status =
widevine_key_source->FetchKeys(widevine.content_id, widevine.policy);

View File

@ -63,6 +63,7 @@ DEFINE_int32(crypto_period_duration,
0,
"Crypto period duration in seconds. If it is non-zero, key "
"rotation is enabled.");
DEFINE_hex_bytes(group_id, "", "Identifier for a group of licenses (hex).");
namespace shaka {
namespace {

View File

@ -27,6 +27,7 @@ DECLARE_hex_bytes(aes_signing_key);
DECLARE_hex_bytes(aes_signing_iv);
DECLARE_string(rsa_signing_key_path);
DECLARE_int32(crypto_period_duration);
DECLARE_hex_bytes(group_id);
namespace shaka {

View File

@ -292,6 +292,10 @@ void WidevineKeySource::set_key_fetcher(
key_fetcher_ = std::move(key_fetcher);
}
void WidevineKeySource::set_group_id(const std::vector<uint8_t>& group_id) {
group_id_ = group_id;
}
Status WidevineKeySource::GetKeyInternal(uint32_t crypto_period_index,
const std::string& stream_label,
EncryptionKey* key) {
@ -434,6 +438,13 @@ void WidevineKeySource::FillRequest(bool enable_key_rotation,
request_dict_.SetInteger("crypto_period_count", crypto_period_count_);
}
// Set group id if present.
if (!group_id_.empty()) {
std::string group_id_base64;
BytesToBase64String(group_id_, &group_id_base64);
request_dict_.SetString("group_id", group_id_base64);
}
base::JSONWriter::WriteWithOptions(
request_dict_,
// Write doubles that have no fractional part as a normal integer, i.e.

View File

@ -67,6 +67,10 @@ class WidevineKeySource : public KeySource {
/// @param key_fetcher points to the @b KeyFetcher object to be injected.
void set_key_fetcher(std::unique_ptr<KeyFetcher> key_fetcher);
// Set the group id for the key source
// @param group_id group identifier
void set_group_id(const std::vector<uint8_t>& group_id);
private:
typedef std::map<std::string, std::unique_ptr<EncryptionKey>>
EncryptionKeyMap;
@ -124,6 +128,7 @@ class WidevineKeySource : public KeySource {
bool key_production_started_;
base::WaitableEvent start_key_production_;
uint32_t first_crypto_period_index_;
std::vector<uint8_t> group_id_;
std::unique_ptr<EncryptionKeyQueue> key_pool_;
EncryptionKeyMap encryption_key_map_; // For non key rotation request.
Status common_encryption_request_status_;

View File

@ -164,6 +164,8 @@ struct WidevineEncryptionParams {
std::string policy;
/// Signer credential for Widevine license / key server.
WidevineSigner signer;
/// Group identifier, if present licenses will belong to this group.
std::vector<uint8_t> group_id;
};
/// Playready encryption parameters.